Skip to content

Commit

Permalink
Use a sensible default map extent for .gpx files with no data in them…
Browse files Browse the repository at this point in the history
… (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@6279 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m committed Dec 18, 2006
1 parent 4282dec commit 57eeba7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/providers/gpx/gpsdata.cpp
Expand Up @@ -135,6 +135,15 @@ QgsRect* GPSData::getExtent() const {
return new QgsRect(xMin, yMin, xMax, yMax);
}

void GPSData::setNoDataExtent() {
if (getNumberOfWaypoints() + getNumberOfRoutes() + getNumberOfTracks() == 0)
{
xMin = -1.0;
xMax = 1.0;
yMin = -1.0;
yMax = 1.0;
}
}

int GPSData::getNumberOfWaypoints() const {
return waypoints.size();
Expand Down Expand Up @@ -345,7 +354,9 @@ GPSData* GPSData::getData(const QString& filename) {
XML_ParserFree(p);
if (failed)
return 0;


data->setNoDataExtent();

dataObjects[filename] = std::pair<GPSData*, unsigned>(data, 0);
}
else
Expand Down
4 changes: 3 additions & 1 deletion src/providers/gpx/gpsdata.h
Expand Up @@ -132,7 +132,9 @@ class GPSData {
which is the bounding box for this dataset. You'll have to deallocate it
yourself. */
QgsRect* getExtent() const;


/** Sets a default sensible extent. Only applies when there are no actual data. */
void setNoDataExtent();

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

0 comments on commit 57eeba7

Please sign in to comment.