User Tools

Site Tools


postgis

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Last revision Both sides next revision
postgis [2020/02/12 12:03]
mantis [Select all geometries in an area]
postgis [2020/02/12 12:05]
mantis [Export table to geojson]
Line 118: Line 118:
 ===== Export table to geojson ===== ===== Export table to geojson =====
  
-Building a FeatureCollection ([[https://​postgis.net/​docs/​ST_AsGeoJSON.html|docs]])+Building a FeatureCollection ([[https://​postgis.net/​docs/​ST_AsGeoJSON.html|docs]], [[https://​gist.github.com/​brambow/​889aca48831e189a62eec5a70067bf8e|code snippet]])
 + 
 +<code psql> 
 + ​SELECT json_build_object( 
 +    '​type',​ '​FeatureCollection',​ 
 +    '​crs', ​ json_build_object( 
 +        '​type', ​     '​name',​  
 +        '​properties',​ json_build_object( 
 +            '​name',​ '​EPSG:​4326' ​  
 +        ) 
 +    ),  
 +    '​features',​ json_agg( 
 +        json_build_object( 
 +              '​type', ​      '​Feature',​ 
 +    '​id', ​        id, 
 +    '​geometry', ​  ​ST_AsGeoJSON(the_geom)::​json,​ 
 +    '​properties',​ json_build_object( 
 +        '​name',​ name, 
 +        '​frc',​ frc, 
 +        '​fromjunction',​ fromjunction,​ 
 +        '​tojunction',​ tojunction,​ 
 +          ) 
 +       ) 
 +    ) 
 +
 + FROM roadmap_table;​ 
 +</​code>​
  
  
postgis.txt · Last modified: 2020/02/12 12:06 by mantis