void NetworkMatcher::_createVertex2Index() { // No tuning was done, I just copied these settings from OsmMapIndex. // 10 children = 368 bytes shared_ptr<MemoryPageStore> mps(new MemoryPageStore(728)); _vertex2Index.reset(new HilbertRTree(mps, 2)); std::vector<Box> boxes; std::vector<int> fids; const OsmNetwork::VertexMap& vm = _n2->getVertexMap(); for (OsmNetwork::VertexMap::const_iterator it = vm.begin(); it != vm.end(); ++it) { fids.push_back((int)_index2Vertex.size()); _index2Vertex.push_back(it.value()); Box b(2); Meters searchRadius = _details2->getSearchRadius(it.value()); Envelope env(_details2->getEnvelope(it.value())); env.expandBy(searchRadius); b.setBounds(0, env.getMinX(), env.getMaxX()); b.setBounds(1, env.getMinY(), env.getMaxY()); boxes.push_back(b); } _vertex2Index->bulkInsert(boxes, fids); }
void IterativeEdgeMatcher::_seedVertexScores() { // go through all the n1 vertices const OsmNetwork::VertexMap& vm = _n1->getVertexMap(); for (OsmNetwork::VertexMap::const_iterator it = vm.begin(); it != vm.end(); ++it) { ConstNetworkVertexPtr v1 = it.value(); // find all the vertices that are in range of this one ConstElementPtr e1 = it.value()->getElement(); Envelope env = _details->getEnvelope(v1); env.expandBy(_details->getSearchRadius(v1)); IntersectionIterator iit = _createIterator(env, _vertex2Index); // set the initial match score to 1 for all candidate matches while (iit.next()) { ConstNetworkVertexPtr v2 = _index2Vertex[iit.getId()]; double score = _scoreVertices(v1, v2); if (score > 0) { _vertex12Scores[v1][v2] = score; _vertex21Scores[v2][v1] = score; } } } }