[mapserver-dev] RFC-93: UTFGrid output
Even Rouault
even.rouault at mines-paris.org
Wed Aug 28 07:30:07 PDT 2013
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
More information about the mapserver-dev
mailing list