Changeset 14768
- Timestamp:
- 06/25/08 15:37:42 (5 months ago)
- Files:
-
- trunk/autotest/ogr/ogr_gml_geom.py (modified) (2 diffs)
- trunk/gdal/ogr/gml2ogrgeometry.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/autotest/ogr/ogr_gml_geom.py
r12007 r14768 105 105 106 106 ############################################################################### 107 # Test GML 3.x "posList" element for a point. 108 109 def gml_posList_line(): 110 111 gml = '<LineString><posList>31 42 53 64 55 76</posList></LineString>' 112 113 geom = ogr.CreateGeometryFromGML( gml ) 114 115 if geom.ExportToWkt() != 'LINESTRING (31 42,53 64,55 76)': 116 gdaltest.post_reason( '<gml:posList> not correctly parsed' ) 117 return 'fail' 118 119 return 'success' 120 121 ############################################################################### 122 # Test GML 3.x "polygon" element for a point. 123 124 def gml_polygon(): 125 126 gml = '<Polygon><exterior><LinearRing><posList>0 0 4 0 4 4 0 4 0 0</posList></LinearRing></exterior><interior><LinearRing><posList>1 1 2 1 2 2 1 2 1 1</posList></LinearRing></interior></Polygon>' 127 geom = ogr.CreateGeometryFromGML( gml ) 128 129 if geom.ExportToWkt() != 'POLYGON ((0 0,4 0,4 4,0 4,0 0),(1 1,2 1,2 2,1 2,1 1))': 130 gdaltest.post_reason( '<gml:Polygon> not correctly parsed' ) 131 return 'fail' 132 133 return 'success' 134 135 ############################################################################### 107 136 # Private utility function to conver WKT to GML with assigned WGS 84 as SRS 108 137 … … 301 330 gdaltest_list.append( gml_space_test ) 302 331 gdaltest_list.append( gml_pos_point ) 332 gdaltest_list.append( gml_posList_line ) 333 gdaltest_list.append( gml_polygon ) 303 334 gdaltest_list.append( gml_out_point_srs ) 304 335 gdaltest_list.append( gml_out_point3d_srs ) trunk/gdal/ogr/gml2ogrgeometry.cpp
r10645 r14768 237 237 238 238 /* -------------------------------------------------------------------- */ 239 /* Is this a "pos"? I think this is a GML 3 construct. */ 240 /* -------------------------------------------------------------------- */ 241 CPLXMLNode *psPos = FindBareXMLChild( psGeomNode, "pos" ); 239 /* Is this a "pos"? GML 3 construct. */ 240 /* Parse if it exist a series of pos elements (this would allow */ 241 /* the correct parsing of gml3.1.1 geomtries such as linestring */ 242 /* defined with pos elements. */ 243 /* -------------------------------------------------------------------- */ 244 CPLXMLNode *psPos; 242 245 243 if( psPos != NULL ) 244 { 246 for( psPos = psGeomNode->psChild; 247 psPos != NULL; 248 psPos = psPos->psNext ) 249 { 250 if( psPos->eType != CXT_Element 251 || !EQUAL(BareGMLElement(psPos->pszValue),"pos") ) 252 continue; 253 245 254 char **papszTokens = CSLTokenizeStringComplex( 246 255 GetElementText( psPos ), " ,", FALSE, FALSE ); … … 268 277 } 269 278 279 CSLDestroy( papszTokens ); 280 281 return bSuccess; 282 } 283 284 285 /* -------------------------------------------------------------------- */ 286 /* Is this a "posList"? GML 3 construct (SF profile). */ 287 /* -------------------------------------------------------------------- */ 288 CPLXMLNode *psPosList = FindBareXMLChild( psGeomNode, "posList" ); 289 290 if( psPosList != NULL ) 291 { 292 char **papszTokens = CSLTokenizeStringComplex( 293 GetElementText( psPosList ), " ,", FALSE, FALSE ); 294 int bSuccess = FALSE; 295 int i=0, nCount=0; 296 297 /*assuming that it is a 2 dimension with x y values*/ 298 /*we could also check to see if there is a count attribute and an srsDimension. 299 These attributes are only availabe for gml3.1.1 but not 300 available for gml3.1 SF*/ 301 302 nCount = CSLCount( papszTokens ); 303 304 if (nCount < 2 || fmod((double)nCount, 2.0) != 0) 305 { 306 307 CPLError( CE_Failure, CPLE_AppDefined, 308 "Did not get at least two values or invalid number of \n" 309 "set of coordinates <gml:posList>%s</gml:posList>", 310 GetElementText( psPosList ) ); 311 } 312 else 313 { 314 i=0; 315 while (i<nCount) 316 { 317 bSuccess = AddPoint( poGeometry, 318 atof(papszTokens[i]), 319 atof(papszTokens[i+1]), 320 0.0, 2 ); 321 i+=2; 322 } 323 } 270 324 CSLDestroy( papszTokens ); 271 325 … … 348 402 // Find outer ring. 349 403 psChild = FindBareXMLChild( psNode, "outerBoundaryIs" ); 404 if (psChild == NULL) 405 psChild = FindBareXMLChild( psNode, "exterior"); 406 350 407 if( psChild == NULL || psChild->psChild == NULL ) 351 408 { … … 383 440 { 384 441 if( psChild->eType == CXT_Element 385 && EQUAL(BareGMLElement(psChild->pszValue),"innerBoundaryIs") ) 442 && (EQUAL(BareGMLElement(psChild->pszValue),"innerBoundaryIs") || 443 EQUAL(BareGMLElement(psChild->pszValue),"interior"))) 386 444 { 387 445 poRing = (OGRLinearRing *)
