本文整理汇总了C++中OGRFeature::SetGeometryDirectly方法的典型用法代码示例。如果您正苦于以下问题:C++ OGRFeature::SetGeometryDirectly方法的具体用法?C++ OGRFeature::SetGeometryDirectly怎么用?C++ OGRFeature::SetGeometryDirectly使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OGRFeature
的用法示例。
在下文中一共展示了OGRFeature::SetGeometryDirectly方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetNextFeature
OGRFeature* GTMWaypointLayer::GetNextFeature()
{
if( bError )
return nullptr;
while (poDS->hasNextWaypoint())
{
Waypoint* poWaypoint = poDS->fetchNextWaypoint();
if (poWaypoint == nullptr)
{
CPLError(CE_Failure, CPLE_AppDefined,
"Could not read waypoint. File probably corrupted");
bError = true;
return nullptr;
}
OGRFeature* poFeature = new OGRFeature( poFeatureDefn );
double altitude = poWaypoint->getAltitude();
if (altitude == 0.0)
poFeature->SetGeometryDirectly(new OGRPoint
(poWaypoint->getLongitude(),
poWaypoint->getLatitude()));
else
poFeature->SetGeometryDirectly(new OGRPoint
(poWaypoint->getLongitude(),
poWaypoint->getLatitude(),
altitude));
if (poSRS)
poFeature->GetGeometryRef()->assignSpatialReference(poSRS);
poFeature->SetField( NAME, poWaypoint->getName());
poFeature->SetField( COMMENT, poWaypoint->getComment());
poFeature->SetField( ICON, poWaypoint->getIcon());
GIntBig wptdate = poWaypoint->getDate();
if (wptdate != 0)
{
struct tm brokendownTime;
CPLUnixTimeToYMDHMS(wptdate, &brokendownTime);
poFeature->SetField( DATE,
brokendownTime.tm_year + 1900,
brokendownTime.tm_mon + 1,
brokendownTime.tm_mday,
brokendownTime.tm_hour,
brokendownTime.tm_min,
static_cast<float>(brokendownTime.tm_sec));
}
poFeature->SetFID( nNextFID++ );
delete poWaypoint;
if( (m_poFilterGeom == nullptr
|| FilterGeometry( poFeature->GetGeometryRef() ) )
&& (m_poAttrQuery == nullptr
|| m_poAttrQuery->Evaluate( poFeature )) )
return poFeature;
delete poFeature;
}
return nullptr;
}
示例2: OGRFeature
OGRFeature*
OGRXPlaneAirwaySegmentLayer::AddFeature(const char* pszAirwaySegmentName,
const char* pszFirstPointName,
const char* pszSecondPointName,
double dfLat1,
double dfLon1,
double dfLat2,
double dfLon2,
int bIsHigh,
int nBaseFL,
int nTopFL)
{
int nCount = 0;
OGRFeature* poFeature = new OGRFeature(poFeatureDefn);
if (fabs(dfLon1 - dfLon2) < 270)
{
OGRLineString* lineString = new OGRLineString();
lineString->addPoint(dfLon1, dfLat1);
lineString->addPoint(dfLon2, dfLat2);
poFeature->SetGeometryDirectly( lineString );
}
else
{
/* Crossing antemeridian */
OGRMultiLineString* multiLineString = new OGRMultiLineString();
OGRLineString* lineString1 = new OGRLineString();
OGRLineString* lineString2 = new OGRLineString();
double dfLatInt;
lineString1->addPoint(dfLon1, dfLat1);
if (dfLon1 < dfLon2)
{
dfLatInt = dfLat1 + (dfLat2 - dfLat1) * (-180 - dfLon1) / ((dfLon2 - 360) - dfLon1);
lineString1->addPoint(-180, dfLatInt);
lineString2->addPoint(180, dfLatInt);
}
else
{
dfLatInt = dfLat1 + (dfLat2 - dfLat1) * (180 - dfLon1) / ((dfLon2 + 360) - dfLon1);
lineString1->addPoint(180, dfLatInt);
lineString2->addPoint(-180, dfLatInt);
}
lineString2->addPoint(dfLon2, dfLat2);
multiLineString->addGeometryDirectly( lineString1 );
multiLineString->addGeometryDirectly( lineString2 );
poFeature->SetGeometryDirectly( multiLineString );
}
poFeature->SetField( nCount++, pszAirwaySegmentName );
poFeature->SetField( nCount++, pszFirstPointName );
poFeature->SetField( nCount++, pszSecondPointName );
poFeature->SetField( nCount++, bIsHigh );
poFeature->SetField( nCount++, nBaseFL );
poFeature->SetField( nCount++, nTopFL );
RegisterFeature(poFeature);
return poFeature;
}
示例3: 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;
}
示例4: VectorOpen
bool V2vProj::Compute(const data::VectorBarral * barrel)
{
OGRDataSource * poSourceDs = VectorOpen(barrel->GetSrcDataSource().c_str(),
GA_ReadOnly);
ON_SCOPE_EXIT([&]() {OGRDataSource::DestroyDataSource(poSourceDs); });
OGRDataSource * poOutputDs = VectorOpen(barrel->GetDstDataSource().c_str(),
GA_Update);
ON_SCOPE_EXIT([&]() {OGRDataSource::DestroyDataSource(poOutputDs); });
OGRLayer * poSrcLayer = poSourceDs->GetLayerByName(
barrel->GetSrcLayer().c_str());
OGRLayer * poDstLayer = poOutputDs->GetLayerByName(
barrel->GetDstLayer().c_str());
OGRSpatialReference * poSourceSRS = poSrcLayer->GetSpatialRef();
OGRCoordinateTransformation * poCT = poCT = OGRCreateCoordinateTransformation(
poSourceSRS, m_ogrSr);
OGRFeatureDefn * poDstFeatureDefn = poDstLayer->GetLayerDefn();
auto features = barrel->GetFeatures();
std::for_each(begin(features), end(features)
, [&](int fid) {
poSrcLayer->GetFeature(fid);
OGRFeature * poDstFeature = OGRFeature::CreateFeature(poDstFeatureDefn);
ON_SCOPE_EXIT([&]() {OGRFeature::DestroyFeature(poDstFeature); });
poDstFeature->SetFrom(poSrcLayer->GetFeature(fid));
OGRGeometry * poDstGeometry = poDstFeature->GetGeometryRef();
OGRGeometry * poReprojectedGeom = OGRGeometryFactory::transformWithOptions(
poDstGeometry, poCT, NULL);
poDstFeature->SetGeometryDirectly(poReprojectedGeom);
poDstLayer->CreateFeature(poDstFeature);
});
return true;
}
示例5: OGRFeature
OGRFeature*
OGRXPlaneGSLayer::AddFeature(const char* pszNavaidID,
const char* pszAptICAO,
const char* pszRwyNum,
double dfLat,
double dfLon,
double dfEle,
double dfFreq,
double dfRange,
double dfTrueHeading,
double dfSlope)
{
int nCount = 0;
OGRFeature* poFeature = new OGRFeature(poFeatureDefn);
poFeature->SetGeometryDirectly( new OGRPoint( dfLon, dfLat ) );
poFeature->SetField( nCount++, pszNavaidID );
poFeature->SetField( nCount++, pszAptICAO );
poFeature->SetField( nCount++, pszRwyNum );
poFeature->SetField( nCount++, dfEle );
poFeature->SetField( nCount++, dfFreq );
poFeature->SetField( nCount++, dfRange );
poFeature->SetField( nCount++, dfTrueHeading );
poFeature->SetField( nCount++, dfSlope );
RegisterFeature(poFeature);
return poFeature;
}
示例6: TranslateFromSrcLayer
OGRFeature* OGRUnionLayer::TranslateFromSrcLayer(OGRFeature* poSrcFeature)
{
CPLAssert(panMap != NULL);
CPLAssert(iCurLayer >= 0 && iCurLayer < nSrcLayers);
OGRFeature* poFeature = new OGRFeature(poFeatureDefn);
poFeature->SetFrom(poSrcFeature, panMap, TRUE);
if( osSourceLayerFieldName.size() &&
!poFeatureDefn->GetFieldDefn(0)->IsIgnored() )
{
poFeature->SetField(0, papoSrcLayers[iCurLayer]->GetName());
}
if( poFeatureDefn->IsGeometryIgnored() )
poFeature->SetGeometryDirectly(NULL);
else
{
OGRGeometry* poGeom = poFeature->GetGeometryRef();
if( poGeom != NULL )
poGeom->assignSpatialReference(GetSpatialRef());
}
if( bPreserveSrcFID )
poFeature->SetFID(poSrcFeature->GetFID());
else
poFeature->SetFID(nNextFID ++);
return poFeature;
}
示例7: while
OGRFeature *OGRKMLLayer::GetNextFeature()
{
#ifndef HAVE_EXPAT
return NULL;
#else
/* -------------------------------------------------------------------- */
/* Loop till we find a feature matching our criteria. */
/* -------------------------------------------------------------------- */
KML *poKMLFile = poDS_->GetKMLFile();
if( poKMLFile == NULL )
return NULL;
poKMLFile->selectLayer(nLayerNumber_);
while( true )
{
Feature *poFeatureKML = NULL;
poFeatureKML = poKMLFile->getFeature(iNextKMLId_++, nLastAsked, nLastCount);
if(poFeatureKML == NULL)
return NULL;
CPLAssert( poFeatureKML != NULL );
OGRFeature *poFeature = new OGRFeature( poFeatureDefn_ );
if(poFeatureKML->poGeom)
{
poFeature->SetGeometryDirectly(poFeatureKML->poGeom);
poFeatureKML->poGeom = NULL;
}
// Add fields
poFeature->SetField( poFeatureDefn_->GetFieldIndex("Name"), poFeatureKML->sName.c_str() );
poFeature->SetField( poFeatureDefn_->GetFieldIndex("Description"), poFeatureKML->sDescription.c_str() );
poFeature->SetFID( iNextKMLId_ - 1 );
// Clean up
delete poFeatureKML;
if( poFeature->GetGeometryRef() != NULL && poSRS_ != NULL)
{
poFeature->GetGeometryRef()->assignSpatialReference( poSRS_ );
}
/* Check spatial/attribute filters */
if ((m_poFilterGeom == NULL || FilterGeometry( poFeature->GetGeometryRef() ) ) &&
(m_poAttrQuery == NULL || m_poAttrQuery->Evaluate( poFeature )) )
{
// Return the feature
return poFeature;
}
else
{
delete poFeature;
}
}
#endif /* HAVE_EXPAT */
}
示例8: if
OGRFeature *OGROpenAirLabelLayer::GetNextRawFeature()
{
const char* pszLine;
double dfLat = 0, dfLon = 0;
int bHasCoord = FALSE;
while(TRUE)
{
pszLine = CPLReadLine2L(fpOpenAir, 1024, NULL);
if (pszLine == NULL)
return NULL;
if (pszLine[0] == '*' || pszLine[0] == '\0')
continue;
if (EQUALN(pszLine, "AC ", 3))
{
if (osCLASS.size() != 0)
{
osNAME = "";
osCEILING = "";
osFLOOR = "";
}
osCLASS = pszLine + 3;
}
else if (EQUALN(pszLine, "AN ", 3))
osNAME = pszLine + 3;
else if (EQUALN(pszLine, "AH ", 3))
osCEILING = pszLine + 3;
else if (EQUALN(pszLine, "AL ", 3))
osFLOOR = pszLine + 3;
else if (EQUALN(pszLine, "AT ", 3))
{
bHasCoord = OGROpenAirGetLatLon(pszLine + 3, dfLat, dfLon);
break;
}
}
OGRFeature* poFeature = new OGRFeature(poFeatureDefn);
poFeature->SetField(0, osCLASS.c_str());
poFeature->SetField(1, osNAME.c_str());
poFeature->SetField(2, osFLOOR.c_str());
poFeature->SetField(3, osCEILING.c_str());
CPLString osStyle;
osStyle.Printf("LABEL(t:\"%s\")", osNAME.c_str());
poFeature->SetStyleString(osStyle.c_str());
if (bHasCoord)
{
OGRPoint* poPoint = new OGRPoint(dfLon, dfLat);
poPoint->assignSpatialReference(poSRS);
poFeature->SetGeometryDirectly(poPoint);
}
poFeature->SetFID(nNextFID++);
return poFeature;
}
示例9: OGRFeature
OGRFeature * cvct2gdal::CVCT2GDALFeature( VCTFeature * poVCTFeat, OGRFeatureDefn * poOGRFeatDefn )
{
OGRFeature * poOGRFeat = new OGRFeature ( poOGRFeatDefn );
OGRGeometry * poOGRGeometry = CVCT2GDALGeometry ( poVCTFeat->geometry );
poOGRFeat->SetGeometryDirectly ( poOGRGeometry );
CVCT2GDALWriteFields ( *poVCTFeat, *poOGRFeat );
return poOGRFeat;
}
示例10: CPLError
OGRFeature *TigerPoint::GetFeature( int nRecordId,
int nX0, int nX1,
int nY0, int nY1 )
{
char achRecord[OGR_TIGER_RECBUF_LEN];
if( nRecordId < 0 || nRecordId >= nFeatures ) {
CPLError( CE_Failure, CPLE_FileIO,
"Request for out-of-range feature %d of %sP",
nRecordId, pszModule );
return nullptr;
}
/* -------------------------------------------------------------------- */
/* Read the raw record data from the file. */
/* -------------------------------------------------------------------- */
if( fpPrimary == nullptr )
return nullptr;
if( VSIFSeekL( fpPrimary, nRecordId * nRecordLength, SEEK_SET ) != 0 ) {
CPLError( CE_Failure, CPLE_FileIO,
"Failed to seek to %d of %sP",
nRecordId * nRecordLength, pszModule );
return nullptr;
}
// Overflow cannot happen since psRTInfo->nRecordLength is unsigned
// char and sizeof(achRecord) == OGR_TIGER_RECBUF_LEN > 255
if( VSIFReadL( achRecord, psRTInfo->nRecordLength, 1, fpPrimary ) != 1 ) {
CPLError( CE_Failure, CPLE_FileIO,
"Failed to read record %d of %sP",
nRecordId, pszModule );
return nullptr;
}
/* -------------------------------------------------------------------- */
/* Set fields. */
/* -------------------------------------------------------------------- */
OGRFeature *poFeature = new OGRFeature( poFeatureDefn );
SetFields( psRTInfo, poFeature, achRecord);
/* -------------------------------------------------------------------- */
/* Set geometry */
/* -------------------------------------------------------------------- */
const double dfX = atoi(GetField(achRecord, nX0, nX1)) / 1000000.0;
const double dfY = atoi(GetField(achRecord, nY0, nY1)) / 1000000.0;
if( dfX != 0.0 || dfY != 0.0 ) {
poFeature->SetGeometryDirectly( new OGRPoint( dfX, dfY ) );
}
return poFeature;
}
示例11: while
OGRFeature *OGRSEGUKOOALineLayer::GetNextRawFeature()
{
if (bEOF)
return NULL;
/* Merge points of base layer that have same value for attribute(0) */
/* into a single linestring */
OGRFeature* poFeature = NULL;
OGRLineString* poLS = NULL;
if (poNextBaseFeature == NULL)
poNextBaseFeature = poBaseLayer->GetNextFeature();
while(poNextBaseFeature != NULL)
{
if (poNextBaseFeature->IsFieldSet(0) &&
poNextBaseFeature->GetFieldAsString(0)[0] != '\0')
{
if (poFeature != NULL &&
strcmp(poFeature->GetFieldAsString(0),
poNextBaseFeature->GetFieldAsString(0)) != 0)
{
return poFeature;
}
OGRPoint* poPoint =
(OGRPoint*) poNextBaseFeature->GetGeometryRef();
if (poPoint != NULL)
{
if (poFeature == NULL)
{
poFeature = new OGRFeature(poFeatureDefn);
poFeature->SetFID(nNextFID ++);
poFeature->SetField(0,
poNextBaseFeature->GetFieldAsString(0));
poLS = new OGRLineString();
if (poBaseLayer->GetSpatialRef())
poLS->assignSpatialReference(
poBaseLayer->GetSpatialRef());
poFeature->SetGeometryDirectly(poLS);
}
poLS->addPoint(poPoint);
}
}
delete poNextBaseFeature;
poNextBaseFeature = poBaseLayer->GetNextFeature();
}
bEOF = TRUE;
return poFeature;
}
示例12: create_point_feature
OGRFeature* create_point_feature(const Osmium::OSM::Node* node) {
OGRFeature* feature = OGRFeature::CreateFeature(m_layer_point->GetLayerDefn());
Osmium::Geometry::Point point(*node);
OGRPoint* ogrgeom = Osmium::Geometry::create_ogr_geometry(point);
ogrgeom->transform(m_transformation);
feature->SetGeometryDirectly(ogrgeom);
sprintf(longint, "%ld", node->id());
feature->SetField("osm_id", longint);
feature->SetField("z_order", calculate_z_order(node));
feature->SetField("way_area", 0);
return feature;
}
示例13: create_line_feature
OGRFeature* create_line_feature(const Osmium::OSM::Way* way, OGRLayer* layer) {
OGRFeature* feature = OGRFeature::CreateFeature(layer->GetLayerDefn());
Osmium::Geometry::LineString linestring(*way);
OGRLineString* ogrgeom = Osmium::Geometry::create_ogr_geometry(linestring);
ogrgeom->transform(m_transformation);
feature->SetGeometryDirectly(ogrgeom);
sprintf(longint, "%ld", way->id());
feature->SetField("osm_id", longint);
feature->SetField("z_order", calculate_z_order(way));
feature->SetField("way_area", 0);
return feature;
}
示例14: create_area_feature
OGRFeature* create_area_feature(const shared_ptr<Osmium::OSM::Area const>& area)
{
OGRFeature* feature = OGRFeature::CreateFeature(m_layer_polygon->GetLayerDefn());
Osmium::Geometry::MultiPolygon mp(*area);
OGRMultiPolygon* ogrgeom = Osmium::Geometry::create_ogr_geometry(mp);
ogrgeom->transform(m_transformation);
feature->SetGeometryDirectly(ogrgeom);
sprintf(longint, "%ld", area->from_way() ? area->orig_id() : -area->orig_id());
feature->SetField("osm_id", longint);
feature->SetField("z_order", calculate_z_order(area.get()));
feature->SetField("way_area", ogrgeom->get_Area());
return feature;
}
示例15: while
OGRFeature *OGRAeronavFAANAVAIDLayer::GetNextRawFeature()
{
char szBuffer[134];
while( true )
{
const char* pszLine = CPLReadLine2L(fpAeronavFAA, 134, nullptr);
if (pszLine == nullptr)
{
bEOF = true;
return nullptr;
}
if (strlen(pszLine) != 132)
continue;
if ( !(pszLine[psRecordDesc->nLatStartCol-1] == 'N' ||
pszLine[psRecordDesc->nLatStartCol-1] == 'S') )
continue;
if ( !(pszLine[psRecordDesc->nLonStartCol-1] == 'E' ||
pszLine[psRecordDesc->nLonStartCol-1] == 'W') )
continue;
OGRFeature* poFeature = new OGRFeature(poFeatureDefn);
poFeature->SetFID(nNextFID ++);
for( int i=0; i < psRecordDesc->nFields; i++ )
{
int nWidth = psRecordDesc->pasFields[i].nLastCol - psRecordDesc->pasFields[i].nStartCol + 1;
strncpy(szBuffer, pszLine + psRecordDesc->pasFields[i].nStartCol - 1, nWidth);
szBuffer[nWidth] = 0;
while(nWidth > 0 && szBuffer[nWidth - 1] == ' ')
{
szBuffer[nWidth - 1] = 0;
nWidth --;
}
if (nWidth != 0)
poFeature->SetField(i, szBuffer);
}
double dfLat = 0.0;
double dfLon = 0.0;
GetLatLon(pszLine + psRecordDesc->nLatStartCol - 1,
pszLine + psRecordDesc->nLonStartCol - 1,
dfLat,
dfLon);
OGRGeometry* poGeom = new OGRPoint(dfLon, dfLat);
poGeom->assignSpatialReference(poSRS);
poFeature->SetGeometryDirectly( poGeom );
return poFeature;
}
}