本文整理汇总了C++中OGRGeometryCollection::addGeometryDirectly方法的典型用法代码示例。如果您正苦于以下问题:C++ OGRGeometryCollection::addGeometryDirectly方法的具体用法?C++ OGRGeometryCollection::addGeometryDirectly怎么用?C++ OGRGeometryCollection::addGeometryDirectly使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OGRGeometryCollection
的用法示例。
在下文中一共展示了OGRGeometryCollection::addGeometryDirectly方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: make
OGRGeometryCollection* make()
{
OGRGeometryCollection* poCollection = new OGRGeometryCollection();
poCollection->addGeometryDirectly(make<OGRPoint>());
poCollection->addGeometryDirectly(make<OGRLinearRing>());
return poCollection;
}
示例2: getCurveGeometry
OGRGeometry* OGRGeometryCollection::getCurveGeometry(
const char* const* papszOptions) const
{
OGRGeometryCollection* poGC =
OGRGeometryFactory::createGeometry(
OGR_GT_GetCurve(getGeometryType()))->toGeometryCollection();
if( poGC == nullptr )
return nullptr;
poGC->assignSpatialReference( getSpatialReference() );
bool bHasCurveGeometry = false;
for( int iGeom = 0; iGeom < nGeomCount; iGeom++ )
{
OGRGeometry* poSubGeom =
papoGeoms[iGeom]->getCurveGeometry(papszOptions);
if( poSubGeom->hasCurveGeometry() )
bHasCurveGeometry = true;
poGC->addGeometryDirectly( poSubGeom );
}
if( !bHasCurveGeometry )
{
delete poGC;
return clone();
}
return poGC;
}
示例3: OGRGeometryCollection
int OGRDB2GeometryValidator::ValidatePolygon(OGRPolygon* poGeom)
{
int i,j;
OGRLinearRing* poRing = poGeom->getExteriorRing();
OGRGeometry* poInteriorRing;
if (poRing == NULL)
return FALSE;
OGRGeometryCollection* poGeometries = NULL;
if (!ValidateLinearRing(poRing))
{
if (poGeom->getNumInteriorRings() > 0)
{
poGeometries = new OGRGeometryCollection();
poGeometries->addGeometryDirectly(poValidGeometry);
}
}
for (i = 0; i < poGeom->getNumInteriorRings(); i++)
{
poInteriorRing = poGeom->getInteriorRing(i);
if (!ValidateLinearRing((OGRLinearRing*)poInteriorRing))
{
if (!poGeometries)
{
poGeometries = new OGRGeometryCollection();
poGeometries->addGeometry(poRing);
for (j = 0; j < i; j++)
poGeometries->addGeometry(poGeom->getInteriorRing(j));
}
poGeometries->addGeometry(poValidGeometry);
continue;
}
if (poGeometries)
poGeometries->addGeometry(poInteriorRing);
}
if (poGeometries)
{
if (poValidGeometry)
delete poValidGeometry;
poValidGeometry = poGeometries;
}
return (poValidGeometry == NULL);
}
示例4: getLinearGeometry
OGRGeometry* OGRGeometryCollection::getLinearGeometry(double dfMaxAngleStepSizeDegrees,
const char* const* papszOptions) const
{
OGRGeometryCollection* poGC = (OGRGeometryCollection*)
OGRGeometryFactory::createGeometry(OGR_GT_GetLinear(getGeometryType()));
if( poGC == NULL )
return NULL;
poGC->assignSpatialReference( getSpatialReference() );
for( int iGeom = 0; iGeom < nGeomCount; iGeom++ )
{
OGRGeometry* poSubGeom = papoGeoms[iGeom]->getLinearGeometry(dfMaxAngleStepSizeDegrees,
papszOptions);
poGC->addGeometryDirectly( poSubGeom );
}
return poGC;
}
示例5: GML_BuildOGRGeometryFromList
OGRGeometry* GML_BuildOGRGeometryFromList(const CPLXMLNode* const * papsGeometry,
int bTryToMakeMultipolygons,
int bInvertAxisOrderIfLatLong,
const char* pszDefaultSRSName,
int bConsiderEPSGAsURN,
int bGetSecondaryGeometryOption,
void* hCacheSRS,
int bFaceHoleNegative)
{
OGRGeometry* poGeom = NULL;
int i;
OGRGeometryCollection* poCollection = NULL;
for(i=0;papsGeometry[i] != NULL;i++)
{
OGRGeometry* poSubGeom = GML2OGRGeometry_XMLNode( papsGeometry[i],
bGetSecondaryGeometryOption,
0, 0, FALSE, TRUE,
bFaceHoleNegative );
if (poSubGeom)
{
if (poGeom == NULL)
poGeom = poSubGeom;
else
{
if (poCollection == NULL)
{
if (bTryToMakeMultipolygons &&
wkbFlatten(poGeom->getGeometryType()) == wkbPolygon &&
wkbFlatten(poSubGeom->getGeometryType()) == wkbPolygon)
{
OGRGeometryCollection* poGeomColl = new OGRMultiPolygon();
poGeomColl->addGeometryDirectly(poGeom);
poGeomColl->addGeometryDirectly(poSubGeom);
poGeom = poGeomColl;
}
else if (bTryToMakeMultipolygons &&
wkbFlatten(poGeom->getGeometryType()) == wkbMultiPolygon &&
wkbFlatten(poSubGeom->getGeometryType()) == wkbPolygon)
{
OGRGeometryCollection* poGeomColl = (OGRGeometryCollection* )poGeom;
poGeomColl->addGeometryDirectly(poSubGeom);
}
else if (bTryToMakeMultipolygons &&
wkbFlatten(poGeom->getGeometryType()) == wkbMultiPolygon &&
wkbFlatten(poSubGeom->getGeometryType()) == wkbMultiPolygon)
{
OGRGeometryCollection* poGeomColl = (OGRGeometryCollection* )poGeom;
OGRGeometryCollection* poGeomColl2 = (OGRGeometryCollection* )poSubGeom;
int nCount = poGeomColl2->getNumGeometries();
int i;
for(i=0;i<nCount;i++)
{
poGeomColl->addGeometry(poGeomColl2->getGeometryRef(i));
}
delete poSubGeom;
}
else if (bTryToMakeMultipolygons &&
wkbFlatten(poGeom->getGeometryType()) == wkbMultiPolygon)
{
delete poGeom;
delete poSubGeom;
return GML_BuildOGRGeometryFromList(papsGeometry, FALSE,
bInvertAxisOrderIfLatLong,
pszDefaultSRSName,
bConsiderEPSGAsURN,
bGetSecondaryGeometryOption,
hCacheSRS);
}
else
{
poCollection = new OGRGeometryCollection();
poCollection->addGeometryDirectly(poGeom);
poGeom = poCollection;
}
}
if (poCollection != NULL)
{
poCollection->addGeometryDirectly(poSubGeom);
}
}
}
}
if( poGeom == NULL )
return NULL;
std::string osWork;
const char* pszSRSName = GML_ExtractSrsNameFromGeometry(papsGeometry, osWork,
bConsiderEPSGAsURN);
const char* pszNameLookup = pszSRSName;
if( pszNameLookup == NULL )
pszNameLookup = pszDefaultSRSName;
if (pszNameLookup != NULL)
{
SRSCache* poSRSCache = (SRSCache*)hCacheSRS;
SRSDesc& oSRSDesc = poSRSCache->Get(pszNameLookup);
poGeom->assignSpatialReference(oSRSDesc.poSRS);
if (oSRSDesc.bAxisInvert && bInvertAxisOrderIfLatLong)
poGeom->swapXY();
//.........这里部分代码省略.........
示例6: getPoint
OGRGeometry *ILI2Reader::getGeometry(DOMElement *elem, int type) {
OGRGeometryCollection *gm = new OGRGeometryCollection();
DOMElement *childElem = elem;
while (childElem != NULL) {
char* pszTagName = XMLString::transcode(childElem->getTagName());
switch (type) {
case ILI2_COORD_TYPE :
if (cmpStr(ILI2_COORD, pszTagName) == 0)
{
delete gm;
XMLString::release(&pszTagName);
return getPoint(childElem);
}
break;
case ILI2_ARC_TYPE :
// is it possible here? It have to be a ARC or COORD before (getPreviousSibling)
if (cmpStr(ILI2_ARC, pszTagName) == 0)
{
delete gm;
XMLString::release(&pszTagName);
return getArc(childElem);
}
break;
case ILI2_POLYLINE_TYPE :
if (cmpStr(ILI2_POLYLINE, pszTagName) == 0)
{
delete gm;
XMLString::release(&pszTagName);
return getLineString(childElem, FALSE);
}
break;
case ILI2_BOUNDARY_TYPE :
if (cmpStr(ILI2_BOUNDARY, pszTagName) == 0)
{
delete gm;
XMLString::release(&pszTagName);
return getLineString(childElem, FALSE);
}
break;
case ILI2_AREA_TYPE :
if ((cmpStr(ILI2_AREA, pszTagName) == 0) ||
(cmpStr(ILI2_SURFACE, pszTagName) == 0))
{
delete gm;
XMLString::release(&pszTagName);
return getPolygon(childElem);
}
break;
default :
if (type >= ILI2_GEOMCOLL_TYPE) {
int subType = getGeometryTypeOfElem(childElem); //????
gm->addGeometryDirectly(getGeometry(childElem, subType));
}
break;
}
XMLString::release(&pszTagName);
// GEOMCOLL
childElem = (DOMElement *)childElem->getNextSibling();
}
return gm;
}
示例7: OGRCreateFromGeomedia
//.........这里部分代码省略.........
{
return OGRERR_FAILURE;
}
pabyGeom += 4;
nBytes -= 4;
if (nBytes < nSubBytes)
{
return OGRERR_FAILURE;
}
if( nSubBytes < 16 )
return OGRERR_FAILURE;
if( !(pabyGeom[1] == 0xFF && pabyGeom[2] == 0xD2 && pabyGeom[3] == 0x0F) )
return OGRERR_FAILURE;
int nSubGeomType = pabyGeom[0];
if ( nSubGeomType != GEOMEDIA_POLYLINE )
bAllPolyline = FALSE;
if ( nSubGeomType != GEOMEDIA_POLYGON )
bAllPolygon = FALSE;
pabyGeom += nSubBytes;
nBytes -= nSubBytes;
}
pabyGeom = pabyGeomBackup;
nBytes = nBytesBackup;
if (bAllPolyline)
nGeomType = GEOMEDIA_MULTILINE;
else if (bAllPolygon)
nGeomType = GEOMEDIA_MULTIPOLYGON;
}
OGRGeometryCollection* poColl = (nGeomType == GEOMEDIA_MULTILINE) ? new OGRMultiLineString() :
(nGeomType == GEOMEDIA_MULTIPOLYGON) ? new OGRMultiPolygon() :
new OGRGeometryCollection();
for(i=0;i<nParts;i++)
{
if (nBytes < 4)
return OGRERR_FAILURE;
int nSubBytes;
memcpy(&nSubBytes, pabyGeom, 4);
CPL_LSBPTR32(&nSubBytes);
if (nSubBytes < 0)
{
delete poColl;
return OGRERR_FAILURE;
}
pabyGeom += 4;
nBytes -= 4;
if (nBytes < nSubBytes)
{
delete poColl;
return OGRERR_FAILURE;
}
OGRGeometry* poSubGeom = NULL;
if (OGRCreateFromGeomedia( pabyGeom, &poSubGeom, nSubBytes ) == OGRERR_NONE)
{
if (wkbFlatten(poColl->getGeometryType()) == wkbMultiPolygon &&
wkbFlatten(poSubGeom->getGeometryType()) == wkbLineString)
{
OGRPolygon* poPoly = new OGRPolygon();
OGRLinearRing* poRing = new OGRLinearRing();
poRing->addSubLineString((OGRLineString*)poSubGeom);
poPoly->addRingDirectly(poRing);
delete poSubGeom;
poSubGeom = poPoly;
}
if (poColl->addGeometryDirectly(poSubGeom) != OGRERR_NONE)
{
//printf("%d %d\n", poColl->getGeometryType() & ~wkb25DBit, poSubGeom->getGeometryType() & ~wkb25DBit);
delete poSubGeom;
}
}
pabyGeom += nSubBytes;
nBytes -= nSubBytes;
}
*ppoGeom = poColl;
return OGRERR_NONE;
}
else
{
CPLDebug("GEOMEDIA", "Unhandled type %d", nGeomType);
}
return OGRERR_FAILURE;
}
示例8: GML_BuildOGRGeometryFromList
OGRGeometry* GML_BuildOGRGeometryFromList(const CPLXMLNode* const * papsGeometry,
int bTryToMakeMultipolygons,
int bInvertAxisOrderIfLatLong,
const char* pszDefaultSRSName,
int bConsiderEPSGAsURN,
int bGetSecondaryGeometryOption,
void* hCacheSRS)
{
OGRGeometry* poGeom = NULL;
int i;
OGRGeometryCollection* poCollection = NULL;
for(i=0;papsGeometry[i] != NULL;i++)
{
OGRGeometry* poSubGeom = GML2OGRGeometry_XMLNode( papsGeometry[i],
bGetSecondaryGeometryOption );
if (poSubGeom)
{
if (poGeom == NULL)
poGeom = poSubGeom;
else
{
if (poCollection == NULL)
{
if (bTryToMakeMultipolygons &&
wkbFlatten(poGeom->getGeometryType()) == wkbPolygon &&
wkbFlatten(poSubGeom->getGeometryType()) == wkbPolygon)
{
OGRGeometryCollection* poGeomColl = new OGRMultiPolygon();
poGeomColl->addGeometryDirectly(poGeom);
poGeomColl->addGeometryDirectly(poSubGeom);
poGeom = poGeomColl;
}
else if (bTryToMakeMultipolygons &&
wkbFlatten(poGeom->getGeometryType()) == wkbMultiPolygon &&
wkbFlatten(poSubGeom->getGeometryType()) == wkbPolygon)
{
OGRGeometryCollection* poGeomColl = (OGRGeometryCollection* )poGeom;
poGeomColl->addGeometryDirectly(poSubGeom);
}
else if (bTryToMakeMultipolygons &&
wkbFlatten(poGeom->getGeometryType()) == wkbMultiPolygon &&
wkbFlatten(poSubGeom->getGeometryType()) == wkbMultiPolygon)
{
OGRGeometryCollection* poGeomColl = (OGRGeometryCollection* )poGeom;
OGRGeometryCollection* poGeomColl2 = (OGRGeometryCollection* )poSubGeom;
int nCount = poGeomColl2->getNumGeometries();
int i;
for(i=0;i<nCount;i++)
{
poGeomColl->addGeometry(poGeomColl2->getGeometryRef(i));
}
delete poSubGeom;
}
else if (bTryToMakeMultipolygons &&
wkbFlatten(poGeom->getGeometryType()) == wkbMultiPolygon)
{
delete poGeom;
delete poSubGeom;
return GML_BuildOGRGeometryFromList(papsGeometry, FALSE,
bInvertAxisOrderIfLatLong,
pszDefaultSRSName,
bConsiderEPSGAsURN,
bGetSecondaryGeometryOption,
hCacheSRS);
}
else
{
poCollection = new OGRGeometryCollection();
poCollection->addGeometryDirectly(poGeom);
poGeom = poCollection;
}
}
if (poCollection != NULL)
{
poCollection->addGeometryDirectly(poSubGeom);
}
}
}
}
if ( poGeom != NULL && bInvertAxisOrderIfLatLong )
{
std::string osWork;
const char* pszSRSName = GML_ExtractSrsNameFromGeometry(papsGeometry, osWork,
bConsiderEPSGAsURN);
const char* pszNameLookup = pszSRSName ? pszSRSName : pszDefaultSRSName;
if (pszNameLookup != NULL)
{
SRSCache* poSRSCache = (SRSCache*)hCacheSRS;
int bSwap;
if (strcmp(poSRSCache->osLastSRSName.c_str(), pszNameLookup) == 0)
{
bSwap = poSRSCache->bAxisInvertLastSRSName;
}
else
{
bSwap = GML_IsSRSLatLongOrder(pszNameLookup);
poSRSCache->osLastSRSName = pszNameLookup;
poSRSCache->bAxisInvertLastSRSName= bSwap;
}
//.........这里部分代码省略.........
示例9: ReadBlocksSection
void OGRDXFDataSource::ReadBlocksSection()
{
char szLineBuf[257];
int nCode;
OGRDXFLayer *poReaderLayer = (OGRDXFLayer *) GetLayerByName( "Entities" );
iEntitiesSectionOffset = oReader.iSrcBufferFileOffset + oReader.iSrcBufferOffset;
while( (nCode = ReadValue( szLineBuf, sizeof(szLineBuf) )) > -1
&& !EQUAL(szLineBuf,"ENDSEC") )
{
// We are only interested in extracting blocks.
if( nCode != 0 || !EQUAL(szLineBuf,"BLOCK") )
continue;
// Process contents of BLOCK definition till we find the
// first entity.
CPLString osBlockName;
while( (nCode = ReadValue( szLineBuf,sizeof(szLineBuf) )) > 0 )
{
if( nCode == 2 )
osBlockName = szLineBuf;
// anything else we want?
}
if( EQUAL(szLineBuf,"ENDBLK") )
continue;
UnreadValue();
// Now we will process entities till we run out at the ENDBLK code.
// we aggregate the geometries of the features into a multi-geometry,
// but throw away other stuff attached to the features.
OGRFeature *poFeature;
OGRGeometryCollection *poColl = new OGRGeometryCollection();
std::vector<OGRFeature*> apoFeatures;
while( (poFeature = poReaderLayer->GetNextUnfilteredFeature()) != NULL )
{
if( poFeature->GetStyleString() != NULL
&& strstr(poFeature->GetStyleString(),"LABEL") != NULL )
{
apoFeatures.push_back( poFeature );
}
else
{
poColl->addGeometryDirectly( poFeature->StealGeometry() );
delete poFeature;
}
}
if( poColl->getNumGeometries() == 0 )
delete poColl;
else
oBlockMap[osBlockName].poGeometry = SimplifyBlockGeometry(poColl);
if( apoFeatures.size() > 0 )
oBlockMap[osBlockName].apoFeatures = apoFeatures;
}
CPLDebug( "DXF", "Read %d blocks with meaningful geometry.",
(int) oBlockMap.size() );
}
示例10: if
//.........这里部分代码省略.........
addRingDirectly ( ( OGRLinearRing * ) poOgrTmpGeometry );
}
}
poOgrGeometry = poOgrPolygon;
break;
case kmldom::Type_MultiGeometry:
{
poKmlMultiGeometry = AsMultiGeometry ( poKmlGeometry );
nGeom = poKmlMultiGeometry->get_geometry_array_size ( );
// Detect subgeometry type to instantiate appropriate
// multi geometry type.
kmldom::KmlDomType type = kmldom::Type_Unknown;
for ( i = 0; i < nGeom; i++ ) {
poKmlTmpGeometry = poKmlMultiGeometry->get_geometry_array_at ( i );
if (type == kmldom::Type_Unknown)
type = poKmlTmpGeometry->Type();
else if (type != poKmlTmpGeometry->Type())
{
type = kmldom::Type_Unknown;
break;
}
}
if (type == kmldom::Type_Point)
poOgrMultiGeometry = new OGRMultiPoint();
else if (type == kmldom::Type_LineString)
poOgrMultiGeometry = new OGRMultiLineString();
else if (type == kmldom::Type_Polygon)
poOgrMultiGeometry = new OGRMultiPolygon();
else
poOgrMultiGeometry = new OGRGeometryCollection ();
for ( i = 0; i < nGeom; i++ ) {
poKmlTmpGeometry = poKmlMultiGeometry->get_geometry_array_at ( i );
poOgrTmpGeometry = kml2geom_rec ( poKmlTmpGeometry, poOgrSRS );
poOgrMultiGeometry->addGeometryDirectly ( poOgrTmpGeometry );
}
poOgrGeometry = poOgrMultiGeometry;
break;
}
case kmldom::Type_GxTrack:
poKmlGxTrack = AsGxTrack ( poKmlGeometry );
nCoords = poKmlGxTrack->get_gx_coord_array_size();
poOgrLineString = new OGRLineString ( );
for ( i = 0; i < nCoords; i++ ) {
oKmlVec = poKmlGxTrack->get_gx_coord_array_at ( i );
if ( oKmlVec.has_altitude ( ) )
poOgrLineString->
addPoint ( oKmlVec.get_longitude ( ),
oKmlVec.get_latitude ( ),
oKmlVec.get_altitude ( ) );
else
poOgrLineString->
addPoint ( oKmlVec.get_longitude ( ),
oKmlVec.get_latitude ( ) );
}
poOgrGeometry = poOgrLineString;
break;
case kmldom::Type_GxMultiTrack:
{
poKmlGxMultiTrack = AsGxMultiTrack ( poKmlGeometry );
nGeom = poKmlGxMultiTrack->get_gx_track_array_size ( );
poOgrMultiGeometry = new OGRMultiLineString();
for( size_t j = 0; j < nGeom; j++ )
{
poKmlGxTrack = poKmlGxMultiTrack->get_gx_track_array_at ( j );
nCoords = poKmlGxTrack->get_gx_coord_array_size();
poOgrLineString = new OGRLineString ( );
for ( i = 0; i < nCoords; i++ ) {
oKmlVec = poKmlGxTrack->get_gx_coord_array_at ( i );
if ( oKmlVec.has_altitude ( ) )
poOgrLineString->
addPoint ( oKmlVec.get_longitude ( ),
oKmlVec.get_latitude ( ),
oKmlVec.get_altitude ( ) );
else
poOgrLineString->
addPoint ( oKmlVec.get_longitude ( ),
oKmlVec.get_latitude ( ) );
}
poOgrMultiGeometry->addGeometryDirectly(poOgrLineString);
}
poOgrGeometry = poOgrMultiGeometry;
break;
}
default:
break;
}
if (poOgrGeometry)
poOgrGeometry->assignSpatialReference(poOgrSRS);
return poOgrGeometry;
}
示例11: ParseKMLGeometry
//.........这里部分代码省略.........
}
}
else if (strcmp(pszGeomType, "Polygon") == 0)
{
OGRPolygon* poPoly = nullptr;
CPLXMLNode* psOuterBoundary = CPLGetXMLNode(psXML, "outerBoundaryIs");
if (psOuterBoundary)
{
CPLXMLNode* psLinearRing = CPLGetXMLNode(psOuterBoundary, "LinearRing");
const char* pszCoordinates = CPLGetXMLValue(
psLinearRing ? psLinearRing : psOuterBoundary, "coordinates", nullptr);
if (pszCoordinates)
{
OGRLinearRing* poLS = new OGRLinearRing();
ParseLineString(poLS, pszCoordinates);
poPoly = new OGRPolygon();
poPoly->addRingDirectly(poLS);
poGeom = poPoly;
}
if (poPoly)
{
CPLXMLNode* psIter = psXML->psChild;
while(psIter)
{
if (psIter->eType == CXT_Element &&
strcmp(psIter->pszValue, "innerBoundaryIs") == 0)
{
psLinearRing = CPLGetXMLNode(psIter, "LinearRing");
pszCoordinates = CPLGetXMLValue(
psLinearRing ? psLinearRing : psIter, "coordinates", nullptr);
if (pszCoordinates)
{
OGRLinearRing* poLS = new OGRLinearRing();
ParseLineString(poLS, pszCoordinates);
poPoly->addRingDirectly(poLS);
}
}
psIter = psIter->psNext;
}
}
}
}
else if (strcmp(pszGeomType, "MultiGeometry") == 0)
{
CPLXMLNode* psIter = nullptr;
OGRwkbGeometryType eType = wkbUnknown;
for(psIter = psXML->psChild; psIter; psIter = psIter->psNext)
{
if (psIter->eType == CXT_Element)
{
OGRwkbGeometryType eNewType = wkbUnknown;
if (strcmp(psIter->pszValue, "Point") == 0)
{
eNewType = wkbPoint;
}
else if (strcmp(psIter->pszValue, "LineString") == 0)
{
eNewType = wkbLineString;
}
else if (strcmp(psIter->pszValue, "Polygon") == 0)
{
eNewType = wkbPolygon;
}
else
break;
if (eType == wkbUnknown)
eType = eNewType;
else if (eType != eNewType)
break;
}
}
OGRGeometryCollection* poColl = nullptr;
if (psIter != nullptr)
poColl = new OGRGeometryCollection();
else if (eType == wkbPoint)
poColl = new OGRMultiPoint();
else if (eType == wkbLineString)
poColl = new OGRMultiLineString();
else if (eType == wkbPolygon)
poColl = new OGRMultiPolygon();
else {
CPLAssert(false);
}
for(psIter = psXML->psChild; psIter; psIter = psIter->psNext)
{
if (psIter->eType == CXT_Element)
{
OGRGeometry* poSubGeom = ParseKMLGeometry(psIter);
if (poSubGeom)
poColl->addGeometryDirectly(poSubGeom);
}
}
poGeom = poColl;
}
return poGeom;
}
示例12: BareGMLElement
//.........这里部分代码省略.........
{
CPLXMLNode *psChild;
OGRMultiPolygon *poMPoly = new OGRMultiPolygon();
// Find all inner rings
for( psChild = psNode->psChild;
psChild != NULL;
psChild = psChild->psNext )
{
if( psChild->eType == CXT_Element
&& EQUAL(BareGMLElement(psChild->pszValue),"polygonMember") )
{
OGRPolygon *poPolygon;
poPolygon = (OGRPolygon *)
GML2OGRGeometry_XMLNode( psChild->psChild );
if( poPolygon == NULL )
{
delete poMPoly;
return NULL;
}
if( !EQUAL(poPolygon->getGeometryName(),"POLYGON") )
{
CPLError( CE_Failure, CPLE_AppDefined,
"Got %.500s geometry as polygonMember instead of MULTIPOLYGON.",
poPolygon->getGeometryName() );
delete poPolygon;
delete poMPoly;
return NULL;
}
poMPoly->addGeometryDirectly( poPolygon );
}
}
return poMPoly;
}
/* -------------------------------------------------------------------- */
/* MultiPoint */
/* -------------------------------------------------------------------- */
if( EQUAL(pszBaseGeometry,"MultiPoint") )
{
CPLXMLNode *psChild;
OGRMultiPoint *poMP = new OGRMultiPoint();
// collect points.
for( psChild = psNode->psChild;
psChild != NULL;
psChild = psChild->psNext )
{
if( psChild->eType == CXT_Element
&& EQUAL(BareGMLElement(psChild->pszValue),"pointMember") )
{
OGRPoint *poPoint;
poPoint = (OGRPoint *)
GML2OGRGeometry_XMLNode( psChild->psChild );
if( poPoint == NULL
|| wkbFlatten(poPoint->getGeometryType()) != wkbPoint )
{
CPLError( CE_Failure, CPLE_AppDefined,
"Got %.500s geometry as pointMember instead of MULTIPOINT",
poPoint ? poPoint->getGeometryName() : "NULL" );
示例13: ReadBlocksSection
void OGRDWGDataSource::ReadBlocksSection()
{
OGRDWGLayer *poReaderLayer = (OGRDWGLayer *) GetLayerByName( "Entities" );
int bMergeBlockGeometries = CSLTestBoolean(
CPLGetConfigOption( "DWG_MERGE_BLOCK_GEOMETRIES", "TRUE" ) );
/* -------------------------------------------------------------------- */
/* Loop over all the block tables, skipping *Model_Space which */
/* we assume is primary entities. */
/* -------------------------------------------------------------------- */
OdDbBlockTableRecordPtr poModelSpace, poBlock;
OdDbBlockTablePtr pTable = GetDB()->getBlockTableId().safeOpenObject();
OdDbSymbolTableIteratorPtr pBlkIter = pTable->newIterator();
for (pBlkIter->start(); ! pBlkIter->done(); pBlkIter->step())
{
poBlock = pBlkIter->getRecordId().safeOpenObject();
CPLString osBlockName = (const char *) poBlock->getName();
if( EQUAL(osBlockName,"*Model_Space") )
{
poModelSpace = poBlock;
continue;
}
poReaderLayer->SetBlockTable( poBlock );
// Now we will process entities till we run out.
// We aggregate the geometries of the features into a multi-geometry,
// but throw away other stuff attached to the features.
OGRFeature *poFeature;
OGRGeometryCollection *poColl = new OGRGeometryCollection();
std::vector<OGRFeature*> apoFeatures;
while( (poFeature = poReaderLayer->GetNextUnfilteredFeature()) != NULL )
{
if( (poFeature->GetStyleString() != NULL
&& strstr(poFeature->GetStyleString(),"LABEL") != NULL)
|| !bMergeBlockGeometries )
{
apoFeatures.push_back( poFeature );
}
else
{
poColl->addGeometryDirectly( poFeature->StealGeometry() );
delete poFeature;
}
}
if( poColl->getNumGeometries() == 0 )
delete poColl;
else
oBlockMap[osBlockName].poGeometry = SimplifyBlockGeometry(poColl);
if( apoFeatures.size() > 0 )
oBlockMap[osBlockName].apoFeatures = apoFeatures;
}
CPLDebug( "DWG", "Read %d blocks with meaningful geometry.",
(int) oBlockMap.size() );
poReaderLayer->SetBlockTable( poModelSpace );
}