From 57eeba70c6a1ebc5929776741ea40a22e2d46b70 Mon Sep 17 00:00:00 2001 From: g_j_m Date: Mon, 18 Dec 2006 23:52:23 +0000 Subject: [PATCH] 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@6279 c8812cc2-4d05-0410-92ff-de0c093fc19c --- src/providers/gpx/gpsdata.cpp | 13 ++++++++++++- src/providers/gpx/gpsdata.h | 4 +++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/providers/gpx/gpsdata.cpp b/src/providers/gpx/gpsdata.cpp index ee700a1ebf8..4284c884226 100644 --- a/src/providers/gpx/gpsdata.cpp +++ b/src/providers/gpx/gpsdata.cpp @@ -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(); @@ -345,7 +354,9 @@ GPSData* GPSData::getData(const QString& filename) { XML_ParserFree(p); if (failed) return 0; - + + data->setNoDataExtent(); + dataObjects[filename] = std::pair(data, 0); } else diff --git a/src/providers/gpx/gpsdata.h b/src/providers/gpx/gpsdata.h index a1f1d20bc98..b8f7aaff36d 100644 --- a/src/providers/gpx/gpsdata.h +++ b/src/providers/gpx/gpsdata.h @@ -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;