本文整理汇总了C++中geos::geom::GeometryFactory类的典型用法代码示例。如果您正苦于以下问题:C++ GeometryFactory类的具体用法?C++ GeometryFactory怎么用?C++ GeometryFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GeometryFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: create_relation
/***
* Union linestrings to multilinestring and insert them into table
* relations.
*/
void create_relation(const osmium::Relation &relation,
const osmium::object_id_type relation_id,
bool &contains_nowaterway_ways,
vector<geos::geom::Geometry *> *linestrings) {
if (!(linestrings->size())) {
return;
}
const geos::geom::GeometryFactory geom_factory =
geos::geom::GeometryFactory();
geos::geom::GeometryCollection *geom_collection = nullptr;
try {
geom_collection = geom_factory.createGeometryCollection(
linestrings);
} catch (...) {
cerr << "Failed to create geometry collection at relation: "
<< relation_id << endl;
delete linestrings;
return;
}
geos::geom::Geometry *geos_geom = nullptr;
try {
geos_geom = geom_collection->Union().release();
} catch (...) {
cerr << "Failed to union linestrings at relation: "
<< relation_id << endl;
delete geom_collection;
return;
}
OGRGeometry *ogr_multilinestring = nullptr;
ogr_multilinestring = geos2ogr(geos_geom);
if (!strcmp(ogr_multilinestring->getGeometryName(),"LINESTRING")) {
try {
ogr_multilinestring =
OGRGeometryFactory::forceToMultiLineString(
ogr_multilinestring);
} catch (...) {
delete geom_collection;
delete geos_geom;
return;
}
}
try {
ds.insert_relation_feature(ogr_multilinestring, relation,
contains_nowaterway_ways);
} catch (osmium::geometry_error&) {
OGRGeometryFactory::destroyGeometry(ogr_multilinestring);
cerr << "Inserting to table failed for relation: "
<< relation_id << endl;
} catch (...) {
OGRGeometryFactory::destroyGeometry(ogr_multilinestring);
cerr << "Inserting to table failed for relation: "
<< relation_id << endl;
cerr << " Unexpected error" << endl;
}
delete geom_collection;
delete geos_geom;
OGRGeometryFactory::destroyGeometry(ogr_multilinestring);
}
示例2:
~test_preparedgeometryfactory_data()
{
// FREE MEMORY per test case
prep::PreparedGeometryFactory::destroy(pg_);
factory_.destroyGeometry(g_);
pg_ = 0;
g_ = 0;
}
示例3: create_discs
void create_discs(geos::geom::GeometryFactory& gf, int num, double radius,
std::vector<geos::geom::Polygon*>* g)
{
for (int i = 0; i < num; ++i) {
for (int j = 0; j < num; ++j) {
std::auto_ptr<geos::geom::Point> pt(
gf.createPoint(geos::geom::Coordinate(i, j)));
g->push_back(dynamic_cast<geos::geom::Polygon*>(pt->buffer(radius)));
}
}
}
示例4: setSampleOffset
namespace Isis {
static geos::geom::GeometryFactory geosFactory;
bool HiJitCube::naifLoaded = false;
int npSamp0[] = {0,1971,3964,5963,7970,7971,7971,9975,9976,9976,11981,13986,15984,17982};
int npSamps[] = {2021,2043,2048,2052,2055,2053,2053,2053,2054,2055,2051,2049,2043,2018};
bool sampinit=false;
bool originst;
/**
* @brief Default constructor with no cube
*/
HiJitCube::HiJitCube() {
initLocal();
}
/**
* @brief Constructor with file to open
*/
HiJitCube::HiJitCube(const std::string &filename) {
initLocal();
OpenCube(filename);
}
/**
* @brief Constructor with file to open and potential shift applied
*/
HiJitCube::HiJitCube(const std::string &filename, PvlObject &shift) {
initLocal();
OpenCube(filename, shift);
}
/**
* @brief Destructor
*/
HiJitCube::~HiJitCube() {
delete fpGeom;
Close();
}
void HiJitCube::setSampleOffset(int soff) {
jdata.sampOffset = soff;
if (IsOpen()) computePoly();
return;
}
void HiJitCube::setLineOffset(int loff) {
jdata.lineOffset = loff;
if (IsOpen()) computePoly();
return;
}
void HiJitCube::OpenCube(const std::string &filename) {
Open(filename);
Init();
return;
}
void HiJitCube::OpenCube(const std::string &filename, PvlObject &shift) {
OpenCube(filename);
// Determine if a shift of the CCD exists in the definitions file
if (shift.HasGroup(jdata.ccdName)) {
PvlGroup &ccddef = shift.FindGroup(jdata.ccdName, Pvl::Traverse);
if (ccddef.HasKeyword("SampleOffset")) {
jdata.sampOffset = (int) ccddef["SampleOffset"];
}
if (ccddef.HasKeyword("LineOffset")) {
jdata.lineOffset = (int) ccddef["LineOffset"];
}
computePoly();
}
return;
}
double HiJitCube::getLineTime(double line) const {
return (((line-1.0) * jdata.linerate) + jdata.obsStartTime);
}
void HiJitCube::Compatable(HiJitCube &cube) throw (iException &) {
JitInfo other = cube.GetInfo();
if (jdata.summing != other.summing) {
ostringstream msg;
msg << "Summing mode (" << jdata.summing
<< ") in file " << Filename() << " is not equal to summing mode ("
<< other.summing << ") in file " << cube.Filename() << endl;
throw iException::Message(iException::User,msg.str(),_FILEINFO_);
}
return;
}
bool HiJitCube::intersects(const HiJitCube &cube) const {
return (fpGeom->intersects(cube.Poly()));
}
//.........这里部分代码省略.........
示例5: computePoly
void HiJitCube::computePoly() {
// Compute sample and line coordinates in the focal plane
int samp0,sampN;
if (originst) {
samp0=jdata.fpSamp0 + jdata.sampOffset;
sampN=samp0 + npSamps[jdata.cpmmNumber] - 1;
} else {
samp0=jdata.fpSamp0 + jdata.sampOffset;
sampN=samp0 + Samples() - 1;
}
int line0(jdata.fpLine0 + jdata.lineOffset), lineN(line0 + Lines() - 1);
// Allocate a new coordinate sequence and define it
geos::geom::CoordinateSequence *pts = new geos::geom::CoordinateArraySequence();
pts->add(geos::geom::Coordinate(samp0, lineN));
pts->add(geos::geom::Coordinate(sampN, lineN));
pts->add(geos::geom::Coordinate(sampN, line0));
pts->add(geos::geom::Coordinate(samp0, line0));
pts->add(geos::geom::Coordinate(samp0, lineN));
// Make this reentrant and delete previous one if it exists and get the
// new one
delete fpGeom;
fpGeom = geosFactory.createPolygon(geosFactory.createLinearRing(pts), 0);
return;
}
示例6: GeomPtr
GeomPtr
getGeometry(SegStrVct& vct)
{
GeomVct* lines = new GeomVct;
for(SegStrVct::size_type i = 0, n = vct.size(); i < n; ++i) {
SegmentString* ss = vct[i];
lines->push_back(gf_->createLineString(*(ss->getCoordinates())));
}
return GeomPtr(gf_->createMultiLineString(lines));
}
示例7: make_point
point_type make_point(const osmium::geom::Coordinates& xy) const {
try {
return point_type(m_geos_factory.createPoint(geos::geom::Coordinate(xy.x, xy.y)));
} catch (geos::util::GEOSException&) {
THROW(osmium::geos_geometry_error());
}
}
示例8: multipolygon_inner_ring_start
void multipolygon_inner_ring_start() {
try {
m_coordinate_sequence.reset(m_geos_factory->getCoordinateSequenceFactory()->create(static_cast<std::size_t>(0), 2));
} catch (const geos::util::GEOSException& e) {
THROW(osmium::geos_geometry_error(e.what()));
}
}
示例9: linestring_start
void linestring_start() {
try {
m_coordinate_sequence.reset(m_geos_factory->getCoordinateSequenceFactory()->create(static_cast<size_t>(0), 2));
} catch (geos::util::GEOSException& e) {
THROW(osmium::geos_geometry_error(e.what()));
}
}
示例10: multipolygon_inner_ring_finish
void multipolygon_inner_ring_finish() {
try {
m_rings.emplace_back(m_geos_factory->createLinearRing(m_coordinate_sequence.release()));
} catch (const geos::util::GEOSException& e) {
THROW(osmium::geos_geometry_error(e.what()));
}
}
示例11: linestring_finish
linestring_type linestring_finish(std::size_t /* num_points */) {
try {
return linestring_type{m_geos_factory->createLineString(m_coordinate_sequence.release())};
} catch (const geos::util::GEOSException& e) {
THROW(osmium::geos_geometry_error(e.what()));
}
}
示例12: multipolygon_outer_ring_start
void multipolygon_outer_ring_start() {
try {
m_coordinate_sequence.reset(m_geos_factory.getCoordinateSequenceFactory()->create(static_cast<size_t>(0), 2));
} catch (geos::util::GEOSException&) {
THROW(osmium::geos_geometry_error());
}
}
示例13: make_point
point_type make_point(const osmium::geom::Coordinates& xy) const {
try {
return point_type{m_geos_factory->createPoint(geos::geom::Coordinate{xy.x, xy.y})};
} catch (const geos::util::GEOSException& e) {
THROW(osmium::geos_geometry_error(e.what()));
}
}
示例14: linestring_finish
linestring_type linestring_finish(size_t /* num_points */) {
try {
return linestring_type(m_geos_factory.createLineString(m_coordinate_sequence.release()));
} catch (geos::util::GEOSException&) {
THROW(osmium::geos_geometry_error());
}
}
示例15:
test_polygon_data()
: pm_(1), factory_(&pm_, 0), reader_(&factory_),
empty_poly_(factory_.createPolygon()), poly_size_(7)
{
// Create non-empty LinearRing
GeometryPtr geo = 0;
geo = reader_.read("POLYGON((0 10, 5 5, 10 5, 15 10, 10 15, 5 15, 0 10))");
poly_ = static_cast<PolygonPtr>(geo);
}