Changeset 12517
- Timestamp:
- 10/23/07 11:07:35 (1 year ago)
- Files:
-
- branches/1.4/gdal/ogr/ogr_geometry.h (modified) (1 diff)
- branches/1.4/gdal/ogr/ogrlinearring.cpp (modified) (1 diff)
- branches/1.4/gdal/ogr/ogrsf_frmts/kml/ogr2kmlgeometry.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.4/gdal/ogr/ogr_geometry.h
r10646 r12517 334 334 virtual OGRGeometry *clone() const; 335 335 virtual int isClockwise() const; 336 virtual void reverseWindingOrder(); 336 337 virtual void closeRings(); 337 338 virtual double get_Area() const; branches/1.4/gdal/ogr/ogrlinearring.cpp
r11695 r12517 358 358 } 359 359 360 /************************************************************************/ 361 /* reverseWindingOrder() */ 362 /************************************************************************/ 363 364 void OGRLinearRing::reverseWindingOrder() 365 366 { 367 int pos = 0; 368 OGRPoint tempPoint; 369 370 for( int i = 0; i < nPointCount / 2; i++ ) 371 { 372 getPoint( i, &tempPoint ); 373 pos = nPointCount - i - 1; 374 setPoint( i, getX(pos), getY(pos), getZ(pos) ); 375 setPoint( pos, tempPoint.getX(), tempPoint.getY(), tempPoint.getZ() ); 376 } 377 } 378 360 379 /************************************************************************/ 361 380 /* closeRing() */ branches/1.4/gdal/ogr/ogrsf_frmts/kml/ogr2kmlgeometry.cpp
r10646 r12517 236 236 "<Polygon>" ); 237 237 238 if( poPolygon->getExteriorRing() != NULL ) 239 { 238 OGRLinearRing *poExteriorRing = poPolygon->getExteriorRing(); 239 if( poExteriorRing != NULL ) 240 { 241 /* Test if we need to reverse the winding order. The KML specification 242 * defines the front of a face as a LinearRing with anti-clockwise 243 * winding order. Full 3D implementations of KML, such as Google Earth, 244 * light the front of the face, not the rear. 245 * For the present case it's safe to assume that all faces exported 246 * from OGR should have anti-clockwise winding orders. 247 */ 248 if ( poExteriorRing->isClockwise() ) 249 { 250 poExteriorRing->reverseWindingOrder(); 251 } 252 240 253 AppendString( ppszText, pnLength, pnMaxLength, 241 254 "<outerBoundaryIs>" ); 242 255 243 if( !OGR2KMLGeometryAppend( po Polygon->getExteriorRing(),256 if( !OGR2KMLGeometryAppend( poExteriorRing, 244 257 ppszText, pnLength, pnMaxLength ) ) 258 { 245 259 return FALSE; 246 260 } 261 247 262 AppendString( ppszText, pnLength, pnMaxLength, 248 263 "</outerBoundaryIs>" ); … … 252 267 { 253 268 OGRLinearRing *poRing = poPolygon->getInteriorRing(iRing); 269 270 /* Perform the winding test again. */ 271 if( poRing->isClockwise() ) 272 { 273 poRing->reverseWindingOrder(); 274 } 254 275 255 276 AppendString( ppszText, pnLength, pnMaxLength,
