mirror of
https://github.com/MariaDB/server.git
synced 2026-10-23 18:49:29 +03:00
280 lines
12 KiB
Plaintext
280 lines
12 KiB
Plaintext
select st_asgeojson(geomfromtext('POINT(1 1)')) as exp;
|
|
exp
|
|
{"type": "Point", "coordinates": [1, 1]}
|
|
select st_asgeojson(geomfromtext('LINESTRING(10 10,20 10,20 20,10 20,10 10)')) as exp;
|
|
exp
|
|
{"type": "LineString", "coordinates": [[10, 10], [20, 10], [20, 20], [10, 20], [10, 10]]}
|
|
select st_asgeojson(geomfromtext('POLYGON((10 10,20 10,20 20,10 20,10 10))')) as exp;
|
|
exp
|
|
{"type": "Polygon", "coordinates": [[[10, 10], [20, 10], [20, 20], [10, 20], [10, 10]]]}
|
|
select st_asgeojson(geomfromtext('MULTIPOLYGON(((10 10,20 10,20 20,10 20,10 10)))')) as exp;
|
|
exp
|
|
{"type": "MultiPolygon", "coordinates": [[[[10, 10], [20, 10], [20, 20], [10, 20], [10, 10]]]]}
|
|
select st_asgeojson(geomfromtext('multilinestring((10 10,20 10,20 20,10 20,10 10))')) as exp;
|
|
exp
|
|
{"type": "MultiLineString", "coordinates": [[[10, 10], [20, 10], [20, 20], [10, 20], [10, 10]]]}
|
|
select st_asgeojson(geomfromtext('multipoint(10 10,20 10,20 20,10 20,10 10)')) as exp;
|
|
exp
|
|
{"type": "MultiPoint", "coordinates": [[10, 10], [20, 10], [20, 20], [10, 20], [10, 10]]}
|
|
select st_asgeojson(st_geomfromtext('GEOMETRYCOLLECTION(POINT(100 0),LINESTRING(101 0,102 1))')) as exp;
|
|
exp
|
|
{"type": "GeometryCollection", "geometries": [{"type": "Point", "coordinates": [100, 0]}, {"type": "LineString", "coordinates": [[101, 0], [102, 1]]}]}
|
|
SELECT st_astext(st_geomfromgeojson('{"type":"point","coordinates":[1,2]}')) as exp;
|
|
exp
|
|
POINT(1 2)
|
|
SELECT st_astext(st_geomfromgeojson('{"type":"LineString","coordinates":[[1,2],[4,5],[7,8]]}')) as exp;
|
|
exp
|
|
LINESTRING(1 2,4 5,7 8)
|
|
SELECT st_astext(st_geomfromgeojson('{"type": "polygon", "coordinates": [[[10, 10], [20, 10], [20, 20], [10, 20], [10, 10]]]}')) as exp;
|
|
exp
|
|
POLYGON((10 10,20 10,20 20,10 20,10 10))
|
|
SELECT st_astext(st_geomfromgeojson('{"type":"multipoint","coordinates":[[1,2],[4,5],[7,8]]}')) as exp;
|
|
exp
|
|
MULTIPOINT(1 2,4 5,7 8)
|
|
SELECT st_astext(st_geomfromgeojson('{"type": "multilinestring", "coordinates": [[[10, 10], [20, 10], [20, 20], [10, 20], [10, 10]]]}')) as exp;
|
|
exp
|
|
MULTILINESTRING((10 10,20 10,20 20,10 20,10 10))
|
|
SELECT st_astext(st_geomfromgeojson('{"type": "multipolygon", "coordinates": [[[[10, 10], [20, 10], [20, 20], [10, 20], [10, 10]]]]}')) as exp;
|
|
exp
|
|
MULTIPOLYGON(((10 10,20 10,20 20,10 20,10 10)))
|
|
SELECT st_astext(st_geomfromgeojson('{"type": "GeometryCollection", "geometries": [{"type": "Point","coordinates": [100.0, 0.0]}, {"type": "LineString","coordinates": [[101.0, 0.0],[102.0, 1.0]]}]}')) as exp;
|
|
exp
|
|
GEOMETRYCOLLECTION(POINT(100 0),LINESTRING(101 0,102 1))
|
|
SELECT st_astext(st_geomfromgeojson('{"type":"point"}'));
|
|
st_astext(st_geomfromgeojson('{"type":"point"}'))
|
|
NULL
|
|
Warnings:
|
|
Warning 4048 Incorrect GeoJSON format specified for st_geomfromgeojson function.
|
|
SELECT st_astext(st_geomfromgeojson('{"type":"point"'));
|
|
st_astext(st_geomfromgeojson('{"type":"point"'))
|
|
NULL
|
|
Warnings:
|
|
Warning 4037 Unexpected end of JSON text in argument 1 to function 'st_geomfromgeojson'
|
|
SELECT st_astext(st_geomfromgeojson('{"type""point"}'));
|
|
st_astext(st_geomfromgeojson('{"type""point"}'))
|
|
NULL
|
|
Warnings:
|
|
Warning 4038 Syntax error in JSON text in argument 1 to function 'st_geomfromgeojson' at position 7
|
|
SELECT st_astext(st_geomfromgeojson('{ "type": "Feature", "geometry": { "type": "Point", "coordinates": [102.0, 0.5] } }')) as exp;
|
|
exp
|
|
POINT(102 0.5)
|
|
SELECT st_astext(st_geomfromgeojson('{ "geometry": { "type": "Point", "coordinates": [102.0, 0.5] }, "type": "Feature" }')) as exp;
|
|
exp
|
|
POINT(102 0.5)
|
|
SELECT st_astext(st_geomfromgeojson('{ "type": "FeatureCollection", "features": [{ "type": "Feature", "geometry": { "type": "Point", "coordinates": [102.0, 0.5] }, "properties": { "prop0": "value0" } }]}')) as exp;
|
|
exp
|
|
GEOMETRYCOLLECTION(POINT(102 0.5))
|
|
SELECT ST_AsText(ST_GeomFromGeoJSON('{ "type": "Point", "coordinates": [5.3, 15.0, 4.3]}',5));
|
|
ERROR HY000: Incorrect option value: '5' for function ST_GeomFromGeoJSON
|
|
SELECT ST_AsText(ST_GeomFromGeoJSON('{ "type": "Point", "coordinates": [5.3, 15.0, 4.3]}',1)) as exp;
|
|
ERROR 22023: Invalid GIS data provided to function ST_GeomFromGeoJSON.
|
|
SELECT ST_AsText(ST_GeomFromGeoJSON('{ "type": "Point", "coordinates": [5.3, 15.0, 4.3]}',2)) as exp;
|
|
exp
|
|
POINT(5.3 15)
|
|
SELECT ST_AsText(ST_GeomFromGeoJSON('{ "type": "Point", "coordinates": [5.3, 15.0, 4.3]}',3)) as exp;
|
|
exp
|
|
POINT(5.3 15)
|
|
SELECT ST_AsText(ST_GeomFromGeoJSON('{ "type": "Point", "coordinates": [5.3, 15.0, 4.3]}',4)) as exp;
|
|
exp
|
|
POINT(5.3 15)
|
|
SELECT ST_AsGeoJSON(ST_GeomFromText('POINT(5.363 7.266)'),2);
|
|
ST_AsGeoJSON(ST_GeomFromText('POINT(5.363 7.266)'),2)
|
|
{"type": "Point", "coordinates": [5.36, 7.27]}
|
|
SELECT ST_AsGeoJSON(ST_GeomFromText('POINT(5.363 7.266)'),1);
|
|
ST_AsGeoJSON(ST_GeomFromText('POINT(5.363 7.266)'),1)
|
|
{"type": "Point", "coordinates": [5.4, 7.3]}
|
|
SELECT ST_AsGeoJSON(ST_GeomFromText('POINT(5.363 7.266)'),10);
|
|
ST_AsGeoJSON(ST_GeomFromText('POINT(5.363 7.266)'),10)
|
|
{"type": "Point", "coordinates": [5.363, 7.266]}
|
|
SELECT ST_AsGeoJSON(ST_GeomFromText("POINT(10 11)"), 100, 1);
|
|
ST_AsGeoJSON(ST_GeomFromText("POINT(10 11)"), 100, 1)
|
|
{"bbox": [10, 11, 10, 11], "type": "Point", "coordinates": [10, 11]}
|
|
SELECT ST_AsGeoJSON(ST_GeomFromText("POINT(10 11)"), 100, 5);
|
|
ST_AsGeoJSON(ST_GeomFromText("POINT(10 11)"), 100, 5)
|
|
{"bbox": [10, 11, 10, 11], "type": "Point", "coordinates": [10, 11]}
|
|
SELECT st_astext(st_geomfromgeojson('{"type": "MultiLineString","coordinates": []}')) as a;
|
|
a
|
|
NULL
|
|
Warnings:
|
|
Warning 4076 Incorrect GeoJSON format - empty 'coordinates' array.
|
|
SELECT st_astext(st_geomfromgeojson('{"type": "Polygon","coordinates": []}')) as a;
|
|
a
|
|
NULL
|
|
Warnings:
|
|
Warning 4076 Incorrect GeoJSON format - empty 'coordinates' array.
|
|
SELECT st_astext(st_geomfromgeojson('{"type": "MultiPolygon","coordinates": []}')) as a;
|
|
a
|
|
NULL
|
|
Warnings:
|
|
Warning 4076 Incorrect GeoJSON format - empty 'coordinates' array.
|
|
SELECT ST_GEOMFROMGEOJSON("{ \"type\": \"Feature\", \"geometry\": [10, 20] }") as exp;
|
|
exp
|
|
NULL
|
|
Warnings:
|
|
Warning 4048 Incorrect GeoJSON format specified for st_geomfromgeojson function.
|
|
SELECT ST_ASTEXT (ST_GEOMFROMGEOJSON ('{ "type": "GEOMETRYCOLLECTION", "coordinates": [102.0, 0.0]}')) as exp;
|
|
exp
|
|
NULL
|
|
Warnings:
|
|
Warning 4048 Incorrect GeoJSON format specified for st_geomfromgeojson function.
|
|
SELECT ST_ASTEXT(ST_GEOMFROMGEOJSON('{"type": ["POINT"], "coINates": [0,0] }')) as exp;
|
|
exp
|
|
NULL
|
|
Warnings:
|
|
Warning 4048 Incorrect GeoJSON format specified for st_geomfromgeojson function.
|
|
#
|
|
# End of 10.2 tests
|
|
#
|
|
#
|
|
# MDEV-39813 ST_GeomFromGeoJSON does not control recursion depth
|
|
#
|
|
SELECT ST_GeomFromGeoJSON(
|
|
concat(
|
|
repeat('{"type":"GeometryCollection","geometries":[', 2000),
|
|
'{"type":"Point","coordinates":[0,0]}',
|
|
repeat(']}', 2000)
|
|
)) as exp;
|
|
exp
|
|
NULL
|
|
Warnings:
|
|
Warning 4040 Limit of 32 on JSON nested structures depth is reached in argument 1 to function 'st_geomfromgeojson' at position 688
|
|
# Boundary condition: foreign-member nesting at depth 32
|
|
SET @geom := '{"type":"Point","coordinates":[1,2]}';
|
|
SET @doc := CONCAT(
|
|
REPEAT('{"x":', 29),
|
|
@geom,
|
|
REPEAT('}', 29)
|
|
);
|
|
SELECT ST_ASTEXT( ST_GeomFromGeoJSON(@doc) ) AS expr;
|
|
expr
|
|
NULL
|
|
Warnings:
|
|
Warning 4048 Incorrect GeoJSON format specified for st_geomfromgeojson function.
|
|
# Foreign-member nesting exceeds depth 32
|
|
SET @geom := '{"type":"Point","coordinates":[1,2]}';
|
|
SET @doc := CONCAT(
|
|
REPEAT('{"x":', 30),
|
|
@geom,
|
|
REPEAT('}', 30)
|
|
);
|
|
SELECT ST_GeomFromGeoJSON(@doc) AS expr;
|
|
expr
|
|
NULL
|
|
Warnings:
|
|
Warning 4040 Limit of 32 on JSON nested structures depth is reached in argument 1 to function 'st_geomfromgeojson' at position 181
|
|
# Deep foreign member attached to otherwise valid GeoJSON
|
|
SET @foreign := CONCAT(
|
|
REPEAT('{"x":', 28),
|
|
'{"leaf":1}',
|
|
REPEAT('}', 28)
|
|
);
|
|
SET @doc := CONCAT(
|
|
'{"type":"Point","coordinates":[10,20],"foreign":',
|
|
@foreign,
|
|
'}'
|
|
);
|
|
SELECT ST_ASTEXT(ST_GeomFromGeoJSON(@doc)) AS expr;
|
|
expr
|
|
POINT(10 20)
|
|
# Foreign member exceeds depth limit
|
|
SET @foreign := CONCAT(
|
|
REPEAT('{"x":', 29),
|
|
'{"leaf":1}',
|
|
REPEAT('}', 29)
|
|
);
|
|
SET @doc := CONCAT(
|
|
'{"type":"Point","coordinates":[10,20],"foreign":',
|
|
@foreign,
|
|
'}'
|
|
);
|
|
SELECT ST_ASTEXT(ST_GeomFromGeoJSON(@doc)) AS expr;
|
|
expr
|
|
POINT(10 20)
|
|
# GeometryCollection containing 33 valid GeoJSON Point objects
|
|
SET @point := '{"type":"Point","coordinates":[1,2]}';
|
|
SET @geoms := CONCAT(
|
|
@point, ',', @point, ',', @point, ',', @point, ',', @point, ',',
|
|
@point, ',', @point, ',', @point, ',', @point, ',', @point, ',',
|
|
@point, ',', @point, ',', @point, ',', @point, ',', @point, ',',
|
|
@point, ',', @point, ',', @point, ',', @point, ',', @point, ',',
|
|
@point, ',', @point, ',', @point, ',', @point, ',', @point, ',',
|
|
@point, ',', @point, ',', @point, ',', @point, ',', @point, ',',
|
|
@point, ',', @point, ',', @point, ',', @point, ',', @point, ',',
|
|
@point, ',', @point, ',', @point
|
|
);
|
|
SET @doc := CONCAT(
|
|
'{"type":"GeometryCollection","geometries":[',
|
|
@geoms,
|
|
']}'
|
|
);
|
|
SELECT ST_AsText(ST_GeomFromGeoJSON(@doc)) AS expr;
|
|
expr
|
|
GEOMETRYCOLLECTION(POINT(1 2),POINT(1 2),POINT(1 2),POINT(1 2),POINT(1 2),POINT(1 2),POINT(1 2),POINT(1 2),POINT(1 2),POINT(1 2),POINT(1 2),POINT(1 2),POINT(1 2),POINT(1 2),POINT(1 2),POINT(1 2),POINT(1 2),POINT(1 2),POINT(1 2),POINT(1 2),POINT(1 2),POINT(1 2),POINT(1 2),POINT(1 2),POINT(1 2),POINT(1 2),POINT(1 2),POINT(1 2),POINT(1 2),POINT(1 2),POINT(1 2),POINT(1 2),POINT(1 2),POINT(1 2),POINT(1 2),POINT(1 2),POINT(1 2),POINT(1 2))
|
|
#
|
|
# MDEV-39981: ST_GEOMFROMGEOJSON returns wrong result with reversed key order
|
|
#
|
|
# GeometryCollection: type before geometries (baseline)
|
|
SELECT ST_ASTEXT(ST_GEOMFROMGEOJSON('{"type":"GeometryCollection","geometries":[]}')) as expr;
|
|
expr
|
|
GEOMETRYCOLLECTION EMPTY
|
|
# GeometryCollection: geometries before type (empty)
|
|
SELECT ST_ASTEXT(ST_GEOMFROMGEOJSON('{"geometries":[],"type":"GeometryCollection"}')) as expr;
|
|
expr
|
|
GEOMETRYCOLLECTION EMPTY
|
|
# GeometryCollection: geometries before type (non-empty)
|
|
SELECT ST_ASTEXT(ST_GEOMFROMGEOJSON('{"geometries":[{"type":"Point","coordinates":[0,1]}],"type":"GeometryCollection"}')) as expr;
|
|
expr
|
|
GEOMETRYCOLLECTION(POINT(0 1))
|
|
# GeometryCollection: multiple geometries before type
|
|
SELECT ST_ASTEXT(ST_GEOMFROMGEOJSON('{"geometries":[{"type":"Point","coordinates":[1,2]},{"type":"Point","coordinates":[3,4]}],"type":"GeometryCollection"}')) as expr;
|
|
expr
|
|
GEOMETRYCOLLECTION(POINT(1 2),POINT(3 4))
|
|
# Point: coordinates before type
|
|
SELECT ST_ASTEXT(ST_GEOMFROMGEOJSON('{"coordinates":[0,1],"type":"Point"}')) as expr;
|
|
expr
|
|
POINT(0 1)
|
|
# LineString: coordinates before type
|
|
SELECT ST_ASTEXT(ST_GEOMFROMGEOJSON('{"coordinates":[[0,0],[1,1],[2,2]],"type":"LineString"}')) as expr;
|
|
expr
|
|
LINESTRING(0 0,1 1,2 2)
|
|
# Polygon: coordinates before type
|
|
SELECT ST_ASTEXT(ST_GEOMFROMGEOJSON('{"coordinates":[[[0,0],[1,0],[1,1],[0,1],[0,0]]],"type":"Polygon"}')) as expr;
|
|
expr
|
|
POLYGON((0 0,1 0,1 1,0 1,0 0))
|
|
# FeatureCollection: features before type
|
|
SELECT ST_ASTEXT(ST_GEOMFROMGEOJSON('{"features":[{"geometry":{"type":"Point","coordinates":[5,6]},"type":"Feature","properties":{}}],"type":"FeatureCollection"}')) as expr;
|
|
expr
|
|
GEOMETRYCOLLECTION(POINT(5 6))
|
|
# Feature: geometry before type
|
|
SELECT ST_ASTEXT(ST_GEOMFROMGEOJSON('{"geometry":{"coordinates":[7,8],"type":"Point"},"type":"Feature","properties":{}}')) as expr;
|
|
expr
|
|
POINT(7 8)
|
|
# Unknown keys interspersed (should be ignored)
|
|
SELECT ST_ASTEXT(ST_GEOMFROMGEOJSON('{"foo":"bar","geometries":[],"type":"GeometryCollection","extra":123}')) as expr;
|
|
expr
|
|
GEOMETRYCOLLECTION EMPTY
|
|
# Deeply nested geometries before type
|
|
SELECT ST_ASTEXT(ST_GEOMFROMGEOJSON('{"geometries":[{"geometries":[{"type":"Point","coordinates":[9,10]}],"type":"GeometryCollection"}],"type":"GeometryCollection"}')) as expr;
|
|
expr
|
|
GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(9 10)))
|
|
# End of 10.6 tests
|
|
#
|
|
# MDEV-34079: ST_AsGeoJSON returns incorrect value for empty geometry
|
|
#
|
|
SELECT ST_AsGeoJSON(GeomFromText('GeometryCollection EMPTY'));
|
|
ST_AsGeoJSON(GeomFromText('GeometryCollection EMPTY'))
|
|
{"type": "GeometryCollection", "geometries": []}
|
|
SELECT ST_AsGeoJSON(ST_DIFFERENCE(POINT(0,0), POINT(0,0)));
|
|
ST_AsGeoJSON(ST_DIFFERENCE(POINT(0,0), POINT(0,0)))
|
|
{"type": "GeometryCollection", "geometries": []}
|
|
SELECT ST_AsGeoJSON(GeomFromText('MultiPoint EMPTY'));
|
|
ST_AsGeoJSON(GeomFromText('MultiPoint EMPTY'))
|
|
NULL
|
|
SELECT ST_AsGeoJSON(GeomFromText('MultiLineString EMPTY'));
|
|
ST_AsGeoJSON(GeomFromText('MultiLineString EMPTY'))
|
|
NULL
|
|
SELECT ST_AsGeoJSON(GeomFromText('MultiPolygon EMPTY'));
|
|
ST_AsGeoJSON(GeomFromText('MultiPolygon EMPTY'))
|
|
NULL
|
|
# End of 10.11 tests
|