#5604 closed defect (fixed)
missing CPLString().FormatC(..) when using doubles - fails on systems using Decimal.Comma
Reported by: | mj10777 | Owned by: | Even Rouault |
---|---|---|---|
Priority: | high | Milestone: | 2.0.0 |
Component: | default | Version: | svn-trunk |
Severity: | critical | Keywords: | FormatC, doubles, Decimal.Comma |
Cc: |
Description
While trying the 'Rasterlite' Format, the images no longer showed.
I have recently updated to Ubuntu 14.04 from 12.04 where this problem was not noticed.
The following error showed in the terminal while loading 'Rasterlite' Databases:
ERROR 1: In ExecuteSQL(): sqlite3_prepare(SELECT m.geometry, r.raster, m.id, m.width, m.height FROM "TrueMarble_metadata" AS m, "TrueMarble_rasters" AS r WHERE m.rowid IN (SELECT pkid FROM "idx_TrueMarble_metadata_geometry" WHERE xmin < 22,916666666666668 AND xmax > 14,583333333333334 AND ymin < 39,416666666666664 AND ymax > 31,083333333333329) AND m.pixel_x_size >= 0,016666666666666 AND m.pixel_x_size <= 0,016666666666668 AND m.pixel_y_size >= 0,016666666666666 AND m.pixel_y_size <= 0,016666666666668 AND r.id = m.id):
near ",": syntax error
---
For:
frmts/rasterlite/ and
ogr/ogrsf_frmts/sqlite
I have replaced in all of the '.Printf('
the '%.15f' or '%.12f' and '%.18g'
everywhere where ' '%.1' could be found
with '%s' and a corresponding:
CPLString().FormatC(padfXResolutions[nLevel] - 1e-15,"%.15f").c_str()
---
After recompiling gdal and QGIS all of my 'Rasterlite' Rasters show up correctly.
---
The diff was created with:
svn upgrade
svn diff frmts/rasterlite > 20140804.rasterlite_formatc.diff
svn diff ogr/ogrsf_frmts/sqlite > 20140804.ogrsf_frmts_sqlite_formatc.diff
for whatever reason 'svn upgrade' had to be called first
---
the diff for 'sqlite' also includes changes already submitted in:
[GDAL] #5582: SpatialView - writable
---
This problem is also meantioned in:
[GDAL] #5603: Rasterlite2 (spatialite)
---
I have NOT looked at other areas of the project to see if there are also other areas when machine specific formatting is needed for doubles
Attachments (4)
Change History (13)
by , 10 years ago
Attachment: | 20140804.rasterlite_formatc.diff added |
---|
by , 10 years ago
Attachment: | 20140804.ogrsf_frmts_sqlite_formatc.diff added |
---|
added CPLString().FormatC to sql-queries
comment:1 by , 10 years ago
Could you redo the patches without all the whitespace changes and without #5582 applied ?
comment:2 by , 10 years ago
I don't know what the cause of the whitespace changes are (possibly the editor - geany)
and I would have to make a fresh copy of everything so that #5582 would not be included.
comment:3 by , 10 years ago
Yes please try fixing the setting of your editor so that it preserve whitespaces, otherwise it produces diffs that are not easily reviewable.
by , 10 years ago
Attachment: | 20140805.ogrsf_frmts_sqlite_formatc.diff added |
---|
diff done in gedit, without SpatialView changes
comment:4 by , 10 years ago
A totally fresh svn was made. The 2 diffs have been redone with gedit (wish I knew why geany does this)
Everything has compiled properly.
comment:5 by , 10 years ago
The use of -x "-w --ignore-eol-style" can avoid such issues.
Most editors remove trailing spaces at the eol, some don't
With the above syntax such 'diff's will be ignored.
svn diff -x "-w --ignore-eol-style" frmts/rasterlite > 20140805.ignore-eol.rasterlite_formatc.diff
comment:6 by , 10 years ago
Milestone: | → 2.0 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
There were errors in your sqlite patch, related to -/+ epsilon, plus an extra %d. You could have caught them by running the autotest/ogr/ogr_sqlite.py script.
In addition to that, I've reworked your patch since it showed that there were numerous copy&paste patterns that could be factored.
trunk r27566 "Rasterlite and Spatialite: avoid locale related issues when formatting floating point numbers (#5604)"
comment:7 by , 10 years ago
comment:8 by , 10 years ago
Sorry, much of the internals are still new for me, so there is still much to learn.
added CPLString().FormatC to sql-queries