void OgrWriter::writeElement(ElementPtr &element, bool debug) { //Unfortunately, this check also has to happen in addition to checking hasMoreElements. See //explanation in ServicesDbReader::readNextElement. if (element.get()) { Tags sourceTags = element->getTags(); Tags destTags; for (Tags::const_iterator it = element->getTags().begin(); it != element->getTags().end(); ++it) { if (sourceTags[it.key()] != "") { destTags.appendValue(it.key(), it.value()); } } // Now that all the empties are gone, update our element element->setTags(destTags); if ( debug == true ) { LOG_DEBUG(element->toString()); } PartialOsmMapWriter::writePartial(element); } }
void TranslationVisitor::visit(const ConstElementPtr& ce) { // this is a hack to get around the visitor interface. The visitor interface should probably be // redesigned into ConstElementVisitor and ElementVisitor. ElementPtr e = _map->getElement(ce->getElementId()); Tags& tags = e->getTags(); if (tags.getNonDebugCount() > 0) { if (_toOgr) { GeometryTypeId gtype = ElementConverter::getGeometryType(e, false); vector<Tags> allTags = _togr->translateToOgrTags(tags, e->getElementType(), gtype); if (allTags.size() > 0) { if (allTags.size() > 1) { LOG_WARN("More than one feature was returned, only keeping the first feature."); } e->setTags(allTags[0]); } } else { QByteArray layerName; if (tags.contains(OsmSchema::layerNameKey())) { layerName = tags[OsmSchema::layerNameKey()].toUtf8(); } _t.translateToOsm(tags, layerName.data()); if (tags.contains(_circularErrorKey)) { e->setCircularError(tags.getDouble(_circularErrorKey)); tags.remove(_circularErrorKey); tags.remove(_accuracyKey); } else if (tags.contains(_accuracyKey)) { e->setCircularError(tags.getDouble(_accuracyKey)); tags.remove(_circularErrorKey); tags.remove(_accuracyKey); } } } }
void OgrWriter::writeElement(ElementInputStream& inputStream, bool debug) { // Make sure incoming element is in WGS84 assert( inputStream.getProjection()->IsSame(&_wgs84) == true ); ElementPtr nextElement = inputStream.readNextElement(); // TERRY TESTING COULD BE CATASTROPHIC Tags sourceTags = nextElement->getTags(); Tags destTags; for (Tags::const_iterator it = nextElement->getTags().begin(); it != nextElement->getTags().end(); ++it) { if (sourceTags[it.key()] != "") { destTags.appendValue(it.key(), it.value()); } } // Now that all the empties are gone, update our element nextElement->setTags(destTags); if ( debug == true ) { LOG_DEBUG(nextElement->toString()); } PartialOsmMapWriter::writePartial(nextElement); /* if ( nextElement->getElementType().getEnum() == ElementType::Node ) { //LOG_DEBUG("\n" << nextElement->toString()); const long nodeID = nextElement->getId(); if ( (nodeID >= -265198) && (nodeID <= -265167) ) { LOG_DEBUG("\n" << nextElement->toString()); PartialOsmMapWriter::writePartial(nextElement); } } else if ((nextElement->getElementType().getEnum() == ElementType::Way) && (nextElement->getId() == -23189) ) { LOG_DEBUG("Writing Little Mill Creek -23189"); LOG_DEBUG("\n" << nextElement->toString()); PartialOsmMapWriter::writePartial(nextElement); } */ }
Handle<Value> ElementJs::setTags(const Arguments& args) { HandleScope scope; ElementPtr e = ObjectWrap::Unwrap<ElementJs>(args.This())->getElement(); if (!e) { return v8::ThrowException(HootExceptionJs::create(IllegalArgumentException( "Unable to set tags on a const Element."))); } Tags& tags = ObjectWrap::Unwrap<TagsJs>(args[0]->ToObject())->getTags(); e->setTags(tags); return scope.Close(Undefined()); }
void PoiPolygonMerger::apply(const OsmMapPtr& map, vector< pair<ElementId, ElementId> >& replaced) const { //// // See "Hootenanny - POI to Building" powerpoint for more details. //// // merge all POI tags first, but keep Unknown1 and Unknown2 separate. It is implicitly assumed // that since they're in a single group they all represent the same entity. Tags poiTags1 = _mergePoiTags(map, Status::Unknown1); Tags poiTags2 = _mergePoiTags(map, Status::Unknown2); // Get all the building parts for each status vector<ElementId> buildings1 = _getBuildingParts(map, Status::Unknown1); vector<ElementId> buildings2 = _getBuildingParts(map, Status::Unknown2); // Merge all the building parts together into a single building entity using the typical building // merge process. ElementId finalBuildingEid = _mergeBuildings(map, buildings1, buildings2, replaced); ElementPtr finalBuilding = map->getElement(finalBuildingEid); Tags finalBuildingTags = finalBuilding->getTags(); if (poiTags1.size()) { finalBuildingTags = TagMergerFactory::getInstance().mergeTags(poiTags1, finalBuildingTags, finalBuilding->getElementType()); } if (poiTags2.size()) { finalBuildingTags = TagMergerFactory::getInstance().mergeTags(finalBuildingTags, poiTags2, finalBuilding->getElementType()); } finalBuilding->setTags(finalBuildingTags); // do some book keeping to remove the POIs and mark them as replaced. for (set< pair<ElementId, ElementId> >::const_iterator it = _pairs.begin(); it != _pairs.end(); ++it) { const pair<ElementId, ElementId>& p = *it; if (p.first.getType() == ElementType::Node) { replaced.push_back(pair<ElementId, ElementId>(p.first, finalBuildingEid)); // clear the tags just in case it is part of a way if (map->containsElement(p.first)) { map->getElement(p.first)->getTags().clear(); RecursiveElementRemover(p.first).apply(map); } } if (p.second.getType() == ElementType::Node) { replaced.push_back(pair<ElementId, ElementId>(p.second, finalBuildingEid)); // clear the tags just in case it is part of a way if (map->containsElement(p.second)) { map->getElement(p.second)->getTags().clear(); RecursiveElementRemover(p.second).apply(map); } } } }