本文整理汇总了C++中OGRGeometry::Intersection方法的典型用法代码示例。如果您正苦于以下问题:C++ OGRGeometry::Intersection方法的具体用法?C++ OGRGeometry::Intersection怎么用?C++ OGRGeometry::Intersection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OGRGeometry
的用法示例。
在下文中一共展示了OGRGeometry::Intersection方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
if( pszSource == NULL )
{
Usage("Source datasource is not specified.");
}
if( pszDest == NULL )
{
Usage("Target dataset is not specified.");
}
if( pszSQL == NULL && papszLayers == NULL )
{
Usage("Neither -sql nor -l are specified.");
}
if ( bClipSrc && pszClipSrcDS != NULL )
{
poClipSrc = LoadGeometry( pszClipSrcDS, pszClipSrcSQL,
pszClipSrcLayer, pszClipSrcWhere );
if ( poClipSrc == NULL )
{
Usage("Cannot load source clip geometry.");
}
}
else if ( bClipSrc && poClipSrc == NULL && !poSpatialFilter )
{
Usage("-clipsrc must be used with -spat option or \n"
"a bounding box, WKT string or datasource must be "
"specified.");
}
if ( poSpatialFilter )
{
if ( poClipSrc )
{
OGRGeometry *poTemp = poSpatialFilter->Intersection( poClipSrc );
if ( poTemp )
{
OGRGeometryFactory::destroyGeometry( poSpatialFilter );
poSpatialFilter = poTemp;
}
OGRGeometryFactory::destroyGeometry( poClipSrc );
poClipSrc = NULL;
}
}
else
{
if ( poClipSrc )
{
poSpatialFilter = poClipSrc;
poClipSrc = NULL;
}
}
/* -------------------------------------------------------------------- */
/* Find the output driver. */
/* -------------------------------------------------------------------- */
hDriver = GDALGetDriverByName( pszFormat );
if( hDriver == NULL )
{
int iDr;
fprintf( stderr,
"FAILURE: Output driver `%s' not recognised.\n", pszFormat );
fprintf( stderr,
"The following format drivers are configured and support output:\n" );
示例2: BuildURL
CPLString OGRPLScenesLayer::BuildURL(int nFeatures)
{
CPLString osURL = osBaseURL + CPLSPrintf("?count=%d", nFeatures);
if( bAcquiredAscending == 1 )
osURL += "&order_by=acquired%20asc";
else if( bAcquiredAscending == 0 )
osURL += "&order_by=acquired%20desc";
if( m_poFilterGeom != NULL || poMainFilter != NULL )
{
OGRGeometry* poIntersection = NULL;
OGRGeometry* poFilterGeom = m_poFilterGeom;
if( poFilterGeom )
{
OGREnvelope sEnvelope;
poFilterGeom->getEnvelope(&sEnvelope);
if( sEnvelope.MinX <= -180 && sEnvelope.MinY <= -90 &&
sEnvelope.MaxX >= 180 && sEnvelope.MaxY >= 90 )
poFilterGeom = NULL;
}
if( poFilterGeom && poMainFilter )
poIntersection = poFilterGeom->Intersection(poMainFilter);
else if( poFilterGeom )
poIntersection = poFilterGeom;
else if( poMainFilter )
poIntersection = poMainFilter;
if( poIntersection )
{
char* pszWKT = NULL;
OGREnvelope sEnvelope;
poIntersection->getEnvelope(&sEnvelope);
if( sEnvelope.MinX == sEnvelope.MaxX && sEnvelope.MinY == sEnvelope.MaxY )
{
pszWKT = CPLStrdup(CPLSPrintf("POINT(%.18g %.18g)",
sEnvelope.MinX, sEnvelope.MinY));
}
else
poIntersection->exportToWkt(&pszWKT);
osURL += "&intersects=";
char* pszWKTEscaped = CPLEscapeString(pszWKT, -1, CPLES_URL);
osURL += pszWKTEscaped;
CPLFree(pszWKTEscaped);
CPLFree(pszWKT);
}
if( poIntersection != m_poFilterGeom && poIntersection != poMainFilter )
delete poIntersection;
}
if( osFilterURLPart.size() )
{
if( osFilterURLPart[0] == '&' )
osURL += osFilterURLPart;
else
osURL = osBaseURL + osFilterURLPart;
}
return osURL;
}
示例3: if
static CPLErr
BlendMaskGenerator(
#ifndef HAVE_GEOS
CPL_UNUSED int nXOff, CPL_UNUSED int nYOff,
CPL_UNUSED int nXSize, CPL_UNUSED int nYSize,
CPL_UNUSED GByte *pabyPolyMask,
CPL_UNUSED float *pafValidityMask,
CPL_UNUSED OGRGeometryH hPolygon,
CPL_UNUSED double dfBlendDist
#else
int nXOff, int nYOff, int nXSize, int nYSize,
GByte *pabyPolyMask, float *pafValidityMask,
OGRGeometryH hPolygon, double dfBlendDist
#endif
)
{
#ifndef HAVE_GEOS
CPLError( CE_Failure, CPLE_AppDefined,
"Blend distance support not available without the GEOS library.");
return CE_Failure;
#else /* HAVE_GEOS */
/* -------------------------------------------------------------------- */
/* Convert the polygon into a collection of lines so that we */
/* measure distance from the edge even on the inside. */
/* -------------------------------------------------------------------- */
OGRGeometry *poLines
= OGRGeometryFactory::forceToMultiLineString(
((OGRGeometry *) hPolygon)->clone() );
/* -------------------------------------------------------------------- */
/* Prepare a clipping polygon a bit bigger than the area of */
/* interest in the hopes of simplifying the cutline down to */
/* stuff that will be relavent for this area of interest. */
/* -------------------------------------------------------------------- */
CPLString osClipRectWKT;
osClipRectWKT.Printf( "POLYGON((%g %g,%g %g,%g %g,%g %g,%g %g))",
nXOff - (dfBlendDist+1),
nYOff - (dfBlendDist+1),
nXOff + nXSize + (dfBlendDist+1),
nYOff - (dfBlendDist+1),
nXOff + nXSize + (dfBlendDist+1),
nYOff + nYSize + (dfBlendDist+1),
nXOff - (dfBlendDist+1),
nYOff + nYSize + (dfBlendDist+1),
nXOff - (dfBlendDist+1),
nYOff - (dfBlendDist+1) );
OGRPolygon *poClipRect = NULL;
char *pszWKT = (char *) osClipRectWKT.c_str();
OGRGeometryFactory::createFromWkt( &pszWKT, NULL,
(OGRGeometry**) (&poClipRect) );
if( poClipRect )
{
/***** if it doesnt intersect the polym zero the mask and return *****/
if ( ! ((OGRGeometry *) hPolygon)->Intersects( poClipRect ) )
{
memset( pafValidityMask, 0, sizeof(float) * nXSize * nYSize );
delete poLines;
delete poClipRect;
return CE_None;
}
/***** if it doesnt intersect the line at all just return *****/
else if ( ! ((OGRGeometry *) poLines)->Intersects( poClipRect ) )
{
delete poLines;
delete poClipRect;
return CE_None;
}
OGRGeometry *poClippedLines =
poLines->Intersection( poClipRect );
delete poLines;
poLines = poClippedLines;
delete poClipRect;
}
/* -------------------------------------------------------------------- */
/* Convert our polygon into GEOS format, and compute an */
/* envelope to accelerate later distance operations. */
/* -------------------------------------------------------------------- */
OGREnvelope sEnvelope;
int iXMin, iYMin, iXMax, iYMax;
GEOSContextHandle_t hGEOSCtxt = OGRGeometry::createGEOSContext();
GEOSGeom poGEOSPoly;
poGEOSPoly = poLines->exportToGEOS(hGEOSCtxt);
OGR_G_GetEnvelope( hPolygon, &sEnvelope );
//.........这里部分代码省略.........