Skip to content

Commit 902b6ea

Browse files
author
g_j_m
committed
Use a sensible default map extent for .gpx files with no data in them (as
produced by the create gpx layer command). Fixes a problem where digitising didn't work when loading a blank .gpx file as the first layer in qgis. git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@6279 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent fe32f63 commit 902b6ea

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/providers/gpx/gpsdata.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,15 @@ QgsRect* GPSData::getExtent() const {
135135
return new QgsRect(xMin, yMin, xMax, yMax);
136136
}
137137

138+
void GPSData::setNoDataExtent() {
139+
if (getNumberOfWaypoints() + getNumberOfRoutes() + getNumberOfTracks() == 0)
140+
{
141+
xMin = -1.0;
142+
xMax = 1.0;
143+
yMin = -1.0;
144+
yMax = 1.0;
145+
}
146+
}
138147

139148
int GPSData::getNumberOfWaypoints() const {
140149
return waypoints.size();
@@ -345,7 +354,9 @@ GPSData* GPSData::getData(const QString& filename) {
345354
XML_ParserFree(p);
346355
if (failed)
347356
return 0;
348-
357+
358+
data->setNoDataExtent();
359+
349360
dataObjects[filename] = std::pair<GPSData*, unsigned>(data, 0);
350361
}
351362
else

src/providers/gpx/gpsdata.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ class GPSData {
132132
which is the bounding box for this dataset. You'll have to deallocate it
133133
yourself. */
134134
QgsRect* getExtent() const;
135-
135+
136+
/** Sets a default sensible extent. Only applies when there are no actual data. */
137+
void setNoDataExtent();
136138

137139
/** Returns the number of waypoints in this dataset. */
138140
int getNumberOfWaypoints() const;

0 commit comments

Comments
 (0)