本文整理汇总了C++中OGRGeometry::toLineString方法的典型用法代码示例。如果您正苦于以下问题:C++ OGRGeometry::toLineString方法的具体用法?C++ OGRGeometry::toLineString怎么用?C++ OGRGeometry::toLineString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OGRGeometry
的用法示例。
在下文中一共展示了OGRGeometry::toLineString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ICreateFeature
OGRErr GTMTrackLayer::ICreateFeature (OGRFeature *poFeature)
{
VSILFILE* fpTmpTrackpoints = poDS->getTmpTrackpointsFP();
if (fpTmpTrackpoints == nullptr)
return OGRERR_FAILURE;
VSILFILE* fpTmpTracks = poDS->getTmpTracksFP();
if (fpTmpTracks == 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 "
"track layer." );
return OGRERR_FAILURE;
}
if (nullptr != poCT)
{
poGeom = poGeom->clone();
poGeom->transform( poCT );
}
switch( poGeom->getGeometryType() )
{
case wkbLineString:
case wkbLineString25D:
{
WriteFeatureAttributes(poFeature);
OGRLineString* line = poGeom->toLineString();
for(int i = 0; i < line->getNumPoints(); ++i)
{
double lat = line->getY(i);
double lon = line->getX(i);
float altitude = 0;
CheckAndFixCoordinatesValidity(lat, lon);
poDS->checkBounds((float)lat, (float)lon);
if (line->getGeometryType() == wkbLineString25D)
altitude = static_cast<float>(line->getZ(i));
WriteTrackpoint( lat, lon, altitude, i==0 );
}
break;
}
case wkbMultiLineString:
case wkbMultiLineString25D:
{
for( auto&& line: poGeom->toMultiLineString() )
{
WriteFeatureAttributes(poFeature);
int n = line->getNumPoints();
for(int i = 0; i < n; ++i)
{
double lat = line->getY(i);
double lon = line->getX(i);
float altitude = 0;
CheckAndFixCoordinatesValidity(lat, lon);
if (line->getGeometryType() == wkbLineString25D)
altitude = static_cast<float>(line->getZ(i));
WriteTrackpoint( lat, lon, altitude, i==0 );
}
}
break;
}
default:
{
CPLError( CE_Failure, CPLE_NotSupported,
"Geometry type of `%s' not supported for 'track' element.\n",
OGRGeometryTypeToName(poGeom->getGeometryType()) );
if (nullptr != poCT)
delete poGeom;
return OGRERR_FAILURE;
}
}
if (nullptr != poCT)
delete poGeom;
return OGRERR_NONE;
}