• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ geom::Geometry类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中geom::Geometry的典型用法代码示例。如果您正苦于以下问题:C++ Geometry类的具体用法?C++ Geometry怎么用?C++ Geometry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: createFactory

/* private */
auto_ptr<Geometry>
GeometryPrecisionReducer::fixPolygonalTopology(const geom::Geometry& geom )
{
  /**
   * If precision model was *not* changed, need to flip
   * geometry to targetPM, buffer in that model, then flip back
   */
  auto_ptr<Geometry> tmp;
  auto_ptr<GeometryFactory> tmpFactory;

  const Geometry* geomToBuffer = &geom;

  if ( ! newFactory ) {
    tmpFactory = createFactory(*geom.getFactory(), targetPM);
    tmp.reset( tmpFactory->createGeometry(&geom) );
    geomToBuffer = tmp.get();
  }

  auto_ptr<Geometry> bufGeom ( geomToBuffer->buffer(0) );

  if ( ! newFactory ) {
    // a slick way to copy the geometry with the original precision factory
    bufGeom.reset( geom.getFactory()->createGeometry(bufGeom.get()) );
  }

  return bufGeom;
}
开发者ID:52North,项目名称:IlwisCore,代码行数:28,代码来源:GeometryPrecisionReducer.cpp


示例2: checkSingleSidedBufferSuccess

static int
checkSingleSidedBufferSuccess(geom::Geometry& gRes,
        geom::Geometry& gRealRes, double dist)
{
    int success = 1;
    do
    {

        if ( gRes.getGeometryTypeId() != gRealRes.getGeometryTypeId() )
        {
            std::cerr << "Expected result is of type "
                << gRes.getGeometryType()
                << "; obtained result is of type "
                << gRealRes.getGeometryType()
                << std::endl;
            success=0;
            break;
        }

        geos::xmltester::SingleSidedBufferResultMatcher matcher;
        if ( ! matcher.isBufferResultMatch(gRealRes,
                           gRes,
                           dist) )
        {
std::cerr << "SingleSidedBufferResultMatcher FAILED" << std::endl;
            success=0;
            break;
        }

    }
    while (0);

    return success;
}
开发者ID:cumtmyf,项目名称:MFC_Viewer,代码行数:34,代码来源:XMLTester.cpp


示例3: actualBdy

bool
BufferResultMatcher::isBoundaryHausdorffDistanceInTolerance(
	const geom::Geometry& actualBuffer,
	const geom::Geometry& expectedBuffer, double distance)
{
	typedef std::auto_ptr<geom::Geometry> GeomPtr;

	using geos::algorithm::distance::DiscreteHausdorffDistance;

	GeomPtr actualBdy ( actualBuffer.getBoundary() );
	GeomPtr expectedBdy ( expectedBuffer.getBoundary() );

	DiscreteHausdorffDistance haus(*actualBdy, *expectedBdy);
	haus.setDensifyFraction(0.25);

	double maxDistanceFound = haus.orientedDistance();

	double expectedDistanceTol = fabs(distance) / MAX_HAUSDORFF_DISTANCE_FACTOR;
	if (expectedDistanceTol < MIN_DISTANCE_TOLERANCE)
	{
		expectedDistanceTol = MIN_DISTANCE_TOLERANCE;
	}

	if (maxDistanceFound > expectedDistanceTol)
	{
std::cerr << "maxDistanceFound: " << maxDistanceFound << " tolerated " << expectedDistanceTol << std::endl;
		return false;
	}

	return true;
}
开发者ID:BlueEyes-Lin,项目名称:sunmap,代码行数:31,代码来源:BufferResultMatcher.cpp


示例4:

bool
BufferResultMatcher::isBufferResultMatch(const geom::Geometry& actualBuffer,
	                         const geom::Geometry& expectedBuffer,
	                         double distance)
{
	if (actualBuffer.isEmpty() && expectedBuffer.isEmpty())
		return true;

	/**
	 * MD - need some more checks here - symDiffArea won't catch
	 * very small holes ("tears")
	 * near the edge of computed buffers (which can happen
	 * in current version of JTS (1.8)).
	 * This can probably be handled by testing
	 * that every point of the actual buffer is at least a certain
	 * distance away from the geometry boundary.
	 */
	if (! isSymDiffAreaInTolerance(actualBuffer, expectedBuffer))
	{
std::cerr << "isSymDiffAreaInTolerance failed" << std::endl;
		return false;
	}

	if (! isBoundaryHausdorffDistanceInTolerance(actualBuffer,
	           expectedBuffer, distance))
	{
std::cerr << "isBoundaryHasudorffDistanceInTolerance failed" << std::endl;
		return false;
	}

	return true;
}
开发者ID:BlueEyes-Lin,项目名称:sunmap,代码行数:32,代码来源:BufferResultMatcher.cpp


示例5: return

bool
AbstractPreparedPolygonContains::isSingleShell( const geom::Geometry & geom)
{
    // handles single-element MultiPolygons, as well as Polygons
    if ( geom.getNumGeometries() != 1)
        return false;

    const geom::Polygon * poly = (Polygon *)geom.getGeometryN( 0);

    int numHoles = poly->getNumInteriorRing();
    return (numHoles == 0);
}
开发者ID:asapnet,项目名称:geos,代码行数:12,代码来源:AbstractPreparedPolygonContains.cpp


示例6:

/* private */
void
SnapOverlayOp::removeCommonBits(const geom::Geometry& geom0,
                                const geom::Geometry& geom1,
				geom::GeomPtrPair& remGeom)
{
	cbr.reset(new precision::CommonBitsRemover());
	cbr->add(&geom0);
	cbr->add(&geom1);

	remGeom.first.reset( cbr->removeCommonBits(geom0.clone()) );
	remGeom.second.reset( cbr->removeCommonBits(geom1.clone()) );
}
开发者ID:52North,项目名称:IlwisCore,代码行数:13,代码来源:SnapOverlayOp.cpp


示例7:

bool 
AbstractPreparedPolygonContains::isSingleShell(const geom::Geometry& geom)
{
	// handles single-element MultiPolygons, as well as Polygons
	if (geom.getNumGeometries() != 1)
    {
		return false;
    }
	
    const geom::Geometry* g = geom.getGeometryN(0);
	const geom::Polygon* poly = static_cast<const Polygon*>(g);

    std::size_t numHoles = poly->getNumInteriorRing();
	return (0 == numHoles);
}
开发者ID:lozpeng,项目名称:applesales,代码行数:15,代码来源:AbstractPreparedPolygonContains.cpp


示例8: visitor

bool
RectangleIntersects::intersects(const geom::Geometry& geom)
{
	if (!rectEnv.intersects(geom.getEnvelopeInternal()))
		return false;

	// test envelope relationships
	EnvelopeIntersectsVisitor visitor(rectEnv);
	visitor.applyTo(geom);
	if (visitor.intersects()) return true;

	// test if any rectangle corner is contained in the target
	ContainsPointVisitor ecpVisitor(rectangle);
	ecpVisitor.applyTo(geom);
	if (ecpVisitor.containsPoint())
		return true;

	// test if any lines intersect
	LineIntersectsVisitor liVisitor(rectangle);
	liVisitor.applyTo(geom);
	if (liVisitor.intersects())
		return true;

	return false;
}
开发者ID:lozpeng,项目名称:applesales,代码行数:25,代码来源:RectangleIntersects.cpp


示例9: BinaryOp

bool
BufferResultMatcher::isSymDiffAreaInTolerance(
	const geom::Geometry& actualBuffer,
	const geom::Geometry& expectedBuffer)
{
	typedef std::auto_ptr<geom::Geometry> GeomPtr;

	using namespace operation::overlay;
	using geos::geom::BinaryOp;

	double area = expectedBuffer.getArea();
	GeomPtr diff = BinaryOp(&actualBuffer, &expectedBuffer,
	                   overlayOp(OverlayOp::opSYMDIFFERENCE));

	double areaDiff = diff->getArea();
	
	// can't get closer than difference area = 0 ! 
	// This also handles case when symDiff is empty
	if (areaDiff <= 0.0) return true;

	if (area <= 0) return false; 
	double frac = areaDiff / area;

	bool ret = frac < MAX_RELATIVE_AREA_DIFFERENCE;
	if ( ! ret )
	{
std::cerr << "symDiffArea frac: " << frac << " tolerated " << MAX_RELATIVE_AREA_DIFFERENCE << std::endl;
	}
	return ret;
}
开发者ID:BlueEyes-Lin,项目名称:sunmap,代码行数:30,代码来源:BufferResultMatcher.cpp


示例10: visit

	void visit(const geom::Geometry &geom)
	{
		using GEOMETRY::algorithm::locate::SimplePointInAreaLocator;

		const geom::Polygon *poly;

		if ( !(poly=dynamic_cast<const geom::Polygon *>(&geom)) ) {
			return;
		}

		const geom::Envelope &elementEnv = *(geom.getEnvelopeInternal());

		if ( !rectEnv.intersects(elementEnv) ) {
			return;
		}

		// test each corner of rectangle for inclusion
		for (int i=0; i<4; i++)
		{

			const geom::Coordinate &rectPt=rectSeq.getAt(i);

			if ( !elementEnv.contains(rectPt) ) {
				continue;
			}

			// check rect point in poly (rect is known not to
			// touch polygon at this point)
			if ( SimplePointInAreaLocator::containsPointInPolygon(rectPt, poly) )
			{
				containsPointVar=true;
				return;
			}
		}
	}
开发者ID:lozpeng,项目名称:applesales,代码行数:35,代码来源:RectangleIntersects.cpp


示例11: ex

/* private static */
void
GeometryNoder::extractSegmentStrings(const geom::Geometry& g,
                                     SegmentString::NonConstVect& to)
{
  SegmentStringExtractor ex(to);
	g.apply_ro(&ex);
}
开发者ID:Joe-xXx,项目名称:geos,代码行数:8,代码来源:GeometryNoder.cpp


示例12: if

/* public static */
void
DistanceToPoint::computeDistance(const geom::Geometry& geom,
                                          const geom::Coordinate& pt,
                                          PointPairDistance& ptDist)
{
	if ( const LineString* ls = dynamic_cast<const LineString*>(&geom) )
	{
		computeDistance(*ls, pt, ptDist);
	}
	else if ( const Polygon* pl = dynamic_cast<const Polygon*>(&geom) )
	{
		computeDistance(*pl, pt, ptDist);
	}
	else if ( const GeometryCollection* gc = dynamic_cast<const GeometryCollection*>(&geom) )
	{
		for (size_t i = 0; i < gc->getNumGeometries(); i++)
		{
			const Geometry* g = gc->getGeometryN(i);
			computeDistance(*g, pt, ptDist);
		}
	}
	else
	{
		// assume geom is Point
		ptDist.setMinimum(*(geom.getCoordinate()), pt);
	}
}
开发者ID:aaronr,项目名称:geos,代码行数:28,代码来源:DistanceToPoint.cpp


示例13:

/*public static*/
double
GeometrySnapper::computeSizeBasedSnapTolerance(const geom::Geometry& g)
{
	const Envelope* env = g.getEnvelopeInternal();
	double minDimension = (std::min)(env->getHeight(), env->getWidth());
	double snapTol = minDimension * snapPrecisionFactor;
	return snapTol;
}
开发者ID:drownedout,项目名称:datamap,代码行数:9,代码来源:GeometrySnapper.cpp


示例14: checkBufferSuccess

/* Could be an XMLTester class private but oh well.. */
static int
checkBufferSuccess(geom::Geometry const& gRes, geom::Geometry const& gRealRes, double dist)
{
    int success = 1;
    do
    {

        if ( gRes.getGeometryTypeId() != gRealRes.getGeometryTypeId() )
        {
            std::cerr << "Expected result is of type "
                << gRes.getGeometryType()
                << "; obtained result is of type "
                << gRealRes.getGeometryType()
                << std::endl;
            success=0;
            break;
        }

        // Is a buffer always an area ?
        if ( gRes.getDimension() != 2 )
        {
            std::cerr << "Don't know how to validate "
                << "result of buffer operation "
                << "when expected result is not an "
                << "areal type."
                << std::endl;
        }
        

        geos::xmltester::BufferResultMatcher matcher;
        if ( ! matcher.isBufferResultMatch(gRealRes,
                           gRes,
                           dist) )
        {
std::cerr << "BufferResultMatcher FAILED" << std::endl;
            success=0;
            break;
        }

    }
    while (0);

    return success;
}
开发者ID:cumtmyf,项目名称:MFC_Viewer,代码行数:45,代码来源:XMLTester.cpp


示例15: checkLinealInput

/* public */
SharedPathsOp::SharedPathsOp(
    const geom::Geometry& g1, const geom::Geometry& g2)
  :
  _g1(g1),
  _g2(g2),
  _gf(*g1.getFactory())
{
  checkLinealInput(_g1);
  checkLinealInput(_g2);
}
开发者ID:AvlWx2014,项目名称:basemap,代码行数:11,代码来源:SharedPathsOp.cpp


示例16: failed

bool
SingleSidedBufferResultMatcher::isBufferResultMatch(const geom::Geometry& actualBuffer,
	                         const geom::Geometry& expectedBuffer,
	                         double distance)
{
	bool aEmpty = actualBuffer.isEmpty();
	bool eEmpty = expectedBuffer.isEmpty();

	// Both empty succeeds
	if (aEmpty && eEmpty) return true;

	// One empty and not the other is a failure
	if (aEmpty || eEmpty)
	{
std::cerr << "isBufferResultMatch failed (one empty and one not)" << std::endl;
		return false;
	}


   // NOTE: we need to test hausdorff distance in both directions

	if (! isBoundaryHausdorffDistanceInTolerance(actualBuffer,
	           expectedBuffer, distance))
	{
std::cerr << "isBoundaryHasudorffDistanceInTolerance failed (actual,expected)" << std::endl;
		return false;
	}

	if (! isBoundaryHausdorffDistanceInTolerance(expectedBuffer,
	           actualBuffer, distance))
	{
std::cerr << "isBoundaryHasudorffDistanceInTolerance failed (expected,actual)" << std::endl;
		return false;
	}

	return true;
}
开发者ID:h4ck3rm1k3,项目名称:geos,代码行数:37,代码来源:SingleSidedBufferResultMatcher.cpp


示例17: computeSizeBasedSnapTolerance

/*public static*/
double
GeometrySnapper::computeOverlaySnapTolerance(const geom::Geometry& g)
{
	double snapTolerance = computeSizeBasedSnapTolerance(g);

	/**
	 * Overlay is carried out in the precision model
	 * of the two inputs.
	 * If this precision model is of type FIXED, then the snap tolerance
	 * must reflect the precision grid size.
	 * Specifically, the snap tolerance should be at least
	 * the distance from a corner of a precision grid cell
	 * to the centre point of the cell.
	 */
	assert(g.getPrecisionModel());
	const PrecisionModel& pm = *(g.getPrecisionModel());
	if (pm.getType() == PrecisionModel::FIXED)
	{
		double fixedSnapTol = (1 / pm.getScale()) * 2 / 1.415;
		if ( fixedSnapTol > snapTolerance )
			snapTolerance = fixedSnapTol;
	}
	return snapTolerance;
}
开发者ID:drownedout,项目名称:datamap,代码行数:25,代码来源:GeometrySnapper.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ geom::OptRect类代码示例发布时间:2022-05-31
下一篇:
C++ geom::Affine类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap