本文整理匯總了C++中GetLayerDefn函數的典型用法代碼示例。如果您正苦於以下問題:C++ GetLayerDefn函數的具體用法?C++ GetLayerDefn怎麽用?C++ GetLayerDefn使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GetLayerDefn函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: CPLSetThreadLocalConfigOption
void OGRILI1Layer::JoinGeomLayers()
{
bGeomsJoined = TRUE;
int bResetConfigOption = FALSE;
if (EQUAL(CPLGetConfigOption("OGR_ARC_STEPSIZE", ""), ""))
{
bResetConfigOption = TRUE;
CPLSetThreadLocalConfigOption("OGR_ARC_STEPSIZE", "0.96");
}
for (GeomFieldInfos::const_iterator it = oGeomFieldInfos.begin(); it != oGeomFieldInfos.end(); ++it)
{
OGRFeatureDefn* geomFeatureDefn = it->second.geomTable;
if (geomFeatureDefn)
{
CPLDebug( "OGR_ILI", "Join geometry table %s of field '%s'", geomFeatureDefn->GetName(), it->first.c_str() );
OGRILI1Layer* poGeomLayer = poDS->GetLayerByName(geomFeatureDefn->GetName());
int nGeomFieldIndex = GetLayerDefn()->GetGeomFieldIndex(it->first.c_str());
if (it->second.iliGeomType == "Surface")
{
JoinSurfaceLayer(poGeomLayer, nGeomFieldIndex);
}
else if (it->second.iliGeomType == "Area")
{
CPLString pointField = it->first + "__Point";
int nPointFieldIndex = GetLayerDefn()->GetGeomFieldIndex(pointField.c_str());
PolygonizeAreaLayer(poGeomLayer, nGeomFieldIndex, nPointFieldIndex);
}
}
}
if( bResetConfigOption )
CPLSetThreadLocalConfigOption("OGR_ARC_STEPSIZE", NULL);
}
示例2: CPLDebug
void OGRILI1Layer::JoinSurfaceLayer( OGRILI1Layer* poSurfaceLineLayer, int nSurfaceFieldIndex )
{
CPLDebug( "OGR_ILI", "Joining surface layer %s with geometries", GetLayerDefn()->GetName());
OGRwkbGeometryType geomType = GetLayerDefn()->GetGeomFieldDefn(nSurfaceFieldIndex)->GetType();
poSurfaceLineLayer->ResetReading();
while (OGRFeature *linefeature = poSurfaceLineLayer->GetNextFeatureRef()) {
//OBJE entries with same _RefTID are polygon rings of same feature
//TODO: non-numeric _RefTID/FID is not supported yet!
GIntBig reftid = linefeature->GetFieldAsInteger64(1); //_RefTID
OGRFeature *feature = GetFeatureRef((int)reftid);
if (feature) {
OGRCurvePolygon *poly;
if (feature->GetGeomFieldRef(nSurfaceFieldIndex)) {
CPLDebug( "OGR_ILI", "Adding ring to FID " CPL_FRMT_GIB, reftid );
poly = (OGRCurvePolygon *)feature->GetGeomFieldRef(nSurfaceFieldIndex);
} else {
poly = (geomType == wkbPolygon) ? new OGRPolygon() : new OGRCurvePolygon();
feature->SetGeomFieldDirectly(nSurfaceFieldIndex, poly);
}
OGRMultiCurve *lines = (OGRMultiCurve*)linefeature->GetGeomFieldRef(0);
for( int i = 0; i < lines->getNumGeometries(); i++ ) {
OGRCurve *line = (OGRCurve*)lines->getGeometryRef(i);
OGRCurve *ring = (geomType == wkbPolygon) ?
OGRCurve::CastToLinearRing((OGRCurve*)line->clone()) :
(OGRCurve*)line->clone();
poly->addRingDirectly(ring);
}
} else {
CPLError(CE_Warning, CPLE_AppDefined, "Couldn't join feature FID " CPL_FRMT_GIB, reftid );
}
}
ResetReading();
poSurfaceLineLayer = 0;
}
示例3: GetLayerDefn
void OGRPGResultLayer::SetSpatialFilter( int iGeomField, OGRGeometry * poGeomIn )
{
if( iGeomField < 0 || iGeomField >= GetLayerDefn()->GetGeomFieldCount() ||
GetLayerDefn()->GetGeomFieldDefn(iGeomField)->GetType() == wkbNone )
{
if( iGeomField != 0 )
{
CPLError(CE_Failure, CPLE_AppDefined,
"Invalid geometry field index : %d", iGeomField);
}
return;
}
m_iGeomFieldFilter = iGeomField;
OGRPGGeomFieldDefn* poGeomFieldDefn =
poFeatureDefn->myGetGeomFieldDefn(m_iGeomFieldFilter);
if( InstallFilter( poGeomIn ) )
{
if ( poGeomFieldDefn->ePostgisType == GEOM_TYPE_GEOMETRY ||
poGeomFieldDefn->ePostgisType == GEOM_TYPE_GEOGRAPHY )
{
if( m_poFilterGeom != NULL)
{
char szBox3D_1[128];
char szBox3D_2[128];
OGREnvelope sEnvelope;
m_poFilterGeom->getEnvelope( &sEnvelope );
if( poGeomFieldDefn->ePostgisType == GEOM_TYPE_GEOGRAPHY )
{
if( sEnvelope.MinX < -180.0 )
sEnvelope.MinX = -180.0;
if( sEnvelope.MinY < -90.0 )
sEnvelope.MinY = -90.0;
if( sEnvelope.MaxX > 180.0 )
sEnvelope.MaxX = 180.0;
if( sEnvelope.MaxY > 90.0 )
sEnvelope.MaxY = 90.0;
}
CPLsnprintf(szBox3D_1, sizeof(szBox3D_1), "%.18g %.18g", sEnvelope.MinX, sEnvelope.MinY);
CPLsnprintf(szBox3D_2, sizeof(szBox3D_2), "%.18g %.18g", sEnvelope.MaxX, sEnvelope.MaxY);
osWHERE.Printf("WHERE %s && %s('BOX3D(%s, %s)'::box3d,%d) ",
OGRPGEscapeColumnName(poGeomFieldDefn->GetNameRef()).c_str(),
(poDS->sPostGISVersion.nMajor >= 2) ? "ST_SetSRID" : "SetSRID",
szBox3D_1, szBox3D_2, poGeomFieldDefn->nSRSId );
}
else
{
osWHERE = "";
}
BuildFullQueryStatement();
}
ResetReading();
}
}
示例4: GetLayerDefn
void OGRUnionLayer::AutoWarpLayerIfNecessary(int iLayer)
{
if( !pabCheckIfAutoWrap[iLayer] )
{
pabCheckIfAutoWrap[iLayer] = TRUE;
for(int i=0; i<GetLayerDefn()->GetGeomFieldCount();i++)
{
OGRSpatialReference* poSRS = GetLayerDefn()->GetGeomFieldDefn(i)->GetSpatialRef();
if( poSRS != NULL )
poSRS->Reference();
OGRFeatureDefn* poSrcFeatureDefn = papoSrcLayers[iLayer]->GetLayerDefn();
int iSrcGeomField = poSrcFeatureDefn->GetGeomFieldIndex(
GetLayerDefn()->GetGeomFieldDefn(i)->GetNameRef());
if( iSrcGeomField >= 0 )
{
OGRSpatialReference* poSRS2 =
poSrcFeatureDefn->GetGeomFieldDefn(iSrcGeomField)->GetSpatialRef();
if( (poSRS == NULL && poSRS2 != NULL) ||
(poSRS != NULL && poSRS2 == NULL) )
{
CPLError(CE_Warning, CPLE_AppDefined,
"SRS of geometry field '%s' layer %s not consistent with UnionLayer SRS",
GetLayerDefn()->GetGeomFieldDefn(i)->GetNameRef(),
papoSrcLayers[iLayer]->GetName());
}
else if (poSRS != NULL && poSRS2 != NULL &&
poSRS != poSRS2 && !poSRS->IsSame(poSRS2))
{
CPLDebug("VRT", "SRS of geometry field '%s' layer %s not consistent with UnionLayer SRS. "
"Trying auto warping",
GetLayerDefn()->GetGeomFieldDefn(i)->GetNameRef(),
papoSrcLayers[iLayer]->GetName());
OGRCoordinateTransformation* poCT =
OGRCreateCoordinateTransformation( poSRS2, poSRS );
OGRCoordinateTransformation* poReversedCT = (poCT != NULL) ?
OGRCreateCoordinateTransformation( poSRS, poSRS2 ) : NULL;
if( poReversedCT != NULL )
papoSrcLayers[iLayer] = new OGRWarpedLayer(
papoSrcLayers[iLayer], iSrcGeomField, TRUE, poCT, poReversedCT);
else
{
CPLError(CE_Warning, CPLE_AppDefined,
"AutoWarpLayerIfNecessary failed to create "
"poCT or poReversedCT.");
if ( poCT != NULL )
delete poCT;
}
}
}
if( poSRS != NULL )
poSRS->Release();
}
}
}
示例5: GetLayerDefn
OGRFeature *OGRGFTLayer::GetNextFeature()
{
GetLayerDefn();
while( true )
{
if (nNextInSeq < nOffset ||
nNextInSeq >= nOffset + static_cast<int>(aosRows.size()))
{
if (bEOF)
return nullptr;
nOffset += static_cast<int>(aosRows.size());
if (!FetchNextRows())
return nullptr;
}
OGRFeature *poFeature = GetNextRawFeature();
if (poFeature == nullptr)
return nullptr;
if((m_poFilterGeom == nullptr
|| FilterGeometry( poFeature->GetGeometryRef() ) )
&& (m_poAttrQuery == nullptr
|| m_poAttrQuery->Evaluate( poFeature )) )
{
return poFeature;
}
else
delete poFeature;
}
}
示例6: strcmp
OGRErr OGRUnionLayer::SetAttributeFilter( const char * pszAttributeFilterIn )
{
if( pszAttributeFilterIn == NULL && pszAttributeFilter == NULL)
return OGRERR_NONE;
if( pszAttributeFilterIn != NULL && pszAttributeFilter != NULL &&
strcmp(pszAttributeFilterIn, pszAttributeFilter) == 0)
return OGRERR_NONE;
if( poFeatureDefn == NULL ) GetLayerDefn();
bAttrFilterPassThroughValue = -1;
OGRErr eErr = OGRLayer::SetAttributeFilter(pszAttributeFilterIn);
if( eErr != OGRERR_NONE )
return eErr;
CPLFree(pszAttributeFilter);
pszAttributeFilter = pszAttributeFilterIn ?
CPLStrdup(pszAttributeFilterIn) : NULL;
if( iCurLayer >= 0 && iCurLayer < nSrcLayers)
ApplyAttributeFilterToSrcLayer(iCurLayer);
return OGRERR_NONE;
}
示例7: FlushDeferedInsert
OGRFeature* OGRCARTODBTableLayer::GetFeature( GIntBig nFeatureId )
{
if( bDeferedCreation && RunDeferedCreationIfNecessary() != OGRERR_NONE )
return NULL;
FlushDeferedInsert();
GetLayerDefn();
if( osFIDColName.size() == 0 )
return OGRCARTODBLayer::GetFeature(nFeatureId);
CPLString osSQL = osSELECTWithoutWHERE;
osSQL += " WHERE ";
osSQL += OGRCARTODBEscapeIdentifier(osFIDColName).c_str();
osSQL += " = ";
osSQL += CPLSPrintf(CPL_FRMT_GIB, nFeatureId);
json_object* poObj = poDS->RunSQL(osSQL);
json_object* poRowObj = OGRCARTODBGetSingleRow(poObj);
if( poRowObj == NULL )
{
if( poObj != NULL )
json_object_put(poObj);
return OGRCARTODBLayer::GetFeature(nFeatureId);
}
OGRFeature* poFeature = BuildFeature(poRowObj);
json_object_put(poObj);
return poFeature;
}
示例8: GetLayerDefn
OGRFeature *OGRGFTLayer::GetNextFeature()
{
OGRFeature *poFeature;
GetLayerDefn();
while(TRUE)
{
if (nNextInSeq < nOffset ||
nNextInSeq >= nOffset + (int)aosRows.size())
{
if (bEOF)
return NULL;
nOffset += aosRows.size();
if (!FetchNextRows())
return NULL;
}
poFeature = GetNextRawFeature();
if (poFeature == NULL)
return NULL;
if((m_poFilterGeom == NULL
|| FilterGeometry( poFeature->GetGeometryRef() ) )
&& (m_poAttrQuery == NULL
|| m_poAttrQuery->Evaluate( poFeature )) )
{
return poFeature;
}
else
delete poFeature;
}
}
示例9: CPLAssert
void OGRGeoJSONLayer::AddFeature( OGRFeature* poFeature )
{
CPLAssert( NULL != poFeature );
// NOTE - mloskot:
// Features may not be sorted according to FID values.
// TODO: Should we check if feature already exists?
// TODO: Think about sync operation, upload, etc.
OGRFeature* poNewFeature = NULL;
poNewFeature = poFeature->Clone();
if( -1 == poNewFeature->GetFID() )
{
int nFID = static_cast<int>(seqFeatures_.size());
poNewFeature->SetFID( nFID );
// TODO - mlokot: We need to redesign creation of FID column
int nField = poNewFeature->GetFieldIndex( DefaultFIDColumn );
if( -1 != nField && GetLayerDefn()->GetFieldDefn(nField)->GetType() == OFTInteger )
{
poNewFeature->SetField( nField, nFID );
}
}
seqFeatures_.push_back( poNewFeature );
}
示例10: GetExtent
OGRErr OGRLayer::GetExtent(OGREnvelope *psExtent, int bForce )
{
OGRFeature *poFeature;
OGREnvelope oEnv;
GBool bExtentSet = FALSE;
/* -------------------------------------------------------------------- */
/* If this layer has a none geometry type, then we can */
/* reasonably assume there are not extents available. */
/* -------------------------------------------------------------------- */
if( GetLayerDefn()->GetGeomType() == wkbNone )
{
psExtent->MinX = 0.0;
psExtent->MaxX = 0.0;
psExtent->MinY = 0.0;
psExtent->MaxY = 0.0;
return OGRERR_FAILURE;
}
/* -------------------------------------------------------------------- */
/* If not forced, we should avoid having to scan all the */
/* features and just return a failure. */
/* -------------------------------------------------------------------- */
if( !bForce )
return OGRERR_FAILURE;
/* -------------------------------------------------------------------- */
/* OK, we hate to do this, but go ahead and read through all */
/* the features to collect geometries and build extents. */
/* -------------------------------------------------------------------- */
ResetReading();
while( (poFeature = GetNextFeature()) != NULL )
{
OGRGeometry *poGeom = poFeature->GetGeometryRef();
if (poGeom && !bExtentSet)
{
poGeom->getEnvelope(psExtent);
bExtentSet = TRUE;
}
else if (poGeom)
{
poGeom->getEnvelope(&oEnv);
if (oEnv.MinX < psExtent->MinX)
psExtent->MinX = oEnv.MinX;
if (oEnv.MinY < psExtent->MinY)
psExtent->MinY = oEnv.MinY;
if (oEnv.MaxX > psExtent->MaxX)
psExtent->MaxX = oEnv.MaxX;
if (oEnv.MaxY > psExtent->MaxY)
psExtent->MaxY = oEnv.MaxY;
}
delete poFeature;
}
ResetReading();
return (bExtentSet ? OGRERR_NONE : OGRERR_FAILURE);
}
示例11: GetLayerDefn
GIntBig OGRSVGLayer::GetFeatureCount( int bForce )
{
if (m_poAttrQuery != NULL || m_poFilterGeom != NULL)
return OGRLayer::GetFeatureCount(bForce);
GetLayerDefn();
return nTotalFeatures;
}
示例12: CPLDebug
void OGRILI1Layer::JoinSurfaceLayer()
{
if (poSurfacePolyLayer == 0) return;
CPLDebug( "OGR_ILI", "Joining surface layer %s with geometries", GetLayerDefn()->GetName());
GetLayerDefn()->SetGeomType(poSurfacePolyLayer->GetLayerDefn()->GetGeomType());
ResetReading();
while (OGRFeature *feature = GetNextFeatureRef())
{
OGRFeature *polyfeature = poSurfacePolyLayer->GetFeatureRef(feature->GetFID());
if (polyfeature) {
feature->SetGeometry(polyfeature->GetGeometryRef());
}
}
ResetReading();
poSurfacePolyLayer = 0;
}
示例13: GetLayerDefn
OGRErr OGRGFTTableLayer::DeleteFeature( long nFID )
{
GetLayerDefn();
if (!poDS->IsReadWrite())
{
CPLError(CE_Failure, CPLE_AppDefined,
"Operation not available in read-only mode");
return OGRERR_FAILURE;
}
if (osTableId.size() == 0)
{
CPLError(CE_Failure, CPLE_NotSupported,
"Cannot delete feature in non-created table");
return OGRERR_FAILURE;
}
if (poDS->GetAuth().size() == 0)
{
CPLError(CE_Failure, CPLE_AppDefined,
"Operation not available in unauthenticated mode");
return OGRERR_FAILURE;
}
CPLString osCommand;
osCommand += "DELETE FROM ";
osCommand += osTableId;
osCommand += " WHERE ROWID = '";
osCommand += CPLSPrintf("%ld", nFID);
osCommand += "'";
//CPLDebug("GFT", "%s", osCommand.c_str());
CPLHTTPResult * psResult = poDS->RunSQL(osCommand);
if (psResult == NULL)
{
CPLError(CE_Failure, CPLE_AppDefined, "Feature deletion failed");
return OGRERR_FAILURE;
}
char* pszLine = (char*) psResult->pabyData;
if (pszLine == NULL ||
strncmp(pszLine, "OK", 2) != 0 ||
psResult->pszErrBuf != NULL)
{
CPLError(CE_Failure, CPLE_AppDefined, "Feature deletion failed");
CPLHTTPDestroyResult(psResult);
return OGRERR_FAILURE;
}
CPLHTTPDestroyResult(psResult);
return OGRERR_NONE;
}
示例14: GetLayerDefn
const char *OGRDB2Layer::GetFIDColumn()
{
GetLayerDefn();
if( pszFIDColumn != nullptr )
return pszFIDColumn;
else
return "";
}
示例15: GetLayerDefn
int OGROCIWritableLayer::FindFieldIndex( const char *pszFieldName, int bExactMatch )
{
int iField = GetLayerDefn()->GetFieldIndex( pszFieldName );
if( !bExactMatch && iField < 0 )
{
// try laundered version
OGROCISession *poSession = poDS->GetSession();
char *pszSafeName = CPLStrdup( pszFieldName );
poSession->CleanName( pszSafeName );
iField = GetLayerDefn()->GetFieldIndex( pszSafeName );
CPLFree( pszSafeName );
}
return iField;
}