当前位置: 首页>>代码示例>>C++>>正文


C++ OGRLinearRing::getNumPoints方法代码示例

本文整理汇总了C++中OGRLinearRing::getNumPoints方法的典型用法代码示例。如果您正苦于以下问题:C++ OGRLinearRing::getNumPoints方法的具体用法?C++ OGRLinearRing::getNumPoints怎么用?C++ OGRLinearRing::getNumPoints使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OGRLinearRing的用法示例。


在下文中一共展示了OGRLinearRing::getNumPoints方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: convert_polygon

void ogr_converter::convert_polygon(OGRPolygon* geom, feature_ptr feature)
{
    OGRLinearRing* exterior = geom->getExteriorRing();
    int num_points = exterior->getNumPoints();
    int num_interior = geom->getNumInteriorRings();
    int capacity = 0;
    for (int r = 0; r < num_interior; ++r)
    {
        OGRLinearRing* interior = geom->getInteriorRing(r);
        capacity += interior->getNumPoints();
    }

    std::auto_ptr<geometry_type> poly(new geometry_type(mapnik::Polygon));

    poly->move_to(exterior->getX(0), exterior->getY(0));
    for (int i = 1; i < num_points - 1; ++i)
    {
        poly->line_to(exterior->getX(i), exterior->getY(i));
    }
    poly->close(exterior->getX(num_points-1), exterior->getY(num_points-1));
    for (int r = 0; r < num_interior; ++r)
    {
        OGRLinearRing* interior = geom->getInteriorRing(r);
        num_points = interior->getNumPoints();
        poly->move_to(interior->getX(0), interior->getY(0));
        for (int i = 1; i < num_points - 1; ++i)
        {
            poly->line_to(interior->getX(i), interior->getY(i));
        }
        poly->close(interior->getX(num_points-1), interior->getY(num_points-1));
    }
    feature->paths().push_back(poly);
}
开发者ID:Jeff885,项目名称:mapnik,代码行数:33,代码来源:ogr_converter.cpp

示例2: convert_polygon

void ogr_converter::convert_polygon(OGRPolygon* geom, feature_ptr feature)
{
    OGRLinearRing* exterior = geom->getExteriorRing();
    int num_points = exterior->getNumPoints();
    int num_interior = geom->getNumInteriorRings();
    int capacity = 0;
    for (int r = 0; r < num_interior; r++)
    {
        OGRLinearRing* interior = geom->getInteriorRing(r);
        capacity += interior->getNumPoints();
    }
    geometry_type* poly = new geometry_type(mapnik::Polygon);
    poly->move_to(exterior->getX(0), exterior->getY(0));
    for (int i = 1; i < num_points; ++i)
    {
        poly->line_to(exterior->getX(i), exterior->getY(i));
    }
    for (int r = 0; r < num_interior; r++)
    {
        OGRLinearRing* interior = geom->getInteriorRing(r);
        num_points = interior->getNumPoints();
        poly->move_to(interior->getX(0), interior->getY(0));
        for (int i = 1; i < num_points; ++i)
        {
            poly->line_to(interior->getX(i), interior->getY(i));
        }
    }
    feature->add_geometry(poly);
}
开发者ID:novldp,项目名称:mapnik,代码行数:29,代码来源:ogr_converter.cpp

示例3: GeomToPoly

Polygon GeomToPoly(OGRGeometry* geometry){
  OGRLinearRing *ring = dynamic_cast<OGRLinearRing *>(dynamic_cast<OGRPolygon *>(geometry)->getExteriorRing());
  Polygon skeleton;
  for(int i=0; i < ring->getNumPoints() - 1; i++)
    if(CGAL::is_finite(ring->getX(i)) && CGAL::is_finite(ring->getY(i)))
      skeleton.push_back(Point(ring->getX(i), ring->getY(i)));
  return skeleton;
}
开发者ID:thejefflarson,项目名称:skeletonize,代码行数:8,代码来源:skeleton.cpp

示例4: SetGeometry

