Skip to content

Commit d93338b

Browse files
author
wonder
committed
OSM: save correctly the extent of data. Most probably the cause of #2098.
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@12518 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent b4a7fe3 commit d93338b

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

src/providers/osm/osmprovider.cpp

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
static const QString TEXT_PROVIDER_KEY = "osm";
3131
static const QString TEXT_PROVIDER_DESCRIPTION = "Open Street Map data provider";
3232
static const QString DATE_TIME_FMT = "dd.MM.yyyy HH:mm:ss";
33-
static const QString PROVIDER_VERSION = "0.5";
33+
static const QString PROVIDER_VERSION = "0.5.1";
3434

3535
// supported attributes
3636
const char* QgsOSMDataProvider::attr[] = { "timestamp", "user", "tags" };
@@ -213,14 +213,19 @@ QgsOSMDataProvider::QgsOSMDataProvider( QString uri )
213213
const unsigned char *boundaries_char = sqlite3_column_text( stmtSelectBoundary, 0 );
214214
QString boundaries(( const char * ) boundaries_char );
215215

216-
// boundaries should be string in following format: "xMin-yMin-xMax-yMax"
217-
int separ1_pos = boundaries.indexOf( "-" );
218-
int separ2_pos = boundaries.indexOf( "-", separ1_pos + 1 );
219-
int separ3_pos = boundaries.indexOf( "-", separ2_pos + 1 );
220-
xMin = boundaries.left( separ1_pos ).toDouble();
221-
yMin = boundaries.mid( separ1_pos + 1, separ2_pos - separ1_pos - 1 ).toDouble();
222-
xMax = boundaries.mid( separ2_pos + 1, separ3_pos - separ2_pos - 1 ).toDouble();
223-
yMax = boundaries.right( boundaries.size() - separ3_pos - 1 ).toDouble();
216+
// boundaries should be string in following format: "xMin:yMin:xMax:yMax"
217+
QStringList parts = boundaries.split( QChar( ':' ) );
218+
if ( parts.count() == 4 )
219+
{
220+
xMin = parts[0].toDouble();
221+
yMin = parts[1].toDouble();
222+
xMax = parts[2].toDouble();
223+
yMax = parts[3].toDouble();
224+
}
225+
else
226+
{
227+
QgsDebugMsg( "Default area boundary has invalid format." );
228+
}
224229
}
225230
}
226231

@@ -1402,8 +1407,8 @@ bool QgsOSMDataProvider::loadOsmFile( QString osm_filename )
14021407
yMax = handler->yMax;
14031408

14041409
// storing boundary information into database
1405-
QString cmd3 = QString( "INSERT INTO meta ( key, val ) VALUES ('default-area-boundaries','%1-%2-%3-%4');" )
1406-
.arg( xMin, 0, 'f', 20 ).arg( yMin, 0, 'f', 20 ).arg( xMax, 0, 'f', 20 ).arg( yMax, 0, 'f', 20 );
1410+
QString cmd3 = QString( "INSERT INTO meta ( key, val ) VALUES ('default-area-boundaries','%1:%2:%3:%4');" )
1411+
.arg( xMin, 0, 'f', 10 ).arg( yMin, 0, 'f', 10 ).arg( xMax, 0, 'f', 10 ).arg( yMax, 0, 'f', 10 );
14071412
QByteArray cmd_bytes3 = cmd3.toAscii();
14081413
const char *ptr3 = cmd_bytes3.data();
14091414

0 commit comments

Comments
 (0)