当前位置: 首页>>代码示例>>C++>>正文


C++ OGRFeatureDefn::AddFieldDefn方法代码示例

本文整理汇总了C++中OGRFeatureDefn::AddFieldDefn方法的典型用法代码示例。如果您正苦于以下问题:C++ OGRFeatureDefn::AddFieldDefn方法的具体用法?C++ OGRFeatureDefn::AddFieldDefn怎么用?C++ OGRFeatureDefn::AddFieldDefn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OGRFeatureDefn的用法示例。


在下文中一共展示了OGRFeatureDefn::AddFieldDefn方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: AddGeomTable

 // Add additional Geometry table for Interlis 1
 void AddGeomTable(CPLString layerName, const char* psFieldName, OGRwkbGeometryType eType, bool bRefTIDField = false)
 {
     OGRFeatureDefn* poGeomTableDefn = new OGRFeatureDefn(layerName);
     OGRFieldDefn fieldDef("_TID", OFTString);
     poGeomTableDefn->AddFieldDefn(&fieldDef);
     if (bRefTIDField)
     {
         OGRFieldDefn fieldDefRef("_RefTID", OFTString);
         poGeomTableDefn->AddFieldDefn(&fieldDefRef);
     }
     poGeomTableDefn->DeleteGeomFieldDefn(0);
     OGRGeomFieldDefn fieldDefGeom(psFieldName, eType);
     poGeomTableDefn->AddGeomFieldDefn(&fieldDefGeom);
     CPLDebug( "OGR_ILI", "Adding geometry table %s for field %s", poGeomTableDefn->GetName(), psFieldName);
     poGeomFieldInfos[psFieldName].geomTable = poGeomTableDefn;
 }
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:17,代码来源:imdreader.cpp

示例2:

OGRErr      OGRLayerWithTransaction::CreateField( OGRFieldDefn *poField,
        int bApproxOK )
{
    if( !m_poDecoratedLayer ) return OGRERR_FAILURE;
    int nFields = m_poDecoratedLayer->GetLayerDefn()->GetFieldCount();
    OGRErr eErr = m_poDecoratedLayer->CreateField(poField, bApproxOK);
    if( m_poFeatureDefn && eErr == OGRERR_NONE && m_poDecoratedLayer->GetLayerDefn()->GetFieldCount() == nFields + 1 )
    {
        m_poFeatureDefn->AddFieldDefn( m_poDecoratedLayer->GetLayerDefn()->GetFieldDefn(nFields) );
    }
    return eErr;
}
开发者ID:miccferr,项目名称:wmshp-electron,代码行数:12,代码来源:ogremulatedtransaction.cpp

示例3:

JNIEXPORT void JNICALL Java_es_gva_cit_jogr_OGRFeatureDefn_addFieldDefnNat
  (JNIEnv *env, jobject obj, jlong cPtr, jlong fdefn){
  
  	  OGRFeatureDefn 	*fd = (OGRFeatureDefn *) 0 ;
	  OGRFieldDefn		*fielddefn;
	  
	  fd = *(OGRFeatureDefn **)&cPtr;
	  fielddefn = *(OGRFieldDefn **)&fdefn;
	  if(fd!=NULL){
	  	fd->AddFieldDefn(fielddefn);
	  }
  }
开发者ID:,项目名称:,代码行数:12,代码来源:

示例4: ofieldDefn

