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
This commit is contained in:
g_j_m 2006-12-18 23:52:23 +00:00
parent 4282deca33
commit 57eeba70c6
2 changed files with 15 additions and 2 deletions

View File

@ -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<GPSData*, unsigned>(data, 0);
}
else

View File

@ -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;