本文整理汇总了C++中OGRGeometry::getGeometryType方法的典型用法代码示例。如果您正苦于以下问题:C++ OGRGeometry::getGeometryType方法的具体用法?C++ OGRGeometry::getGeometryType怎么用?C++ OGRGeometry::getGeometryType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OGRGeometry
的用法示例。
在下文中一共展示了OGRGeometry::getGeometryType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GDBGeometryToOGRGeometry
bool GDBGeometryToOGRGeometry(bool forceMulti, FileGDBAPI::ShapeBuffer* pGdbGeometry,
OGRSpatialReference* pOGRSR, OGRGeometry** ppOutGeometry)
{
OGRGeometry* pOGRGeometry = NULL;
OGRErr eErr = OGRCreateFromShapeBin( pGdbGeometry->shapeBuffer,
&pOGRGeometry,
pGdbGeometry->inUseLength);
//OGRErr eErr = OGRGeometryFactory::createFromWkb(pGdbGeometry->shapeBuffer, pOGRSR, &pOGRGeometry, pGdbGeometry->inUseLength );
if (eErr != OGRERR_NONE)
{
CPLError( CE_Failure, CPLE_AppDefined, "Failed attempting to import GDB WKB Geometry. OGRGeometryFactory err:%d", eErr);
return false;
}
if( pOGRGeometry != NULL )
{
// force geometries to multi if requested
// If it is a polygon, force to MultiPolygon since we always produce multipolygons
if (wkbFlatten(pOGRGeometry->getGeometryType()) == wkbPolygon)
{
pOGRGeometry = OGRGeometryFactory::forceToMultiPolygon(pOGRGeometry);
}
else if (forceMulti)
{
if (wkbFlatten(pOGRGeometry->getGeometryType()) == wkbLineString)
{
pOGRGeometry = OGRGeometryFactory::forceToMultiLineString(pOGRGeometry);
}
else if (wkbFlatten(pOGRGeometry->getGeometryType()) == wkbPoint)
{
pOGRGeometry = OGRGeometryFactory::forceToMultiPoint(pOGRGeometry);
}
}
if (pOGRGeometry)
pOGRGeometry->assignSpatialReference( pOGRSR );
}
*ppOutGeometry = pOGRGeometry;
return true;
}
示例2: GDBGeometryToOGRGeometry
bool GDBGeometryToOGRGeometry(bool forceMulti, FileGDBAPI::ShapeBuffer* pGdbGeometry,
OGRSpatialReference* pOGRSR, OGRGeometry** ppOutGeometry)
{
OGRGeometry* pOGRGeometry = nullptr;
OGRErr eErr = OGRCreateFromShapeBin( pGdbGeometry->shapeBuffer,
&pOGRGeometry,
static_cast<int>(pGdbGeometry->inUseLength));
//OGRErr eErr = OGRGeometryFactory::createFromWkb(pGdbGeometry->shapeBuffer, pOGRSR, &pOGRGeometry, pGdbGeometry->inUseLength );
if (eErr != OGRERR_NONE)
{
CPLError( CE_Failure, CPLE_AppDefined, "Failed attempting to import GDB WKB Geometry. OGRGeometryFactory err:%d", eErr);
return false;
}
if( pOGRGeometry != nullptr )
{
// force geometries to multi if requested
// If it is a polygon, force to MultiPolygon since we always produce multipolygons
OGRwkbGeometryType eFlattenType = wkbFlatten(pOGRGeometry->getGeometryType());
if (eFlattenType == wkbPolygon)
{
pOGRGeometry = OGRGeometryFactory::forceToMultiPolygon(pOGRGeometry);
}
else if (eFlattenType == wkbCurvePolygon)
{
OGRMultiSurface* poMS = new OGRMultiSurface();
poMS->addGeometryDirectly( pOGRGeometry );
pOGRGeometry = poMS;
}
else if (forceMulti)
{
if (eFlattenType == wkbLineString)
{
pOGRGeometry = OGRGeometryFactory::forceToMultiLineString(pOGRGeometry);
}
else if (eFlattenType == wkbCompoundCurve)
{
OGRMultiCurve* poMC = new OGRMultiCurve();
poMC->addGeometryDirectly( pOGRGeometry );
pOGRGeometry = poMC;
}
else if (eFlattenType == wkbPoint)
{
pOGRGeometry = OGRGeometryFactory::forceToMultiPoint(pOGRGeometry);
}
}
if (pOGRGeometry)
pOGRGeometry->assignSpatialReference( pOGRSR );
}
*ppOutGeometry = pOGRGeometry;
return true;
}
示例3: getBBoxOfShape
/** @brief Extract bounding box from shape
*
* get bounding box as OGREnvelope from polygon shape in OGRFeature
*/
OGREnvelope* getBBoxOfShape(OGRFeature* poFeature)
{
OGRGeometry *poGeometry;
poGeometry = poFeature->GetGeometryRef();
cout <<"extracting shape of " << poFeature->GetFieldAsString(1) << endl;
if (poGeometry != NULL
&& wkbFlatten(poGeometry->getGeometryType()) == wkbPolygon)
{
OGRPolygon *poPoly = (OGRPolygon *) poGeometry;
OGREnvelope *poEnv = new OGREnvelope();
poPoly->getEnvelope(poEnv);
return poEnv;
// ofstream outfile ("outfile.kml");
// double s = poEnv->MaxY;
// double n = poEnv->MinY;
// double e = poEnv->MaxX;
// double w = poEnv->MinX;
//
// cout<< s << ", " << n << " to " << e << ", " << w << endl;
// outfile.close();
// cout << poPoint->getX() <<", "<<poPoint->getY()<<endl;
}
else
{
cout << "No point Geometry"<<endl;
return NULL;
}
}
示例4: multiPointToDrawable
osg::Geometry* multiPointToDrawable(OGRMultiPoint* mpoint) const
{
osg::Geometry* geom = new osg::Geometry;
osg::Geometry* pointGeom = new osg::Geometry();
osg::Vec3Array* vertices = new osg::Vec3Array();
vertices->reserve(mpoint->getNumGeometries());
for (int i = 0; i < mpoint->getNumGeometries(); i++ )
{
OGRGeometry* ogrGeom = mpoint->getGeometryRef(i);
OGRwkbGeometryType ogrGeomType = ogrGeom->getGeometryType();
if (wkbPoint != ogrGeomType && wkbPoint25D != ogrGeomType)
continue; // skip
OGRPoint* points = static_cast<OGRPoint*>(ogrGeom);
vertices->push_back(osg::Vec3(points->getX(), points->getY(), points->getZ()));
}
pointGeom->setVertexArray(vertices);
pointGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::POINTS, 0, vertices->size()));
if (pointGeom->getVertexArray())
{
OSG_INFO << "osgOgrFeature::multiPointToDrawable " << geom->getVertexArray()->getNumElements() << " vertexes"<< std::endl;
}
return pointGeom;
}
示例5: DetectGeometryType
void OGRGeoJSONLayer::DetectGeometryType()
{
if (poFeatureDefn_->GetGeomType() != wkbUnknown)
return;
OGRwkbGeometryType featType = wkbUnknown;
OGRGeometry* poGeometry = NULL;
FeaturesSeq::const_iterator it = seqFeatures_.begin();
FeaturesSeq::const_iterator end = seqFeatures_.end();
if( it != end )
{
poGeometry = (*it)->GetGeometryRef();
if( NULL != poGeometry )
{
featType = poGeometry->getGeometryType();
if( featType != poFeatureDefn_->GetGeomType() )
{
poFeatureDefn_->SetGeomType( featType );
}
}
++it;
}
while( it != end )
{
poGeometry = (*it)->GetGeometryRef();
if( NULL != poGeometry )
{
featType = poGeometry->getGeometryType();
if( featType != poFeatureDefn_->GetGeomType() )
{
CPLDebug( "GeoJSON",
"Detected layer of mixed-geometry type features." );
poFeatureDefn_->SetGeomType( DefaultGeometryType );
break;
}
}
++it;
}
}
示例6: multiPolygonToDrawable
osg::Geometry* multiPolygonToDrawable(OGRMultiPolygon* mpolygon) const
{
osg::Geometry* geom = new osg::Geometry;
for (int i = 0; i < mpolygon->getNumGeometries(); i++ )
{
OGRGeometry* ogrGeom = mpolygon->getGeometryRef(i);
OGRwkbGeometryType ogrGeomType = ogrGeom->getGeometryType();
if (wkbPolygon != ogrGeomType && wkbPolygon25D != ogrGeomType)
continue; // skip
OGRPolygon* polygon = static_cast<OGRPolygon*>(ogrGeom);
osg::ref_ptr<osg::Drawable> drw = polygonToDrawable(polygon);
osg::ref_ptr<osg::Geometry> geometry = drw->asGeometry();
if (geometry.valid() && geometry->getVertexArray() &&
geometry->getVertexArray()->getNumElements() &&
geometry->getNumPrimitiveSets() &&
geometry->getVertexArray()->getType() == osg::Array::Vec3ArrayType )
{
if (!geom->getVertexArray())
{ // no yet data we put the first in
geom->setVertexArray(geometry->getVertexArray());
geom->setPrimitiveSetList(geometry->getPrimitiveSetList());
}
else
{ // already a polygon then append
int size = geom->getVertexArray()->getNumElements();
osg::Vec3Array* arrayDst = static_cast<osg::Vec3Array*>(geom->getVertexArray());
osg::ref_ptr<osg::Vec3Array> triangulized = triangulizeGeometry(geometry.get());
if (triangulized.valid())
{
arrayDst->insert(arrayDst->end(), triangulized->begin(), triangulized->end());
// shift index
geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::TRIANGLES, size, triangulized->size()));
}
}
}
else
{
OSG_WARN << "Warning something wrong with a polygon in a multi polygon" << std::endl;
}
}
if (geom->getVertexArray())
{
OSG_INFO << "osgOgrFeature::multiPolygonToDrawable " << geom->getVertexArray()->getNumElements() << " vertexes"<< std::endl;
}
return geom;
}
示例7: run
void GDALMergeFaces::run()
{
OGRGeometry * geo;
leadingView.resetReading();
OGRFeature * f;
std::set<int> indizes;
while (f = leadingView.getNextFeature()) {
indizes.insert(f->GetFieldAsInteger(this->attriubteName.c_str()));
}
//int cluster_id = 1;
int counter = 1;
foreach (int cluster_id, indizes) {
//while(geo = joinCluster(cluster_id)) {
//cluster_id++;
geo = joinCluster(cluster_id);
if (counter % 100 == 0) {
DM::Logger(DM::Standard) << "merged " << counter << "/" << indizes.size();
}
counter++;
if (!geo)
continue;
if (wkbMultiPolygon == geo->getGeometryType()){
geo = geo->UnionCascaded();
OGRMultiPolygon * mgeo = (OGRMultiPolygon*) geo;
if (mgeo->getNumGeometries() == 0) {
continue;
}
geo = mgeo->getGeometryRef(0);
int n = mgeo->getNumGeometries();
for (int i = 0; i < n; i++) {
OGRFeature * f = combinedView.createFeature();
f->SetGeometry(mgeo->getGeometryRef(i));
f->SetField("test_id", counter);
}
continue;
}
OGRFeature * f = combinedView.createFeature();
f->SetGeometry(geo);
}
示例8: PointOnSurface
int OGRPolygon::PointOnSurface( OGRPoint *poPoint ) const
{
if( poPoint == NULL )
return OGRERR_FAILURE;
#ifndef HAVE_GEOS
return OGRERR_FAILURE;
#else
GEOSGeom hThisGeosGeom = NULL;
GEOSGeom hOtherGeosGeom = NULL;
hThisGeosGeom = exportToGEOS();
if( hThisGeosGeom != NULL )
{
hOtherGeosGeom = GEOSPointOnSurface( hThisGeosGeom );
GEOSGeom_destroy( hThisGeosGeom );
if( hOtherGeosGeom == NULL )
return OGRERR_FAILURE;
OGRGeometry *poInsidePointGeom = (OGRGeometry *)
OGRGeometryFactory::createFromGEOS( hOtherGeosGeom );
GEOSGeom_destroy( hOtherGeosGeom );
if (poInsidePointGeom == NULL)
return OGRERR_FAILURE;
if (wkbFlatten(poInsidePointGeom->getGeometryType()) != wkbPoint)
{
delete poInsidePointGeom;
return OGRERR_FAILURE;
}
OGRPoint *poInsidePoint = (OGRPoint *) poInsidePointGeom;
poPoint->setX( poInsidePoint->getX() );
poPoint->setY( poInsidePoint->getY() );
delete poInsidePointGeom;
return OGRERR_NONE;
}
else
{
return OGRERR_FAILURE;
}
#endif /* HAVE_GEOS */
}
示例9: get_Length
double OGRGeometryCollection::get_Length() const
{
double dfLength = 0.0;
for( int iGeom = 0; iGeom < nGeomCount; iGeom++ )
{
OGRGeometry* geom = papoGeoms[iGeom];
OGRwkbGeometryType eType = wkbFlatten(geom->getGeometryType());
if( OGR_GT_IsCurve(eType) )
{
dfLength += ((OGRCurve *) geom)->get_Length();
}
else if( OGR_GT_IsSubClassOf(eType, wkbMultiCurve) ||
eType == wkbGeometryCollection )
{
dfLength += ((OGRGeometryCollection *) geom)->get_Length();
}
}
return dfLength;
}
示例10: readMultiPolygon
/**
* 複数のポリゴンから成るオブジェクトを読み込む。
* 今の実装は、正確には対応していない。オブジェクトのpartsに順次格納していくだけ。
* そのため、アプリケーション側でparts[0]しか使わない場合、まずい。
*/
void Shape::readMultiPolygon(OGRMultiPolygon* poMultiPolygon, ShapeObject& shapeObject) {
int numGeometries = poMultiPolygon->getNumGeometries();
int partsIndex = 0;
for (int i = 0; i < numGeometries; ++i) {
OGRGeometry* geo = poMultiPolygon->getGeometryRef(i);
if (wkbFlatten(geo->getGeometryType()) == wkbPolygon) {
OGRPolygon* poPolygon = (OGRPolygon*)geo;
int nInteriorRings = poPolygon->getNumInteriorRings();
shapeObject.parts.resize(shapeObject.parts.size() + nInteriorRings + 1);
OGRLinearRing* ring = poPolygon->getExteriorRing();
readRing(ring, shapeObject.parts[partsIndex++]);
for (int j = 0; j < nInteriorRings; ++j) {
OGRLinearRing* ring = poPolygon->getInteriorRing(j);
readRing(ring, shapeObject.parts[partsIndex++]);
}
}
}
}
示例11: multiLineStringToDrawable
osg::Geometry* multiLineStringToDrawable(OGRMultiLineString* mlineString) const
{
osg::Geometry* geom = new osg::Geometry;
for (int i = 0; i < mlineString->getNumGeometries(); i++ )
{
OGRGeometry* ogrGeom = mlineString->getGeometryRef(i);
OGRwkbGeometryType ogrGeomType = ogrGeom->getGeometryType();
if (wkbLineString != ogrGeomType && wkbLineString25D != ogrGeomType)
continue; // skip
OGRLineString* lineString = static_cast<OGRLineString*>(ogrGeom);
osg::ref_ptr<osg::Geometry> geometry = lineStringToDrawable(lineString);
if (geometry.valid() &&
geometry->getVertexArray() &&
geometry->getNumPrimitiveSets() &&
geometry->getVertexArray()->getType() == osg::Array::Vec3ArrayType)
{
if (!geom->getVertexArray())
{
geom->setVertexArray(geometry->getVertexArray());
geom->setPrimitiveSetList(geometry->getPrimitiveSetList());
}
else
{
int size = geom->getVertexArray()->getNumElements();
osg::Vec3Array* arraySrc = static_cast<osg::Vec3Array*>(geometry->getVertexArray());
osg::Vec3Array* arrayDst = static_cast<osg::Vec3Array*>(geom->getVertexArray());
arrayDst->insert(arrayDst->end(), arraySrc->begin(), arraySrc->end());
// shift index
geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINE_STRIP, size, arraySrc->size()));
}
}
}
return geom;
}
示例12: get_Area
double OGRGeometryCollection::get_Area() const
{
double dfArea = 0.0;
for( int iGeom = 0; iGeom < nGeomCount; iGeom++ )
{
OGRGeometry* geom = papoGeoms[iGeom];
switch( wkbFlatten(geom->getGeometryType()) )
{
case wkbPolygon:
dfArea += ((OGRPolygon *) geom)->get_Area();
break;
case wkbMultiPolygon:
dfArea += ((OGRMultiPolygon *) geom)->get_Area();
break;
case wkbLinearRing:
case wkbLineString:
/* This test below is required to filter out wkbLineString geometries
* not being of type of wkbLinearRing.
*/
if( EQUAL( ((OGRGeometry*) geom)->getGeometryName(), "LINEARRING" ) )
{
dfArea += ((OGRLinearRing *) geom)->get_Area();
}
break;
case wkbGeometryCollection:
dfArea +=((OGRGeometryCollection *) geom)->get_Area();
break;
default:
break;
}
}
return dfArea;
}
示例13: line2end_points
void line2end_points(std::vector<unsigned char> &wkb, OGRPoint *firstlast){
OGRGeometryFactory gf;
OGRGeometry *gg;
int ret = gf.createFromWkb( (unsigned char *)&wkb[0], NULL, &gg);
if (ret != OGRERR_NONE ){
std::cout << "Invalid geometry";
return;
}
if (gg->getGeometryType() != wkbLineString ){
OGRGeometryFactory::destroyGeometry(gg);
std::cout << "Geometry must be a LINESTRING" << std::endl;
return;
}
OGRLineString *ls = (OGRLineString *)gg;
ls->StartPoint(firstlast);
ls->EndPoint(firstlast+1);
//free allocated memory
OGRGeometryFactory::destroyGeometry(gg);
}
示例14: get_Length
double OGRGeometryCollection::get_Length() const
{
double dfLength = 0.0;
for( int iGeom = 0; iGeom < nGeomCount; iGeom++ )
{
OGRGeometry* geom = papoGeoms[iGeom];
switch( wkbFlatten(geom->getGeometryType()) )
{
case wkbLinearRing:
case wkbLineString:
dfLength += ((OGRCurve *) geom)->get_Length();
break;
case wkbGeometryCollection:
dfLength +=((OGRGeometryCollection *) geom)->get_Length();
break;
default:
break;
}
}
return dfLength;
}
示例15: ISetFeature
OGRErr OGRPCIDSKLayer::ISetFeature( OGRFeature *poFeature )
{
PCIDSK::ShapeId id = (PCIDSK::ShapeId) poFeature->GetFID();
/* -------------------------------------------------------------------- */
/* Translate attribute fields. */
/* -------------------------------------------------------------------- */
try {
int iPCI;
std::vector<PCIDSK::ShapeField> aoPCIFields;
aoPCIFields.resize(poVecSeg->GetFieldCount());
for( iPCI = 0; iPCI < poVecSeg->GetFieldCount(); iPCI++ )
{
int iOGR;
iOGR = poFeatureDefn->GetFieldIndex(
poVecSeg->GetFieldName(iPCI).c_str() );
if( iOGR == -1 )
continue;
switch( poVecSeg->GetFieldType(iPCI) )
{
case PCIDSK::FieldTypeInteger:
aoPCIFields[iPCI].SetValue(
poFeature->GetFieldAsInteger( iOGR ) );
break;
case PCIDSK::FieldTypeFloat:
aoPCIFields[iPCI].SetValue(
(float) poFeature->GetFieldAsDouble( iOGR ) );
break;
case PCIDSK::FieldTypeDouble:
aoPCIFields[iPCI].SetValue(
(double) poFeature->GetFieldAsDouble( iOGR ) );
break;
case PCIDSK::FieldTypeString:
aoPCIFields[iPCI].SetValue(
poFeature->GetFieldAsString( iOGR ) );
break;
case PCIDSK::FieldTypeCountedInt:
{
int nCount;
const int *panList =
poFeature->GetFieldAsIntegerList( iOGR, &nCount );
std::vector<PCIDSK::int32> anList;
anList.resize( nCount );
memcpy( &(anList[0]), panList, 4 * anList.size() );
aoPCIFields[iPCI].SetValue( anList );
}
break;
default:
CPLAssert( FALSE );
break;
}
}
if( poVecSeg->GetFieldCount() > 0 )
poVecSeg->SetFields( id, aoPCIFields );
/* -------------------------------------------------------------------- */
/* Translate the geometry. */
/* -------------------------------------------------------------------- */
std::vector<PCIDSK::ShapeVertex> aoVertices;
OGRGeometry *poGeometry = poFeature->GetGeometryRef();
if( poGeometry == NULL )
{
}
else if( wkbFlatten(poGeometry->getGeometryType()) == wkbPoint )
{
OGRPoint *poPoint = (OGRPoint *) poGeometry;
aoVertices.resize(1);
aoVertices[0].x = poPoint->getX();
aoVertices[0].y = poPoint->getY();
aoVertices[0].z = poPoint->getZ();
}
else if( wkbFlatten(poGeometry->getGeometryType()) == wkbLineString )
{
OGRLineString *poLS = (OGRLineString *) poGeometry;
unsigned int i;
aoVertices.resize(poLS->getNumPoints());
for( i = 0; i < aoVertices.size(); i++ )
{
aoVertices[i].x = poLS->getX(i);
aoVertices[i].y = poLS->getY(i);
//.........这里部分代码省略.........