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

Rename ST_EXTENT to ENVELOPE

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