diff options
author | Yuri Gorshenin <y@maps.me> | 2016-07-05 21:28:14 +0300 |
---|---|---|
committer | Yuri Gorshenin <y@maps.me> | 2016-07-05 21:43:49 +0300 |
commit | abad74b76c735eca873ee1384de40607993aec32 (patch) | |
tree | 888a078227bc383ced634f6332b3640061586baa /routing | |
parent | e7915eb557ff76a913e934da17c601d71f891fe6 (diff) |
[indexer] Fixed FeaturesLoaderGuard.
Diffstat (limited to 'routing')
-rw-r--r-- | routing/bicycle_directions.cpp | 28 | ||||
-rw-r--r-- | routing/bicycle_directions.hpp | 1 | ||||
-rw-r--r-- | routing/features_road_graph.cpp | 11 | ||||
-rw-r--r-- | routing/osrm_helpers.cpp | 7 | ||||
-rw-r--r-- | routing/osrm_path_segment_factory.cpp | 8 | ||||
-rw-r--r-- | routing/osrm_router.cpp | 7 |
6 files changed, 41 insertions, 21 deletions
diff --git a/routing/bicycle_directions.cpp b/routing/bicycle_directions.cpp index 30db2041ba..3025e925a1 100644 --- a/routing/bicycle_directions.cpp +++ b/routing/bicycle_directions.cpp @@ -145,8 +145,16 @@ void BicycleDirectionsEngine::Generate(IRoadGraph const & graph, vector<Junction // Checking for if |edge| is a fake edge. if (!outFeatureId.IsValid()) continue; + + FeatureType ft; + if (!GetLoader(outFeatureId.m_mwmId).GetFeatureByIndex(outFeatureId.m_index, ft)) + continue; + + auto const highwayClass = ftypes::GetHighwayClass(ft); + ASSERT_NOT_EQUAL(highwayClass, ftypes::HighwayClass::Error, ()); + ASSERT_NOT_EQUAL(highwayClass, ftypes::HighwayClass::Undefined, ()); adjacentEdges.m_outgoingTurns.candidates.emplace_back(0.0 /* angle */, outFeatureId.m_index, - GetHighwayClass(outFeatureId)); + highwayClass); } LoadedPathSegment pathSegment; @@ -174,16 +182,6 @@ Index::FeaturesLoaderGuard & BicycleDirectionsEngine::GetLoader(MwmSet::MwmId co return *m_loader; } -ftypes::HighwayClass BicycleDirectionsEngine::GetHighwayClass(FeatureID const & featureId) -{ - FeatureType ft; - GetLoader(featureId.m_mwmId).GetFeatureByIndex(featureId.m_index, ft); - auto const highwayClass = ftypes::GetHighwayClass(ft); - ASSERT_NOT_EQUAL(highwayClass, ftypes::HighwayClass::Error, ()); - ASSERT_NOT_EQUAL(highwayClass, ftypes::HighwayClass::Undefined, ()); - return highwayClass; -} - void BicycleDirectionsEngine::LoadPathGeometry(FeatureID const & featureId, vector<m2::PointD> const & path, LoadedPathSegment & pathSegment) @@ -197,7 +195,13 @@ void BicycleDirectionsEngine::LoadPathGeometry(FeatureID const & featureId, } FeatureType ft; - GetLoader(featureId.m_mwmId).GetFeatureByIndex(featureId.m_index, ft); + if (!GetLoader(featureId.m_mwmId).GetFeatureByIndex(featureId.m_index, ft)) + { + // The feature can't be read, therefore path geometry can't be + // loaded. + return; + } + auto const highwayClass = ftypes::GetHighwayClass(ft); ASSERT_NOT_EQUAL(highwayClass, ftypes::HighwayClass::Error, ()); ASSERT_NOT_EQUAL(highwayClass, ftypes::HighwayClass::Undefined, ()); diff --git a/routing/bicycle_directions.hpp b/routing/bicycle_directions.hpp index 8fd2ac23b2..23ae01a11d 100644 --- a/routing/bicycle_directions.hpp +++ b/routing/bicycle_directions.hpp @@ -33,7 +33,6 @@ public: private: Index::FeaturesLoaderGuard & GetLoader(MwmSet::MwmId const & id); - ftypes::HighwayClass GetHighwayClass(FeatureID const & featureId); void LoadPathGeometry(FeatureID const & featureId, vector<m2::PointD> const & path, LoadedPathSegment & pathSegment); diff --git a/routing/features_road_graph.cpp b/routing/features_road_graph.cpp index 62d8aa7829..602d0a2d37 100644 --- a/routing/features_road_graph.cpp +++ b/routing/features_road_graph.cpp @@ -197,9 +197,10 @@ void FeaturesRoadGraph::GetFeatureTypes(FeatureID const & featureId, feature::Ty { FeatureType ft; Index::FeaturesLoaderGuard loader(m_index, featureId.m_mwmId); - loader.GetFeatureByIndex(featureId.m_index, ft); - ASSERT_EQUAL(ft.GetFeatureType(), feature::GEOM_LINE, ()); + if (!loader.GetFeatureByIndex(featureId.m_index, ft)) + return; + ASSERT_EQUAL(ft.GetFeatureType(), feature::GEOM_LINE, ()); types = feature::TypesHolder(ft); } @@ -262,8 +263,12 @@ IRoadGraph::RoadInfo const & FeaturesRoadGraph::GetCachedRoadInfo(FeatureID cons return ri; FeatureType ft; + Index::FeaturesLoaderGuard loader(m_index, featureId.m_mwmId); - loader.GetFeatureByIndex(featureId.m_index, ft); + + if (!loader.GetFeatureByIndex(featureId.m_index, ft)) + return ri; + ASSERT_EQUAL(ft.GetFeatureType(), feature::GEOM_LINE, ()); ft.ParseGeometry(FeatureType::BEST_GEOMETRY); diff --git a/routing/osrm_helpers.cpp b/routing/osrm_helpers.cpp index c83cc2e3bb..2aed745f84 100644 --- a/routing/osrm_helpers.cpp +++ b/routing/osrm_helpers.cpp @@ -101,7 +101,8 @@ void Point2PhantomNode::CalculateWeight(OsrmMappingTypes::FtSeg const & seg, continue; FeatureType ft; - loader.GetFeatureByIndex(segment.m_fid, ft); + if (!loader.GetFeatureByIndex(segment.m_fid, ft)) + continue; ft.ParseGeometry(FeatureType::BEST_GEOMETRY); // Find whole edge weight by node outgoing point. @@ -230,7 +231,9 @@ void Point2PhantomNode::MakeResult(vector<FeatureGraphNode> & res, size_t maxCou OsrmMappingTypes::FtSeg const & node_seg = segments[j]; FeatureType feature; Index::FeaturesLoaderGuard loader(m_index, m_routingMapping.GetMwmId()); - loader.GetFeatureByIndex(node_seg.m_fid, feature); + if (!loader.GetFeatureByIndex(node_seg.m_fid, feature)) + continue; + feature.ParseGeometry(FeatureType::BEST_GEOMETRY); m2::PointD const featureDirection = feature.GetPoint(node_seg.m_pointEnd) - feature.GetPoint(node_seg.m_pointStart); bool const sameDirection = (m2::DotProduct(featureDirection, m_direction) > 0); diff --git a/routing/osrm_path_segment_factory.cpp b/routing/osrm_path_segment_factory.cpp index c935d551e7..6232cc75a2 100644 --- a/routing/osrm_path_segment_factory.cpp +++ b/routing/osrm_path_segment_factory.cpp @@ -32,10 +32,16 @@ void LoadPathGeometry(buffer_vector<TSeg, 8> const & buffer, size_t startIndex, loadPathGeometry.m_path.clear(); return; } + // Load data from drive. FeatureType ft; Index::FeaturesLoaderGuard loader(index, mapping.GetMwmId()); - loader.GetFeatureByIndex(segment.m_fid, ft); + if (!loader.GetFeatureByIndex(segment.m_fid, ft)) + { + loadPathGeometry.m_path.clear(); + return; + } + ft.ParseGeometry(FeatureType::BEST_GEOMETRY); // Get points in proper direction. diff --git a/routing/osrm_router.cpp b/routing/osrm_router.cpp index 11ee0619d4..01954a3416 100644 --- a/routing/osrm_router.cpp +++ b/routing/osrm_router.cpp @@ -128,7 +128,9 @@ public: FeatureType ft; Index::FeaturesLoaderGuard loader(m_index, m_routingMapping.GetMwmId()); - loader.GetFeatureByIndex(seg.m_fid, ft); + if (!loader.GetFeatureByIndex(seg.m_fid, ft)) + continue; + ft.ParseGeometry(FeatureType::BEST_GEOMETRY); m2::PointD const outgoingPoint = ft.GetPoint( @@ -244,7 +246,8 @@ void FindGraphNodeOffsets(uint32_t const nodeId, m2::PointD const & point, FeatureType ft; Index::FeaturesLoaderGuard loader(*pIndex, mapping->GetMwmId()); - loader.GetFeatureByIndex(s.m_fid, ft); + if (!loader.GetFeatureByIndex(s.m_fid, ft)) + continue; helpers::Point2PhantomNode::Candidate mappedSeg; size_t start_idx = min(s.m_pointStart, s.m_pointEnd); |