/*!
  \brief Set feature geometry

  Also checks if given geometry is valid

  \param poGeom pointer to OGRGeometry

  \return TRUE on valid feature or otherwise FALSE
*/
bool IVFKFeature::SetGeometry(OGRGeometry *poGeom)
{
    m_bGeometry = TRUE;

    delete m_paGeom;
    m_paGeom = NULL;
    m_bValid = TRUE;

    if (!poGeom) {
	return m_bValid;
    }

    /* check empty geometries */
    if (m_nGeometryType == wkbNone && poGeom->IsEmpty()) {
	CPLDebug("OGR-VFK", "%s: empty geometry fid = %ld",
		 m_poDataBlock->GetName(), m_nFID);
        m_bValid = FALSE;
    }
    
    /* check coordinates */
    if (m_nGeometryType == wkbPoint) {
        double x, y;
        x = ((OGRPoint *) poGeom)->getX();
        y = ((OGRPoint *) poGeom)->getY();
        if (x > -430000 || x < -910000 ||
            y > -930000 || y < -1230000) {
            CPLDebug("OGR-VFK", "%s: invalid point fid = %ld",
                     m_poDataBlock->GetName(), m_nFID);
            m_bValid = FALSE;
        }
    }

    /* check degenerated linestrings */
    if (m_nGeometryType == wkbLineString &&
        ((OGRLineString *) poGeom)->getNumPoints() < 2) {
        CPLDebug("OGR-VFK", "%s: invalid linestring fid = %ld",
		 m_poDataBlock->GetName(), m_nFID);
        m_bValid = FALSE;
    }
    
    /* check degenerated polygons */
    if (m_nGeometryType == wkbPolygon) {
        OGRLinearRing *poRing;
        poRing = ((OGRPolygon *) poGeom)->getExteriorRing();
        if (!poRing || poRing->getNumPoints() < 3) {
	    CPLDebug("OGR-VFK", "%s: invalid polygon fid = %ld",
		     m_poDataBlock->GetName(), m_nFID);
            m_bValid = FALSE;
	}
    }

    if (m_bValid)
        m_paGeom = (OGRGeometry *) poGeom->clone(); /* make copy */

    return m_bValid;
}
开发者ID:samalone,项目名称:gdal-ios,代码行数:65,代码来源:vfkfeature.cpp

示例5: polygonToDrawable

    osg::Geometry* polygonToDrawable(OGRPolygon* polygon) const
    {
        osg::Geometry* geom = new osg::Geometry();
        osg::Vec3Array* vertices = new osg::Vec3Array();
        geom->setVertexArray(vertices);
        {
            OGRLinearRing *ring = polygon->getExteriorRing();
            OGRPoint point;
            for(int i = 0; i < ring->getNumPoints(); i++)
            {
                ring->getPoint(i, &point);
                vertices->push_back(osg::Vec3(point.getX(), point.getY(), point.getZ()));
            }
            geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINE_LOOP, 0, vertices->size()));
        }

        if (polygon->getNumInteriorRings())
        {
            for (int i = 0; i < polygon->getNumInteriorRings(); i++)
            {
                OGRLinearRing *ring = polygon->getInteriorRing(i);
                OGRPoint point;
                for (int j = 0; j < ring->getNumPoints(); j++)
                {
                    ring->getPoint(j, &point);
                    vertices->push_back(osg::Vec3(point.getX(), point.getY(), point.getZ()));
                }
                geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINE_LOOP, vertices->size()-ring->getNumPoints() , ring->getNumPoints()));
            }
        }
        osgUtil::Tessellator tsl;
        tsl.setTessellationType(osgUtil::Tessellator::TESS_TYPE_GEOMETRY);
        tsl.setBoundaryOnly(false);
        tsl.retessellatePolygons(*geom);

        osg::Vec3Array* array = triangulizeGeometry(geom);
        geom->setVertexArray(array);
        geom->removePrimitiveSet(0,geom->getNumPrimitiveSets());
        geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::TRIANGLES, 0, array->size()));

        return geom;
    }
开发者ID:Kurdakov,项目名称:emscripten_OSG,代码行数:42,代码来源:ReaderWriterOGR.cpp

示例6: extrude_envelope

