[GeoJSON] AsJSON(geometry)

Paul Ramsey pramsey at refractions.net
Sat Mar 17 10:54:49 PDT 2007


My interest in this subject is solely so that I can add an AsJSON() and 
GeometryFromJSON() functions to PostGIS to make life easier for people 
writing scripting access to the database.  A recent experience with 
writing a quick'n'dirty KML service really hammered home how utility 
functions like these can make scripters lives easier.

I see there's a simple draft on the wiki already, which goes all the way 
to the feature model.  All the AsJSON() function would do is the 
geometry part: would you say the geometry representation is largely set?

So,

AsJSON(GeometryFromText('POLYGON(((0 0 0, 1 0 0, 1 1 0, 0 1 0, 0 0 
0)))',4326))

would return

"polygon": [[[0.0, 0.0, 0.0] [1.0, 0.0, 0.0] [1.0, 1.0, 0.0] [0.0, 1.0, 
0.0] [0.0, 0.0, 0.0]]]

At some point you should note that "the behavior of our rings and vertex 
arrays is meant to follow the semantics defined in the OGC SF model" (no 
interior/exterior ring intersections, except at a single point) . Are 
you planning on distinguishing between POLYGON and MULTIPOLYGON or going 
for a more Shapefileish "always a MULTIPOLYGON" model?

P

-- 

   Paul Ramsey
   Refractions Research
   http://www.refractions.net
   pramsey at refractions.net
   Phone: 250-383-3022
   Cell: 250-885-0632



More information about the GeoJSON mailing list