Bug report #11587

all coordinates truncated to integer values when system has certain locale settings

Added by Etienne Trimaille over 9 years ago. Updated over 7 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Vectors
Affected QGIS version:2.6.0 Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:up/downstream
Crashes QGIS or corrupts data:No Copied to github as #:19846

Description

I have two files (attached annex) with the same content : one in OSM, the other in GeoJson.

I can open the OSM file (point layer), every thing is OK.
However, if I open the geojson, all coordinates are truncated to integer values.

I can run this script :

##Debug=group
##Test decimal=name
##layer=vector
layer = processing.getObject(layer)
for feature in layer.getFeatures():
    print feature.geometry().exportToWkt()

For OSM, I get : "POINT (2.36937020000000009 48.82156119999999788)"
But for geojson : "POINT (2 48)"
But as you can see in the geojson, there are some decimal too.

I tried to play with parameters in Kubuntu about decimal separator, I can't resolve this problem.

Another issue is related to this :
https://github.com/3liz/QgisQuickOSMPlugin/issues/34

tmpeCOKIN.osm - OSM (318 KB) Etienne Trimaille, 2014-11-06 01:49 PM

tmpZcvhzs_points.geojson - The same as OSM but in GeoJSON (206 KB) Etienne Trimaille, 2014-11-06 01:49 PM


Related issues

Duplicated by QGIS Application - Bug report #12555: geojson open with bad result with all data on same point,... Closed 2015-04-13
Duplicated by QGIS Application - Bug report #13098: GeoJSON vector issue Closed 2015-07-09
Duplicated by QGIS Application - Bug report #13391: GeoJSON not displayed correctly Closed 2015-09-21

History

#1 Updated by Giovanni Manghi over 9 years ago

  • Priority changed from High to Normal
  • Status changed from Open to Feedback

seems a local issue. Any tool I tested to get that points coordinates returns decimal values.

#2 Updated by Milos Kroulik over 9 years ago

I'm also having this problem in QGIS 2.7-master on Ubuntu 14.04 (precisely Linux Mint 17.1) installed using Ubuntugis unstable and QGIS devel repositories. What can i try to mitigate the problem? My coworker tried it with Win 7, at it works well.

Full environment info:

QGIS version 2.7.0-Master QGIS code revision exported
Compiled against Qt 4.8.6 Running against Qt 4.8.6
Compiled against GDAL/OGR 1.11.0 Running against GDAL/OGR 1.11.0
Compiled against GEOS 3.4.2-CAPI-1.8.2 Running against GEOS 3.4.2-CAPI-1.8.2 r3921
PostgreSQL Client Version 9.3.4 SpatiaLite Version 4.1.1
QWT Version 5.2.3 PROJ.4 Version 480

#3 Updated by Milos Kroulik over 9 years ago

New findings confirm, that this issue is definitely related to system locale settings. I changed locale settings in Cinnamon environment to en-US and (after reboot) QGIS was able to load GeoJSON file correctly. So title of this issue should be changed - or should I close this issue and create new one based on new findings?

#4 Updated by Giovanni Manghi over 9 years ago

  • Status changed from Feedback to Open
  • Subject changed from all coordinates truncated to integer values to all coordinates truncated to integer values when system has certain locale settings
  • Category set to Vectors

Milos Kroulik wrote:

New findings confirm, that this issue is definitely related to system locale settings. I changed locale settings in Cinnamon environment to en-US and (after reboot) QGIS was able to load GeoJSON file correctly. So title of this issue should be changed - or should I close this issue and create new one based on new findings?

title edited. This was an issue also in older qgis releases?

#5 Updated by Milos Kroulik over 9 years ago

It's present at least in 2.6, another poster in linked Github issue mentioned, that it was also present in 2.4

#6 Updated by Etienne Trimaille over 9 years ago

I confirm that bug on qgis 2.4 too.
Sure it's a problem with locales. The decimal separator should be treated by any locales.
Do you think we should check more GDAL/OGR ? And maybe open an issue linked to this one on GDAL's tracker.

#7 Updated by Michael Douchin almost 9 years ago

  • Target version changed from Version 2.6 to Future Release - Nice to have

#8 Updated by Martin Weis over 8 years ago

I had this issue, too and here is my bugreport:

GeoJSON import fails based on LANG settings

I found the import of GeoJSON files to fail based on the language settings. The file gets imported, but the decimals are lost.
An import with qgis started under a generic english LANG environment imports the file correctly:
LANG=C qgis

With the following test.json:

{"features": [ {"geometry": {"coordinates": [[[9.0, 48.0], [9.0, 49.5], [9.5, 49.5], [9.5, 48.0], [9.0, 48.0]]], "type": "Polygon"}, "properties": {"xyid": "0 0"}, "type": "Feature"},
], "type": "FeatureCollection"}

The import under a german environment (de_DE.UTF-8) yields a deformed polygon, "Plain Geometry editor" extension shows these coordinates:
Polygon ((9 48, 9 49, 9 49, 9 48, 9 48))

with LANG=C qgis loads the same file correctly:
Polygon ((9 48, 9 49.5, 9.5 49.5, 9.5 48, 9 48))

ogr standalone binary correctly converts the coordinates, e.g. to GML (excerpt):
ogr2ogr -f "GML" out.gml in.json

<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>9,48 9.0,49.5 9.5,49.5 9.5,48.0 9,48</gml:coordinates></gml:L
inearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>

QGIS version
2.12.1-Lyon
QGIS code revision
exported
Compiled against Qt
4.8.6
Running against Qt
4.8.6
Compiled against GDAL/OGR
1.10.1
Running against GDAL/OGR
1.11.2
Compiled against GEOS
3.4.2-CAPI-1.8.2
Running against GEOS
3.4.2-CAPI-1.8.2 r3921
PostgreSQL Client Version
9.3.4
SpatiaLite Version
4.1.1
QWT Version
5.2.3
PROJ.4 Version
480
QScintilla2 Version
2.8.1

#9 Updated by Martin Weis over 8 years ago

There are duplicates in the bugreports: #13391, #13098
I can confirm these to suffer from the LANG issue. Correctly imported with LANG=C env var.

#10 Updated by Martin Weis over 8 years ago

Another duplicate: #12555

#11 Updated by Even Rouault over 7 years ago

  • Resolution set to up/downstream
  • Status changed from Open to Closed

This has been fixed in GDAL 2.0

Also available in: Atom PDF