Changeset 13469
- Timestamp:
- 12/31/07 12:35:58 (6 months ago)
- Files:
-
- trunk/gdal/ogr/ogrsf_frmts/gpx/drv_gpx.html (modified) (1 diff)
- trunk/gdal/ogr/ogrsf_frmts/gpx/ogr_gpx.h (modified) (2 diffs)
- trunk/gdal/ogr/ogrsf_frmts/gpx/ogrgpxdatasource.cpp (modified) (5 diffs)
- trunk/gdal/ogr/ogrsf_frmts/gpx/ogrgpxlayer.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/gdal/ogr/ogrsf_frmts/gpx/drv_gpx.html
r13176 r13469 11 11 12 12 OGR has support for GPX reading (if GDAL is build with <i>expat</i> library support) and writing.<p> 13 14 Version supported are GPX 1.0 and 1.1 for reading, GPX 1.1 for writing.<p> 13 15 14 16 The OGR driver supports reading and writing of all the GPX feature types : trunk/gdal/ogr/ogrsf_frmts/gpx/ogr_gpx.h
r13357 r13469 176 176 OGRGPXValidity validity; 177 177 int nElementsRead; 178 char* pszVersion; 178 179 179 180 public: … … 208 209 209 210 void startElementValidateCbk(const char *pszName, const char **ppszAttr); 211 212 const char* GetVersion() { return pszVersion; } 210 213 }; 211 214 trunk/gdal/ogr/ogrsf_frmts/gpx/ogrgpxdatasource.cpp
r13239 r13469 50 50 51 51 pszName = NULL; 52 pszVersion = NULL; 52 53 } 53 54 … … 71 72 CPLFree( pszExtensionsNS ); 72 73 CPLFree( pszName ); 74 CPLFree( pszVersion ); 73 75 } 74 76 … … 162 164 if (strcmp(pszName, "gpx") == 0) 163 165 { 166 int i; 164 167 validity = GPX_VALIDITY_VALID; 168 for(i=0; ppszAttr[i] != NULL; i+= 2) 169 { 170 if (strcmp(ppszAttr[i], "version") == 0) 171 { 172 pszVersion = CPLStrdup(ppszAttr[i+1]); 173 break; 174 } 175 } 165 176 } 166 177 else … … 219 230 220 231 validity = GPX_VALIDITY_UNKNOWN; 232 CPLFree(pszVersion); 233 pszVersion = NULL; 221 234 bUseExtensions = FALSE; 222 235 nElementsRead = 0; … … 287 300 if (bUseExtensions) 288 301 CPLDebug("GPX", "It uses <extensions>"); 302 303 if (pszVersion == NULL) 304 { 305 /* Default to 1.1 */ 306 CPLError(CE_Warning, CPLE_AppDefined, "GPX schema version is unknown. " 307 "The driver may not be able to handle the file correctly and will behave as if it is GPX 1.1."); 308 pszVersion = CPLStrdup("1.1"); 309 } 310 else if (strcmp(pszVersion, "1.0") == 0 || strcmp(pszVersion, "1.1") == 0) 311 { 312 /* Fine */ 313 } 314 else 315 { 316 CPLError(CE_Warning, CPLE_AppDefined, 317 "GPX schema version '%s' is not handled by the driver. " 318 "The driver may not be able to handle the file correctly and will behave as if it is GPX 1.1.", pszVersion); 319 } 320 289 321 nLayers = 5; 290 322 papoLayers = (OGRGPXLayer **) CPLRealloc(papoLayers, nLayers * sizeof(OGRGPXLayer*)); trunk/gdal/ogr/ogrsf_frmts/gpx/ogrgpxlayer.cpp
r13463 r13469 46 46 47 47 { 48 const char* gpxVersion = poDS->GetVersion(); 49 48 50 int i; 49 51 … … 106 108 poFeatureDefn->AddFieldDefn( &oFieldTime ); 107 109 110 if (gpxGeomType == GPX_TRACK_POINT && 111 gpxVersion && strcmp(gpxVersion, "1.0") == 0) 112 { 113 OGRFieldDefn oFieldCourse("course", OFTReal ); 114 poFeatureDefn->AddFieldDefn( &oFieldCourse ); 115 116 OGRFieldDefn oFieldSpeed("speed", OFTReal ); 117 poFeatureDefn->AddFieldDefn( &oFieldSpeed ); 118 } 119 108 120 OGRFieldDefn oFieldMagVar("magvar", OFTReal ); 109 121 poFeatureDefn->AddFieldDefn( &oFieldMagVar ); … … 126 138 poFeatureDefn->AddFieldDefn( &oFieldSrc ); 127 139 128 for(i=1;i<=nMaxLinks;i++) 129 { 130 char szFieldName[32]; 131 sprintf(szFieldName, "link%d_href", i); 132 OGRFieldDefn oFieldLinkHref( szFieldName, OFTString ); 133 poFeatureDefn->AddFieldDefn( &oFieldLinkHref ); 140 if (gpxVersion && strcmp(gpxVersion, "1.0") == 0) 141 { 142 OGRFieldDefn oFieldUrl("url", OFTString ); 143 poFeatureDefn->AddFieldDefn( &oFieldUrl ); 134 144 135 sprintf(szFieldName, "link%d_text", i); 136 OGRFieldDefn oFieldLinkText( szFieldName, OFTString ); 137 poFeatureDefn->AddFieldDefn( &oFieldLinkText ); 138 139 sprintf(szFieldName, "link%d_type", i); 140 OGRFieldDefn oFieldLinkType( szFieldName, OFTString ); 141 poFeatureDefn->AddFieldDefn( &oFieldLinkType ); 145 OGRFieldDefn oFieldUrlName("urlname", OFTString ); 146 poFeatureDefn->AddFieldDefn( &oFieldUrlName ); 147 } 148 else 149 { 150 for(i=1;i<=nMaxLinks;i++) 151 { 152 char szFieldName[32]; 153 sprintf(szFieldName, "link%d_href", i); 154 OGRFieldDefn oFieldLinkHref( szFieldName, OFTString ); 155 poFeatureDefn->AddFieldDefn( &oFieldLinkHref ); 156 157 sprintf(szFieldName, "link%d_text", i); 158 OGRFieldDefn oFieldLinkText( szFieldName, OFTString ); 159 poFeatureDefn->AddFieldDefn( &oFieldLinkText ); 160 161 sprintf(szFieldName, "link%d_type", i); 162 OGRFieldDefn oFieldLinkType( szFieldName, OFTString ); 163 poFeatureDefn->AddFieldDefn( &oFieldLinkType ); 164 } 142 165 } 143 166
