本文整理汇总了C++中OGRFeatureDefn::SetGeomType方法的典型用法代码示例。如果您正苦于以下问题:C++ OGRFeatureDefn::SetGeomType方法的具体用法?C++ OGRFeatureDefn::SetGeomType怎么用?C++ OGRFeatureDefn::SetGeomType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OGRFeatureDefn
的用法示例。
在下文中一共展示了OGRFeatureDefn::SetGeomType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
JNIEXPORT void JNICALL Java_es_gva_cit_jogr_OGRFeatureDefn_setGeomTypeNat
(JNIEnv *env, jobject obj, jlong cPtr, jstring eGType){
OGRFeatureDefn *fd = (OGRFeatureDefn *) 0 ;
OGRwkbGeometryType geomtype;
fd = *(OGRFeatureDefn **)&cPtr;
if(fd!=NULL){
const char *type = env->GetStringUTFChars( eGType, 0);
if(strcmp(type,"wkbUnknown")==0)geomtype = wkbUnknown;
else if(strcmp(type,"wkbPoint")==0)geomtype = wkbPoint;
else if(strcmp(type,"wkbLineString")==0)geomtype = wkbLineString;
else if(strcmp(type,"wkbPolygon")==0)geomtype = wkbPolygon;
else if(strcmp(type,"wkbMultiPoint")==0)geomtype = wkbMultiPoint;
else if(strcmp(type,"wkbMultiLineString")==0)geomtype = wkbMultiLineString;
else if(strcmp(type,"wkbMultiPolygon")==0)geomtype = wkbMultiPolygon;
else if(strcmp(type,"wkbGeometryCollection")==0)geomtype = wkbGeometryCollection;
else if(strcmp(type,"wkbNone")==0)geomtype = wkbNone;
else if(strcmp(type,"wkbLinearRing")==0)geomtype = wkbLinearRing;
else if(strcmp(type,"wkbPoint25D")==0)geomtype = wkbPoint25D;
else if(strcmp(type,"wkbLineString25D")==0)geomtype = wkbLineString25D;
else if(strcmp(type,"wkbPolygon25D")==0)geomtype = wkbPolygon25D;
else if(strcmp(type,"wkbMultiPoint25D")==0)geomtype = wkbMultiPoint25D;
else if(strcmp(type,"wkbMultiLineString25D")==0)geomtype = wkbMultiLineString25D;
else if(strcmp(type,"wkbMultiPolygon25D")==0)geomtype = wkbMultiPolygon25D;
else if(strcmp(type,"wkbGeometryCollection25D")==0)geomtype = wkbGeometryCollection25D;
fd->SetGeomType(geomtype);
env->ReleaseStringUTFChars( eGType, type );
}
}
示例2: CPLError
OGRLayer *
OGRILI2DataSource::CreateLayer( const char * pszLayerName,
OGRSpatialReference *poSRS,
OGRwkbGeometryType eType,
char ** papszOptions )
{
if (fpOutput == NULL)
return NULL;
FeatureDefnInfo featureDefnInfo = poImdReader->GetFeatureDefnInfo(pszLayerName);
OGRFeatureDefn* poFeatureDefn = featureDefnInfo.poTableDefn;
if (poFeatureDefn == NULL)
{
CPLError(CE_Warning, CPLE_AppDefined,
"Layer '%s' not found in model definition. Creating adhoc layer", pszLayerName);
poFeatureDefn = new OGRFeatureDefn(pszLayerName);
poFeatureDefn->SetGeomType( eType );
}
OGRILI2Layer *poLayer = new OGRILI2Layer(poFeatureDefn, featureDefnInfo.poGeomFieldInfos, this);
nLayers++;
papoLayers = (OGRILI2Layer**)CPLRealloc(papoLayers, sizeof(OGRILI2Layer*) * nLayers);
papoLayers[nLayers-1] = poLayer;
return poLayer;
}
示例3: CPLError
OGRLayer *OGRSOSIDataSource::ICreateLayer( const char *pszNameIn,
OGRSpatialReference *poSpatialRef,
OGRwkbGeometryType eGType,
CPL_UNUSED char **papszOptions ) {
/* SOSI does not really support layers - so let's first see that the global settings are consistent */
if (poSRS == NULL) {
if (poSpatialRef!=NULL) {
poSRS = poSpatialRef;
poSRS->Reference();
const char *pszKoosys = poSRS->GetAuthorityCode("PROJCS");
if (pszKoosys == NULL) {
OGRErr err = poSRS->AutoIdentifyEPSG();
if (err == OGRERR_UNSUPPORTED_SRS) {
CPLError( CE_Failure, CPLE_OpenFailed,
"Could not identify EPSG code for spatial reference system");
return NULL;
}
pszKoosys = poSRS->GetAuthorityCode("PROJCS");
}
if (pszKoosys != NULL) {
int nKoosys = epsg2sosi(atoi(pszKoosys));
CPLDebug( "[CreateLayer]","Projection set to SOSI %i", nKoosys);
LC_PutTrans(nKoosys,0,0,0.01,0.01,0.01);
} else {
pszKoosys = poSRS->GetAuthorityCode("GEOGCS");
if (pszKoosys != NULL) {
int nKoosys = epsg2sosi(atoi(pszKoosys));
LC_PutTrans(nKoosys,0,0,0.01,0.01,0.01);
} else {
CPLError( CE_Failure, CPLE_OpenFailed,
"Could not retrieve EPSG code for spatial reference system");
return NULL;
}
}
}
LC_WsGr(poFileadm); /* Writing the header here! */
} else {
if (!poSRS->IsSame(poSpatialRef)) {
CPLError( CE_Failure, CPLE_AppDefined,
"SOSI driver does not support different spatial reference systems in one file.");
}
}
OGRFeatureDefn *poFeatureDefn = new OGRFeatureDefn( pszNameIn );
poFeatureDefn->Reference();
poFeatureDefn->SetGeomType( eGType );
OGRSOSILayer *poLayer = new OGRSOSILayer( this, poFeatureDefn, poFileadm, NULL /*poHeaderDefn*/);
/* todo: where do we delete poLayer and poFeatureDefn? */
return poLayer;
}
示例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;
}
示例5: if
OGRFeatureDefn *S57GenerateGeomFeatureDefn( OGRwkbGeometryType eGType,
int nOptionFlags )
{
OGRFeatureDefn *poFDefn = NULL;
if( eGType == wkbPoint )
{
poFDefn = new OGRFeatureDefn( "Point" );
poFDefn->SetGeomType( eGType );
}
else if( eGType == wkbLineString )
{
poFDefn = new OGRFeatureDefn( "Line" );
poFDefn->SetGeomType( eGType );
}
else if( eGType == wkbPolygon )
{
poFDefn = new OGRFeatureDefn( "Area" );
poFDefn->SetGeomType( eGType );
}
else if( eGType == wkbNone )
{
poFDefn = new OGRFeatureDefn( "Meta" );
poFDefn->SetGeomType( eGType );
}
else if( eGType == wkbUnknown )
{
poFDefn = new OGRFeatureDefn( "Generic" );
poFDefn->SetGeomType( eGType );
}
else
return NULL;
poFDefn->Reference();
S57GenerateStandardAttributes( poFDefn, nOptionFlags );
return poFDefn;
}
示例6: 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;
}
示例7: 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;
}
示例8: ExtractTopic
OGRLayer *
OGRILI1DataSource::ICreateLayer( const char * pszLayerName,
CPL_UNUSED OGRSpatialReference *poSRS,
OGRwkbGeometryType eType,
CPL_UNUSED char ** papszOptions )
{
FeatureDefnInfo featureDefnInfo
= poImdReader->GetFeatureDefnInfo(pszLayerName);
const char *table = pszLayerName;
char * topic = ExtractTopic(pszLayerName);
if (nLayers) VSIFPrintf( fpTransfer, "ETAB\n" );
if (topic)
{
table = pszLayerName+strlen(topic)+2; //after "__"
if (pszTopic == NULL || !EQUAL(topic, pszTopic))
{
if (pszTopic)
{
VSIFPrintf( fpTransfer, "ETOP\n" );
CPLFree(pszTopic);
}
pszTopic = topic;
VSIFPrintf( fpTransfer, "TOPI %s\n", pszTopic );
}
else
{
CPLFree(topic);
}
}
else
{
if (pszTopic == NULL) pszTopic = CPLStrdup("Unknown");
VSIFPrintf( fpTransfer, "TOPI %s\n", pszTopic );
}
VSIFPrintf( fpTransfer, "TABL %s\n", table );
OGRFeatureDefn* poFeatureDefn = new OGRFeatureDefn(table);
poFeatureDefn->SetGeomType( eType );
OGRILI1Layer *poLayer
= new OGRILI1Layer(poFeatureDefn, featureDefnInfo.poGeomFieldInfos,
this);
nLayers ++;
papoLayers = static_cast<OGRILI1Layer **>(
CPLRealloc(papoLayers, sizeof(OGRILI1Layer*) * nLayers) );
papoLayers[nLayers-1] = poLayer;
return poLayer;
}
示例9: 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;
}
示例10: oField
//.........这里部分代码省略.........
oField.SetType( OFTString );
oField.SetWidth((int)psMSField->length);
poDefn->AddFieldDefn( &oField );
break;
}
case FIELD_TYPE_TINY_BLOB:
case FIELD_TYPE_MEDIUM_BLOB:
case FIELD_TYPE_LONG_BLOB:
case FIELD_TYPE_BLOB:
{
if( psMSField->charsetnr == 63 )
oField.SetType( OFTBinary );
else
oField.SetType( OFTString );
oField.SetWidth((int)psMSField->max_length);
poDefn->AddFieldDefn( &oField );
break;
}
case FIELD_TYPE_GEOMETRY:
{
if (pszGeomColumn == nullptr)
{
pszGeomColumnTable = CPLStrdup( psMSField->table);
pszGeomColumn = CPLStrdup( psMSField->name);
}
break;
}
default:
// any other field we ignore.
break;
}
// assume a FID name first, and if it isn't there
// take a field that is not null, a primary key,
// and is an integer-like field
if( EQUAL(psMSField->name,"ogc_fid") )
{
bHasFid = TRUE;
pszFIDColumn = CPLStrdup(oField.GetNameRef());
continue;
} else
if (IS_NOT_NULL(psMSField->flags)
&& IS_PRI_KEY(psMSField->flags)
&&
(
psMSField->type == FIELD_TYPE_TINY
|| psMSField->type == FIELD_TYPE_SHORT
|| psMSField->type == FIELD_TYPE_LONG
|| psMSField->type == FIELD_TYPE_INT24
|| psMSField->type == FIELD_TYPE_LONGLONG
)
)
{
bHasFid = TRUE;
pszFIDColumn = CPLStrdup(oField.GetNameRef());
continue;
}
}
poDefn->SetGeomType( wkbNone );
if (pszGeomColumn)
{
char* pszType=nullptr;
CPLString osCommand;
char **papszRow;
// set to unknown first
poDefn->SetGeomType( wkbUnknown );
poDefn->GetGeomFieldDefn(0)->SetName( pszGeomColumn );
osCommand.Printf(
"SELECT type FROM geometry_columns WHERE f_table_name='%s'",
pszGeomColumnTable );
if( hResultSet != nullptr )
mysql_free_result( hResultSet );
hResultSet = nullptr;
if( !mysql_query( poDS->GetConn(), osCommand ) )
hResultSet = mysql_store_result( poDS->GetConn() );
papszRow = nullptr;
if( hResultSet != nullptr )
papszRow = mysql_fetch_row( hResultSet );
if( papszRow != nullptr && papszRow[0] != nullptr )
{
pszType = papszRow[0];
OGRwkbGeometryType l_nGeomType = OGRFromOGCGeomType(pszType);
poDefn->SetGeomType( l_nGeomType );
}
nSRSId = FetchSRSId();
}
return poDefn;
}
示例11: OGRFeatureDefn
OGRFeatureDefn *S57GenerateDSIDFeatureDefn()
{
OGRFeatureDefn *poFDefn = new OGRFeatureDefn( "DSID" );
OGRFieldDefn oField( "", OFTInteger );
poFDefn->SetGeomType( wkbNone );
poFDefn->Reference();
/* -------------------------------------------------------------------- */
/* DSID fields. */
/* -------------------------------------------------------------------- */
oField.Set( "DSID_EXPP", OFTInteger, 3, 0 );
poFDefn->AddFieldDefn( &oField );
oField.Set( "DSID_INTU", OFTInteger, 3, 0 );
poFDefn->AddFieldDefn( &oField );
oField.Set( "DSID_DSNM", OFTString, 0, 0 );
poFDefn->AddFieldDefn( &oField );
oField.Set( "DSID_EDTN", OFTString, 0, 0 );
poFDefn->AddFieldDefn( &oField );
oField.Set( "DSID_UPDN", OFTString, 0, 0 );
poFDefn->AddFieldDefn( &oField );
oField.Set( "DSID_UADT", OFTString, 8, 0 );
poFDefn->AddFieldDefn( &oField );
oField.Set( "DSID_ISDT", OFTString, 8, 0 );
poFDefn->AddFieldDefn( &oField );
oField.Set( "DSID_STED", OFTReal, 11, 6 );
poFDefn->AddFieldDefn( &oField );
oField.Set( "DSID_PRSP", OFTInteger, 3, 0 );
poFDefn->AddFieldDefn( &oField );
oField.Set( "DSID_PSDN", OFTString, 0, 0 );
poFDefn->AddFieldDefn( &oField );
oField.Set( "DSID_PRED", OFTString, 0, 0 );
poFDefn->AddFieldDefn( &oField );
oField.Set( "DSID_PROF", OFTInteger, 3, 0 );
poFDefn->AddFieldDefn( &oField );
oField.Set( "DSID_AGEN", OFTInteger, 5, 0 );
poFDefn->AddFieldDefn( &oField );
oField.Set( "DSID_COMT", OFTString, 0, 0 );
poFDefn->AddFieldDefn( &oField );
/* -------------------------------------------------------------------- */
/* DSSI fields. */
/* -------------------------------------------------------------------- */
oField.Set( "DSSI_DSTR", OFTInteger, 3, 0 );
poFDefn->AddFieldDefn( &oField );
oField.Set( "DSSI_AALL", OFTInteger, 3, 0 );
poFDefn->AddFieldDefn( &oField );
oField.Set( "DSSI_NALL", OFTInteger, 3, 0 );
poFDefn->AddFieldDefn( &oField );
oField.Set( "DSSI_NOMR", OFTInteger, 10, 0 );
poFDefn->AddFieldDefn( &oField );
oField.Set( "DSSI_NOCR", OFTInteger, 10, 0 );
poFDefn->AddFieldDefn( &oField );
oField.Set( "DSSI_NOGR", OFTInteger, 10, 0 );
poFDefn->AddFieldDefn( &oField );
oField.Set( "DSSI_NOLR", OFTInteger, 10, 0 );
poFDefn->AddFieldDefn( &oField );
oField.Set( "DSSI_NOIN", OFTInteger, 10, 0 );
poFDefn->AddFieldDefn( &oField );
oField.Set( "DSSI_NOCN", OFTInteger, 10, 0 );
poFDefn->AddFieldDefn( &oField );
oField.Set( "DSSI_NOED", OFTInteger, 10, 0 );
poFDefn->AddFieldDefn( &oField );
oField.Set( "DSSI_NOFA", OFTInteger, 10, 0 );
poFDefn->AddFieldDefn( &oField );
/* -------------------------------------------------------------------- */
/* DSPM fields. */
/* -------------------------------------------------------------------- */
oField.Set( "DSPM_HDAT", OFTInteger, 3, 0 );
poFDefn->AddFieldDefn( &oField );
oField.Set( "DSPM_VDAT", OFTInteger, 3, 0 );
poFDefn->AddFieldDefn( &oField );
//.........这里部分代码省略.........
示例12: if
int ILI1Reader::ReadFeatures() {
char **tokens = NULL;
const char *pszLine = NULL;
char *topic = CPLStrdup("(null)");
int ret = TRUE;
while (ret && (tokens = ReadParseLine()) != NULL)
{
const char *firsttok = tokens[0];
if (EQUAL(firsttok, "SCNT"))
{
//read description
do
{
pszLine = CPLReadLine( fpItf );
}
while (pszLine && !STARTS_WITH_CI(pszLine, "////"));
ret = (pszLine != NULL);
}
else if (EQUAL(firsttok, "MOTR"))
{
//read model
do
{
pszLine = CPLReadLine( fpItf );
}
while (pszLine && !STARTS_WITH_CI(pszLine, "////"));
ret = (pszLine != NULL);
}
else if (EQUAL(firsttok, "MTID"))
{
}
else if (EQUAL(firsttok, "MODL"))
{
}
else if (EQUAL(firsttok, "TOPI") && CSLCount(tokens) >= 2)
{
CPLFree(topic);
topic = CPLStrdup(CSLGetField(tokens, 1));
}
else if (EQUAL(firsttok, "TABL") && CSLCount(tokens) >= 2)
{
const char *layername
= GetLayerNameString(topic, CSLGetField(tokens, 1));
CPLDebug( "OGR_ILI", "Reading table '%s'", layername );
curLayer = GetLayerByName(layername);
if (curLayer == NULL) { //create one
CPLError( CE_Warning, CPLE_AppDefined,
"No model definition for table '%s' found, "
"using default field names.", layername );
OGRFeatureDefn* poFeatureDefn
= new OGRFeatureDefn(
GetLayerNameString(topic, CSLGetField(tokens, 1)));
poFeatureDefn->SetGeomType( wkbUnknown );
GeomFieldInfos oGeomFieldInfos;
curLayer = new OGRILI1Layer(poFeatureDefn, oGeomFieldInfos, NULL);
AddLayer(curLayer);
}
if(curLayer != NULL) {
for (int i=0; i < curLayer->GetLayerDefn()->GetFieldCount(); i++) {
CPLDebug( "OGR_ILI", "Field %d: %s", i,
curLayer->GetLayerDefn()->GetFieldDefn(i)->GetNameRef());
}
}
ret = ReadTable(layername);
}
else if (EQUAL(firsttok, "ETOP"))
{
}
else if (EQUAL(firsttok, "EMOD"))
{
}
else if (EQUAL(firsttok, "ENDE"))
{
CSLDestroy(tokens);
CPLFree(topic);
return TRUE;
}
else
{
CPLError( CE_Warning, CPLE_AppDefined,
"Unexpected token: %s", firsttok );
}
CSLDestroy(tokens);
tokens = NULL;
}
CSLDestroy(tokens);
CPLFree(topic);
return ret;
}
示例13: OGRFeatureDefn
OGRFeatureDefn *OGRIngresResultLayer::ReadResultDefinition()
{
/* -------------------------------------------------------------------- */
/* Parse the returned table information. */
/* -------------------------------------------------------------------- */
OGRFeatureDefn *poDefn = new OGRFeatureDefn( "sql_statement" );
int iRawField;
poDefn->Reference();
for( iRawField = 0;
iRawField < (int) poResultSet->getDescrParm.gd_descriptorCount;
iRawField++ )
{
IIAPI_DESCRIPTOR *psFDesc =
poResultSet->getDescrParm.gd_descriptor + iRawField;
OGRFieldDefn oField( psFDesc->ds_columnName, OFTString);
switch( psFDesc->ds_dataType )
{
case IIAPI_CHR_TYPE:
case IIAPI_CHA_TYPE:
// string - fixed width.
oField.SetWidth( psFDesc->ds_length );
poDefn->AddFieldDefn( &oField );
break;
case IIAPI_LVCH_TYPE:
case IIAPI_LTXT_TYPE:
case IIAPI_VCH_TYPE:
case IIAPI_TXT_TYPE:
// default variable length string
poDefn->AddFieldDefn( &oField );
break;
case IIAPI_INT_TYPE:
oField.SetType( OFTInteger );
poDefn->AddFieldDefn( &oField );
break;
case IIAPI_FLT_TYPE:
oField.SetType( OFTReal );
poDefn->AddFieldDefn( &oField );
break;
case IIAPI_DEC_TYPE:
oField.SetWidth( psFDesc->ds_precision );
if( psFDesc->ds_scale == 0 )
oField.SetType( OFTInteger );
else
{
oField.SetType( OFTReal );
oField.SetPrecision( psFDesc->ds_scale );
}
poDefn->AddFieldDefn( &oField );
break;
default:
// any other field we ignore.
break;
}
}
poDefn->SetGeomType( wkbNone );
return poDefn;
}
示例14: if
//.........这里部分代码省略.........
}
else if( EQUAL(pszType, "time") )
{
oField.SetType( OFTTime );
}
else if( EQUAL(pszType, "datetime")
|| EQUAL(pszType, "timestamp") )
{
oField.SetType( OFTDateTime );
}
else if( EQUAL(pszType, "year") )
{
oField.SetType( OFTString );
oField.SetWidth( 10 );
}
else if( EQUAL(pszType, "geometry") )
{
pszGeomColumn = CPLStrdup(papszRow[0]);
continue;
}
// Is this an integer primary key field?
if( !bHasFid && papszRow[3] != NULL && EQUAL(papszRow[3],"PRI")
&& oField.GetType() == OFTInteger )
{
bHasFid = TRUE;
pszFIDColumn = CPLStrdup(oField.GetNameRef());
continue;
}
poDefn->AddFieldDefn( &oField );
}
// set to none for now... if we have a geometry column it will be set layer.
poDefn->SetGeomType( wkbNone );
if( hResult != NULL )
{
mysql_free_result( hResult );
hResultSet = NULL;
}
if( bHasFid )
CPLDebug( "MySQL", "table %s has FID column %s.",
pszTable, pszFIDColumn );
else
CPLDebug( "MySQL",
"table %s has no FID column, FIDs will not be reliable!",
pszTable );
if (pszGeomColumn)
{
char* pszType=NULL;
// set to unknown first
poDefn->SetGeomType( wkbUnknown );
sprintf(szCommand, "SELECT type, coord_dimension FROM geometry_columns WHERE f_table_name='%s'",
pszTable );
hResult = NULL;
if( !mysql_query( poDS->GetConn(), szCommand ) )
hResult = mysql_store_result( poDS->GetConn() );
papszRow = NULL;
if( hResult != NULL )
papszRow = mysql_fetch_row( hResult );
示例15: oField
OGRFeatureDefn *
OGROCISelectLayer::ReadTableDefinition( OGROCIStatement *poCommand )
{
OGROCISession *poSession = poDS->GetSession();
/* -------------------------------------------------------------------- */
/* Parse the returned table information. */
/* -------------------------------------------------------------------- */
for( int iParm = 0; TRUE; iParm++ )
{
OGRFieldDefn oField( "", OFTString );
int nStatus;
OCIParam *hParmDesc;
ub2 nOCIType;
ub4 nOCILen;
nStatus =
OCIParamGet( poCommand->GetStatement(), OCI_HTYPE_STMT,
poSession->hError, (dvoid**)&hParmDesc,
(ub4) iParm+1 );
if( nStatus == OCI_ERROR )
break;
if( poSession->GetParmInfo( hParmDesc, &oField, &nOCIType, &nOCILen )
!= CE_None )
break;
if( oField.GetType() == OFTBinary && nOCIType == 108 )
{
CPLFree( pszGeomName );
pszGeomName = CPLStrdup( oField.GetNameRef() );
iGeomColumn = iParm;
break;
}
}
/* -------------------------------------------------------------------- */
/* Use the schema off the statement. */
/* -------------------------------------------------------------------- */
OGRFeatureDefn *poDefn;
poDefn = poCommand->GetResultDefn();
if( iGeomColumn >= 0 )
poDefn->SetGeomType(wkbUnknown);
poDefn->Reference();
/* -------------------------------------------------------------------- */
/* Do we have an FID? */
/* -------------------------------------------------------------------- */
const char *pszExpectedFIDName =
CPLGetConfigOption( "OCI_FID", "OGR_FID" );
if( poDefn->GetFieldIndex(pszExpectedFIDName) > -1 )
{
iFIDColumn = poDefn->GetFieldIndex(pszExpectedFIDName);
pszFIDName = CPLStrdup(poDefn->GetFieldDefn(iFIDColumn)->GetNameRef());
}
if( EQUAL(pszExpectedFIDName, "OGR_FID") && pszFIDName )
{
for(int i=0;i<poDefn->GetFieldCount();i++)
{
// This is presumably a Integer since we always create Integer64 with a
// defined precision
if( poDefn->GetFieldDefn(i)->GetType() == OFTInteger64 &&
poDefn->GetFieldDefn(i)->GetWidth() == 0 )
{
poDefn->GetFieldDefn(i)->SetType(OFTInteger);
}
}
}
return poDefn;
}