int ILI2Reader::AddFeature(DOMElement *elem) {
  bool newLayer = true;
  OGRLayer *curLayer = NULL;
  char *pszName = tr_strdup(elem->getTagName());
  //CPLDebug( "OGR_ILI", "Reading layer: %s", pszName );

  // test if this layer exist
  curLayer = GetLayer(pszName);
  newLayer = (curLayer == NULL);

  // add a layer
  if (newLayer) {
    CPLDebug( "OGR_ILI", "Adding layer: %s", pszName );
    OGRFeatureDefn* poFeatureDefn = new OGRFeatureDefn(pszName);
    poFeatureDefn->SetGeomType( wkbUnknown );
    GeomFieldInfos oGeomFieldInfos;
    curLayer = new OGRILI2Layer(poFeatureDefn, oGeomFieldInfos, NULL);
    m_listLayer.push_back(curLayer);
  }

  // the feature and field definition
  OGRFeatureDefn *featureDef = curLayer->GetLayerDefn();
  if (newLayer) {
    // add TID field
    OGRFieldDefn ofieldDefn (ILI2_TID, OFTString);
    featureDef->AddFieldDefn(&ofieldDefn);

    setFieldDefn(featureDef, elem);
  }

  // add the features
  OGRFeature *feature = new OGRFeature(featureDef);

  // assign TID
  int fIndex = feature->GetFieldIndex(ILI2_TID);
  if (fIndex != -1) {
      XMLCh *pszIli2_tid = XMLString::transcode(ILI2_TID);
      char *fChVal = tr_strdup(elem->getAttribute(pszIli2_tid));
      feature->SetField(fIndex, fChVal);
      XMLString::release(&pszIli2_tid);
      CPLFree(fChVal);
  } else {
      CPLDebug( "OGR_ILI","'%s' not found", ILI2_TID);
  }

  SetFieldValues(feature, elem);
  CPL_IGNORE_RET_VAL(curLayer->SetFeature(feature));

  CPLFree(pszName);

  return 0;
}
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:52,代码来源:ili2reader.cpp

示例5: OGRFieldDefn

OGRFeatureDefn *AoIIntersection::buildFeatureDefinition ( int& acreIndex, int& areaIndex, OGRFieldDefn*& acreFldDefn, OGRFieldDefn*& areaPctFldDefn )
{
  OGRFeatureDefn *ogrFeatureDefn = NULL;

  // Create two Field Definitions
  acreFldDefn = new OGRFieldDefn( "Acres in AoI", OFTReal );
  areaPctFldDefn = new OGRFieldDefn( "Percent of AOI", OFTReal );
  if ( acreFldDefn && areaPctFldDefn )
  {
    // Create Feature Definition
    ogrFeatureDefn = new OGRFeatureDefn( "Intersection Features" );
    if ( ogrFeatureDefn )
    {
      // Add Field Definitions to Feature Definition
      ogrFeatureDefn->AddFieldDefn( acreFldDefn );
      ogrFeatureDefn->AddFieldDefn( areaPctFldDefn );
      // Get the field Indices from the Feature Def.
      acreIndex = ogrFeatureDefn->GetFieldIndex( "Acres in AoI" );
      areaIndex = ogrFeatureDefn->GetFieldIndex( "Percent of AOI" );
    }
  }
  return ogrFeatureDefn;
}
开发者ID:gideonmay,项目名称:minervagis,代码行数:23,代码来源:AoIIntersection.cpp

示例6: InitFieldDefinitions

    void InitFieldDefinitions()
    {
        // Delete default geometry field
        poTableDefn->DeleteGeomFieldDefn(0);

        const char* psKind = CPLGetXMLValue( node, "Kind", NULL );
        //CPLDebug( "OGR_ILI", "InitFieldDefinitions of '%s' kind: %s", GetName(), psKind);
        if (EQUAL(psKind, "Structure"))
        {
            // add foreign_key field
            OGRFieldDefn ofieldDefn1("REF_NAME", OFTString);
            poTableDefn->AddFieldDefn(&ofieldDefn1);
            OGRFieldDefn ofieldDefn2("REF_ID", OFTString);
            poTableDefn->AddFieldDefn(&ofieldDefn2);
        } else { // Class
            // add TID field
            const char* psTidColName = (iliVersion == 1) ? "_TID" : "TID";
            OGRFieldDefn ofieldDefn(psTidColName, OFTString);
            poTableDefn->AddFieldDefn(&ofieldDefn);
        }
        if (CSLTestBoolean(CPLGetXMLValue( node, "Abstract", "FALSE" )))
            hasDerivedClasses = true;
    }
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:23,代码来源:imdreader.cpp

示例7: oFieldTemplate

OGRFeatureDefn *defineLayer(char *szName, OGRwkbGeometryType szType, S2I *poHeaders) {
    OGRFeatureDefn *poFeatureDefn = new OGRFeatureDefn( szName );
    poFeatureDefn->SetGeomType( szType );
    
    for (unsigned int n=0; n<poHeaders->size(); n++) { /* adding headers in the correct order again */
        for (S2I::iterator i=poHeaders->begin(); i!=poHeaders->end(); i++) {
            if (n==i->second) {
                OGRFieldDefn oFieldTemplate( i->first.c_str(), OFTString );
                poFeatureDefn->AddFieldDefn( &oFieldTemplate );
            }
        }
    }
    return poFeatureDefn;
}
开发者ID:sylvainallard,项目名称:gdal,代码行数:14,代码来源:ogrsosidatasource.cpp

