void operator() (feature_ptr feat) { for (std::size_t i=0;i<feat->num_geometries();++i) { geometry_type & geom = feat->get_geometry(i); if ( first_ ) { first_ = false; ext_ = geom.envelope(); } else { ext_.expand_to_include(geom.envelope()); } } }
void ogr_converter::convert_polygon(OGRPolygon* geom, feature_ptr feature) { OGRLinearRing* exterior = geom->getExteriorRing(); int num_points = exterior->getNumPoints(); int num_interior = geom->getNumInteriorRings(); int capacity = 0; for (int r = 0; r < num_interior; ++r) { OGRLinearRing* interior = geom->getInteriorRing(r); capacity += interior->getNumPoints(); } std::auto_ptr<geometry_type> poly(new geometry_type(mapnik::Polygon)); poly->move_to(exterior->getX(0), exterior->getY(0)); for (int i = 1; i < num_points - 1; ++i) { poly->line_to(exterior->getX(i), exterior->getY(i)); } poly->close(exterior->getX(num_points-1), exterior->getY(num_points-1)); for (int r = 0; r < num_interior; ++r) { OGRLinearRing* interior = geom->getInteriorRing(r); num_points = interior->getNumPoints(); poly->move_to(interior->getX(0), interior->getY(0)); for (int i = 1; i < num_points - 1; ++i) { poly->line_to(interior->getX(i), interior->getY(i)); } poly->close(interior->getX(num_points-1), interior->getY(num_points-1)); } feature->paths().push_back(poly); }
void ogr_converter::convert_polygon(OGRPolygon* geom, feature_ptr feature) { OGRLinearRing* exterior = geom->getExteriorRing(); int num_points = exterior->getNumPoints(); int num_interior = geom->getNumInteriorRings(); int capacity = 0; for (int r = 0; r < num_interior; r++) { OGRLinearRing* interior = geom->getInteriorRing(r); capacity += interior->getNumPoints(); } geometry_type* poly = new geometry_type(mapnik::Polygon); poly->move_to(exterior->getX(0), exterior->getY(0)); for (int i = 1; i < num_points; ++i) { poly->line_to(exterior->getX(i), exterior->getY(i)); } for (int r = 0; r < num_interior; r++) { OGRLinearRing* interior = geom->getInteriorRing(r); num_points = interior->getNumPoints(); poly->move_to(interior->getX(0), interior->getY(0)); for (int i = 1; i < num_points; ++i) { poly->line_to(interior->getX(i), interior->getY(i)); } } feature->add_geometry(poly); }
GMsg VectorBuffer::EraseFeatureFromInteraction( const feature_ptr &src, const string &proj, const std::unordered_set<long> &targets, const std::unordered_set<long> &immunes) { GRect ext = MapnikUtils::Box2d2GRect(src->envelope()); unordered_map<long, feature_ptr> fs = GetFeaturesInRect( proj, ext, _config_app().VIEW_VECTORBUFFER_SELECTION_MAX); unordered_map<long, feature_ptr> edited_in_clipping; unordered_set<long> removed_in_clipping; for (unordered_map<long, feature_ptr>::const_iterator it = fs.begin(); it != fs.end(); it++) { feature_ptr f = it->second; if (immunes.find(f->id()) != immunes.end()) continue; if (!targets.empty() && targets.find(f->id()) == targets.end()) continue; if (MapnikUtils::contains( src, f, wkbPolygon, _book->GetGeomType(), proj, _layer->proj())) { removed_in_clipping.insert(it->first); } else if (MapnikUtils::intersects( src, f, wkbPolygon, _book->GetGeomType(), proj, _layer->proj())) { feature_ptr clipped = MapnikUtils::difference( f, src, _book->GetGeomType(), wkbPolygon, _layer->proj(), proj); if (clipped != nullptr) { edited_in_clipping.insert(pair<long, feature_ptr>(it->first, clipped)); } } } unsigned int num = removed_in_clipping.size() + edited_in_clipping.size(); if (num == 0) return G_NOERR; _undoStack->beginMacro(num == 1 ? "Erase feature" : "Erase features"); for (unordered_set<long>::const_iterator it = removed_in_clipping.begin(); it != removed_in_clipping.end(); it++) { _undoStack->push(new VBCommandDeleteFeature(this, *it)); } for (unordered_map<long, feature_ptr>::const_iterator it = edited_in_clipping.begin(); it != edited_in_clipping.end(); it++) { long fid = it->first; feature_ptr f = it->second; Q_ASSERT(_deletedFeatures.find(fid) == _deletedFeatures.end()); f->put<value_unicode_string>( _config_app().VIEW_VECTORBUFFER_FIELD_EDITED, transcoder("utf-8").transcode("edited")); _undoStack->push(new VBCommandEditFeature(this, fid, f)); } _undoStack->endMacro(); return G_NOERR; }
void ogr_converter::convert_linestring(OGRLineString* geom, feature_ptr feature) { int num_points = geom->getNumPoints(); std::auto_ptr<geometry_type> line(new geometry_type(mapnik::LineString)); line->move_to(geom->getX(0), geom->getY(0)); for (int i = 1; i < num_points; ++i) { line->line_to (geom->getX(i), geom->getY(i)); } feature->paths().push_back(line); }
void ogr_converter::convert_linestring(OGRLineString* geom, feature_ptr feature) { int num_points = geom->getNumPoints(); geometry_type* line = new geometry_type(mapnik::LineString); line->move_to(geom->getX(0), geom->getY(0)); for (int i = 1; i < num_points; ++i) { line->line_to (geom->getX(i), geom->getY(i)); } feature->add_geometry(line); }
GMsg VectorBuffer::SplitFeatureFromInteraction( const feature_ptr &src, const string &proj) { GRect ext = MapnikUtils::Box2d2GRect(src->envelope()); unordered_map<long, feature_ptr> fs = GetFeaturesInRect( proj, ext, _config_app().VIEW_VECTORBUFFER_SELECTION_MAX); unordered_map<long, vector<feature_ptr> > edited_in_splitting; GMsg retmsg; for (unordered_map<long, feature_ptr>::const_iterator it = fs.begin(); it != fs.end(); it++) { feature_ptr f = it->second; if (MapnikUtils::intersects( src, f, wkbLineString, _book->GetGeomType(), proj, _layer->proj())) { vector<mapnik::feature_ptr> splitted; GMsg msg = MapnikUtils::split(f, src, _book->GetGeomType(), splitted, _layer->proj(), proj); if (msg != G_NOERR) { if (msg.is_error()) retmsg = msg; } else { edited_in_splitting.insert(pair<long, vector<feature_ptr> >(it->first, splitted)); } } } unsigned int num = edited_in_splitting.size(); if (num == 0) return retmsg; _undoStack->beginMacro(num == 1 ? "Split feature" : "Split features"); for (unordered_map<long, vector<feature_ptr> >::const_iterator it = edited_in_splitting.begin(); it != edited_in_splitting.end(); it++) { long fid = it->first; vector<feature_ptr> fs = it->second; Q_ASSERT(_deletedFeatures.find(fid) == _deletedFeatures.end()); _undoStack->push(new VBCommandDeleteFeature(this, fid)); for (unsigned int i = 0; i != fs.size(); i++) { feature_ptr f = fs.at(i); f->set_id(_fidCandidate); f->put<value_unicode_string>( _config_app().VIEW_VECTORBUFFER_FIELD_EDITED, transcoder("utf-8").transcode("edited")); _undoStack->push(new VBCommandAddFeature(this, _fidCandidate, f)); _fidCandidate++; } } _undoStack->endMacro(); return retmsg; }
void occi_featureset::convert_geometry(SDOGeometry* geom, feature_ptr feature) { int gtype = (int)geom->getSdo_gtype(); int dimensions = gtype / 1000; int lrsvalue = (gtype - dimensions * 1000) / 100; int geomtype = (gtype - dimensions * 1000 - lrsvalue * 100); const std::vector<Number>& elem_info = geom->getSdo_elem_info(); const std::vector<Number>& ordinates = geom->getSdo_ordinates(); const int ordinates_size = (int)ordinates.size(); switch (geomtype) { case SDO_GTYPE_POINT: { SDOPointType* sdopoint = geom->getSdo_point(); if (sdopoint && ! sdopoint->isNull()) { std::unique_ptr<geometry_type> point = std::make_unique<geometry_type>(mapnik::geometry_type::types::Point); point->move_to(sdopoint->getX(), sdopoint->getY()); feature->add_geometry(point.release()); } } break; case SDO_GTYPE_LINE: { if (ordinates_size >= dimensions) { const bool is_single_geom = true; const bool is_point_type = false; convert_ordinates(feature, mapnik::geometry_type::types::LineString, elem_info, ordinates, dimensions, is_single_geom, is_point_type); } } break; case SDO_GTYPE_POLYGON: { if (ordinates_size >= dimensions) { const bool is_single_geom = true; const bool is_point_type = false; convert_ordinates(feature, mapnik::geometry_type::types::Polygon, elem_info, ordinates, dimensions, is_single_geom, is_point_type); } } break; case SDO_GTYPE_MULTIPOINT: { if (ordinates_size >= dimensions) { const bool is_single_geom = false; const bool is_point_type = true; convert_ordinates(feature, mapnik::geometry_type::types::Point, elem_info, ordinates, dimensions, is_single_geom, is_point_type); } } break; case SDO_GTYPE_MULTILINE: { if (ordinates_size >= dimensions) { const bool is_single_geom = false; const bool is_point_type = false; convert_ordinates(feature, mapnik::geometry_type::types::LineString, elem_info, ordinates, dimensions, is_single_geom, is_point_type); } } break; case SDO_GTYPE_MULTIPOLYGON: { if (ordinates_size >= dimensions) { const bool is_single_geom = false; const bool is_point_type = false; convert_ordinates(feature, mapnik::geometry_type::types::Polygon, elem_info, ordinates, dimensions, is_single_geom, is_point_type); } } break; case SDO_GTYPE_COLLECTION: { if (ordinates_size >= dimensions) { const bool is_single_geom = false; const bool is_point_type = false; convert_ordinates(feature, mapnik::geometry_type::types::Polygon, elem_info, ordinates, dimensions, is_single_geom, is_point_type); } } break; case SDO_GTYPE_UNKNOWN: default: { MAPNIK_LOG_WARN(occi) << "occi_featureset: Unknown oracle enum " << occi_enums::resolve_gtype(geomtype) << "(gtype=" << gtype << ")"; } break; } }
void ogr_converter::convert_point(OGRPoint* geom, feature_ptr feature) { std::auto_ptr<geometry_type> point(new geometry_type(mapnik::Point)); point->move_to(geom->getX(), geom->getY()); feature->paths().push_back(point); }
void ogr_converter::convert_point(OGRPoint* geom, feature_ptr feature) { geometry_type * point = new geometry_type(mapnik::Point); point->move_to(geom->getX(), geom->getY()); feature->add_geometry(point); }