[mapserver-dev] Fwd: Re: RFC-93: UTFGrid output

Lime, Steve D (MNIT) Steve.Lime at state.mn.us
Wed Aug 28 07:58:21 PDT 2013


Could really use a general JSON escaping function then. ;-)

-----Original Message-----
From: mapserver-dev-bounces at lists.osgeo.org [mailto:mapserver-dev-bounces at lists.osgeo.org] On Behalf Of Even Rouault
Sent: Wednesday, August 28, 2013 9:58 AM
To: mapserver-dev at lists.osgeo.org
Subject: [mapserver-dev] Fwd: Re: RFC-93: UTFGrid output

Re-adding mapserver-dev

----------  Message transmis  ----------

Sujet : Re: [mapserver-dev] RFC-93: UTFGrid output Date : mercredi 28 août 2013, 16:50:47 De : Francois Desjarlais <fdesjarlais1 at gmail.com> À : Even Rouault <even.rouault at mines-paris.org>

Hi Even,

I misunderstood on the first place and had to re-read your first message.
You are right, the datas in the UTFITEM and UTFDATA aren't escaped. These item are only the evaluated expression and contains copies of the datas in the shapefiles. I will add a note in the doc specifying that UTFITEM and UTFDATA should use JSON valid only datas.

Steve, since I misunderstood in the first place, I doubt that my function is the one you think about so I will not add it to the mapstring.c file.

Thanks
Francois


2013/8/28 Even Rouault <even.rouault at mines-paris.org>

> Hi François,
>
> > My code is already escaping non-valid characters in the JSON. It 
> > should always return a valid one.
>
> Are you sure of that ?
>
> Consider this :
>
> $ cat test.csv
> id,name,WKT
> "a""b\c","d""e\f","POINT(2 49)"
>
> $ ogrinfo test.csv -al
> INFO: Open of `test.csv'
>       using driver `CSV' successful.
>
> Layer name: test
> Geometry: Unknown (any)
> Feature Count: 1
> Extent: (2.000000, 49.000000) - (2.000000, 49.000000) Layer SRS WKT:
> (unknown)
> id: String (0.0)
> name: String (0.0)
> WKT: String (0.0)
> OGRFeature(test):1
>   id (String) = a"b\c
>   name (String) = d"e\f
>   WKT (String) = POINT(2 49)
>   POINT (2 49)
>
> $ cat test_utfgrid.map
> MAP
>
> SIZE 10 10
> EXTENT 1 48 3 50
>
> OUTPUTFORMAT
>   NAME "utfgrid"
>   DRIVER UTFGRID
>   MIMETYPE "application/json"
>   EXTENSION "json"
> END
>
> LAYER
>   NAME test
>   CONNECTIONTYPE OGR
>   CONNECTION "test.csv"
>   UTFITEM   "id"
>   UTFDATA   "{\"id\":\"[id]\",\"name\":\"[name]\"}"
>   TYPE POINT
>   STATUS ON
>   CLASS
>     COLOR 0 0 0
>   END
> END
>
> END
>
> $ shp2img -m test_utfgrid.map  -o out.json
>
> $ cat out.json
> {"grid":["  ","  "],"keys":["","a"b\c"],"data":{"a"b\c":
> {"id":"a"b\c","name":"d"e\f"}}}
>
> The strings in keys and data are not JSON escaped.
>
> > Also, I don't have enough time to add the suggested mode before the 
> > end
> of
> > the project and school restarting.
>
> Understood. That was just an idea. And others might disagree it is 
> appropriate.
>
> Even
>
> --
> Geospatial professional services
> http://even.rouault.free.fr/services.html
>

-------------------------------------------------------
--
Geospatial professional services
http://even.rouault.free.fr/services.html
_______________________________________________
mapserver-dev mailing list
mapserver-dev at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-dev




More information about the mapserver-dev mailing list