本文整理汇总了C++中OGRGeometry::toPoint方法的典型用法代码示例。如果您正苦于以下问题:C++ OGRGeometry::toPoint方法的具体用法?C++ OGRGeometry::toPoint怎么用?C++ OGRGeometry::toPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OGRGeometry
的用法示例。
在下文中一共展示了OGRGeometry::toPoint方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
OGRFeature *OGRSEGUKOOALineLayer::GetNextRawFeature()
{
if( bEOF )
return nullptr;
/* Merge points of base layer that have same value for attribute(0) */
/* into a single linestring */
OGRFeature* poFeature = nullptr;
OGRLineString* poLS = nullptr;
if (poNextBaseFeature == nullptr)
poNextBaseFeature = poBaseLayer->GetNextFeature();
while(poNextBaseFeature != nullptr)
{
if (poNextBaseFeature->IsFieldSetAndNotNull(0) &&
poNextBaseFeature->GetFieldAsString(0)[0] != '\0')
{
if (poFeature != nullptr &&
strcmp(poFeature->GetFieldAsString(0),
poNextBaseFeature->GetFieldAsString(0)) != 0)
{
poFeature->SetGeometryDirectly(poLS);
return poFeature;
}
OGRGeometry* poGeom =
poNextBaseFeature->GetGeometryRef();
OGRPoint* poPoint = poGeom ? poGeom->toPoint(): nullptr;
if (poPoint != nullptr)
{
if (poFeature == nullptr)
{
poFeature = new OGRFeature(poFeatureDefn);
poFeature->SetFID(nNextFID ++);
poFeature->SetField(0,
poNextBaseFeature->GetFieldAsString(0));
poLS = new OGRLineString();
if (poBaseLayer->GetSpatialRef())
poLS->assignSpatialReference(
poBaseLayer->GetSpatialRef());
}
poLS->addPoint(poPoint);
}
}
delete poNextBaseFeature;
poNextBaseFeature = poBaseLayer->GetNextFeature();
}
bEOF = true;
if( poFeature )
poFeature->SetGeometryDirectly(poLS);
return poFeature;
}
示例2: ICreateFeature
OGRErr GTMWaypointLayer::ICreateFeature (OGRFeature *poFeature)
{
VSILFILE* fp = poDS->getOutputFP();
if (fp == nullptr)
return OGRERR_FAILURE;
OGRGeometry *poGeom = poFeature->GetGeometryRef();
if ( poGeom == nullptr )
{
CPLError( CE_Failure, CPLE_AppDefined,
"Features without geometry not supported by GTM writer in waypoints layer." );
return OGRERR_FAILURE;
}
if (nullptr != poCT)
{
poGeom = poGeom->clone();
poGeom->transform( poCT );
}
switch( poGeom->getGeometryType() )
{
case wkbPoint:
case wkbPoint25D:
{
OGRPoint* point = poGeom->toPoint();
double lat = point->getY();
double lon = point->getX();
CheckAndFixCoordinatesValidity(lat, lon);
poDS->checkBounds((float)lat, (float)lon);
writeDouble(fp, lat);
writeDouble(fp, lon);
float altitude = 0.0;
if (poGeom->getGeometryType() == wkbPoint25D)
altitude = (float) point->getZ();
WriteFeatureAttributes(poFeature, altitude);
break;
}
default:
{
CPLError( CE_Failure, CPLE_NotSupported,
"Geometry type of `%s' not supported for 'waypoint' element.\n",
OGRGeometryTypeToName(poGeom->getGeometryType()) );
return OGRERR_FAILURE;
}
}
if (nullptr != poCT)
delete poGeom;
return OGRERR_NONE;
}
示例3: if
OGRErr OGRILI1Layer::ICreateFeature( OGRFeature *poFeature ) {
// FIXME: tid not thread safe
static long tid = -1; //system generated TID (must be unique within table)
VSILFILE* fp = poDS->GetTransferFile();
VSIFPrintfL( fp, "OBJE" );
if ( poFeatureDefn->GetFieldCount() &&
!EQUAL(poFeatureDefn->GetFieldDefn(0)->GetNameRef(), "TID") )
{
//Input is not generated from an Interlis 1 source
if (poFeature->GetFID() != OGRNullFID)
tid = (int)poFeature->GetFID();
else
++tid;
VSIFPrintfL( fp, " %ld", tid );
//Embedded geometry
if( poFeature->GetGeometryRef() != nullptr )
{
OGRGeometry *poGeometry = poFeature->GetGeometryRef();
// 2D Point
if( poGeometry->getGeometryType() == wkbPoint )
{
OGRPoint *poPoint = poGeometry->toPoint();
VSIFPrintfL( fp, " %s",
d2str(poPoint->getX()) );
VSIFPrintfL( fp, " %s",
d2str(poPoint->getY()) );
}
// 3D Point
else if( poGeometry->getGeometryType() == wkbPoint25D )
{
OGRPoint *poPoint = poGeometry->toPoint();
VSIFPrintfL( fp, " %s",
d2str(poPoint->getX()) );
VSIFPrintfL( fp, " %s",
d2str(poPoint->getY()) );
VSIFPrintfL( fp, " %s",
d2str(poPoint->getZ()) );
}
}
}
// Write all fields.
for( int iField = 0; iField < poFeatureDefn->GetFieldCount(); iField++ )
{
if ( poFeature->IsFieldSetAndNotNull( iField ) )
{
const char *pszRaw = poFeature->GetFieldAsString( iField );
if (poFeatureDefn->GetFieldDefn( iField )->GetType() == OFTString) {
//Interlis 1 encoding is ISO 8859-1 (Latin1) -> Recode from UTF-8
char* pszString
= CPLRecode( pszRaw, CPL_ENC_UTF8, CPL_ENC_ISO8859_1 );
//Replace spaces
for(size_t i=0; i<strlen(pszString); i++ ) {
if (pszString[i] == ' ') pszString[i] = '_';
}
VSIFPrintfL( fp, " %s", pszString );
CPLFree( pszString );
} else {
VSIFPrintfL( fp, " %s", pszRaw );
}
}
else
{
VSIFPrintfL( fp, " @" );
}
}
VSIFPrintfL( fp, "\n" );
// Write out Geometry
if( poFeature->GetGeometryRef() != nullptr )
{
GeometryAppend(poFeature->GetGeometryRef());
}
return OGRERR_NONE;
}