[geos-devel] about OGRGeometry's Union/Intersection/Difference
unsuccessfully.
xhgis
xhgis at 163.com
Wed Mar 31 12:53:40 EDT 2010
hello,everyone!
I couldn't succeed to use OGRGeometry's Union/Intersection/Difference function. Union two Geometrys,but get a null value. I couldn't find some errors.
the following code,thanks.
{
OGRRegisterAll();
OGRDataSource *poDS;
poDS = OGRSFDriverRegistrar::Open("f:\\t1.shp", FALSE ); // Only include two polygon features. SRS is null.
if( poDS == NULL )
{
printf( "Open failed.\n%s" );
exit( 1 );
}
OGRLayer *poLayer;
poLayer = poDS->GetLayerByName( "t1" );
OGRFeature *poFeature0;
OGRFeature *poFeature1;
poLayer->ResetReading();
poFeature0=poLayer->GetNextFeature();
poFeature1=poLayer->GetNextFeature();
OGRGeometry *geoS0;
OGRGeometry *geoS1;
geoS0=poFeature0->GetGeometryRef();
geoS1=poFeature1->GetGeometryRef();
OGRPolygon *pgon0=(OGRPolygon*)geoS0;
OGRPolygon *pgon1=(OGRPolygon*)geoS1;
OGRGeometry *g2=geoS0->Intersection(geoS1);
//OGRGeometry *g2=geoS0->Union(geoS1);...
//g2 always is null?
OGRFeature::DestroyFeature( poFeature0 );
OGRFeature::DestroyFeature( poFeature1 );
OGRDataSource::DestroyDataSource( poDS );
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/geos-devel/attachments/20100401/ad8b3566/attachment.html
More information about the geos-devel
mailing list