File tree Expand file tree Collapse file tree 4 files changed +46
-0
lines changed Expand file tree Collapse file tree 4 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -2841,6 +2841,7 @@ void QgsOgrProvider::open( OpenMode mode )
28412841 QgsDebugMsg ( " mLayerName: " + mLayerName );
28422842 QgsDebugMsg ( " mSubsetString: " + mSubsetString );
28432843 CPLSetConfigOption ( " OGR_ORGANIZE_POLYGONS" , " ONLY_CCW" ); // "SKIP" returns MULTIPOLYGONs for multiringed POLYGONs
2844+ CPLSetConfigOption ( " GPX_ELE_AS_25D" , " YES" ); // use GPX elevation as z values
28442845
28452846 if ( mFilePath .startsWith ( " MySQL:" ) && !mLayerName .isEmpty () && !mFilePath .endsWith ( " ,tables=" + mLayerName ) )
28462847 {
Original file line number Diff line number Diff line change @@ -153,5 +153,23 @@ def testNoDanglingFileDescriptorAfterCloseVariant2(self):
153153 os .unlink (datasource )
154154 self .assertFalse (os .path .exists (datasource ))
155155
156+ def testGpxElevation (self ):
157+ # GPX without elevation data
158+ datasource = os .path .join (TEST_DATA_DIR , 'noelev.gpx' )
159+ vl = QgsVectorLayer (u'{}|layername=routes' .format (datasource ), u'test' , u'ogr' )
160+ self .assertTrue (vl .isValid ())
161+ f = next (vl .getFeatures ())
162+ self .assertEqual (f .constGeometry ().geometry ().wkbType (), QgsWKBTypes .LineString )
163+
164+ # GPX with elevation data
165+ datasource = os .path .join (TEST_DATA_DIR , 'elev.gpx' )
166+ vl = QgsVectorLayer (u'{}|layername=routes' .format (datasource ), u'test' , u'ogr' )
167+ self .assertTrue (vl .isValid ())
168+ f = next (vl .getFeatures ())
169+ self .assertEqual (f .constGeometry ().geometry ().wkbType (), QgsWKBTypes .LineString25D )
170+ self .assertEqual (f .constGeometry ().geometry ().pointN (0 ).z (), 1 )
171+ self .assertEqual (f .constGeometry ().geometry ().pointN (1 ).z (), 2 )
172+ self .assertEqual (f .constGeometry ().geometry ().pointN (2 ).z (), 3 )
173+
156174if __name__ == '__main__' :
157175 unittest .main ()
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" ?>
2+ <gpx version =" 1.1" creator =" GDAL 1.11.3" xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" xmlns =" http://www.topografix.com/GPX/1/1" xsi : schemaLocation =" http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd" >
3+ <metadata ><bounds minlat =" 56.134840267383296" minlon =" -3.877982991747363" maxlat =" 56.135514185147493" maxlon =" -3.852565020533009" /></metadata >
4+ <rte >
5+ <rtept lat =" 56.134840267383296" lon =" -3.877982991747363" >
6+ <ele >1</ele >
7+ </rtept >
8+ <rtept lat =" 56.134933668432737" lon =" -3.865962243986197" >
9+ <ele >2</ele >
10+ </rtept >
11+ <rtept lat =" 56.135514185147493" lon =" -3.852565020533009" >
12+ <ele >3</ele >
13+ </rtept >
14+ </rte >
15+ </gpx >
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" ?>
2+ <gpx version =" 1.1" creator =" GDAL 1.11.3" xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" xmlns =" http://www.topografix.com/GPX/1/1" xsi : schemaLocation =" http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd" >
3+ <metadata ><bounds minlat =" 56.134840267383240" minlon =" -3.877982991747359" maxlat =" 56.135514185147436" maxlon =" -3.852565020533005" /></metadata >
4+ <rte >
5+ <rtept lat =" 56.13484026738324" lon =" -3.877982991747359" >
6+ </rtept >
7+ <rtept lat =" 56.13493366843268" lon =" -3.865962243986193" >
8+ </rtept >
9+ <rtept lat =" 56.135514185147436" lon =" -3.852565020533005" >
10+ </rtept >
11+ </rte >
12+ </gpx >
You can’t perform that action at this time.
0 commit comments