-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
H2 - H2GIS geojson #1198
Comments
I don't know what There is no There is no Personally I don't think that H2 should support PostgreSQL-specific functions, because people who use them typically also use obscure PostgreSQL-specific operators in combination with them, these operators aren't supported by H2 and most likely aren't going to be supported. H2 actually can write GeoJSON by itself, but if you need features, you need to construct them with JSON functions, subqueries, etc. SELECT CAST(GEOMETRY 'POINT(1 1)' AS JSON);
> {"type":"Point","coordinates":[1,1]} |
I don't want to support PostgreSQL-specific functions but find a way to return {"type" : "FeatureCollection", "features" : [{"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"}}]} with H2 functions will be good. Something like :
|
You can use something like SELECT JSON_OBJECT(
'type': 'FeatureCollection',
'features': (
SELECT JSON_ARRAYAGG(
JSON_OBJECT('type': 'feature', 'geometry': GEOM, 'properties': JSON_OBJECT('id': ID, 'name': NAME)))
FROM (VALUES
(1, 'one', GEOMETRY 'POINT(1 1)'),
(2, 'two', GEOMETRY 'POINT(2 2)'),
(3, 'three', GEOMETRY 'POINT(3 3)')
) T(ID, NAME, GEOM))); It returns
|
It'd be nice to support this kind of query in the famous H2 db with H2GIS functions
return
Source : http://postgis.net/docs/ST_AsGeoJSON.html
The text was updated successfully, but these errors were encountered: