本文整理汇总了C++中GeomPtr类的典型用法代码示例。如果您正苦于以下问题:C++ GeomPtr类的具体用法?C++ GeomPtr怎么用?C++ GeomPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GeomPtr类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: geom
void object::test<4>()
{
GeomPtr geom ( wktreader.read("POINT(-117 33 120)") );
std::string result;
wktwriter.setOutputDimension(2);
wktwriter.setTrim( true );
wktwriter.setOld3D( false );
result = wktwriter.write( geom.get() );
ensure_equals( result, std::string("POINT (-117 33)") );
}
示例2: ensure
void object::test<6>()
{
GeomPtr geom;
try {
geom.reset(wktreader.read("POLYGON( EMPTY, (1 1,2 2,1 2,1 1))"));
ensure( !"Didn't get expected exception" );
} catch (const geos::util::IllegalArgumentException& ex) {
ensure( "Did get expected exception" );
ex.what();
} catch (...) {
ensure( !"Got unexpected exception" );
}
}
示例3: fromWKT
void object::test<4>()
{
GeomPtr geom = fromWKT("POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1) ))");
Polygon* poly = dynamic_cast<Polygon*>(geom.get());
ensure(nullptr != poly);
const LineString* ring = poly->getInteriorRingN(0);
const LinearRing* lr = dynamic_cast<const LinearRing*>(ring);
ensure(nullptr != lr);
LinearRing* nclr = const_cast<LinearRing*>(lr);
updateNonClosedRing(*nclr);
checkIsValid(*geom, false);
}
示例4: readGeometry
GeomPtr
readGeometry(const std::string& wkt)
{
GeomPtr g;
if(wkt[0] == '0' || wkt[0] == '1') {
WKBReader r;
std::istringstream is(wkt);
g.reset(r.readHEX(is));
}
else {
WKTReader r;
g.reset(r.read(wkt));
}
return g;
}
示例5: runLineSequencer
void runLineSequencer(const char * const * inputWKT,
const std::string& expectedWKT)
{
readWKT(inputWKT, inpGeoms);
LineSequencer sequencer;
sequencer.add(inpGeoms);
if ( ! sequencer.isSequenceable() ) {
ensure( expectedWKT.empty() );
} else {
GeomPtr expected = readWKT(expectedWKT);
GeomPtr result ( sequencer.getSequencedLineStrings() );
ensure( expected->equalsExact( result.get() ) );
bool isSequenced = LineSequencer::isSequenced(result.get());
ensure( isSequenced );
}
}
示例6: CoordinateArraySequence
void object::test<1>()
{
CoordinateSequence* cs = new CoordinateArraySequence();
cs->add(Coordinate(0.0, 0.0));
cs->add(Coordinate(1.0, DoubleNotANumber));
GeomPtr line ( factory_.createLineString(cs) );
IsValidOp isValidOp(line.get());
bool valid = isValidOp.isValid();
TopologyValidationError* err = isValidOp.getValidationError();
ensure(0 != err);
const Coordinate& errCoord = err->getCoordinate();
ensure_equals( err->getErrorType(),
TopologyValidationError::eInvalidCoordinate );
ensure(0 != ISNAN(errCoord.y));
ensure_equals(valid, false);
}
示例7: p1
void object::test<13>()
{
Coordinate p1(-123456789, -40);
Coordinate p2(381039468754763.0, 123456789);
Coordinate q(0, 0);
using geos::geom::CoordinateSequence;
using geos::geom::GeometryFactory;
using geos::geom::LineString;
GeometryFactory::Ptr factory = GeometryFactory::create();
CoordinateSequence* cs = new CoordinateArraySequence();
cs->add(p1);
cs->add(p2);
GeomPtr l ( factory->createLineString(cs) );
GeomPtr p ( factory->createPoint(q) );
ensure(!l->intersects(p.get()));
ensure(!CGAlgorithms::isOnLine(q, cs));
ensure_equals(CGAlgorithms::computeOrientation(p1, p2, q), -1);
}
示例8: doClipTest
void doClipTest(const char* inputWKT, const std::string& expectedWKT, const Rectangle& rect, double tolerance=0)
{
GeomPtr g = readWKT(inputWKT);
ensure(g.get());
GeomPtr obt = RectangleIntersection::clip(*g,rect);
ensure(obt.get());
bool ok = isEqual(*readWKT(expectedWKT), *obt, tolerance);
ensure(ok);
// Compare with GEOSIntersection output
#if 0
GeomPtr g2 ( rect.toPolygon(*g->getFactory()) );
obt.reset(g->intersection(g2.get()));
ensure(obt.get());
ok = isEqual(*readWKT(expectedWKT), *obt, tolerance);
ensure(ok);
#endif
}
示例9: test_dpsimp_group
group test_dpsimp_group("geos::simplify::DouglasPeuckerSimplifier");
//
// Test Cases
//
// 1 - PolygonNoReduction
template<>
template<>
void object::test<1>()
{
std::string wkt("POLYGON((20 220, 40 220, 60 220, 80 220, 100 220, \
120 220, 140 220, 140 180, 100 180, 60 180, 20 180, 20 220))");
GeomPtr g(wktreader.read(wkt));
GeomPtr simplified = DouglasPeuckerSimplifier::simplify(
g.get(), 10.0);
ensure( simplified->isValid() );
// topology is unchanged
ensure( simplified->equals(g.get()) );
}
// 2 - PolygonReductionWithSplit
template<>
template<>
void object::test<2>()
{
示例10: test_tpsimp_group
group test_tpsimp_group("geos::simplify::TopologyPreservingSimplifier");
//
// Test Cases
//
// PolygonNoReduction
template<>
template<>
void object::test<1>()
{
std::string wkt("POLYGON((20 220, 40 220, 60 220, 80 220, \
100 220, 120 220, 140 220, 140 180, 100 180, \
60 180, 20 180, 20 220))");
GeomPtr g(wktreader.read(wkt));
GeomPtr simplified = TopologyPreservingSimplifier::simplify(g.get(), 10.0);
ensure( "Simplified geometry is invalid!", simplified->isValid() );
ensure( "Simplified and original geometry inequal", simplified->equals(g.get()) );
ensure_equals_geometry( g.get(), simplified.get() );
}
// PolygonNoReductionWithConflicts
template<>
template<>
void object::test<2>()
{
std::string wkt("POLYGON ((40 240, 160 241, 280 240, 280 160, \
160 240, 40 140, 40 240))");
示例11: runIsSequenced
void runIsSequenced(const std::string& inputWKT, bool exp)
{
GeomPtr g = readWKT(inputWKT);
bool isSequenced = LineSequencer::isSequenced(g.get());
ensure_equals( isSequenced, exp );
}
示例12: unionNoOpt
/*public*/
std::unique_ptr<geom::Geometry>
UnaryUnionOp::Union()
{
using geom::Puntal;
typedef std::unique_ptr<geom::Geometry> GeomPtr;
GeomPtr ret;
if(! geomFact) {
return ret;
}
/**
* For points and lines, only a single union operation is
* required, since the OGC model allowings self-intersecting
* MultiPoint and MultiLineStrings.
* This is not the case for polygons, so Cascaded Union is required.
*/
GeomPtr unionPoints;
if(!points.empty()) {
GeomPtr ptGeom = geomFact->buildGeometry(points.begin(),
points.end());
unionPoints = unionNoOpt(*ptGeom);
}
GeomPtr unionLines;
if(!lines.empty()) {
/* JTS compatibility NOTE:
* we use cascaded here for robustness [1]
* but also add a final unionNoOpt step to deal with
* self-intersecting lines [2]
*
* [1](http://trac.osgeo.org/geos/ticket/392
* [2](http://trac.osgeo.org/geos/ticket/482
*
*/
unionLines.reset(CascadedUnion::Union(lines.begin(),
lines.end()));
if(unionLines.get()) {
unionLines = unionNoOpt(*unionLines);
}
}
GeomPtr unionPolygons;
if(!polygons.empty()) {
unionPolygons.reset(CascadedPolygonUnion::Union(polygons.begin(),
polygons.end()));
}
/**
* Performing two unions is somewhat inefficient,
* but is mitigated by unioning lines and points first
*/
GeomPtr unionLA = unionWithNull(std::move(unionLines), std::move(unionPolygons));
assert(!unionLines.get());
assert(!unionPolygons.get());
if(! unionPoints.get()) {
ret = std::move(unionLA);
assert(!unionLA.get());
}
else if(! unionLA.get()) {
ret = std::move(unionPoints);
assert(!unionPoints.get());
}
else {
Puntal& up = dynamic_cast<Puntal&>(*unionPoints);
ret = PointGeometryUnion::Union(up, *unionLA);
}
if(! ret.get()) {
ret.reset(geomFact->createGeometryCollection());
}
return ret;
}
示例13: pg
bool
pointsWithinDistance(vector<Coordinate>& coords, double dist)
{
// we expect some numerical instability here
// OffsetPointGenerator could produce points
// at *slightly* farther locations then
// requested
//
dist *= 1.0000001;
for (size_t i=0, n=coords.size(); i<n; ++i)
{
const Coordinate& c = coords[i];
auto_ptr<Geometry> pg(gf.createPoint(c));
double rdist = g->distance(pg.get());
if ( rdist > dist )
{
return false;
}
}
return true;
}