bool WayMergeManipulation::_directConnect(const OsmMapPtr& map, WayPtr w) const { boost::shared_ptr<LineString> ls = ElementConverter(map).convertToLineString(w); CoordinateSequence* cs = GeometryFactory::getDefaultInstance()->getCoordinateSequenceFactory()-> create(2, 2); cs->setAt(map->getNode(w->getNodeId(0))->toCoordinate(), 0); cs->setAt(map->getNode(w->getLastNodeId())->toCoordinate(), 1); // create a straight line and buffer it boost::shared_ptr<LineString> straight(GeometryFactory::getDefaultInstance()->createLineString(cs)); boost::shared_ptr<Geometry> g(straight->buffer(w->getCircularError())); // is the way in question completely contained in the buffer? return g->contains(ls.get()); }
void WayMergeManipulation::_removeSpans(OsmMapPtr map, set<ElementId>& impactedElements) const { WayPtr left = map->getWay(_left); WayPtr right = map->getWay(_right); set<ElementId> impactedWaysTmp = impactedElements; for (set<ElementId>::iterator it = impactedWaysTmp.begin(); it != impactedWaysTmp.end(); ++it) { ElementId eid = *it; WayPtr w = map->getWay(eid.getId()); long first = w->getNodeId(0); long last = w->getLastNodeId(); if ((left->hasNode(first) && right->hasNode(last)) || (left->hasNode(last) && right->hasNode(first))) { if (_directConnect(map, w)) { RemoveWayOp::removeWay(map, eid.getId()); impactedElements.erase(eid); } } } }