[postgis-devel] [PostGIS] #1833: full record json output in 9.2 with valid geojson output

PostGIS trac at osgeo.org
Mon May 21 13:52:09 PDT 2012


#1833: full record json output in 9.2 with valid geojson output
-------------------------+--------------------------------------------------
 Reporter:  robe         |       Owner:  pramsey      
     Type:  enhancement  |      Status:  new          
 Priority:  medium       |   Milestone:  PostGIS 2.1.0
Component:  postgis      |     Version:  2.0.x        
 Keywords:               |  
-------------------------+--------------------------------------------------
 9.2 now has native json support.  YES. It has a json type and I can output
 a whole dataset as a single json object with this SWEET command.


 {{{
 CREATE TABLE test(gid serial primary key, title text, geog
 geography(Point,4326));

 INSERT INTO test(title, geog) VALUES('My neck of the woods',
 ST_GeogFromText('POINT(-71.057811 42.358274)'));

 INSERT INTO test(title, geog) VALUES('some other neck of the woods',
 ST_GeogFromText('POINT(42.358274 -71.057811 )'));

 SELECT array_to_json(array_agg(t))
 FROM test As t
 }}}

 Ah but our beautiful geography which we have grown to love is not
 outputting using our json function. We need to rectify this.


 {{{
  [{"gid":1,"title":"My neck of the
 woods","geog":"0101000020E61000005796E82CB3C3
 51C0E98024ECDB2D4540"},{"gid":2,"title":"some other neck of the
 woods","geog":"0
 101000020E6100000E98024ECDB2D45405796E82CB3C351C0"}]
 }}}

 I'm hoping its as trivial as defining a CAST for geography/geometry to
 json using our ST_AsGeoJSON functions.  I'll test that theory out next.

-- 
Ticket URL: <http://trac.osgeo.org/postgis/ticket/1833>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-devel mailing list