本文整理汇总了C++中OGR_SRSNode::GetChildCount方法的典型用法代码示例。如果您正苦于以下问题:C++ OGR_SRSNode::GetChildCount方法的具体用法?C++ OGR_SRSNode::GetChildCount怎么用?C++ OGR_SRSNode::GetChildCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OGR_SRSNode
的用法示例。
在下文中一共展示了OGR_SRSNode::GetChildCount方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnItemRightClick
void ProjectionDlg::OnItemRightClick( wxListEvent &event )
{
int item_clicked = event.GetIndex();
OGR_SRSNode *root = m_proj.GetRoot();
OGR_SRSNode *node, *par1, *par2;
const char *value;
int children = root->GetChildCount();
int i, item = 0;
wxString str;
for (i = 0; i < children; i++)
{
node = root->GetChild(i);
value = node->GetValue();
if (strcmp(value, "PARAMETER"))
continue;
par1 = node->GetChild(0);
par2 = node->GetChild(1);
value = par2->GetValue();
if (item == item_clicked)
{
wxString caption = _("Value for ");
str = wxString(par1->GetValue(), wxConvUTF8);
caption += str;
str = wxString(value, wxConvUTF8);
wxString result = wxGetTextFromUser(caption, _("Enter new value"),
str, this);
if (result != _T(""))
{
// double newval = atof((const char *)result);
par2->SetValue(result.mb_str(wxConvUTF8));
DisplayProjectionSpecificParams();
return;
}
}
item++;
}
}
示例2: DisplayProjectionSpecificParams
void ProjectionDlg::DisplayProjectionSpecificParams()
{
m_pParamCtrl->DeleteAllItems();
OGR_SRSNode *root = m_proj.GetRoot();
if (!root)
{
m_pParamCtrl->InsertItem(0, _("(Invalid projection)"));
return; // bogus projection
}
OGR_SRSNode *node, *par1, *par2;
const char *value;
int children = root->GetChildCount();
int i, item = 0;
wxString str;
for (i = 0; i < children; i++)
{
node = root->GetChild(i);
value = node->GetValue();
if (!strcmp(value, "PARAMETER"))
{
par1 = node->GetChild(0);
value = par1->GetValue();
str = wxString(value, wxConvUTF8);
item = m_pParamCtrl->InsertItem(item, str);
par2 = node->GetChild(1);
value = par2->GetValue();
str = wxString(value, wxConvUTF8);
m_pParamCtrl->SetItem(item, 1, str);
item++;
}
}
}
示例3: Validate
OGRErr OGRSpatialReference::Validate(OGR_SRSNode *poRoot)
{
if( !EQUAL(poRoot->GetValue(),"GEOGCS")
&& !EQUAL(poRoot->GetValue(),"PROJCS")
&& !EQUAL(poRoot->GetValue(),"LOCAL_CS")
&& !EQUAL(poRoot->GetValue(),"GEOCCS")
&& !EQUAL(poRoot->GetValue(),"VERT_CS")
&& !EQUAL(poRoot->GetValue(),"COMPD_CS"))
{
CPLDebug( "OGRSpatialReference::Validate",
"Unrecognised root node `%s'\n",
poRoot->GetValue() );
return OGRERR_CORRUPT_DATA;
}
/* -------------------------------------------------------------------- */
/* For a COMPD_CS, validate subparameters and head & tail cs */
/* -------------------------------------------------------------------- */
if( EQUAL(poRoot->GetValue(),"COMPD_CS") )
{
OGR_SRSNode *poNode;
int i;
for( i = 1; i < poRoot->GetChildCount(); i++ )
{
poNode = poRoot->GetChild(i);
if( EQUAL(poNode->GetValue(),"GEOGCS") ||
EQUAL(poNode->GetValue(),"PROJCS") ||
EQUAL(poNode->GetValue(),"LOCAL_CS") ||
EQUAL(poNode->GetValue(),"GEOCCS") ||
EQUAL(poNode->GetValue(),"VERT_CS") ||
EQUAL(poNode->GetValue(),"COMPD_CS") )
{
OGRErr eErr = Validate(poNode);
if (eErr != OGRERR_NONE)
return eErr;
}
else if( EQUAL(poNode->GetValue(),"AUTHORITY") )
{
OGRErr eErr = ValidateAuthority(poNode);
if (eErr != OGRERR_NONE)
return eErr;
}
else
{
CPLDebug( "OGRSpatialReference::Validate",
"Unexpected child for COMPD_CS `%s'.\n",
poNode->GetValue() );
return OGRERR_CORRUPT_DATA;
}
}
return OGRERR_NONE;
}
/* -------------------------------------------------------------------- */
/* Validate VERT_CS */
/* -------------------------------------------------------------------- */
if( EQUAL(poRoot->GetValue(),"VERT_CS") )
{
OGR_SRSNode *poNode;
int i;
int bGotVertDatum = FALSE;
int bGotUnit = FALSE;
int nCountAxis = 0;
for( i = 1; i < poRoot->GetChildCount(); i++ )
{
poNode = poRoot->GetChild(i);
if( EQUAL(poNode->GetValue(),"VERT_DATUM") )
{
OGRErr eErr = ValidateVertDatum(poNode);
if (eErr != OGRERR_NONE)
return eErr;
bGotVertDatum = TRUE;
}
else if( EQUAL(poNode->GetValue(),"UNIT") )
{
OGRErr eErr = ValidateUnit(poNode);
if (eErr != OGRERR_NONE)
return eErr;
bGotUnit = TRUE;
}
else if( EQUAL(poNode->GetValue(),"AXIS") )
{
OGRErr eErr = ValidateAxis(poNode);
if (eErr != OGRERR_NONE)
return eErr;
nCountAxis ++;
}
else if( EQUAL(poNode->GetValue(),"AUTHORITY") )
{
OGRErr eErr = ValidateAuthority(poNode);
if (eErr != OGRERR_NONE)
return eErr;
}
else
//.........这里部分代码省略.........
示例4: ValidateProjection
/**
* \brief Validate the current PROJECTION's arguments.
*
* @return OGRERR_NONE if the PROJECTION's arguments validate, an error code
* otherwise
*/
OGRErr OGRSpatialReference::ValidateProjection(OGR_SRSNode *poRoot)
{
OGR_SRSNode *poPROJCS = poRoot->GetNode( "PROJCS" );
if( poPROJCS == NULL )
return OGRERR_NONE;
if( poPROJCS->GetNode( "PROJECTION" ) == NULL )
{
CPLDebug( "OGRSpatialReference::Validate",
"PROJCS does not have PROJECTION subnode." );
return OGRERR_CORRUPT_DATA;
}
/* -------------------------------------------------------------------- */
/* Find the matching group in the proj and parms table. */
/* -------------------------------------------------------------------- */
const char *pszProjection;
int iOffset;
pszProjection = poPROJCS->GetNode("PROJECTION")->GetChild(0)->GetValue();
for( iOffset = 0;
papszProjWithParms[iOffset] != NULL
&& !EQUAL(papszProjWithParms[iOffset],pszProjection); )
{
while( papszProjWithParms[iOffset] != NULL )
iOffset++;
iOffset++;
}
if( papszProjWithParms[iOffset] == NULL )
return OGRERR_UNSUPPORTED_SRS;
iOffset++;
/* -------------------------------------------------------------------- */
/* Check all parameters, and verify they are in the permitted */
/* list. */
/* -------------------------------------------------------------------- */
int iNode;
for( iNode = 0; iNode < poPROJCS->GetChildCount(); iNode++ )
{
OGR_SRSNode *poParm = poPROJCS->GetChild(iNode);
int i;
const char *pszParmName;
if( !EQUAL(poParm->GetValue(),"PARAMETER") )
continue;
pszParmName = poParm->GetChild(0)->GetValue();
for( i = iOffset; papszProjWithParms[i] != NULL; i++ )
{
if( EQUAL(papszProjWithParms[i],pszParmName) )
break;
}
/* This parameter is not an exact match, is it an alias? */
if( papszProjWithParms[i] == NULL )
{
for( i = iOffset; papszProjWithParms[i] != NULL; i++ )
{
if( IsAliasFor(papszProjWithParms[i],pszParmName) )
break;
}
if( papszProjWithParms[i] == NULL )
{
CPLDebug( "OGRSpatialReference::Validate",
"PARAMETER %s for PROJECTION %s is not permitted.",
pszParmName, pszProjection );
return OGRERR_CORRUPT_DATA;
}
else
{
CPLDebug( "OGRSpatialReference::Validate",
"PARAMETER %s for PROJECTION %s is an alias for %s.",
pszParmName, pszProjection,
papszProjWithParms[i] );
return OGRERR_CORRUPT_DATA;
}
}
}
return OGRERR_NONE;
}
示例5: CheckCitationKeyForStatePlaneUTM
OGRBoolean CheckCitationKeyForStatePlaneUTM(GTIF* hGTIF, GTIFDefn* psDefn, OGRSpatialReference* poSRS, OGRBoolean* pLinearUnitIsSet)
{
if( !hGTIF || !psDefn || !poSRS )
return FALSE;
/* -------------------------------------------------------------------- */
/* For ESRI builds we are interested in maximizing PE */
/* compatability, but generally we prefer to use EPSG */
/* definitions of the coordinate system if PCS is defined. */
/* -------------------------------------------------------------------- */
#if !defined(ESRI_BUILD)
if( psDefn->PCS != KvUserDefined )
return FALSE;
#endif
char szCTString[512];
szCTString[0] = '\0';
/* Check units */
char units[32];
units[0] = '\0';
OGRBoolean hasUnits = FALSE;
if( GTIFKeyGet( hGTIF, GTCitationGeoKey, szCTString, 0, sizeof(szCTString) ) )
{
CPLString osLCCT = szCTString;
osLCCT.tolower();
if( strstr(osLCCT,"us") && strstr(osLCCT,"survey")
&& (strstr(osLCCT,"feet") || strstr(osLCCT,"foot")) )
strcpy(units, "us_survey_feet");
else if(strstr(osLCCT, "linear_feet")
|| strstr(osLCCT, "linear_foot")
|| strstr(osLCCT, "international"))
strcpy(units, "international_feet");
else if( strstr(osLCCT,"meter") )
strcpy(units, "meters");
if (strlen(units) > 0)
hasUnits = TRUE;
if( strstr( szCTString, "Projection Name = ") && strstr( szCTString, "_StatePlane_"))
{
const char *pStr = strstr( szCTString, "Projection Name = ") + strlen("Projection Name = ");
const char* pReturn = strchr( pStr, '\n');
char CSName[128];
strncpy(CSName, pStr, pReturn-pStr);
CSName[pReturn-pStr] = '\0';
if( poSRS->ImportFromESRIStatePlaneWKT(0, NULL, NULL, 32767, CSName) == OGRERR_NONE )
{
// for some erdas citation keys, the state plane CS name is incomplete, the unit check is necessary.
OGRBoolean done = FALSE;
if (hasUnits)
{
OGR_SRSNode *poUnit = poSRS->GetAttrNode( "PROJCS|UNIT" );
if( poUnit != NULL && poUnit->GetChildCount() >= 2 )
{
CPLString unitName = poUnit->GetChild(0)->GetValue();
unitName.tolower();
if (strstr(units, "us_survey_feet"))
{
if (strstr(unitName, "us_survey_feet") || strstr(unitName, "foot_us") )
done = TRUE;
}
else if (strstr(units, "international_feet"))
{
if (strstr(unitName, "feet") || strstr(unitName, "foot"))
done = TRUE;
}
else if (strstr(units, "meters"))
{
if (strstr(unitName, "meter") )
done = TRUE;
}
}
}
if (done)
return TRUE;
}
}
}
if( !hasUnits )
{
char *pszUnitsName = NULL;
GTIFGetUOMLengthInfo( psDefn->UOMLength, &pszUnitsName, NULL );
if( pszUnitsName && strlen(pszUnitsName) > 0 )
{
CPLString osLCCT = pszUnitsName;
GTIFFreeMemory( pszUnitsName );
osLCCT.tolower();
if( strstr(osLCCT, "us") && strstr(osLCCT, "survey")
&& (strstr(osLCCT, "feet") || strstr(osLCCT, "foot")))
strcpy(units, "us_survey_feet");
else if(strstr(osLCCT, "feet") || strstr(osLCCT, "foot"))
strcpy(units, "international_feet");
else if(strstr(osLCCT, "meter"))
//.........这里部分代码省略.........
示例6: if
int OGRProj4CT::InitializeNoLock( OGRSpatialReference * poSourceIn,
OGRSpatialReference * poTargetIn )
{
if( poSourceIn == NULL || poTargetIn == NULL )
return FALSE;
poSRSSource = poSourceIn->Clone();
poSRSTarget = poTargetIn->Clone();
bSourceLatLong = poSRSSource->IsGeographic();
bTargetLatLong = poSRSTarget->IsGeographic();
/* -------------------------------------------------------------------- */
/* Setup source and target translations to radians for lat/long */
/* systems. */
/* -------------------------------------------------------------------- */
dfSourceToRadians = DEG_TO_RAD;
bSourceWrap = FALSE;
dfSourceWrapLong = 0.0;
if( bSourceLatLong )
{
OGR_SRSNode *poUNITS = poSRSSource->GetAttrNode( "GEOGCS|UNIT" );
if( poUNITS && poUNITS->GetChildCount() >= 2 )
{
dfSourceToRadians = atof(poUNITS->GetChild(1)->GetValue());
if( dfSourceToRadians == 0.0 )
dfSourceToRadians = DEG_TO_RAD;
}
}
dfTargetFromRadians = RAD_TO_DEG;
bTargetWrap = FALSE;
dfTargetWrapLong = 0.0;
if( bTargetLatLong )
{
OGR_SRSNode *poUNITS = poSRSTarget->GetAttrNode( "GEOGCS|UNIT" );
if( poUNITS && poUNITS->GetChildCount() >= 2 )
{
double dfTargetToRadians = atof(poUNITS->GetChild(1)->GetValue());
if( dfTargetToRadians != 0.0 )
dfTargetFromRadians = 1 / dfTargetToRadians;
}
}
/* -------------------------------------------------------------------- */
/* Preliminary logic to setup wrapping. */
/* -------------------------------------------------------------------- */
const char *pszCENTER_LONG;
if( CPLGetConfigOption( "CENTER_LONG", NULL ) != NULL )
{
bSourceWrap = bTargetWrap = TRUE;
dfSourceWrapLong = dfTargetWrapLong =
atof(CPLGetConfigOption( "CENTER_LONG", "" ));
CPLDebug( "OGRCT", "Wrap at %g.", dfSourceWrapLong );
}
pszCENTER_LONG = poSRSSource->GetExtension( "GEOGCS", "CENTER_LONG" );
if( pszCENTER_LONG != NULL )
{
dfSourceWrapLong = atof(pszCENTER_LONG);
bSourceWrap = TRUE;
CPLDebug( "OGRCT", "Wrap source at %g.", dfSourceWrapLong );
}
pszCENTER_LONG = poSRSTarget->GetExtension( "GEOGCS", "CENTER_LONG" );
if( pszCENTER_LONG != NULL )
{
dfTargetWrapLong = atof(pszCENTER_LONG);
bTargetWrap = TRUE;
CPLDebug( "OGRCT", "Wrap target at %g.", dfTargetWrapLong );
}
bCheckWithInvertProj = CSLTestBoolean(CPLGetConfigOption( "CHECK_WITH_INVERT_PROJ", "NO" ));
/* The threshold is rather experimental... Works well with the cases of ticket #2305 */
if (bSourceLatLong)
dfThreshold = atof(CPLGetConfigOption( "THRESHOLD", ".1" ));
else
/* 1 works well for most projections, except for +proj=aeqd that requires */
/* a tolerance of 10000 */
dfThreshold = atof(CPLGetConfigOption( "THRESHOLD", "10000" ));
/* -------------------------------------------------------------------- */
/* Establish PROJ.4 handle for source if projection. */
/* -------------------------------------------------------------------- */
// OGRThreadSafety: The following variable is not a thread safety issue
// since the only issue is incrementing while accessing which at worse
// means debug output could be one "increment" late.
static int nDebugReportCount = 0;
char *pszSrcProj4Defn = NULL;
if( poSRSSource->exportToProj4( &pszSrcProj4Defn ) != OGRERR_NONE )
{
CPLFree( pszSrcProj4Defn );
return FALSE;
//.........这里部分代码省略.........
示例7: if
int OGRProj4CT::InitializeNoLock( OGRSpatialReference * poSourceIn,
OGRSpatialReference * poTargetIn )
{
if( poSourceIn == NULL || poTargetIn == NULL )
return FALSE;
poSRSSource = poSourceIn->Clone();
poSRSTarget = poTargetIn->Clone();
bSourceLatLong = CPL_TO_BOOL(poSRSSource->IsGeographic());
bTargetLatLong = CPL_TO_BOOL(poSRSTarget->IsGeographic());
/* -------------------------------------------------------------------- */
/* Setup source and target translations to radians for lat/long */
/* systems. */
/* -------------------------------------------------------------------- */
dfSourceToRadians = DEG_TO_RAD;
bSourceWrap = false;
dfSourceWrapLong = 0.0;
if( bSourceLatLong )
{
OGR_SRSNode *poUNITS = poSRSSource->GetAttrNode( "GEOGCS|UNIT" );
if( poUNITS && poUNITS->GetChildCount() >= 2 )
{
dfSourceToRadians = CPLAtof(poUNITS->GetChild(1)->GetValue());
if( dfSourceToRadians == 0.0 )
dfSourceToRadians = DEG_TO_RAD;
}
}
dfTargetFromRadians = RAD_TO_DEG;
bTargetWrap = false;
dfTargetWrapLong = 0.0;
if( bTargetLatLong )
{
OGR_SRSNode *poUNITS = poSRSTarget->GetAttrNode( "GEOGCS|UNIT" );
if( poUNITS && poUNITS->GetChildCount() >= 2 )
{
double dfTargetToRadians = CPLAtof(poUNITS->GetChild(1)->GetValue());
if( dfTargetToRadians != 0.0 )
dfTargetFromRadians = 1 / dfTargetToRadians;
}
}
/* -------------------------------------------------------------------- */
/* Preliminary logic to setup wrapping. */
/* -------------------------------------------------------------------- */
if( CPLGetConfigOption( "CENTER_LONG", NULL ) != NULL )
{
bSourceWrap = true;
bTargetWrap = true;
dfSourceWrapLong = dfTargetWrapLong =
CPLAtof(CPLGetConfigOption( "CENTER_LONG", "" ));
CPLDebug( "OGRCT", "Wrap at %g.", dfSourceWrapLong );
}
const char *pszCENTER_LONG =
poSRSSource->GetExtension( "GEOGCS", "CENTER_LONG" );
if( pszCENTER_LONG != NULL )
{
dfSourceWrapLong = CPLAtof(pszCENTER_LONG);
bSourceWrap = true;
CPLDebug( "OGRCT", "Wrap source at %g.", dfSourceWrapLong );
}
pszCENTER_LONG = poSRSTarget->GetExtension( "GEOGCS", "CENTER_LONG" );
if( pszCENTER_LONG != NULL )
{
dfTargetWrapLong = CPLAtof(pszCENTER_LONG);
bTargetWrap = true;
CPLDebug( "OGRCT", "Wrap target at %g.", dfTargetWrapLong );
}
bCheckWithInvertProj =
CPLTestBool(CPLGetConfigOption( "CHECK_WITH_INVERT_PROJ", "NO" ));
// The threshold is experimental. Works well with the cases of ticket #2305.
if( bSourceLatLong )
dfThreshold = CPLAtof(CPLGetConfigOption( "THRESHOLD", ".1" ));
else
// 1 works well for most projections, except for +proj=aeqd that
// requires a tolerance of 10000.
dfThreshold = CPLAtof(CPLGetConfigOption( "THRESHOLD", "10000" ));
// OGRThreadSafety: The following variable is not a thread safety issue
// since the only issue is incrementing while accessing which at worse
// means debug output could be one "increment" late.
static int nDebugReportCount = 0;
char *pszSrcProj4Defn = NULL;
if( poSRSSource->exportToProj4( &pszSrcProj4Defn ) != OGRERR_NONE )
{
CPLFree( pszSrcProj4Defn );
return FALSE;
}
//.........这里部分代码省略.........
示例8: toOssimKwl
bool rspfOgcWktTranslator::toOssimKwl( const rspfString& wktString,
rspfKeywordlist &kwl,
const char *prefix)const
{
static const char MODULE[] = "rspfOgcWktTranslator::toOssimKwl";
if(traceDebug())
{
rspfNotify(rspfNotifyLevel_DEBUG) << MODULE << " entered...\n";
}
const char* wkt = wktString.c_str();
OGRSpatialReferenceH hSRS = NULL;
rspfDpt falseEastingNorthing;
hSRS = OSRNewSpatialReference(NULL);
if( OSRImportFromWkt( hSRS, (char **) &wkt ) != OGRERR_NONE )
{
OSRDestroySpatialReference( hSRS );
return false;
}
rspfString rspfProj = "";
const char* epsg_code = OSRGetAttrValue( hSRS, "AUTHORITY", 1 );
if(traceDebug())
{
rspfNotify(rspfNotifyLevel_DEBUG)
<< "epsg_code: " << (epsg_code?epsg_code:"null") << "\n";
}
const char* units = NULL;
OGR_SRSNode* node = ((OGRSpatialReference *)hSRS)->GetRoot();
int nbChild = node->GetChildCount();
for (int i = 0; i < nbChild; i++)
{
OGR_SRSNode* curChild = node->GetChild(i);
if (strcmp(curChild->GetValue(), "UNIT") == 0)
{
units = curChild->GetChild(0)->GetValue();
}
}
if(traceDebug())
{
rspfNotify(rspfNotifyLevel_DEBUG)
<< "units: " << (units?units:"null") << "\n";
}
rspfString rspf_units;
bool bGeog = OSRIsGeographic(hSRS);
if ( bGeog == false )
{
rspf_units = "meters";
if ( units != NULL )
{
rspfString s = units;
s.downcase();
if( ( s == rspfString("us survey foot") ) ||
( s == rspfString("u.s. foot") ) ||
( s == rspfString("foot_us") ) )
{
rspf_units = "us_survey_feet";
}
else if( s == rspfString("degree") )
{
rspf_units = "degrees";
}
else if( ( s == rspfString("meter") ) ||
( s == rspfString("metre") ) )
{
rspf_units = "meters";
}
}
}
else
{
rspf_units = "degrees";
}
if(traceDebug())
{
rspfNotify(rspfNotifyLevel_DEBUG)
<< "rspf_units: " << rspf_units << "\n";
}
if (epsg_code)
{
rspfString epsg_spec ("EPSG:");
epsg_spec += rspfString::toString(epsg_code);
rspfProjection* proj = rspfEpsgProjectionFactory::instance()->createProjection(epsg_spec);
if (proj)
rspfProj = proj->getClassName();
delete proj;
}
if(rspfProj == "")
{
const char* pszProjection = OSRGetAttrValue( hSRS, "PROJECTION", 0 );
if(pszProjection)
{
rspfProj = wktToOssimProjection(pszProjection);
}
else
//.........这里部分代码省略.........