bziobrowski opened a new pull request, #14405:
URL: https://github.com/apache/pinot/pull/14405

   This PR adds support for GeoJSON format (see 1 & 2) 
   
   with following functions:
   ``
   ST_GeomFromGeoJson(string) -> binary
   ST_GeogFromGeoJson(string) -> binary
   ST_AsGeoJson(binary) -> string
   ``
   
   Supported data types:
   - Point
   - LineString
   - Polygon
   - MultiPoint
   - MultiLineString
   - MultiPolygon
   - GeometryCollection
   - Feature
   - FeatureCollection
   
   Examples:
   
   A. Convert from WKT to GeoJSON:
   
   - convert Point geometry 
   ```sql
   select ST_AsGeoJson(ST_GeomFromText('POINT (1 2)'))
   ```
   returns  
   ```json
   { 
     "type":"Point",
     "coordinates":[1,2],
     "crs":{"type":"name","properties":{"name":"EPSG:0"}}
   }
   ```
   
   - convert point geography
   ```sql
   select ST_AsGeoJson(ST_GeogFromText('POINT (1 2)'))
   ```    
   returns 
   ```json
   {
     "type":"Point",
     "coordinates":[1,2],
     "crs":{"type":"name","properties":{"name":"EPSG:4326"}}
   }
   ```
   
   - convert MultiLineString geometry
   ```sql
   select ST_AsGeoJson(ST_GeomFromText('MULTILINESTRING ((1 1, 5 1), (2 4, 4 
4))'))
   ```
   returns 
   ```json
   {
     "type":"MultiLineString",
     "coordinates":[[[1,1],[5,1]],[[2,4],[4,4]]],
     "crs":{"type":"name","properties":{"name":"EPSG:0"}}
   }
   ```
   
   - convert MultiLineString geography
   ```sql
   select ST_AsGeoJson(ST_GeogFromText('MULTILINESTRING ((1 1, 5 1), (2 4, 4 
4))')) 
   ```
   returns 
   ```json
   {
     "type":"MultiLineString",
     "coordinates":[[[1,1],[5,1]],[[2,4],[4,4]]],
     "crs":{"type":"name","properties":{"name":"EPSG:4326"}}
   }
   ```
   
   B. Convert from GeoJson to WKT:
   
   - convert Point geometry
   ```sql
   select ST_AsText(ST_GeomFromGeoJson('{"type":"Point","coordinates":[1,2]}')) 
   ``` 
   returns
   `POINT (1 2)`
   
   - convert MultiLineString geometry
   ```sql
   select 
ST_AsText(ST_GeomFromGeoJson('{"type":"MultiLineString","coordinates":[[[1,1],[5,1]],[[2,4],[4,4]]]}'')
   ```
   returns 
   `MULTILINESTRING ((1 1, 5 1), (2 4, 4 4))`
   
   References:
   1. https://geojson.org/
   2. https://datatracker.ietf.org/doc/html/rfc7946


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to