本文整理汇总了C++中OGRLinearRing::addSubLineString方法的典型用法代码示例。如果您正苦于以下问题:C++ OGRLinearRing::addSubLineString方法的具体用法?C++ OGRLinearRing::addSubLineString怎么用?C++ OGRLinearRing::addSubLineString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OGRLinearRing
的用法示例。
在下文中一共展示了OGRLinearRing::addSubLineString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: while
OGRFeature *OGRSOSILayer::GetNextFeature() {
short nName, nNumLines;
long nNumCoo;
unsigned short nInfo;
/* iterate through the SOSI groups*/
while (LC_NextBgr(poNextSerial,LC_FRAMGR)) {
nName = LC_RxGr(&oNextSerial, LES_OPTIMALT, &nNumLines, &nNumCoo, &nInfo);
S2S oHeaders;
S2S::iterator iHeaders;
/* extract reference strings from group header */
CPLString osKey, osValue;
for (short i=1; i<=nNumLines; i++) {
char *pszLine = LC_GetGi(i);
if (pszLine[0] == '!') continue; /* If we have a comment line, skip it. */
if ((pszLine[0] == ':')||(pszLine[0] == '(')) { /* if we have a continued REF line... */
osValue.append(CPLString(pszLine)); /* append to previous line. */
oHeaders.insert(std::pair<CPLString,CPLString>(osKey,osValue));
continue;
}
while (pszLine[0] == '.') pszLine++; /* skipping the dots at the beginning of a SOSI line */
char *pszUTFLine = CPLRecode(pszLine, poParent->pszEncoding, CPL_ENC_UTF8); /* switch to UTF encoding here */
char *pszPos = strstr(pszUTFLine, " ");
if (pszPos != NULL) {
osKey = CPLString(std::string(pszUTFLine,pszPos));
osValue = CPLString(pszPos+1);
oHeaders.insert(std::pair<CPLString,CPLString>(osKey,osValue));
}
CPLFree(pszUTFLine);
}
/* get Feature from fyba, according to feature definition */
OGRGeometry *poGeom = NULL;
OGRwkbGeometryType oGType = wkbUnknown;
switch (nName) {
case INGEN_GRUPPE: { /* No group */
CPLDebug( "[GetNextFeature]", "Could not load further groups - FYBA reported INGEN_GRUPPE.");
break;
}
case L_FLATE: { /* Area */
oGType = wkbPolygon;
OGRLinearRing *poOuter = new OGRLinearRing(); /* Initialize a new closed polygon */
long nRefNr;
unsigned char nRefStatus;
long nRefCount;
bool correct = true;
LC_GRF_STATUS oGrfStat;
// Iterate through all objects that constitute this area.
LC_InitGetRefFlate(&oGrfStat);
nRefCount = LC_GetRefFlate(&oGrfStat, GRF_YTRE, &nRefNr, &nRefStatus, 1);
while (nRefCount > 0) {
if (poParent->papoBuiltGeometries[nRefNr] == NULL) {
// This should not happen under normal operation.
CPLError( CE_Warning, CPLE_AppDefined, "Feature %li referenced by %li, but it was not initialized. Geometry may be broken.", nRefNr, oNextSerial.lNr);
correct = false;
//return NULL;
break;
}
OGRGeometry *geom = poParent->papoBuiltGeometries[nRefNr];
if (geom->getGeometryType() == wkbLineString) {
OGRLineString *poCurve = (OGRLineString*)geom;
if (nRefStatus == LC_MED_DIG) { /* clockwise */
poOuter->addSubLineString(poCurve);
} else if (nRefStatus == LC_MOT_DIG) { /* counter-clockwise */
poOuter->addSubLineString(poCurve,poCurve->getNumPoints()-1,0);
} else {
CPLError( CE_Failure, CPLE_OpenFailed, "Internal error: GRF_*_OY encountered.");
return NULL;
}
} else {
CPLError( CE_Warning, CPLE_AppDefined, "Element %li composed of non-linestrings (REF %li of type %i). Ignored.", oNextSerial.lNr, nRefNr, geom->getGeometryType());
}
nRefCount = LC_GetRefFlate(&oGrfStat, GRF_YTRE, &nRefNr, &nRefStatus, 1);
}
if (correct) {
OGRPolygon *poLy = new OGRPolygon();
poOuter->closeRings();
poLy->addRingDirectly(poOuter);
OGRLinearRing *poInner = 0;
nRefCount = LC_GetRefFlate(&oGrfStat, GRF_INDRE, &nRefNr, &nRefStatus, 1);
while (nRefCount > 0) {
if (nRefNr == -1) {
if (poInner && (poInner->getNumPoints()>2)) { /* If this is not the first polygon, terminate and add the last */
poInner->closeRings();
poLy->addRingDirectly(poInner);
}
poInner = new OGRLinearRing(); /* Initialize a new closed polygon */
} else {
if (poParent->papoBuiltGeometries[nRefNr] == NULL) { /* this shouldn't happen under normal operation */
CPLError( CE_Fatal, CPLE_AppDefined, "Feature %li referenced by %li, but it was not initialized.", nRefNr, oNextSerial.lNr);
return NULL;
}
OGRGeometry *geom = poParent->papoBuiltGeometries[nRefNr];
if (geom->getGeometryType() == wkbLineString) {
OGRLineString *poCurve = (OGRLineString*)geom;
//.........这里部分代码省略.........