Surface* Building::extrude_envelope() const
{
    Surface* envelope = new Surface(SurfaceType::Envelope,0,_length,_width,_height);

    OGRLinearRing* ringFt = _footprint->getExteriorRing();
    if(ringFt->isClockwise())
         adjust_winding_ccw(ringFt);

    envelope->addChild(new Surface(SurfaceType::Footprint,_footprint,_length,_width,0.));
    //extrude roof
    OGRLinearRing* ringRoof = new OGRLinearRing;
    for(int i=0; i<ringFt->getNumPoints(); i++)
        ringRoof->addPoint(ringFt->getX(i),ringFt->getY(i),_height);

    OGRPolygon plyRoof;
    plyRoof.addRingDirectly(ringRoof);

    envelope->addChild(new Surface(SurfaceType::Roof,&plyRoof,_length,_width,0.));

    //extrude walls
    for(int i=0; i<ringFt->getNumPoints()-1; i++)
    {
        OGRLinearRing* ringWall = new OGRLinearRing;
        ringWall->addPoint(ringFt->getX(i),ringFt->getY(i),0);
        ringWall->addPoint(ringFt->getX(i+1),ringFt->getY(i+1),0);
        ringWall->addPoint(ringFt->getX(i+1),ringFt->getY(i+1),_height);
        ringWall->addPoint(ringFt->getX(i),ringFt->getY(i),_height);
        ringWall->addPoint(ringFt->getX(i),ringFt->getY(i),0);

        OGRPolygon plyWall;
        plyWall.addRingDirectly(ringWall);

        OGRPoint pt1(ringFt->getX(i),ringFt->getY(i),0);
        OGRPoint pt2(ringFt->getX(i+1),ringFt->getY(i+1),0);

        envelope->addChild(new Wall(&plyWall,pt1.Distance(&pt2),_height,&pt1,&pt2));

    }

    return envelope;
}
开发者ID:HEShuang,项目名称:BuildUP,代码行数:41,代码来源:Building.cpp

示例7: extrude

osg::ref_ptr<osg::Group> MapExtruder::osg_assemble()
{
  	osg::ref_ptr<osg::Group> osg = new osg::Group;
	osg::ref_ptr<osg::Node> surface = osgDB::readNodeFile(_map2dFile);

	ExtrudeVisitor extrude(_height);
	surface->accept(extrude);
	osg->addChild(surface);

	int n = _sides ->getNumGeometries();
	osg::ref_ptr<osg::Geode> geode = new osg::Geode;			


	for(int i=0;i<n;i++)
	{
		osg::ref_ptr<osg::Geometry> geom = new osg::Geometry;
		osg::ref_ptr<osg::Vec3Array> verts = new osg::Vec3Array;

		std::vector<OGRPoint> points;
		OGRLinearRing *ring = ((OGRPolygon*)_sides->getGeometryRef(i))->getExteriorRing();
		int m = ring->getNumPoints();
		for(int j=0;j<m;j++)
		{
			OGRPoint pt;
			ring->getPoint(j,&pt);
			verts->push_back(osg::Vec3(pt.getX(),pt.getY(),pt.getZ()));
		}

		geom->setVertexArray(verts);
	
		osg::Vec4Array* colors = new osg::Vec4Array;
		colors->push_back(YELLOW);
		geom->setColorArray(colors);
		geom->setColorBinding(osg::Geometry::BIND_OVERALL);
    

		geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::POLYGON,0,m));
		geode->addDrawable(geom);
	}
	
	osg->addChild(geode);

	return osg;
}
开发者ID:HEShuang,项目名称:3DCityLoD,代码行数:44,代码来源:MapExtruder.cpp

示例8: pdal_error

