本文整理汇总了C++中geom::Geometry类的典型用法代码示例。如果您正苦于以下问题:C++ Geometry类的具体用法?C++ Geometry怎么用?C++ Geometry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Geometry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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()) );
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
}
}
示例11: ex
/* private static */
void
GeometryNoder::extractSegmentStrings(const geom::Geometry& g,
SegmentString::NonConstVect& to)
{
SegmentStringExtractor ex(to);
g.apply_ro(&ex);
}
示例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);
}
}
示例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;
}
示例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;
}
示例15: checkLinealInput
/* public */
SharedPathsOp::SharedPathsOp(
const geom::Geometry& g1, const geom::Geometry& g2)
:
_g1(g1),
_g2(g2),
_gf(*g1.getFactory())
{
checkLinealInput(_g1);
checkLinealInput(_g2);
}