geo: fix GeoJSON and allow options in ST_AsGeoJSON#49888
geo: fix GeoJSON and allow options in ST_AsGeoJSON#49888craig[bot] merged 1 commit intocockroachdb:masterfrom
Conversation
062fb41 to
59292a9
Compare
sumeerbhola
left a comment
There was a problem hiding this comment.
Reviewed 9 of 9 files at r1.
Reviewable status:complete! 0 of 0 LGTMs obtained (waiting on @otan)
pkg/geo/encode_test.go, line 99 at r1 (raw file):
{"SRID=4004;POINT(1.0 1.0)", EWKBToGeoJSONFlagShortCRS, `{"type":"Point","crs":{"type":"name","properties":{"name":"EPSG:4004"}},"coordinates":[1,1]}`}, {"SRID=4004;POINT(1.0 1.0)", EWKBToGeoJSONFlagShortCRS | EWKBToGeoJSONFlagIncludeBBox, `{"type":"Point","bbox":[1,1,1,1],"crs":{"type":"name","properties":{"name":"EPSG:4004"}},"coordinates":[1,1]}`}, {"SRID=4326;POINT(1.0 1.0)", EWKBToGeoJSONFlagShortCRSIfNot4326, `{"type":"Point","coordinates":[1,1]}`},
can you repeat this last case with "SRID=4004"
pkg/geo/parse_test.go, line 228 at r1 (raw file):
}, { `{ "type": "Point", "coordinates": [1.0, 1.0] }`,
I'm assuming we don't currently support the following "feature" example from the PostGIS documentation -- correct?
SELECT ST_AsGeoJSON(t.*)
FROM (VALUES
(1, 'one', 'POINT(1 1)'::geometry),
(2, 'two', 'POINT(2 2)'),
(3, 'three', 'POINT(3 3)'))
AS t(id, name, geom);
st_asgeojson
-----------------------------------------------------------------------------------------------------------------
{"type": "Feature", "geometry": {"type":"Point","coordinates":[1,1]}, "properties": {"id": 1, "name": "one"}}
{"type": "Feature", "geometry": {"type":"Point","coordinates":[2,2]}, "properties": {"id": 2, "name": "two"}}
{"type": "Feature", "geometry": {"type":"Point","coordinates":[3,3]}, "properties": {"id": 3, "name": "three"}}
pkg/sql/sem/builtins/geo_builtins.go, line 948 at r1 (raw file):
Options is a flag that can be bitmasked. The options are: * 0: no option
https://postgis.net/docs/ST_AsGeoJSON.html suggests 0 is the default for geography
text ST_AsGeoJSON(geography geog, integer maxdecimaldigits=9, integer options=0);
otan
left a comment
There was a problem hiding this comment.
Reviewable status:
complete! 0 of 0 LGTMs obtained (waiting on @sumeerbhola)
pkg/geo/encode_test.go, line 99 at r1 (raw file):
Previously, sumeerbhola wrote…
can you repeat this last case with "SRID=4004"
Done.
pkg/geo/parse_test.go, line 228 at r1 (raw file):
Previously, sumeerbhola wrote…
I'm assuming we don't currently support the following "feature" example from the PostGIS documentation -- correct?
SELECT ST_AsGeoJSON(t.*) FROM (VALUES (1, 'one', 'POINT(1 1)'::geometry), (2, 'two', 'POINT(2 2)'), (3, 'three', 'POINT(3 3)')) AS t(id, name, geom); st_asgeojson ----------------------------------------------------------------------------------------------------------------- {"type": "Feature", "geometry": {"type":"Point","coordinates":[1,1]}, "properties": {"id": 1, "name": "one"}} {"type": "Feature", "geometry": {"type":"Point","coordinates":[2,2]}, "properties": {"id": 2, "name": "two"}} {"type": "Feature", "geometry": {"type":"Point","coordinates":[3,3]}, "properties": {"id": 3, "name": "three"}}
Yeah we don't suppoer the "record" type.
pkg/sql/sem/builtins/geo_builtins.go, line 948 at r1 (raw file):
Previously, sumeerbhola wrote…
https://postgis.net/docs/ST_AsGeoJSON.html suggests 0 is the default for geography
text ST_AsGeoJSON(geography geog, integer maxdecimaldigits=9, integer options=0);
oops, typo
sumeerbhola
left a comment
There was a problem hiding this comment.
Reviewed 3 of 3 files at r2.
Reviewable status:complete! 1 of 0 LGTMs obtained (waiting on @sumeerbhola)
|
bors r=sumeerbhola |
|
bors r- |
Canceled |
There was a bug in GeoJSON where we used the high level name:"Feature" field, as opposed to the inner Geometry. This has been fixed. We also support more options for ST_AsGeoJSON now that these changes are in twpayne/go-geom. Release note (sql change): Implement ST_AsGeoJSON with options to show bbox and CRS information.
|
bors r=sumeerbhola |
Merge conflict (retrying...) |
1 similar comment
Merge conflict (retrying...) |
Build succeeded |
There was a bug in GeoJSON where we used the high level name:"Feature"
field, as opposed to the inner Geometry. This has been fixed.
We also support more options for ST_AsGeoJSON now that these changes are
in twpayne/go-geom.
Resolves #48381.
Release note (sql change): Implement ST_AsGeoJSON with options to show
bbox and CRS information.