示例8: OGRFeatureDefn

OGRFeatureDefn *OGRFeatureDefn::Clone()

{
    OGRFeatureDefn *poCopy;

    poCopy = new OGRFeatureDefn( GetName() );

    poCopy->SetGeomType( GetGeomType() );

    for( int i = 0; i < GetFieldCount(); i++ )
        poCopy->AddFieldDefn( GetFieldDefn( i ) );

    return poCopy;
}
开发者ID:maowang,项目名称:sqlite-ogc,代码行数:14,代码来源:ogrfeaturedefn.cpp

示例9: GenerateLayerDefn

bool OGRESRIJSONReader::GenerateLayerDefn()
{
    CPLAssert( nullptr != poGJObject_ );
    CPLAssert( nullptr != poLayer_->GetLayerDefn() );
    CPLAssert( 0 == poLayer_->GetLayerDefn()->GetFieldCount() );

    bool bSuccess = true;

/* -------------------------------------------------------------------- */
/*      Scan all features and generate layer definition.                */
/* -------------------------------------------------------------------- */
    json_object* poFields =
        OGRGeoJSONFindMemberByName( poGJObject_, "fields" );
    if( nullptr != poFields &&
        json_type_array == json_object_get_type( poFields ) )
    {
        const int nFeatures = json_object_array_length( poFields );
        for( int i = 0; i < nFeatures; ++i )
        {
            json_object* poField =
                json_object_array_get_idx( poFields, i );
            if( !ParseField( poField ) )
            {
                CPLDebug( "GeoJSON", "Create feature schema failure." );
                bSuccess = false;
            }
        }
    }
    else
    {
        poFields = OGRGeoJSONFindMemberByName(
            poGJObject_, "fieldAliases" );
        if( nullptr != poFields &&
            json_object_get_type(poFields) == json_type_object )
        {
            OGRFeatureDefn* poDefn = poLayer_->GetLayerDefn();
            json_object_iter it;
            it.key = nullptr;
            it.val = nullptr;
            it.entry = nullptr;
            json_object_object_foreachC( poFields, it )
            {
                OGRFieldDefn fldDefn( it.key, OFTString );
                poDefn->AddFieldDefn( &fldDefn );
            }
        }
开发者ID:koordinates,项目名称:gdal,代码行数:46,代码来源:ogresrijsonreader.cpp

示例10: oOGRFieldDefn

OGRFeatureDefn * cvct2gdal::CVCT2GDALFeatureDefn ( VCTFeatureDefn * poVCTFeatDefn )
{
	OGRFeatureDefn * poOGRFeatDefn = new OGRFeatureDefn();

	for ( auto iVCTFieldDefn = poVCTFeatDefn->fielddefnlist.begin();
	        iVCTFieldDefn != poVCTFeatDefn->fielddefnlist.end(); ++iVCTFieldDefn )
	{
		OGRFieldDefn oOGRFieldDefn ( "", OFTInteger );
		oOGRFieldDefn.SetName ( iVCTFieldDefn->name.c_str() );
		oOGRFieldDefn.SetWidth ( iVCTFieldDefn->width );
		oOGRFieldDefn.SetPrecision ( iVCTFieldDefn->precision );
		oOGRFieldDefn.SetType ( CVCT2GDALFieldType ( iVCTFieldDefn->type ) );
		poOGRFeatDefn->AddFieldDefn ( &oOGRFieldDefn );
	}

	return poOGRFeatDefn;
}
开发者ID:htoooth,项目名称:CNSDTFL,代码行数:17,代码来源:fmts.cvct2gdal.cpp

示例11: oFieldTemplate

static
OGRFeatureDefn *defineLayer(const char *szName, OGRwkbGeometryType szType, S2I *poHeaders, S2I **ppoHeadersNew) {
    OGRFeatureDefn *poFeatureDefn = new OGRFeatureDefn( szName );
    poFeatureDefn->SetGeomType( szType );
    S2I* poHeadersNew  = *ppoHeadersNew;

    for (S2I::iterator i=poHeaders->begin(); i!=poHeaders->end(); i++) {
                OGRSOSIDataType* poType = SOSIGetType(i->first);
                OGRSOSISimpleDataType* poElements = poType->getElements();
                for (int k=0; k<poType->getElementCount(); k++) {
                    if (strcmp(poElements[k].GetName(),"")==0) continue;
                    OGRFieldDefn oFieldTemplate( poElements[k].GetName(), poElements[k].GetType() );
                    (*poHeadersNew)[CPLString(poElements[k].GetName())] = poFeatureDefn->GetFieldCount();
                    poFeatureDefn->AddFieldDefn( &oFieldTemplate );
                }
    }
    return poFeatureDefn;
}
开发者ID:nextgis-borsch,项目名称:lib_gdal,代码行数:18,代码来源:ogrsosidatasource.cpp

示例12: OGRFeatureDefn

OGRFeatureDefn *OGRFeatureDefn::Clone()

{
    int i;
    OGRFeatureDefn *poCopy;

    poCopy = new OGRFeatureDefn( GetName() );

    GetFieldCount();
    for( i = 0; i < nFieldCount; i++ )
        poCopy->AddFieldDefn( GetFieldDefn( i ) );

    /* There is a default geometry field created at OGRFeatureDefn instanciation */
    poCopy->DeleteGeomFieldDefn(0);
    GetGeomFieldCount();
    for( i = 0; i < nGeomFieldCount; i++ )
        poCopy->AddGeomFieldDefn( GetGeomFieldDefn( i ) );

    return poCopy;
}
开发者ID:garnertb,项目名称:gdal,代码行数:20,代码来源:ogrfeaturedefn.cpp

示例13: ofieldDefn

int ILI2Reader::AddFeature(DOMElement *elem) {
  bool newLayer = true;
  OGRLayer *curLayer = 0;
  char *pszName = XMLString::transcode(elem->getTagName());

  // test if this layer exist
  for (list<OGRLayer *>::reverse_iterator layerIt = m_listLayer.rbegin();
       layerIt != m_listLayer.rend();
       ++layerIt) {
    OGRFeatureDefn *fDef = (*layerIt)->GetLayerDefn();
    if (cmpStr(fDef->GetName(), pszName) == 0) {
      newLayer = false;
      curLayer = *layerIt;
      break;
    }
  }

  // add a layer
  if (newLayer) { // FIXME in Layer: SRS Writer Type datasource
    CPLDebug( "OGR_ILI", "Adding layer: %s", pszName );
    // new layer data
    OGRSpatialReference *poSRSIn = NULL; // FIXME fix values for initial layer
    int bWriterIn = 0;
    OGRwkbGeometryType eReqType = wkbUnknown;
    OGRILI2DataSource *poDSIn = NULL;
    curLayer = new OGRILI2Layer(pszName, poSRSIn, bWriterIn, eReqType, poDSIn);
    m_listLayer.push_back(curLayer);
  }

  // the feature and field definition
  OGRFeatureDefn *featureDef = curLayer->GetLayerDefn();
  if (newLayer) {
    // add TID field
    OGRFieldDefn ofieldDefn (ILI2_TID, OFTString);
    featureDef->AddFieldDefn(&ofieldDefn);

    setFieldDefn(featureDef, elem);
  }

  // add the features
  OGRFeature *feature = new OGRFeature(featureDef);

  // assign TID
  int fIndex = feature->GetFieldIndex(ILI2_TID);
  if (fIndex != -1) {
      XMLCh *pszIli2_tid = XMLString::transcode(ILI2_TID);
      char *fChVal = XMLString::transcode(elem->getAttribute(pszIli2_tid));
      feature->SetField(fIndex, fChVal);
      XMLString::release (&pszIli2_tid);
      XMLString::release (&fChVal);
  } else {
      CPLDebug( "OGR_ILI","'%s' not found", ILI2_TID);
  }

  SetFieldValues(feature, elem);
  curLayer->SetFeature(feature);
  
  XMLString::release (&pszName);

  return 0;
}
开发者ID:imincik,项目名称:pkg-gdal,代码行数:61,代码来源:ili2reader.cpp

示例14: CreateField

OGRErr OGRNULLLayer::CreateField( OGRFieldDefn *poField,
                                  int bApproxOK )
{
    poFeatureDefn->AddFieldDefn(poField);
    return OGRERR_NONE;
}
开发者ID:0004c,项目名称:node-gdal,代码行数:6,代码来源:ogrnulldriver.cpp

示例15: if

int ILI1Reader::ReadTable(const char *layername) {
    char **tokens = NULL;
    const char *firsttok = NULL;
    int ret = TRUE;
    int warned = FALSE;
    int fIndex;
    int geomIdx;

    // curLayer is NULL if we have more than one
    // point geometry column
    if(curLayer == NULL) {
      OGRFeature *metaFeature = NULL;
      metaLayer->ResetReading();
      while((metaFeature = metaLayer->GetNextFeature()) != NULL ) {
        if(EQUAL(layername, metaFeature->GetFieldAsString(0))) {
          const char *geomlayername = metaFeature->GetFieldAsString(2);
          curLayer = GetLayerByName(geomlayername);
          break;
        }
      }
    }

    OGRFeatureDefn *featureDef = curLayer->GetLayerDefn();
    OGRFeature *feature = NULL;

    // get the geometry index of the current layer
    // only if the model is read
    if(featureDef->GetFieldCount() != 0) {
      OGRFeature *metaFeature = NULL;
      metaLayer->ResetReading();
      while((metaFeature = metaLayer->GetNextFeature()) != NULL ) {
        if(EQUAL(curLayer->GetLayerDefn()->GetName(), metaFeature->GetFieldAsString(2))) {
          geomIdx = metaFeature->GetFieldAsInteger(1);
        }
      }
    }

    long fpos = VSIFTell(fpItf);
    while (ret && (tokens = ReadParseLine()))
    {
      firsttok = CSLGetField(tokens, 0);
      if (EQUAL(firsttok, "OBJE"))
      {
        //Check for features spread over multiple objects
        if (featureDef->GetGeomType() == wkbPolygon)
        {
          //Multiple polygon rings
          feature = curLayer->GetFeatureRef(atol(CSLGetField(tokens, 2)));
        }
        else if (featureDef->GetGeomType() == wkbGeometryCollection)
        {
          //AREA lines spread over mutltiple objects
        }
        else
        {
          feature = NULL;
        }

        if (feature == NULL)
        {
          if (featureDef->GetFieldCount() == 0)
          {
            CPLDebug( "OGR_ILI", "No field definition found for table: %s", featureDef->GetName() );
            //Model not read - use heuristics
            for (fIndex=1; fIndex<CSLCount(tokens); fIndex++)
            {
              char szFieldName[32];
              sprintf(szFieldName, "Field%02d", fIndex);
              OGRFieldDefn oFieldDefn(szFieldName, OFTString);
              featureDef->AddFieldDefn(&oFieldDefn);
            }
          }
          //start new feature
          feature = new OGRFeature(featureDef);

          int fieldno = 0;
          for (fIndex=1; fIndex<CSLCount(tokens) && fieldno < featureDef->GetFieldCount(); fIndex++, fieldno++)
          {
            if (!EQUAL(tokens[fIndex], "@")) {
              //CPLDebug( "READ TABLE OGR_ILI", "Adding Field %d: %s", fieldno, tokens[fIndex]);
              feature->SetField(fieldno, tokens[fIndex]);
              if (featureDef->GetFieldDefn(fieldno)->GetType() == OFTReal
                  && fieldno > 0
                  && featureDef->GetFieldDefn(fieldno-1)->GetType() == OFTReal
                  && featureDef->GetGeomType() == wkbPoint

                  /*
                  // if there is no ili model read,
                  // we have no chance to detect the
                  // geometry column!!
                  */

                  && (fieldno-2) == geomIdx) {
                //add Point geometry
                OGRPoint *ogrPoint = new OGRPoint(atof(tokens[fIndex-1]), atof(tokens[fIndex]));
                feature->SetGeometryDirectly(ogrPoint);
              }
            }
          }
          if (!warned && featureDef->GetFieldCount() != CSLCount(tokens)-1 && !(featureDef->GetFieldCount() == CSLCount(tokens) && EQUAL(featureDef->GetFieldDefn(featureDef->GetFieldCount()-1)->GetNameRef(), "ILI_Geometry"))) {
//.........这里部分代码省略.........
开发者ID:Chaduke,项目名称:bah.mod,代码行数:101,代码来源:ili1reader.cpp


注:本文中的OGRFeatureDefn::AddFieldDefn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。