std::vector<Polygon::Ring> Polygon::interiorRings() const
{
    std::vector<Ring> rings;

    OGRwkbGeometryType t = m_geom->getGeometryType();
    if (t != wkbPolygon && t != wkbPolygon25D)
        throw pdal_error("Request for exterior ring on non-polygon.");

//    OGRPolygon *poly = m_geom->toPolygon();
     OGRPolygon *poly = static_cast<OGRPolygon *>(m_geom.get());
    for (int i = 0; i < poly->getNumInteriorRings(); ++i)
    {
        OGRLinearRing *er = poly->getInteriorRing(i);

        Ring r;
        for (int j = 0; j < er->getNumPoints(); ++j)
            r.push_back({er->getX(j), er->getY(j)});
        rings.push_back(r);
    }
    return rings;
}
开发者ID:PDAL,项目名称:PDAL,代码行数:21,代码来源:Polygon.cpp

示例9: extrusion

void MapExtruder::extrusion()
{
	_sides = new OGRMultiPolygon();

	int n = _map2d->getNumGeometries();
	for(int i=0;i<n;i++)
	{

		OGRLinearRing* ring = ((OGRPolygon*)_map2d->getGeometryRef(i))->getExteriorRing();
		ring->closeRings();
		int nPoints = ring->getNumPoints();


		for(int j=0;j<nPoints-1;j++)
		{
			
			OGRPolygon side;
			OGRLinearRing* ring_side = new OGRLinearRing();

			OGRPoint p1,p4;

			ring->getPoint(j,&p1);
			ring->getPoint(j+1,&p4);

			OGRPoint p2(p1.getX(),p1.getY(),_height);
			OGRPoint p3(p4.getX(),p4.getY(),_height);
			
			
	
			ring_side->addPoint(&p1);			
		    ring_side->addPoint(&p2);
			ring_side->addPoint(&p3);
			ring_side->addPoint(&p4);
			ring_side->addPoint(&p1);

			side.addRing(ring_side);
			_sides->addGeometry(&side);
		}
	}
}
开发者ID:HEShuang,项目名称:3DCityLoD,代码行数:40,代码来源:MapExtruder.cpp

示例10: SurfacicGraphics

MultiPolygonGraphics::MultiPolygonGraphics(OGRMultiPolygon* OGRMultiPoly, const QPen& Pen, const QBrush& Brush):
  SurfacicGraphics(Brush.color())
{
  QPainterPath Path;

  for (int i=0; i<OGRMultiPoly->getNumGeometries();i++)
  {

    OGRLinearRing* LinearRing = dynamic_cast<OGRPolygon*>(OGRMultiPoly->getGeometryRef(i))->getExteriorRing();

    QPolygonF Poly;

    for (int i=0; i < LinearRing->getNumPoints(); i++)
      Poly << QPointF(LinearRing->getX(i),LinearRing->getY(i));

    Path.addPolygon(Poly);
  }

  setPen(Pen);
  setBrush(Brush);

  setPath(Path);
}
开发者ID:jylfc0307,项目名称:OpenFluidPlus,代码行数:23,代码来源:MultiPolygonGraphics.cpp

示例11: OGRLinearRing

Footprint::Footprint(OGRLinearRing* r):_index(-1),_visited(false),_degenerated(false),_altitude(0),_height(0)
{
	if(r->IsEmpty())
		std::cerr<<"Footprint constructor error: empty ring"<<std::endl;
	
	// create polygon with clockwise exterior ring
	OGRLinearRing * ring = new OGRLinearRing(r);
	remove_colinear_edges(ring);
	
	if(ring->getNumPoints()>3)
		adjust_winding(ring,ClockWise);
	else
		_degenerated = true;

	_polygon = new OGRPolygon();
	_polygon->addRingDirectly(ring);	

   	_polygon = new OGRPolygon();
	_polygon->addRing(r);
	_polygon->closeRings();
	

}	
开发者ID:HEShuang,项目名称:3DCityLoD,代码行数:23,代码来源:Footprint.cpp

示例12: exteriorRing

Polygon::Ring Polygon::exteriorRing() const
{
    Ring r;

    OGRwkbGeometryType t = m_geom->getGeometryType();
    if (t != wkbPolygon && t != wkbPolygon25D)
        throw pdal_error("Request for exterior ring on non-polygon.");

    // Not until GDAL 2.3
    /**
    OGRLinearRing *er = m_geom->toPolygon()->getExteriorRing();

    // For some reason there's no operator -> on an iterator.
    for (auto it = er->begin(); it != er->end(); ++it)
        r.push_back({(*it).getX(), (*it).getY()});
    **/
    OGRLinearRing *er =
        static_cast<OGRPolygon *>(m_geom.get())->getExteriorRing();
    for (int i = 0; i < er->getNumPoints(); ++i)
        r.push_back({er->getX(i), er->getY(i)});

    return r;
}
开发者ID:PDAL,项目名称:PDAL,代码行数:23,代码来源:Polygon.cpp

