本文整理汇总了C++中OGRFeature::IsFieldSet方法的典型用法代码示例。如果您正苦于以下问题:C++ OGRFeature::IsFieldSet方法的具体用法?C++ OGRFeature::IsFieldSet怎么用?C++ OGRFeature::IsFieldSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OGRFeature
的用法示例。
在下文中一共展示了OGRFeature::IsFieldSet方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getLaneNumber
int
NIImporter_ArcView::getLaneNo(OGRFeature& poFeature, const std::string& edgeid,
SUMOReal speed) {
if (myOptions.isSet("shapefile.type-id")) {
return (int) myTypeCont.getNumLanes(poFeature.GetFieldAsString((char*)(myOptions.getString("shapefile.type-id").c_str())));
}
// try to get definitions as to be found in SUMO-XML-definitions
// idea by John Michael Calandrino
int index = poFeature.GetDefnRef()->GetFieldIndex("nolanes");
if (index >= 0 && poFeature.IsFieldSet(index)) {
return (int) poFeature.GetFieldAsInteger(index);
}
index = poFeature.GetDefnRef()->GetFieldIndex("NOLANES");
if (index >= 0 && poFeature.IsFieldSet(index)) {
return (int) poFeature.GetFieldAsInteger(index);
}
index = poFeature.GetDefnRef()->GetFieldIndex("rnol");
if (index >= 0 && poFeature.IsFieldSet(index)) {
return (int) poFeature.GetFieldAsInteger(index);
}
index = poFeature.GetDefnRef()->GetFieldIndex("LANE_CAT");
if (index >= 0 && poFeature.IsFieldSet(index)) {
std::string def = poFeature.GetFieldAsString(index);
return NINavTeqHelper::getLaneNumber(edgeid, def, speed);
}
return 0;
}
示例2: OGRFeatureFetcher
static swq_expr_node* OGRFeatureFetcher(swq_expr_node *op, void *pFeatureIn)
{
OGRFeature *poFeature = (OGRFeature*) pFeatureIn;
swq_expr_node *poRetNode = NULL;
switch (op->field_type)
{
case SWQ_INTEGER:
case SWQ_BOOLEAN:
poRetNode = new swq_expr_node(
poFeature->GetFieldAsInteger(op->field_index));
break;
case SWQ_FLOAT:
poRetNode = new swq_expr_node(
poFeature->GetFieldAsDouble(op->field_index));
break;
default:
poRetNode = new swq_expr_node(
poFeature->GetFieldAsString(op->field_index));
break;
}
poRetNode->is_null = !(poFeature->IsFieldSet(op->field_index));
return poRetNode;
}
示例3: OGR2SQLITE_ogr_geocode_set_result
static
void OGR2SQLITE_ogr_geocode_set_result(sqlite3_context* pContext,
OGRLayerH hLayer,
const char* pszField)
{
if( hLayer == NULL )
sqlite3_result_null (pContext);
else
{
OGRLayer* poLayer = (OGRLayer*)hLayer;
OGRFeatureDefn* poFDefn = poLayer->GetLayerDefn();
OGRFeature* poFeature = poLayer->GetNextFeature();
int nIdx = -1;
if( poFeature == NULL )
sqlite3_result_null (pContext);
else if( strcmp(pszField, "geometry") == 0 &&
poFeature->GetGeometryRef() != NULL )
{
GByte* pabyGeomBLOB = NULL;
int nGeomBLOBLen = 0;
if( OGRSQLiteLayer::ExportSpatiaLiteGeometry(
poFeature->GetGeometryRef(), 4326, wkbNDR, FALSE, FALSE, FALSE,
&pabyGeomBLOB,
&nGeomBLOBLen ) != CE_None )
{
sqlite3_result_null (pContext);
}
else
{
sqlite3_result_blob (pContext, pabyGeomBLOB, nGeomBLOBLen, CPLFree);
}
}
else if( (nIdx = poFDefn->GetFieldIndex(pszField)) >= 0 &&
poFeature->IsFieldSet(nIdx) )
{
OGRFieldType eType = poFDefn->GetFieldDefn(nIdx)->GetType();
if( eType == OFTInteger )
sqlite3_result_int(pContext,
poFeature->GetFieldAsInteger(nIdx));
else if( eType == OFTInteger64 )
sqlite3_result_int64(pContext,
poFeature->GetFieldAsInteger64(nIdx));
else if( eType == OFTReal )
sqlite3_result_double(pContext,
poFeature->GetFieldAsDouble(nIdx));
else
sqlite3_result_text(pContext,
poFeature->GetFieldAsString(nIdx),
-1, SQLITE_TRANSIENT);
}
else
sqlite3_result_null (pContext);
delete poFeature;
OGRGeocodeFreeResult(hLayer);
}
}
示例4:
int
NIImporter_ArcView::getPriority(OGRFeature& poFeature, const std::string& /*edgeid*/) {
if (myOptions.isSet("shapefile.type-id")) {
return myTypeCont.getPriority(poFeature.GetFieldAsString((char*)(myOptions.getString("shapefile.type-id").c_str())));
}
// try to get definitions as to be found in SUMO-XML-definitions
// idea by John Michael Calandrino
int index = poFeature.GetDefnRef()->GetFieldIndex("priority");
if (index >= 0 && poFeature.IsFieldSet(index)) {
return poFeature.GetFieldAsInteger(index);
}
index = poFeature.GetDefnRef()->GetFieldIndex("PRIORITY");
if (index >= 0 && poFeature.IsFieldSet(index)) {
return poFeature.GetFieldAsInteger(index);
}
// try to determine priority from NavTechs FUNC_CLASS attribute
index = poFeature.GetDefnRef()->GetFieldIndex("FUNC_CLASS");
if (index >= 0 && poFeature.IsFieldSet(index)) {
return poFeature.GetFieldAsInteger(index);
}
return 0;
}
示例5: getSpeed
SUMOReal
NIImporter_ArcView::getSpeed(OGRFeature& poFeature, const std::string& edgeid) {
if (myOptions.isSet("shapefile.type-id")) {
return myTypeCont.getSpeed(poFeature.GetFieldAsString((char*)(myOptions.getString("shapefile.type-id").c_str())));
}
// try to get definitions as to be found in SUMO-XML-definitions
// idea by John Michael Calandrino
int index = poFeature.GetDefnRef()->GetFieldIndex("speed");
if (index >= 0 && poFeature.IsFieldSet(index)) {
return (SUMOReal) poFeature.GetFieldAsDouble(index);
}
index = poFeature.GetDefnRef()->GetFieldIndex("SPEED");
if (index >= 0 && poFeature.IsFieldSet(index)) {
return (SUMOReal) poFeature.GetFieldAsDouble(index);
}
// try to get the NavTech-information
index = poFeature.GetDefnRef()->GetFieldIndex("SPEED_CAT");
if (index >= 0 && poFeature.IsFieldSet(index)) {
std::string def = poFeature.GetFieldAsString(index);
return NINavTeqHelper::getSpeed(edgeid, def);
}
return -1;
}
示例6: switch
static swq_expr_node *OGRFeatureFetcher( swq_expr_node *op, void *pFeatureIn )
{
OGRFeature *poFeature = (OGRFeature *) pFeatureIn;
swq_expr_node *poRetNode = NULL;
if( op->field_type == SWQ_GEOMETRY )
{
int iField = op->field_index - (poFeature->GetFieldCount() + SPECIAL_FIELD_COUNT);
poRetNode = new swq_expr_node( poFeature->GetGeomFieldRef(iField) );
return poRetNode;
}
switch( op->field_type )
{
case SWQ_INTEGER:
case SWQ_BOOLEAN:
poRetNode = new swq_expr_node(
poFeature->GetFieldAsInteger(op->field_index) );
break;
case SWQ_INTEGER64:
poRetNode = new swq_expr_node(
poFeature->GetFieldAsInteger64(op->field_index) );
break;
case SWQ_FLOAT:
poRetNode = new swq_expr_node(
poFeature->GetFieldAsDouble(op->field_index) );
break;
default:
poRetNode = new swq_expr_node(
poFeature->GetFieldAsString(op->field_index) );
break;
}
poRetNode->is_null = !(poFeature->IsFieldSet(op->field_index));
return poRetNode;
}
示例7: GetNextRawFeature
OGRFeature* OGRPLScenesLayer::GetNextRawFeature()
{
if( bEOF ||
(!bFilterMustBeClientSideEvaluated && nFeatureCount >= 0 && nNextFID > nFeatureCount) )
return NULL;
if( poGeoJSONLayer == NULL )
{
if( !GetNextPage() )
return NULL;
}
#ifdef notdef
if( CSLTestBoolean(CPLGetConfigOption("OGR_LIMIT_TOO_MANY_FEATURES", "FALSE")) &&
nFeatureCount > nPageSize )
{
bEOF = TRUE;
OGRFeature* poFeature = new OGRFeature(poFeatureDefn);
OGRGeometry* poGeom;
const char* pszWKT = "MULTIPOLYGON(((-180 90,180 90,180 -90,-180 -90,-180 90)))";
OGRGeometryFactory::createFromWkt((char**)&pszWKT, poSRS, &poGeom);
poFeature->SetGeometryDirectly(poGeom);
return poFeature;
}
#endif
OGRFeature* poGeoJSONFeature = poGeoJSONLayer->GetNextFeature();
if( poGeoJSONFeature == NULL )
{
osRequestURL = osNextURL;
bStillInFirstPage = FALSE;
if( !GetNextPage() )
return NULL;
poGeoJSONFeature = poGeoJSONLayer->GetNextFeature();
if( poGeoJSONFeature == NULL )
{
bEOF = TRUE;
return NULL;
}
}
OGRFeature* poFeature = new OGRFeature(poFeatureDefn);
poFeature->SetFID(nNextFID++);
OGRGeometry* poGeom = poGeoJSONFeature->StealGeometry();
if( poGeom != NULL )
{
if( poGeom->getGeometryType() == wkbPolygon )
{
OGRMultiPolygon* poMP = new OGRMultiPolygon();
poMP->addGeometryDirectly(poGeom);
poGeom = poMP;
}
poGeom->assignSpatialReference(poSRS);
poFeature->SetGeometryDirectly(poGeom);
}
for(int i=0;i<poFeatureDefn->GetFieldCount();i++)
{
OGRFieldDefn* poFieldDefn = poFeatureDefn->GetFieldDefn(i);
OGRFieldType eType = poFieldDefn->GetType();
int iSrcField = poGeoJSONFeature->GetFieldIndex(poFieldDefn->GetNameRef());
if( iSrcField >= 0 && poGeoJSONFeature->IsFieldSet(iSrcField) )
{
if( eType == OFTInteger )
poFeature->SetField(i,
poGeoJSONFeature->GetFieldAsInteger(iSrcField));
else if( eType == OFTReal )
poFeature->SetField(i,
poGeoJSONFeature->GetFieldAsDouble(iSrcField));
else
poFeature->SetField(i,
poGeoJSONFeature->GetFieldAsString(iSrcField));
}
}
delete poGeoJSONFeature;
return poFeature;
}
示例8: pos
//.........这里部分代码省略.........
WRITE_ERROR("The description seems to be invalid. Please recheck usage of types.");
return;
}
}
if (mySpeedInKMH) {
speed = speed / (SUMOReal) 3.6;
}
// read in the geometry
OGRGeometry* poGeometry = poFeature->GetGeometryRef();
OGRwkbGeometryType gtype = poGeometry->getGeometryType();
assert(gtype == wkbLineString);
UNUSED_PARAMETER(gtype); // ony used for assertion
OGRLineString* cgeom = (OGRLineString*) poGeometry;
if (poCT != 0) {
// try transform to wgs84
cgeom->transform(poCT);
}
PositionVector shape;
for (int j = 0; j < cgeom->getNumPoints(); j++) {
Position pos((SUMOReal) cgeom->getX(j), (SUMOReal) cgeom->getY(j));
if (!NBNetBuilder::transformCoordinate(pos)) {
WRITE_WARNING("Unable to project coordinates for edge '" + id + "'.");
}
shape.push_back_noDoublePos(pos);
}
// build from-node
NBNode* from = myNodeCont.retrieve(from_node);
if (from == 0) {
Position from_pos = shape[0];
from = myNodeCont.retrieve(from_pos);
if (from == 0) {
from = new NBNode(from_node, from_pos);
if (!myNodeCont.insert(from)) {
WRITE_ERROR("Node '" + from_node + "' could not be added");
delete from;
continue;
}
}
}
// build to-node
NBNode* to = myNodeCont.retrieve(to_node);
if (to == 0) {
Position to_pos = shape[-1];
to = myNodeCont.retrieve(to_pos);
if (to == 0) {
to = new NBNode(to_node, to_pos);
if (!myNodeCont.insert(to)) {
WRITE_ERROR("Node '" + to_node + "' could not be added");
delete to;
continue;
}
}
}
if (from == to) {
WRITE_WARNING("Edge '" + id + "' connects identical nodes, skipping.");
continue;
}
// retrieve the information whether the street is bi-directional
std::string dir;
int index = poFeature->GetDefnRef()->GetFieldIndex("DIR_TRAVEL");
if (index >= 0 && poFeature->IsFieldSet(index)) {
dir = poFeature->GetFieldAsString(index);
}
// add positive direction if wanted
if (dir == "B" || dir == "F" || dir == "" || myOptions.getBool("shapefile.all-bidirectional")) {
if (myEdgeCont.retrieve(id) == 0) {
LaneSpreadFunction spread = dir == "B" || dir == "FALSE" ? LANESPREAD_RIGHT : LANESPREAD_CENTER;
NBEdge* edge = new NBEdge(id, from, to, type, speed, nolanes, priority, width, NBEdge::UNSPECIFIED_OFFSET, shape, name, id, spread);
myEdgeCont.insert(edge);
checkSpread(edge);
}
}
// add negative direction if wanted
if (dir == "B" || dir == "T" || myOptions.getBool("shapefile.all-bidirectional")) {
if (myEdgeCont.retrieve("-" + id) == 0) {
LaneSpreadFunction spread = dir == "B" || dir == "FALSE" ? LANESPREAD_RIGHT : LANESPREAD_CENTER;
NBEdge* edge = new NBEdge("-" + id, to, from, type, speed, nolanes, priority, width, NBEdge::UNSPECIFIED_OFFSET, shape.reverse(), name, id, spread);
myEdgeCont.insert(edge);
checkSpread(edge);
}
}
//
OGRFeature::DestroyFeature(poFeature);
}
#if GDAL_VERSION_MAJOR < 2
OGRDataSource::DestroyDataSource(poDS);
#else
GDALClose(poDS);
#endif
PROGRESS_DONE_MESSAGE();
#else
WRITE_ERROR("SUMO was compiled without GDAL support.");
#endif
}
示例9: if
OGRFeatureDefn * OGRCARTODBTableLayer::GetLayerDefnInternal(CPL_UNUSED json_object* poObjIn)
{
if( poFeatureDefn != NULL )
return poFeatureDefn;
CPLString osCommand;
if( poDS->IsAuthenticatedConnection() )
{
// Get everything !
osCommand.Printf(
"SELECT a.attname, t.typname, a.attlen, "
"format_type(a.atttypid,a.atttypmod), "
"a.attnum, "
"a.attnotnull, "
"i.indisprimary, "
"pg_get_expr(def.adbin, c.oid) AS defaultexpr, "
"postgis_typmod_dims(a.atttypmod) dim, "
"postgis_typmod_srid(a.atttypmod) srid, "
"postgis_typmod_type(a.atttypmod)::text geomtyp, "
"srtext "
"FROM pg_class c "
"JOIN pg_attribute a ON a.attnum > 0 AND "
"a.attrelid = c.oid AND c.relname = '%s' "
"JOIN pg_type t ON a.atttypid = t.oid "
"JOIN pg_namespace n ON c.relnamespace=n.oid AND n.nspname= '%s' "
"LEFT JOIN pg_index i ON c.oid = i.indrelid AND "
"i.indisprimary = 't' AND a.attnum = ANY(i.indkey) "
"LEFT JOIN pg_attrdef def ON def.adrelid = c.oid AND "
"def.adnum = a.attnum "
"LEFT JOIN spatial_ref_sys srs ON srs.srid = postgis_typmod_srid(a.atttypmod) "
"ORDER BY a.attnum",
OGRCARTODBEscapeLiteral(osName).c_str(),
OGRCARTODBEscapeLiteral(poDS->GetCurrentSchema()).c_str());
}
else if( poDS->HasOGRMetadataFunction() != FALSE )
{
osCommand.Printf( "SELECT * FROM ogr_table_metadata('%s', '%s')",
OGRCARTODBEscapeLiteral(poDS->GetCurrentSchema()).c_str(),
OGRCARTODBEscapeLiteral(osName).c_str() );
}
if( osCommand.size() )
{
if( !poDS->IsAuthenticatedConnection() && poDS->HasOGRMetadataFunction() < 0 )
CPLPushErrorHandler(CPLQuietErrorHandler);
OGRLayer* poLyr = poDS->ExecuteSQLInternal(osCommand);
if( !poDS->IsAuthenticatedConnection() && poDS->HasOGRMetadataFunction() < 0 )
{
CPLPopErrorHandler();
if( poLyr == NULL )
{
CPLDebug("CARTODB", "ogr_table_metadata(text, text) not available");
CPLErrorReset();
}
else if( poLyr->GetLayerDefn()->GetFieldCount() != 12 )
{
CPLDebug("CARTODB", "ogr_table_metadata(text, text) has unexpected column count");
poDS->ReleaseResultSet(poLyr);
poLyr = NULL;
}
poDS->SetOGRMetadataFunction(poLyr != NULL);
}
if( poLyr )
{
OGRFeature* poFeat;
while( (poFeat = poLyr->GetNextFeature()) != NULL )
{
if( poFeatureDefn == NULL )
{
// We could do that outside of the while() loop, but
// by doing that here, we are somewhat robust to
// ogr_table_metadata() returning suddenly an empty result set
// for example if CDB_UserTables() no longer works
poFeatureDefn = new OGRFeatureDefn(osName);
poFeatureDefn->Reference();
poFeatureDefn->SetGeomType(wkbNone);
}
const char* pszAttname = poFeat->GetFieldAsString("attname");
const char* pszType = poFeat->GetFieldAsString("typname");
int nWidth = poFeat->GetFieldAsInteger("attlen");
const char* pszFormatType = poFeat->GetFieldAsString("format_type");
int bNotNull = poFeat->GetFieldAsInteger("attnotnull");
int bIsPrimary = poFeat->GetFieldAsInteger("indisprimary");
int iDefaultExpr = poLyr->GetLayerDefn()->GetFieldIndex("defaultexpr");
const char* pszDefault = (iDefaultExpr >= 0 && poFeat->IsFieldSet(iDefaultExpr)) ?
poFeat->GetFieldAsString(iDefaultExpr) : NULL;
if( bIsPrimary &&
(EQUAL(pszType, "int2") ||
EQUAL(pszType, "int4") ||
EQUAL(pszType, "int8") ||
EQUAL(pszType, "serial") ||
EQUAL(pszType, "bigserial")) )
{
osFIDColName = pszAttname;
}
else if( strcmp(pszAttname, "created_at") == 0 ||
strcmp(pszAttname, "updated_at") == 0 ||
strcmp(pszAttname, "the_geom_webmercator") == 0)
//.........这里部分代码省略.........
示例10: ogrReadListColumn
SEXP ogrReadListColumn(OGRLayer *poLayer, SEXP FIDs, int iField, int k, int int64) {
// read feature data and return something according to the type
OGRFeatureDefn *poDefn;
OGRFieldDefn *poField;
OGRFeature *poFeature;
int iRow,nRows,nlist;
SEXP ans = R_NilValue;
nRows=length(FIDs);
// get field data from layer
installErrorHandler();
poDefn = poLayer->GetLayerDefn();
poField = poDefn->GetFieldDefn(iField);
uninstallErrorHandlerAndTriggerError();
if(poField == NULL) {
error("Error getting field %d ",iField);
}
// allocate an object for the result depending on the feature type:
installErrorHandler();
switch(poField->GetType()) {
case OFTIntegerList:
PROTECT(ans=allocVector(INTSXP,nRows));
break;
#ifdef GDALV2
case OFTInteger64List:
if (int64 == 3) {
PROTECT(ans=allocVector(STRSXP,nRows));
} else {
PROTECT(ans=allocVector(INTSXP,nRows));
}
break;
#endif
case OFTRealList:
PROTECT(ans=allocVector(REALSXP,nRows));
break;
case OFTStringList:
PROTECT(ans=allocVector(STRSXP,nRows));
break;
default:
const char *desc = poField->GetFieldTypeName(poField->GetType());
uninstallErrorHandlerAndTriggerError();
error("unsupported field type: %s", desc);
break;
}
uninstallErrorHandlerAndTriggerError();
// now go over each row and retrieve data. iRow is an index in a
// vector of FIDs
installErrorHandler();
poLayer->ResetReading();
OGRField* psField;
iRow = 0;
while((poFeature = poLayer->GetNextFeature()) != NULL) {
if (poFeature->IsFieldSet(iField)) {
// now get the value using the right type:
psField = poFeature->GetRawFieldRef(iField);
switch(poField->GetType()) {
case OFTIntegerList:
nlist = psField->IntegerList.nCount;
if (k < nlist)
INTEGER(ans)[iRow] = psField->IntegerList.paList[k];
else INTEGER(ans)[iRow]=NA_INTEGER;
break;
#ifdef GDALV2
case OFTInteger64List:
nlist = psField->Integer64List.nCount;
if (k < nlist) {
if (int64 == 3) {
// FIXME clang++
// GIntBig nVal64 = psField->Integer64List.paList[k];
char szItem[32];
snprintf(szItem, sizeof(szItem), CPL_FRMT_GIB,
psField->Integer64List.paList[k]);
SET_STRING_ELT(ans, iRow, mkChar(szItem));
} else {
GIntBig nVal64 = psField->Integer64List.paList[k];
int nVal = (nVal64 > INT_MAX) ? INT_MAX :
(nVal64 < INT_MIN) ? INT_MIN : (int) nVal64;
if (((GIntBig)nVal != nVal64) && int64 == 2) {
warning("Integer64 value clamped: feature %d", iRow);
}
INTEGER(ans)[iRow]=nVal;
}
} else {
if (int64 == 3) {
SET_STRING_ELT(ans, iRow, NA_STRING);
} else {
INTEGER(ans)[iRow]=NA_INTEGER;
}
}
break;
#endif
case OFTRealList:
nlist = psField->RealList.nCount;
if (k < nlist)
REAL(ans)[iRow] = psField->RealList.paList[k];
//.........这里部分代码省略.........
示例11: ogrReadColumn
SEXP ogrReadColumn(OGRLayer *poLayer, SEXP FIDs, int iField, int int64, int ENC_DEBUG) {
// read feature data and return something according to the type
OGRFeatureDefn *poDefn;
OGRFieldDefn *poField;
OGRFeature *poFeature;
int iRow,nRows;
SEXP ans = R_NilValue;
nRows=length(FIDs);
// get field data from layer
installErrorHandler();
poDefn = poLayer->GetLayerDefn();
poField = poDefn->GetFieldDefn(iField);
uninstallErrorHandlerAndTriggerError();
if(poField == NULL) {
error("Error getting field %d ",iField);
}
// allocate an object for the result depending on the feature type:
installErrorHandler();
switch(poField->GetType()) {
case OFTInteger:
PROTECT(ans=allocVector(INTSXP,nRows));
break;
#ifdef GDALV2
case OFTInteger64:
if (int64 ==3) {
PROTECT(ans=allocVector(STRSXP,nRows));
} else {
PROTECT(ans=allocVector(INTSXP,nRows));
}
break;
#endif
case OFTReal:
PROTECT(ans=allocVector(REALSXP,nRows));
break;
case OFTString:
PROTECT(ans=allocVector(STRSXP,nRows));
break;
case OFTDate:
PROTECT(ans=allocVector(STRSXP,nRows));
break;
case OFTDateTime:
PROTECT(ans=allocVector(STRSXP,nRows));
break;
case OFTTime:
PROTECT(ans=allocVector(STRSXP,nRows));
break;
default:
const char *desc = poField->GetFieldTypeName(poField->GetType());
uninstallErrorHandlerAndTriggerError();
error("unsupported field type: %s", desc);
break;
}
uninstallErrorHandlerAndTriggerError();
// now go over each row and retrieve data. iRow is an index in a
// vector of FIDs
/*#ifndef EJP
installErrorHandler();
for(iRow=0;iRow<nRows;iRow++){
poFeature=poLayer->GetFeature(INTEGER(FIDs)[iRow]);
if(poFeature == NULL){
error("Error getting feature FID: %d",(INTEGER(FIDs)[iRow]));
}
}
uninstallErrorHandlerAndTriggerError();
#else*/
// EJP, changed into:
installErrorHandler();
poLayer->ResetReading();
iRow = 0;
while((poFeature = poLayer->GetNextFeature()) != NULL) {
//#endif
// now get the value using the right type:
switch(poField->GetType()) {
case OFTInteger:
if (poFeature->IsFieldSet(iField))
INTEGER(ans)[iRow]=poFeature->GetFieldAsInteger(iField);
else INTEGER(ans)[iRow]=NA_INTEGER;
break;
#ifdef GDALV2
case OFTInteger64:
if (poFeature->IsFieldSet(iField)) {
if (int64 == 3) {
SET_STRING_ELT(ans, iRow,
mkChar(poFeature->GetFieldAsString(iField)));
} else {
GIntBig nVal64 = poFeature->GetFieldAsInteger64(iField);
int nVal = (nVal64 > INT_MAX) ? INT_MAX :
(nVal64 < INT_MIN) ? INT_MIN : (int) nVal64;
INTEGER(ans)[iRow]=nVal;
if (((GIntBig)nVal != nVal64) && int64 == 2) {
warning("Integer64 value clamped: feature %d", iRow);
}
}
} else {
if (int64 == 3) {
SET_STRING_ELT(ans, iRow, NA_STRING);
} else {
INTEGER(ans)[iRow]=NA_INTEGER;
//.........这里部分代码省略.........
示例12: OpenRasterScene
//.........这里部分代码省略.........
{
json_object* poProducts = json_object_object_get(poData, "products");
if( poProducts != NULL && json_object_get_type(poProducts) == json_type_object )
{
json_object* poProduct = json_object_object_get(poProducts, pszProductType);
if( poProduct != NULL && json_object_get_type(poProduct) == json_type_object )
{
json_object* poFull = json_object_object_get(poProduct, "full");
if( poFull && json_object_get_type(poFull) == json_type_string )
pszLink = json_object_get_string(poFull);
}
}
}
}
osRasterURL = pszLink ? pszLink : "";
json_object_put(poObj);
if( osRasterURL.size() == 0 )
{
CPLError(CE_Failure, CPLE_AppDefined, "Cannot find link to scene %s",
osScene.c_str());
return NULL;
}
if( strncmp(osRasterURL, "http://", strlen("http://")) == 0 )
{
osRasterURL = "http://" + osAPIKey + ":@" + osRasterURL.substr(strlen("http://"));
}
else if( strncmp(osRasterURL, "https://", strlen("https://")) == 0 )
{
osRasterURL = "https://" + osAPIKey + ":@" + osRasterURL.substr(strlen("https://"));
}
CPLString osOldHead(CPLGetConfigOption("CPL_VSIL_CURL_USE_HEAD", ""));
CPLString osOldExt(CPLGetConfigOption("CPL_VSIL_CURL_ALLOWED_EXTENSIONS", ""));
int bUseVSICURL = CSLFetchBoolean(poOpenInfo->papszOpenOptions, "RANDOM_ACCESS", TRUE);
if( bUseVSICURL && !(strncmp(osBaseURL, "/vsimem/", strlen("/vsimem/")) == 0) )
{
CPLSetThreadLocalConfigOption("CPL_VSIL_CURL_USE_HEAD", "NO");
CPLSetThreadLocalConfigOption("CPL_VSIL_CURL_ALLOWED_EXTENSIONS", "{noext}");
VSIStatBufL sStat;
if( VSIStatL(("/vsicurl/" + osRasterURL).c_str(), &sStat) == 0 &&
sStat.st_size > 0 )
{
osRasterURL = "/vsicurl/" + osRasterURL;
}
else
{
CPLDebug("PLSCENES", "Cannot use random access for that file");
}
}
GDALDataset* poOutDS = (GDALDataset*) GDALOpen(osRasterURL, GA_ReadOnly);
if( poOutDS )
{
poOutDS->SetDescription(poOpenInfo->pszFilename);
poOutDS->GetFileList(); /* so as to probe all auxiliary files before reseting the allowed extensions */
if( !EQUAL(pszProductType, "thumb") )
{
OGRPLScenesLayer* poLayer = new OGRPLScenesLayer(this, "ortho",
(osBaseURL + "ortho/").c_str());
papoLayers = (OGRPLScenesLayer**) CPLRealloc(papoLayers,
sizeof(OGRPLScenesLayer*) * (nLayers + 1));
papoLayers[nLayers ++] = poLayer;
/* Attach scene matadata */
poLayer->SetAttributeFilter(CPLSPrintf("id = '%s'", osScene.c_str()));
OGRFeature* poFeat = poLayer->GetNextFeature();
if( poFeat )
{
for(int i=0;i<poFeat->GetFieldCount();i++)
{
if( poFeat->IsFieldSet(i) )
{
const char* pszKey = poFeat->GetFieldDefnRef(i)->GetNameRef();
const char* pszVal = poFeat->GetFieldAsString(i);
if( strstr(pszKey, "file_size") == NULL &&
strstr(pszVal, "https://") == NULL )
{
poOutDS->SetMetadataItem(pszKey, pszVal);
}
}
}
}
delete poFeat;
}
}
if( bUseVSICURL )
{
CPLSetThreadLocalConfigOption("CPL_VSIL_CURL_USE_HEAD",
osOldHead.size() ? osOldHead.c_str(): NULL);
CPLSetThreadLocalConfigOption("CPL_VSIL_CURL_ALLOWED_EXTENSIONS",
osOldExt.size() ? osOldExt.c_str(): NULL);
}
return poOutDS;
}