本文整理汇总了C++中GeomPtr::reset方法的典型用法代码示例。如果您正苦于以下问题:C++ GeomPtr::reset方法的具体用法?C++ GeomPtr::reset怎么用?C++ GeomPtr::reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeomPtr
的用法示例。
在下文中一共展示了GeomPtr::reset方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: is
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;
}
示例2: snapTrans
/*public*/
std::auto_ptr<geom::Geometry>
GeometrySnapper::snapToSelf(double snapTolerance, bool cleanResult)
{
using std::auto_ptr;
using geom::util::GeometryTransformer;
// Get snap points
auto_ptr<Coordinate::ConstVect> snapPts=extractTargetCoordinates(srcGeom);
// Apply a SnapTransformer to source geometry
// (we need a pointer for dynamic polymorphism)
auto_ptr<GeometryTransformer> snapTrans(new SnapTransformer(snapTolerance, *snapPts));
GeomPtr result = snapTrans->transform(&srcGeom);
if (cleanResult && ( dynamic_cast<const Polygon*>(result.get()) ||
dynamic_cast<const MultiPolygon*>(result.get()) ) )
{
// TODO: use better cleaning approach
result.reset(result->buffer(0));
}
return result;
}
示例3: pm
void object::test<7>()
{
GeomPtr geom;
try
{
// use FLOATING model
namespace ggm = geos::geom;
namespace gio = geos::io;
ggm::PrecisionModel pm(ggm::PrecisionModel::FLOATING);
ggm::GeometryFactory gf(&pm);
gio::WKTReader wktReader(&gf);
const std::string str = " POINT (0 0) ";
geom.reset(wktReader.read(str)); //HERE IT FAILS
geos::geom::CoordinateSequence *coords = geom->getCoordinates();
ensure_equals(coords->getDimension(), 2U);
ensure_distance(coords->getX(0), 0.0, 1e-12);
ensure_distance( coords->getY(0), 0.0, 1e-12);
delete coords;
}
catch (const geos::util::IllegalArgumentException& ex)
{
ensure( "Did get expected exception" );
ex.what();
}
catch (...)
{
ensure( !"Got unexpected exception" );
}
}
示例4: fromWKT
GeomPtr fromWKT(const std::string& wkt)
{
GeomPtr geom;
try {
geom.reset( rdr.read(wkt) );
}
catch (const GEOSException& ex) {
cerr << ex.what() << endl;
}
return geom;
}
示例5: 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" );
}
}
示例6: 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
}
示例7: if
/*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;
}