#4814 closed defect (fixed)
SetFeature from string to real on some locales cause wrong values
Reported by: | bishop | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | 1.9.2 |
Component: | OGR_SF | Version: | unspecified |
Severity: | normal | Keywords: | SetFeature atof locale GeoJSON |
Cc: |
Description
I work with GeoJSON driver and get data from http://geofuse.geoeye.com.
OGRSFDriverRegistrar::Open("http://geofuse.geoeye.com/ArcGIS/rest/services/GeoEyeCatalogFeatures/MapServer/2/query?text=&geometry=37.000000%2C54.000000%2C38.000000%2C55.000000&geometryType=esriGeometryEnvelope&inSR=4326&spatialRel=esriSpatialRelIntersects&relationParam=&objectIds=&where=COLLECTION_VEHICLE_SHORT='IK-2'%20AND%20CLOUD_COVER_PERCENT%20<=%20100&time=&returnIdsOnly=false&returnGeometry=true&maxAllowableOffset=&outSR=4326&outFields=*&f=json", FALSE);
In ogresrijsonreader.cpp while parsing output in line 328 the feature of type OGRReal set from string
poFeature->SetField( nField, json_object_get_string(it.val) );
I use russian locale and delimiter for real values is ",", but server use us locale and output data has "." delimiter.
In ogrfeature.cpp line 1948 we have such code
pauFields[iField].Real = atof(pszValue);
and I lose decimal part.
I see 2 solutions:
- change
pauFields[iField].Real = atof(pszValue);
to
pauFields[iField].Real = CPLAtofM(pszValue);
but this may be slow and influence on other drivers.
- Rewrite OGRFeature* OGRESRIJSONReader::ReadFeature( json_object* poObj ) (gdal_root\ogr\ogrsf_frmts\geojson\ogresrijsonreader.cpp:297) to prepare input of SetFeature in locale specific form. Also adding support for esriFieldTypeDate which is now set as OGRString field type.
What is preferable?
Change History (2)
follow-up: 2 comment:1 by , 12 years ago
Milestone: | → 1.9.2 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Version: | svn-trunk → unspecified |
comment:2 by , 12 years ago
Replying to rouault:
The subject of supporting esriFieldTypeDate would deserve its own ticket to avoid mixing things. I assume you want to have a try on implementing it ?
Yes, I'll paln to do it, but not right now
Fixed in trunk (r24923) and branches/1.9 (r24924) by using CPLAtofM() in ogresrijsonreader.cpp
I'm closing this ticket. The subject of supporting esriFieldTypeDate would deserve its own ticket to avoid mixing things. I assume you want to have a try on implementing it ?