提交 dffed9ed authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Rename ST_EXTENT to ENVELOPE

上级 a741e6d5
......@@ -3438,7 +3438,7 @@ MODE() WITHIN GROUP(ORDER BY X)
"
"Functions (Aggregate)","ST_EXTENT","
ST_EXTENT( value ) [ FILTER ( WHERE expression ) ]
ENVELOPE( value ) [ FILTER ( WHERE expression ) ]
","
Returns the minimum bounding box that encloses all specified GEOMETRY values.
Only 2D coordinate plane is supported.
......@@ -3446,7 +3446,7 @@ NULL values are ignored in the calculation.
If no rows are selected, the result is NULL.
Aggregates are only allowed in select statements.
","
ST_EXTENT(X)
ENVELOPE(X)
"
"Functions (Numeric)","ABS","
......
......@@ -145,9 +145,9 @@ public class Aggregate extends Expression {
MODE,
/**
* The aggregate type for ST_EXTENT(expression).
* The aggregate type for ENVELOPE(expression).
*/
ST_EXTENT,
ENVELOPE,
}
private static final HashMap<String, AggregateType> AGGREGATES = new HashMap<>(64);
......@@ -218,7 +218,7 @@ public class Aggregate extends Expression {
addAggregate("MODE", AggregateType.MODE);
// Oracle compatibility
addAggregate("STATS_MODE", AggregateType.MODE);
addAggregate("ST_EXTENT", AggregateType.ST_EXTENT);
addAggregate("ENVELOPE", AggregateType.ENVELOPE);
}
private static void addAggregate(String name, AggregateType type) {
......@@ -378,8 +378,8 @@ public class Aggregate extends Expression {
}
case MEDIAN:
return AggregateDataMedian.getResultFromIndex(session, on, dataType);
case ST_EXTENT:
return ((MVSpatialIndex) AggregateDataST_Extent.getGeometryColumnIndex(on)).getBounds(session);
case ENVELOPE:
return ((MVSpatialIndex) AggregateDataEnvelope.getGeometryColumnIndex(on)).getBounds(session);
default:
DbException.throwInternalError("type=" + type);
}
......@@ -562,7 +562,7 @@ public class Aggregate extends Expression {
scale = 0;
precision = displaySize = Integer.MAX_VALUE;
break;
case ST_EXTENT:
case ENVELOPE:
dataType = Value.GEOMETRY;
scale = 0;
precision = displaySize = Integer.MAX_VALUE;
......@@ -712,8 +712,8 @@ public class Aggregate extends Expression {
case MODE:
text = "MODE";
break;
case ST_EXTENT:
text = "ST_EXTENT";
case ENVELOPE:
text = "ENVELOPE";
break;
default:
throw DbException.throwInternalError("type=" + type);
......@@ -765,8 +765,8 @@ public class Aggregate extends Expression {
return false;
}
return AggregateDataMedian.getMedianColumnIndex(on) != null;
case ST_EXTENT:
return AggregateDataST_Extent.getGeometryColumnIndex(on) != null;
case ENVELOPE:
return AggregateDataEnvelope.getGeometryColumnIndex(on) != null;
default:
return false;
}
......
......@@ -37,8 +37,8 @@ abstract class AggregateData {
return new AggregateDataMedian();
case MODE:
return new AggregateDataMode();
case ST_EXTENT:
return new AggregateDataST_Extent();
case ENVELOPE:
return new AggregateDataEnvelope();
default:
return new AggregateDataDefault(aggregateType);
}
......
......@@ -23,7 +23,7 @@ import org.locationtech.jts.geom.GeometryFactory;
/**
* Data stored while calculating an aggregate.
*/
class AggregateDataST_Extent extends AggregateData {
class AggregateDataEnvelope extends AggregateData {
private Envelope envelope;
......
......@@ -136,8 +136,8 @@ public class TestScript extends TestDb {
for (String s : new String[] { "help" }) {
testScript("other/" + s + ".sql");
}
for (String s : new String[] { "avg", "bit-and", "bit-or", "count",
"group-concat", "max", "median", "min", "mode", "selectivity", "st_extent", "stddev-pop",
for (String s : new String[] { "avg", "bit-and", "bit-or", "count", "envelope",
"group-concat", "max", "median", "min", "mode", "selectivity", "stddev-pop",
"stddev-samp", "sum", "var-pop", "var-samp", "array-agg" }) {
testScript("functions/aggregate/" + s + ".sql");
}
......
......@@ -6,21 +6,21 @@
CREATE TABLE TEST(V GEOMETRY);
> ok
SELECT ST_EXTENT(V) FROM TEST;
SELECT ENVELOPE(V) FROM TEST;
>> null
INSERT INTO TEST VALUES ('POINT(1 1)');
> update count: 1
SELECT ST_EXTENT(V) FROM TEST;
SELECT ENVELOPE(V) FROM TEST;
>> POINT (1 1)
INSERT INTO TEST VALUES ('POINT(1 2)'), (NULL), ('POINT(3 1)');
> update count: 3
SELECT ST_EXTENT(V), ST_EXTENT(V) FILTER (WHERE V <> 'POINT(3 1)') FILTERED1,
ST_EXTENT(V) FILTER (WHERE V <> 'POINT(1 2)') FILTERED2 FROM TEST;
> ST_EXTENT(V) FILTERED1 FILTERED2
SELECT ENVELOPE(V), ENVELOPE(V) FILTER (WHERE V <> 'POINT(3 1)') FILTERED1,
ENVELOPE(V) FILTER (WHERE V <> 'POINT(1 2)') FILTERED2 FROM TEST;
> ENVELOPE(V) FILTERED1 FILTERED2
> ----------------------------------- --------------------- ---------------------
> POLYGON ((1 1, 1 2, 3 2, 3 1, 1 1)) LINESTRING (1 1, 1 2) LINESTRING (1 1, 3 1)
> rows: 1
......@@ -29,41 +29,41 @@ CREATE SPATIAL INDEX IDX ON TEST(V);
> ok
-- Without index
SELECT ST_EXTENT(N) FROM (SELECT V AS N FROM TEST);
SELECT ENVELOPE(N) FROM (SELECT V AS N FROM TEST);
>> POLYGON ((1 1, 1 2, 3 2, 3 1, 1 1))
-- With index
SELECT ST_EXTENT(V) FROM TEST;
SELECT ENVELOPE(V) FROM TEST;
>> POLYGON ((1 1, 1 2, 3 2, 3 1, 1 1))
-- Without index
SELECT ST_EXTENT(V) FILTER (WHERE V <> 'POINT(3 1)') FILTERED FROM TEST;
SELECT ENVELOPE(V) FILTER (WHERE V <> 'POINT(3 1)') FILTERED FROM TEST;
>> LINESTRING (1 1, 1 2)
-- Without index
SELECT ST_EXTENT(V) FROM TEST WHERE V <> 'POINT(3 1)';
SELECT ENVELOPE(V) FROM TEST WHERE V <> 'POINT(3 1)';
>> LINESTRING (1 1, 1 2)
INSERT INTO TEST VALUES ('POINT(-1.0000000001 1)');
> update count: 1
-- Without index
SELECT ST_EXTENT(N) FROM (SELECT V AS N FROM TEST);
SELECT ENVELOPE(N) FROM (SELECT V AS N FROM TEST);
>> POLYGON ((-1.0000000001 1, -1.0000000001 2, 3 2, 3 1, -1.0000000001 1))
-- With index
SELECT ST_EXTENT(V) FROM TEST;
SELECT ENVELOPE(V) FROM TEST;
>> POLYGON ((-1.0000000001 1, -1.0000000001 2, 3 2, 3 1, -1.0000000001 1))
TRUNCATE TABLE TEST;
> ok
-- Without index
SELECT ST_EXTENT(N) FROM (SELECT V AS N FROM TEST);
SELECT ENVELOPE(N) FROM (SELECT V AS N FROM TEST);
>> null
-- With index
SELECT ST_EXTENT(V) FROM TEST;
SELECT ENVELOPE(V) FROM TEST;
>> null
SELECT RAND(1000) * 0;
......@@ -73,11 +73,11 @@ INSERT INTO TEST SELECT CAST('POINT(' || CAST(RAND() * 100000 AS INT) || ' ' ||
> update count: 1000
-- Without index
SELECT ST_EXTENT(N) FROM (SELECT V AS N FROM TEST);
SELECT ENVELOPE(N) FROM (SELECT V AS N FROM TEST);
>> POLYGON ((68 78, 68 99951, 99903 99951, 99903 78, 68 78))
-- With index
SELECT ST_EXTENT(V) FROM TEST;
SELECT ENVELOPE(V) FROM TEST;
>> POLYGON ((68 78, 68 99951, 99903 99951, 99903 78, 68 78))
TRUNCATE TABLE TEST;
......@@ -91,11 +91,11 @@ INSERT INTO TEST SELECT CAST('POINT(' || (CAST(RAND() * 100000 AS INT) * 0.00000
> update count: 1000
-- Without index
SELECT ST_EXTENT(N) FROM (SELECT V AS N FROM TEST);
SELECT ENVELOPE(N) FROM (SELECT V AS N FROM TEST);
>> POLYGON ((1.000000068 1.000000078, 1.000000068 1.000099951, 1.000099903 1.000099951, 1.000099903 1.000000078, 1.000000068 1.000000078))
-- With index
SELECT ST_EXTENT(V) FROM TEST;
SELECT ENVELOPE(V) FROM TEST;
>> POLYGON ((1.000000068 1.000000078, 1.000000068 1.000099951, 1.000099903 1.000099951, 1.000099903 1.000000078, 1.000000068 1.000000078))
DROP TABLE TEST;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论