示例13: OGRGetCentroid

int OGRGetCentroid(OGRPolygon *poPoly, OGRPoint *poCentroid)
{
    int i,j;
    double cent_weight_x=0.0, cent_weight_y=0.0;
    double len, total_len=0;

    for(i=0; i<OGR_NUM_RINGS(poPoly); i++) 
    {
        double x1, y1, x2, y2;
        OGRLinearRing *poRing = OGR_GET_RING(poPoly, i);

        x2 = poRing->getX(0);
        y2 = poRing->getY(0);

        for(j=1; j<poRing->getNumPoints(); j++) 
        {
            x1 = x2;
            y1 = y2;
            x2 = poRing->getX(j);
            y2 = poRing->getY(j);

            len = sqrt( pow((x2-x1),2) + pow((y2-y1),2) );
            cent_weight_x += len * ((x1 + x2)/2.0);
            cent_weight_y += len * ((y1 + y2)/2.0);
            total_len += len;
        }
    }

    if(total_len == 0)
        return(OGRERR_FAILURE);

    poCentroid->setX( cent_weight_x / total_len );
    poCentroid->setY( cent_weight_y / total_len );
  
    return OGRERR_NONE;
}
开发者ID:brunosimoes,项目名称:WorldWind,代码行数:36,代码来源:mitab_geometry.cpp

示例14: extrude_box

OGRMultiPolygon* Building::extrude_box() const
{
    OGRMultiPolygon* block = new OGRMultiPolygon;

    //extrude roof
    OGRPolygon roof;
    {
        roof.addRing(_footprint->getExteriorRing());
        OGRLinearRing* ring = roof.getExteriorRing();
        for(int i=0; i<ring->getNumPoints(); i++)
            ring->setPoint(i,ring->getX(i),ring->getY(i),_height);
    }

    if(int n = _footprint->getNumInteriorRings())
    {
        for (int j=0; j<n; j++)
        {
            roof.addRing(_footprint->getInteriorRing(j));
            OGRLinearRing* ring = roof.getInteriorRing(j);
            for(int i=0; i<ring->getNumPoints(); i++)
                ring->setPoint(i,ring->getX(i),ring->getY(i),_height);
        }
    }

    block->addGeometry(&roof);

    //extrude exter walls
    OGRLinearRing* ringEx = _footprint->getExteriorRing();
    for(int i=0; i<ringEx->getNumPoints()-1; i++)
    {
        OGRPolygon wall;
        OGRLinearRing ring;
        ring.addPoint(ringEx->getX(i),ringEx->getY(i),0);
        ring.addPoint(ringEx->getX(i+1),ringEx->getY(i+1),0);
        ring.addPoint(ringEx->getX(i+1),ringEx->getY(i+1),_height);
        ring.addPoint(ringEx->getX(i),ringEx->getY(i),_height);
        ring.addPoint(ringEx->getX(i),ringEx->getY(i),0);
        wall.addRing(&ring);
        block->addGeometry(&wall);
    }

    //extrude inner walls if exist
    if(int n = _footprint->getNumInteriorRings())
    {
        for (int i=0; i<n; i++)
        {
            OGRLinearRing* ringIn = _footprint->getInteriorRing(i);
            for(int j=0; j<ringIn->getNumPoints()-1; j++)
            {
                OGRPolygon wall;
                OGRLinearRing ring;
                ring.addPoint(ringIn->getX(j),ringIn->getY(j),0);
                ring.addPoint(ringIn->getX(j+1),ringIn->getY(j+1),0);
                ring.addPoint(ringIn->getX(j+1),ringIn->getY(j+1),_height);
                ring.addPoint(ringIn->getX(j),ringIn->getY(j),_height);
                ring.addPoint(ringIn->getX(j),ringIn->getY(j),0);
                wall.addRing(&ring);
                block->addGeometry(&wall);
            }
        }
    }


    return block;

}
开发者ID:HEShuang,项目名称:BuildUP,代码行数:66,代码来源:Building.cpp

