本文整理汇总了C++中OsmMapPtr类的典型用法代码示例。如果您正苦于以下问题:C++ OsmMapPtr类的具体用法?C++ OsmMapPtr怎么用?C++ OsmMapPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OsmMapPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runRoadsTest
void runRoadsTest()
{
//test highway (linestring)
OsmMapPtr map(new OsmMap());
_map = map;
WayPtr w1(new Way(Status::Unknown1, map->createNextWayId(), 13.0));
w1->setTag("highway", "track");
w1->setTag("name", "w1");
w1->addNode(createNode(-104.9, 38.855)->getId());
w1->addNode(createNode(-104.899, 38.8549)->getId());
_map->addWay(w1);
WayPtr w2(new Way(Status::Unknown1, map->createNextWayId(), 13.0));
w2->setTag("highway", "road");
w2->setTag("name", "w2");
w2->addNode(createNode(-104.91, 38.8548)->getId());
w2->addNode(createNode(-104.8993, 38.8548)->getId());
_map->addWay(w2);
CentroidDistanceExtractor uut;
const OsmMap* constMap = const_cast<const OsmMap*>(_map.get());
CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00515218,
uut.distance(*constMap, boost::const_pointer_cast<const Way>(w1), boost::const_pointer_cast<const Way>(w2)),
0.000001);
}
示例2: generateGeometry
OsmMapPtr AlphaShapeGenerator::generateMap(OsmMapPtr inputMap)
{
boost::shared_ptr<Geometry> cutterShape = generateGeometry(inputMap);
if (cutterShape->getArea() == 0.0)
{
//would rather this be thrown than a warning logged, as the warning may go unoticed by web
//clients who are expecting the alpha shape to be generated
throw HootException("Alpha Shape area is zero. Try increasing the buffer size and/or alpha.");
}
OsmMapPtr result;
result.reset(new OsmMap(inputMap->getProjection()));
// add the resulting alpha shape for debugging.
GeometryConverter(result).convertGeometryToElement(cutterShape.get(), Status::Invalid, -1);
const RelationMap& rm = result->getRelations();
for (RelationMap::const_iterator it = rm.begin(); it != rm.end(); ++it)
{
Relation* r = result->getRelation(it->first).get();
r->setTag("area", "yes");
}
return result;
}
示例3: alphaShape
boost::shared_ptr<Geometry> AlphaShapeGenerator::generateGeometry(OsmMapPtr inputMap)
{
MapProjector::projectToPlanar(inputMap);
// put all the nodes into a vector of points.
std::vector< std::pair<double, double> > points;
points.reserve(inputMap->getNodes().size());
const NodeMap& nodes = inputMap->getNodes();
for (NodeMap::const_iterator it = nodes.begin(); it != nodes.end(); ++it)
{
pair<double, double> p;
p.first = (it->second)->getX();
p.second = (it->second)->getY();
points.push_back(p);
}
// create a complex geometry representing the alpha shape
boost::shared_ptr<Geometry> cutterShape;
{
AlphaShape alphaShape(_alpha);
alphaShape.insert(points);
cutterShape = alphaShape.toGeometry();
cutterShape.reset(cutterShape->buffer(_buffer));
}
return cutterShape;
}
示例4: _addReviewTags
void UnifyingConflator::_addReviewTags(const OsmMapPtr& map, const vector<const Match*>& matches)
{
if (ConfigOptions(_settings).getConflateAddScoreTags())
{
for (size_t i = 0; i < matches.size(); i++)
{
const Match* m = matches[i];
const MatchClassification& mc = m->getClassification();
set< pair<ElementId, ElementId> > pairs = m->getMatchPairs();
for (set< pair<ElementId, ElementId> >::const_iterator it = pairs.begin();
it != pairs.end(); ++it)
{
if (mc.getReviewP() > 0.0)
{
ElementPtr e1 = map->getElement(it->first);
ElementPtr e2 = map->getElement(it->second);
_addScoreTags(e1, mc);
_addScoreTags(e2, mc);
e1->getTags().appendValue(scoreUuidKey(), e2->getTags().getCreateUuid());
e2->getTags().appendValue(scoreUuidKey(), e1->getTags().getCreateUuid());
}
}
}
}
}
示例5: prepMap
void MatchScoringMapPreparer::prepMap(OsmMapPtr map, const bool removeNodes)
{
// if an element has a uuid, but no REF1/REF2 tag then create a REF tag with the uuid. The
// 1/2 is determined by the unknown status.
ConvertUuidToRefVisitor convertUuidToRef;
map->visitRw(convertUuidToRef);
// #5891 if the feature is marked as todo then there is no need to conflate & evaluate it.
shared_ptr<TagCriterion> isTodo(new TagCriterion("REF2", "todo"));
RemoveElementsVisitor remover(isTodo);
remover.setRecursive(true);
map->visitRw(remover);
// add a uuid to all elements with a REF tag.
HasTagCriterion criterion("REF1", "REF2", "REVIEW");
AddUuidVisitor uuid("uuid");
FilteredVisitor v(criterion, uuid);
map->visitRw(v);
if (removeNodes)
{
// remove all REF1/REF2 tags from the nodes.
RemoveTagVisitor removeRef("REF1", "REF2");
IsNodeFilter nodeFilter(Filter::KeepMatches);
FilteredVisitor removeRefV(nodeFilter, removeRef);
map->visitRw(removeRefV);
}
//MapCleaner().apply(map);
}
示例6: cut
void CookieCutter::cut(OsmMapPtr cutterShapeMap, OsmMapPtr doughMap)
{
OGREnvelope env = cutterShapeMap->calculateBounds();
env.Merge(doughMap->calculateBounds());
// reproject the dough and cutter into the same planar projection.
MapReprojector::reprojectToPlanar(doughMap, env);
MapReprojector::reprojectToPlanar(cutterShapeMap, env);
// create a complex geometry representing the alpha shape
UnionPolygonsVisitor v;
cutterShapeMap->visitRo(v);
shared_ptr<Geometry> cutterShape = v.getUnion();
if (_outputBuffer != 0.0)
{
cutterShape.reset(cutterShape->buffer(_outputBuffer));
}
if (cutterShape->getArea() == 0.0)
{
LOG_WARN("Cutter area is zero. Try increasing the buffer size or check the input.");
}
// free up a little RAM
cutterShapeMap.reset();
// remove the cookie cutter portion from the "dough"
// if crop is true, then the cookie cutter portion is kept and the "dough" is dropped.
MapCropper::crop(doughMap, cutterShape, !_crop);
// clean up any ugly bits left over
SuperfluousWayRemover::removeWays(doughMap);
SuperfluousNodeRemover::removeNodes(doughMap);
}
示例7: tagKeyCountTest
void tagKeyCountTest()
{
OsmMapPtr map = _loadMap();
boost::shared_ptr<TagKeyCountVisitor> visitor(new TagKeyCountVisitor("source"));
map->visitRo(*visitor);
CPPUNIT_ASSERT_EQUAL((long)6, (long)visitor->getStat());
}
示例8: duplicateNode
void PertyDuplicatePoiOp::duplicateNode(const NodePtr& n, const OsmMapPtr& map)
{
boost::normal_distribution<> nd;
boost::variate_generator<boost::minstd_rand&, boost::normal_distribution<> > N(*_rng, nd);
Meters sigma = n->getCircularError() / 2.0;
double x = n->getX() + N() * sigma * _moveMultiplier;
double y = n->getY() + N() * sigma * _moveMultiplier;
NodePtr newNode(new Node(n->getStatus(), map->createNextNodeId(), x, y,
n->getCircularError()));
map->addNode(newNode);
}
示例9: toWay
WayPtr WaySubline::toWay(const OsmMapPtr& map, GeometryConverter::NodeFactory* nf) const
{
ConstWayPtr way = _start.getWay();
auto_ptr<GeometryConverter::NodeFactory> nfPtr;
if (nf == 0)
{
nf = new FindNodesInWayFactory(way);
// delete it automatically.
nfPtr.reset(nf);
}
WayPtr result(new Way(way->getStatus(), map->createNextWayId(), way->getCircularError()));
result->setTags(way->getTags());
int includedStartIndex = _start.getSegmentIndex();
if (_start.getSegmentFraction() > 0.0)
{
includedStartIndex += 1;
}
int includedEndIndex = _end.getSegmentIndex();
if (_end.getSegmentFraction() >= 1.0)
{
includedEndIndex += 1;
}
if (!_start.isNode())
{
Coordinate c = _start.getCoordinate();
shared_ptr<Node> n = nf->createNode(map, c, way->getStatus(),
way->getCircularError());
map->addNode(n);
result->addNode(n->getId());
}
for (int i = includedStartIndex; i <= includedEndIndex; i++)
{
result->addNode(way->getNodeId(i));
}
if (!_end.isNode())
{
Coordinate c = _end.getCoordinate();
shared_ptr<Node> n = nf->createNode(map, c, way->getStatus(), way->getCircularError());
map->addNode(n);
result->addNode(n->getId());
}
return result;
}
示例10: tagRenameKeyTest
void tagRenameKeyTest()
{
OsmMapPtr map = _loadMap();
TagRenameKeyVisitor visitor("source", "source_modified");
map->visitRw(visitor);
boost::shared_ptr<TagKeyCountVisitor> keyCountVisitor1(new TagKeyCountVisitor("source"));
map->visitRo(*keyCountVisitor1);
CPPUNIT_ASSERT_EQUAL((long)0, (long)keyCountVisitor1->getStat());
boost::shared_ptr<TagKeyCountVisitor> keyCountVisitor2(new TagKeyCountVisitor("source_modified"));
map->visitRo(*keyCountVisitor2);
CPPUNIT_ASSERT_EQUAL((long)6, (long)keyCountVisitor2->getStat());
}
示例11: getArea
Meters CalculateAreaForStatsVisitor::getArea(const OsmMapPtr& map, ElementPtr e)
{
CalculateAreaForStatsVisitor v;
v.setOsmMap(map.get());
e->visitRo(*map, v);
return v.getArea();
}
示例12: createMergers
void MergerFactory::createMergers(const OsmMapPtr& map, const MatchSet& matches,
vector<Merger*>& result) const
{
for (size_t i = 0; i < _creators.size(); i++)
{
OsmMapConsumer* omc = dynamic_cast<OsmMapConsumer*>(_creators[i]);
if (omc)
{
omc->setOsmMap(map.get());
}
if (_creators[i]->createMergers(matches, result))
{
return;
}
// we don't want the creators to hold onto a map pointer that will go out of scope
if (omc)
{
omc->setOsmMap((OsmMap*)0);
}
}
LOG_WARN("Error finding Mergers for these matches: " << matches);
LOG_WARN("Creators: " << _creators);
throw HootException("Error creating a merger for the provided set of matches.");
}
示例13: _saveMap
void PertyMatchScorer::_saveMap(OsmMapPtr map, QString path)
{
BuildingOutlineUpdateOp().apply(map);
LOG_VARD(map->getNodeMap().size());
LOG_VARD(map->getWays().size());
if (Log::getInstance().getLevel() <= Log::Debug)
{
TagCountVisitor tagCountVisitor;
map->visitRo(tagCountVisitor);
const long numTotalTags = (long)tagCountVisitor.getStat();
LOG_VARD(numTotalTags);
}
MapProjector::projectToWgs84(map);
OsmUtils::saveMap(map, path);
}
示例14: generate
OsmMapPtr AlphaShapeGenerator::generate(OsmMapPtr cutterShapeMap)
{
MapProjector::projectToPlanar(cutterShapeMap);
// put all the nodes into a vector of points.
std::vector< std::pair<double, double> > points;
points.reserve(cutterShapeMap->getNodeMap().size());
const NodeMap& nodes = cutterShapeMap->getNodeMap();
for (NodeMap::const_iterator it = nodes.begin(); it != nodes.end(); ++it)
{
pair<double, double> p;
p.first = (it->second)->getX();
p.second = (it->second)->getY();
points.push_back(p);
}
// create a complex geometry representing the alpha shape
shared_ptr<Geometry> cutterShape;
{
AlphaShape alphaShape(_alpha);
alphaShape.insert(points);
cutterShape = alphaShape.toGeometry();
cutterShape.reset(cutterShape->buffer(_buffer));
}
if (cutterShape->getArea() == 0.0)
{
LOG_WARN("Alpha Shape area is zero. Try increasing the buffer size and/or alpha.");
}
shared_ptr<OsmMap> result;
result.reset(new OsmMap(cutterShapeMap->getProjection()));
// add the resulting alpha shape for debugging.
GeometryConverter(result).convertGeometryToElement(cutterShape.get(), Status::Invalid, -1);
const RelationMap& rm = result->getRelationMap();
for (RelationMap::const_iterator it = rm.begin(); it != rm.end(); ++it)
{
Relation* r = result->getRelation(it->first).get();
r->setTag("area", "yes");
}
return result;
}
示例15: runIsCandidateTest
void runIsCandidateTest()
{
PoiPolygonMatchCreator uut;
OsmMapPtr map = getTestMap1();
CPPUNIT_ASSERT(
uut.isMatchCandidate(map->getNode(FindNodesVisitor::findNodesByTag(map, "name", "foo")[0]), map));
CPPUNIT_ASSERT(
uut.isMatchCandidate(map->getWay(FindWaysVisitor::findWaysByTag(map, "name", "foo")[0]), map));
OsmXmlReader reader;
map.reset(new OsmMap());
reader.setDefaultStatus(Status::Unknown1);
reader.read("test-files/ToyTestA.osm", map);
MapProjector::projectToPlanar(map);
CPPUNIT_ASSERT(
!uut.isMatchCandidate(map->getWay(FindWaysVisitor::findWaysByTag(map, "note", "1")[0]), map));
}