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

Daniel Morissette dmorissette at mapgears.com
Wed Aug 28 07:58:49 PDT 2013


François,

A note in the docs is not sufficient since the data can be used for 
other uses independent of UTFGrid which won't be able to deal with the 
JSON escapes.

We will need proper escaping of the values in the UTFGrid driver before 
this can be merged into MapServer.

Daniel


On 13-08-28 10:58 AM, Even Rouault wrote:
> 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
>>
>
> -------------------------------------------------------
>


-- 
Daniel Morissette
http://www.mapgears.com/
Provider of Professional MapServer Support since 2000



More information about the mapserver-dev mailing list