示例15: OGRBuildPolygonFromEdges

OGRGeometryH OGRBuildPolygonFromEdges( OGRGeometryH hLines,
                                       int bBestEffort,
                                       int bAutoClose,
                                       double dfTolerance,
                                       OGRErr * peErr )

{
    int         bSuccess = TRUE;
    OGRGeometryCollection *poLines = (OGRGeometryCollection *) hLines;
    OGRPolygon  *poPolygon = new OGRPolygon();

    (void) bBestEffort;

/* -------------------------------------------------------------------- */
/*      Setup array of line markers indicating if they have been        */
/*      added to a ring yet.                                            */
/* -------------------------------------------------------------------- */
    int         nEdges = poLines->getNumGeometries();
    int         *panEdgeConsumed, nRemainingEdges = nEdges;

    panEdgeConsumed = (int *) CPLCalloc(sizeof(int),nEdges);

/* ==================================================================== */
/*      Loop generating rings.                                          */
/* ==================================================================== */
    while( nRemainingEdges > 0 )
    {
        int             iEdge;
        OGRLineString   *poLine;

/* -------------------------------------------------------------------- */
/*      Find the first unconsumed edge.                                 */
/* -------------------------------------------------------------------- */
        for( iEdge = 0; panEdgeConsumed[iEdge]; iEdge++ ) {}

        poLine = (OGRLineString *) poLines->getGeometryRef(iEdge);

/* -------------------------------------------------------------------- */
/*      Start a new ring, copying in the current line directly          */
/* -------------------------------------------------------------------- */
        OGRLinearRing   *poRing = new OGRLinearRing();

        AddEdgeToRing( poRing, poLine, FALSE );

        panEdgeConsumed[iEdge] = TRUE;
        nRemainingEdges--;

/* ==================================================================== */
/*      Loop adding edges to this ring until we make a whole pass       */
/*      within finding anything to add.                                 */
/* ==================================================================== */
        int             bWorkDone = TRUE;
        double          dfBestDist = dfTolerance;

        while( !CheckPoints(poRing,0,poRing,poRing->getNumPoints()-1,NULL)
               && nRemainingEdges > 0
               && bWorkDone )
        {
            int         iBestEdge = -1, bReverse = FALSE;

            bWorkDone = FALSE;
            dfBestDist = dfTolerance;

            // We consider linking the end to the beginning.  If this is
            // closer than any other option we will just close the loop.

            //CheckPoints(poRing,0,poRing,poRing->getNumPoints()-1,&dfBestDist);

            // Find unused edge with end point closest to our loose end.
            for( iEdge = 0; iEdge < nEdges; iEdge++ )
            {
                if( panEdgeConsumed[iEdge] )
                    continue;

                poLine = (OGRLineString *) poLines->getGeometryRef(iEdge);

                if( CheckPoints(poLine,0,poRing,poRing->getNumPoints()-1,
                                &dfBestDist) )
                {
                    iBestEdge = iEdge;
                    bReverse = FALSE;
                }
                if( CheckPoints(poLine,poLine->getNumPoints()-1,
                                poRing,poRing->getNumPoints()-1,
                                &dfBestDist) )
                {
                    iBestEdge = iEdge;
                    bReverse = TRUE;
                }
            }

            // We found one within tolerance - add it.
            if( iBestEdge != -1 )
            {
                poLine = (OGRLineString *)
                    poLines->getGeometryRef(iBestEdge);

                AddEdgeToRing( poRing, poLine, bReverse );

                panEdgeConsumed[iBestEdge] = TRUE;
//.........这里部分代码省略.........
开发者ID:AluOne,项目名称:OpenCPN,代码行数:101,代码来源:ograssemblepolygon.cpp


注:本文中的OGRLinearRing::getNumPoints方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。