forked from organicmaps/organicmaps
Merge pull request #6220 from darina/routing-mark
Route points based on UserMark.
This commit is contained in:
commit
d109fc3012
23 changed files with 430 additions and 74 deletions
|
@ -1146,17 +1146,17 @@ Java_com_mapswithme_maps_Framework_nativeGetBestRouter(JNIEnv * env, jclass, jdo
|
|||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_Framework_nativeSetRouteStartPoint(JNIEnv * env, jclass, jdouble lat, jdouble lon, jboolean valid)
|
||||
{
|
||||
frm()->GetRoutingManager().SetRouteStartPoint(frm()->GetBookmarkManager(),
|
||||
m2::PointD(MercatorBounds::FromLatLon(lat, lon)),
|
||||
static_cast<bool>(valid));
|
||||
frm()->GetRoutingManager().RemoveRoutePoint(RouteMarkType::Start);
|
||||
frm()->GetRoutingManager().AddRoutePoint(m2::PointD(MercatorBounds::FromLatLon(lat, lon)),
|
||||
static_cast<bool>(!valid), RouteMarkType::Start);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_Framework_nativeSetRouteEndPoint(JNIEnv * env, jclass, jdouble lat, jdouble lon, jboolean valid)
|
||||
{
|
||||
frm()->GetRoutingManager().SetRouteFinishPoint(frm()->GetBookmarkManager(),
|
||||
m2::PointD(MercatorBounds::FromLatLon(lat, lon)),
|
||||
static_cast<bool>(valid));
|
||||
frm()->GetRoutingManager().RemoveRoutePoint(RouteMarkType::Finish);
|
||||
frm()->GetRoutingManager().AddRoutePoint(m2::PointD(MercatorBounds::FromLatLon(lat, lon)),
|
||||
static_cast<bool>(!valid), RouteMarkType::Finish);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
|
|
|
@ -90,6 +90,8 @@ void CacheUserPoints(UserMarksProvider const * provider, ref_ptr<dp::TextureMana
|
|||
for (size_t i = 0; i < markCount; ++i)
|
||||
{
|
||||
UserPointMark const * userMark = provider->GetUserPointMark(i);
|
||||
if (!userMark->IsVisible())
|
||||
continue;
|
||||
TileKey const tileKey = GetTileKeyByPoint(userMark->GetPivot(), kZoomLevel);
|
||||
marks[tileKey].push_back(userMark);
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ public:
|
|||
virtual dp::Anchor GetAnchor() const = 0;
|
||||
virtual float GetDepth() const = 0;
|
||||
virtual bool RunCreationAnim() const = 0;
|
||||
virtual bool IsVisible() const { return true; }
|
||||
};
|
||||
|
||||
class UserLineMark
|
||||
|
|
|
@ -202,8 +202,10 @@ bool isMarkerPoint(MWMRoutePoint * point) { return point.isValid && !point.isMyP
|
|||
self.type =
|
||||
routerType(GetFramework().GetRoutingManager().GetBestRouter(startPoint, finishPoint));
|
||||
f.GetRoutingManager().BuildRoute(startPoint, finishPoint, isP2P, 0 /* timeoutSec */);
|
||||
f.GetRoutingManager().SetRouteStartPoint(f.GetBookmarkManager(), startPoint, isMarkerPoint(self.startPoint));
|
||||
f.GetRoutingManager().SetRouteFinishPoint(f.GetBookmarkManager(), finishPoint, isMarkerPoint(self.finishPoint));
|
||||
if (self.startPoint.isValid)
|
||||
f.GetRoutingManager().AddRoutePoint(startPoint, self.startPoint.isMyPosition, RouteMarkType::Start);
|
||||
if (self.finishPoint.isValid)
|
||||
f.GetRoutingManager().AddRoutePoint(finishPoint, self.finishPoint.isMyPosition, RouteMarkType::Finish);
|
||||
[mapViewControlsManager onRouteRebuild];
|
||||
}
|
||||
|
||||
|
|
|
@ -145,6 +145,10 @@ using BannerIsReady = void (^)();
|
|||
- (NSURL *)URLToAllReviews;
|
||||
- (NSArray<MWMGalleryItemModel *> *)photos;
|
||||
|
||||
// Route points
|
||||
- (RouteMarkType)routeMarkType;
|
||||
- (int8_t)intermediateIndex;
|
||||
|
||||
// Banner
|
||||
- (id<MWMBanner>)nativeAd;
|
||||
|
||||
|
|
|
@ -517,6 +517,8 @@ using namespace place_page;
|
|||
|
||||
#pragma mark - Getters
|
||||
|
||||
- (RouteMarkType)routeMarkType { return m_info.m_routeMarkType; }
|
||||
- (int8_t)intermediateIndex { return m_info.m_intermediateIndex; }
|
||||
- (NSString *)address { return @(m_info.GetAddress().c_str()); }
|
||||
- (NSString *)apiURL { return @(m_info.GetApiUrl().c_str()); }
|
||||
- (vector<Sections> const &)sections { return m_sections; }
|
||||
|
|
|
@ -276,13 +276,15 @@ void logSponsoredEvent(MWMPlacePageData * data, NSString * eventName)
|
|||
|
||||
- (void)addStop
|
||||
{
|
||||
// TODO: Implement adding a routing point.
|
||||
// self.data contains all point's data.
|
||||
GetFramework().GetRoutingManager().AddRoutePoint(self.data.mercator, false /* isMyPosition */,
|
||||
RouteMarkType::Intermediate, 0);
|
||||
[self close];
|
||||
}
|
||||
|
||||
- (void)removeStop
|
||||
{
|
||||
// TODO: Implement removing a routing point.
|
||||
GetFramework().GetRoutingManager().RemoveRoutePoint(self.data.routeMarkType, self.data.intermediateIndex);
|
||||
[self close];
|
||||
}
|
||||
|
||||
- (void)taxiTo
|
||||
|
|
|
@ -64,8 +64,7 @@ extern NSString * const kAlohalyticsTapEventKey;
|
|||
BOOL const isP2P = self.isPrepareRouteMode;
|
||||
BOOL const isMyPosition = data.isMyPosition;
|
||||
BOOL const isRoutePoint = data.isRoutePoint;
|
||||
BOOL const isNeedToAddIntermediatePoint = GetFramework().GetRoutingManager().IsRoutingActive()
|
||||
/* && there is no intermediate point yet */;
|
||||
BOOL const isNeedToAddIntermediatePoint = GetFramework().GetRoutingManager().CouldAddIntermediatePoint();
|
||||
|
||||
EButton sponsoredButton = EButton::BookingSearch;
|
||||
if (isBooking)
|
||||
|
|
|
@ -56,6 +56,8 @@ set(
|
|||
reachable_by_taxi_checker.hpp
|
||||
routing_manager.cpp
|
||||
routing_manager.hpp
|
||||
routing_mark.cpp
|
||||
routing_mark.hpp
|
||||
track.cpp
|
||||
track.hpp
|
||||
traffic_manager.cpp
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "map/bookmark_manager.hpp"
|
||||
#include "map/framework.hpp"
|
||||
#include "map/routing_mark.hpp"
|
||||
#include "map/user_mark.hpp"
|
||||
|
||||
#include "platform/platform.hpp"
|
||||
|
@ -23,6 +24,7 @@ BookmarkManager::BookmarkManager(Framework & f)
|
|||
m_userMarkLayers.push_back(new SearchUserMarkContainer(0.0 /* activePinDepth */, m_framework));
|
||||
m_userMarkLayers.push_back(new ApiUserMarkContainer(0.0 /* activePinDepth */, m_framework));
|
||||
m_userMarkLayers.push_back(new DebugUserMarkContainer(0.0 /* debugDepth */, m_framework));
|
||||
m_userMarkLayers.push_back(new RouteUserMarkContainer(0.0 /* activePinDepth */, m_framework));
|
||||
UserMarkContainer::InitStaticMarks(FindUserMarksContainer(UserMarkType::SEARCH_MARK));
|
||||
}
|
||||
|
||||
|
@ -229,6 +231,7 @@ UserMark const * BookmarkManager::FindNearestUserMark(TTouchRectHolder const & h
|
|||
for_each(m_categories.begin(), m_categories.end(), ref(finder));
|
||||
finder(FindUserMarksContainer(UserMarkType::API_MARK));
|
||||
finder(FindUserMarksContainer(UserMarkType::SEARCH_MARK));
|
||||
finder(FindUserMarksContainer(UserMarkType::ROUTING_MARK));
|
||||
|
||||
return finder.GetFindedMark();
|
||||
}
|
||||
|
|
|
@ -414,6 +414,7 @@ Framework::Framework(FrameworkParams const & params)
|
|||
m_connectToGpsTrack = GpsTracker::Instance().IsEnabled();
|
||||
|
||||
m_ParsedMapApi.SetBookmarkManager(&m_bmManager);
|
||||
m_routingManager.SetBookmarkManager(&m_bmManager);
|
||||
|
||||
// Init strings bundle.
|
||||
// @TODO. There are hardcoded strings below which are defined in strings.txt as well.
|
||||
|
@ -942,6 +943,14 @@ void Framework::FillMyPositionInfo(place_page::Info & info) const
|
|||
info.m_customName = m_stringsBundle.GetString("my_position");
|
||||
}
|
||||
|
||||
void Framework::FillRouteMarkInfo(RouteMarkPoint const & rmp, place_page::Info & info) const
|
||||
{
|
||||
FillPointInfo(rmp.GetPivot(), "", info);
|
||||
info.m_isRoutePoint = true;
|
||||
info.m_routeMarkType = rmp.GetRoutePointType();
|
||||
info.m_intermediateIndex = rmp.GetIntermediateIndex();
|
||||
}
|
||||
|
||||
void Framework::ShowBookmark(BookmarkAndCategory const & bnc)
|
||||
{
|
||||
StopLocationFollow();
|
||||
|
@ -2417,6 +2426,9 @@ df::SelectionShape::ESelectedObject Framework::OnTapEventImpl(TapEvent const & t
|
|||
case UserMark::Type::SEARCH:
|
||||
FillSearchResultInfo(*static_cast<SearchMarkPoint const *>(mark), outInfo);
|
||||
break;
|
||||
case UserMark::Type::ROUTING:
|
||||
FillRouteMarkInfo(*static_cast<RouteMarkPoint const *>(mark), outInfo);
|
||||
break;
|
||||
default:
|
||||
ASSERT(false, ("FindNearestUserMark returned invalid mark."));
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "map/mwm_url.hpp"
|
||||
#include "map/place_page_info.hpp"
|
||||
#include "map/routing_manager.hpp"
|
||||
#include "map/routing_mark.hpp"
|
||||
#include "map/track.hpp"
|
||||
#include "map/traffic_manager.hpp"
|
||||
|
||||
|
@ -676,6 +677,7 @@ private:
|
|||
void FillApiMarkInfo(ApiMarkPoint const & api, place_page::Info & info) const;
|
||||
void FillSearchResultInfo(SearchMarkPoint const & smp, place_page::Info & info) const;
|
||||
void FillMyPositionInfo(place_page::Info & info) const;
|
||||
void FillRouteMarkInfo(RouteMarkPoint const & rmp, place_page::Info & info) const;
|
||||
|
||||
public:
|
||||
void FillBookmarkInfo(Bookmark const & bmk, BookmarkAndCategory const & bac, place_page::Info & info) const;
|
||||
|
|
|
@ -33,6 +33,7 @@ HEADERS += \
|
|||
place_page_info.hpp \
|
||||
reachable_by_taxi_checker.hpp \
|
||||
routing_manager.hpp \
|
||||
routing_mark.hpp \
|
||||
track.hpp \
|
||||
traffic_manager.hpp \
|
||||
user_mark.hpp \
|
||||
|
@ -63,6 +64,7 @@ SOURCES += \
|
|||
place_page_info.cpp \
|
||||
reachable_by_taxi_checker.cpp \
|
||||
routing_manager.cpp \
|
||||
routing_mark.cpp \
|
||||
track.cpp \
|
||||
traffic_manager.cpp \
|
||||
user_mark.cpp \
|
||||
|
|
|
@ -22,18 +22,13 @@ char const * const Info::kPricingSymbol = "$";
|
|||
bool Info::IsFeature() const { return m_featureID.IsValid(); }
|
||||
bool Info::IsBookmark() const { return m_bac.IsValid(); }
|
||||
bool Info::IsMyPosition() const { return m_isMyPosition; }
|
||||
bool Info::IsRoutePoint() const { return m_isRoutePoint; }
|
||||
bool Info::IsSponsored() const { return m_sponsoredType != SponsoredType::None; }
|
||||
bool Info::IsNotEditableSponsored() const
|
||||
{
|
||||
return m_sponsoredType != SponsoredType::None && m_sponsoredType != SponsoredType::Opentable;
|
||||
}
|
||||
|
||||
bool Info::IsRoutePoint() const
|
||||
{
|
||||
//TODO(@darina) Implement checker
|
||||
return m_bac.IsValid() && m_bookmarkCategoryName == "TMP_Routing_Points";
|
||||
}
|
||||
|
||||
bool Info::ShouldShowAddPlace() const
|
||||
{
|
||||
auto const isPointOrBuilding = IsPointType() || IsBuilding();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "map/bookmark.hpp"
|
||||
#include "map/routing_mark.hpp"
|
||||
|
||||
#include "storage/index.hpp"
|
||||
|
||||
|
@ -147,6 +148,10 @@ public:
|
|||
/// one part of the country (or several countries for disputed territories).
|
||||
storage::TCountriesVec m_topmostCountryIds;
|
||||
|
||||
bool m_isRoutePoint = false;
|
||||
RouteMarkType m_routeMarkType;
|
||||
int8_t m_intermediateIndex = 0;
|
||||
|
||||
bool m_isMyPosition = false;
|
||||
/// True if editing of a selected point is allowed by basic logic.
|
||||
/// See initialization in framework.
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "routing_manager.hpp"
|
||||
|
||||
#include "map/chart_generator.hpp"
|
||||
#include "map/routing_mark.hpp"
|
||||
#include "map/mwm_tree.hpp"
|
||||
|
||||
#include "private.h"
|
||||
|
@ -64,6 +65,11 @@ RoutingManager::RoutingManager(Callbacks && callbacks, Delegate & delegate)
|
|||
[this](Route const & route, IRouter::ResultCode code) { OnRebuildRouteReady(route, code); });
|
||||
}
|
||||
|
||||
void RoutingManager::SetBookmarkManager(BookmarkManager * bmManager)
|
||||
{
|
||||
m_bmManager = bmManager;
|
||||
}
|
||||
|
||||
void RoutingManager::OnBuildRouteReady(Route const & route, IRouter::ResultCode code)
|
||||
{
|
||||
// Hide preview.
|
||||
|
@ -257,7 +263,7 @@ void RoutingManager::FollowRoute()
|
|||
|
||||
m_delegate.OnRouteFollow(m_currentRouterType);
|
||||
|
||||
// TODO(@darina) Hide start point user mark
|
||||
HideRoutePoint(RouteMarkType::Start);
|
||||
}
|
||||
|
||||
void RoutingManager::CloseRouting()
|
||||
|
@ -273,7 +279,8 @@ void RoutingManager::CloseRouting()
|
|||
m_routingSession.Reset();
|
||||
RemoveRoute(true /* deactivateFollowing */);
|
||||
|
||||
//TODO (@darina) Remove route points
|
||||
UserMarkControllerGuard guard(*m_bmManager, UserMarkType::ROUTING_MARK);
|
||||
guard.m_controller.Clear();
|
||||
}
|
||||
|
||||
void RoutingManager::SetLastUsedRouter(RouterType type)
|
||||
|
@ -281,71 +288,96 @@ void RoutingManager::SetLastUsedRouter(RouterType type)
|
|||
settings::Set(kRouterTypeKey, routing::ToString(type));
|
||||
}
|
||||
|
||||
// TODO(@darina) Remove me
|
||||
// TEMPORARY {
|
||||
void TempAddBookmarkAsRoutePoint(BookmarkManager & bm, std::string const & name,
|
||||
std::string const & bookmarkSymbol,
|
||||
m2::PointD const & pt, bool isValid)
|
||||
void RoutingManager::HideRoutePoint(RouteMarkType type, int8_t intermediateIndex)
|
||||
{
|
||||
std::string categoryName = "TMP_Routing_Points";
|
||||
int categoryIndex = -1;
|
||||
for (size_t i = 0; i < bm.GetBmCategoriesCount(); ++i)
|
||||
UserMarkControllerGuard guard(*m_bmManager, UserMarkType::ROUTING_MARK);
|
||||
RoutePointsLayout routePoints(guard.m_controller);
|
||||
RouteMarkPoint * mark = routePoints.GetRoutePoint(type, intermediateIndex);
|
||||
if (mark != nullptr)
|
||||
{
|
||||
if (bm.GetBmCategory(i)->GetName() == categoryName)
|
||||
mark->SetIsVisible(false);
|
||||
guard.m_controller.Update();
|
||||
}
|
||||
}
|
||||
|
||||
void RoutingManager::UpdateRoute()
|
||||
{
|
||||
if (!IsRoutingActive())
|
||||
return;
|
||||
|
||||
bool isValid = false;
|
||||
|
||||
m2::PointD startPt;
|
||||
m2::PointD finishPt;
|
||||
{
|
||||
UserMarkControllerGuard guard(*m_bmManager, UserMarkType::ROUTING_MARK);
|
||||
RoutePointsLayout routePoints(guard.m_controller);
|
||||
RouteMarkPoint * start = routePoints.GetRoutePoint(RouteMarkType::Start);
|
||||
RouteMarkPoint * finish = routePoints.GetRoutePoint(RouteMarkType::Finish);
|
||||
if (start != nullptr && finish != nullptr)
|
||||
{
|
||||
categoryIndex = static_cast<int>(i);
|
||||
break;
|
||||
startPt = start->GetPivot();
|
||||
finishPt = finish->GetPivot();
|
||||
isValid = true;
|
||||
}
|
||||
}
|
||||
if (categoryIndex == -1)
|
||||
categoryIndex = bm.CreateBmCategory(categoryName);
|
||||
|
||||
if (!isValid)
|
||||
if (isValid)
|
||||
{
|
||||
BookmarkCategory * cat = bm.GetBmCategory(categoryIndex);
|
||||
BookmarkCategory::Guard guard(*cat);
|
||||
int indexToDelete = -1;
|
||||
for (size_t i = 0; i < guard.m_controller.GetUserMarkCount(); ++i)
|
||||
{
|
||||
Bookmark const * bookmark = static_cast<Bookmark const *>(guard.m_controller.GetUserMark(i));
|
||||
if (bookmark->GetName() == name)
|
||||
{
|
||||
indexToDelete = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (indexToDelete >= 0)
|
||||
guard.m_controller.DeleteUserMark(indexToDelete);
|
||||
RemoveRoute(true /* deactivateFollowing */);
|
||||
m_routingSession.SetUserCurrentPosition(startPt);
|
||||
m_routingSession.BuildRoute(startPt, finishPt, 0 /* timeoutSec */);
|
||||
}
|
||||
else
|
||||
{
|
||||
BookmarkData dat(name, bookmarkSymbol);
|
||||
bm.AddBookmark(categoryIndex, pt, dat);
|
||||
CloseRouting();
|
||||
}
|
||||
}
|
||||
|
||||
bool RoutingManager::CouldAddIntermediatePoint() const
|
||||
{
|
||||
if (!IsRoutingActive())
|
||||
return false;
|
||||
UserMarkControllerGuard guard(*m_bmManager, UserMarkType::ROUTING_MARK);
|
||||
return guard.m_controller.GetUserMarkCount() < RoutePointsLayout::kMaxIntermediatePointsCount + 2;
|
||||
}
|
||||
|
||||
void RoutingManager::AddRoutePoint(m2::PointD const & pt, bool isMyPosition,
|
||||
RouteMarkType type, int8_t intermediateIndex)
|
||||
{
|
||||
ASSERT(m_bmManager != nullptr, ());
|
||||
UserMarkControllerGuard guard(*m_bmManager, UserMarkType::ROUTING_MARK);
|
||||
RoutePointsLayout routePoints(guard.m_controller);
|
||||
RouteMarkPoint * mark = routePoints.AddRoutePoint(pt, type, intermediateIndex);
|
||||
if (mark != nullptr)
|
||||
{
|
||||
BookmarkCategory * cat = bm.GetBmCategory(categoryIndex);
|
||||
cat->SaveToKMLFile();
|
||||
mark->SetIsVisible(!isMyPosition);
|
||||
mark->SetIsMyPosition(isMyPosition);
|
||||
}
|
||||
}
|
||||
// } TEMPORARY
|
||||
|
||||
void RoutingManager::SetRouteStartPoint(BookmarkManager & bm, m2::PointD const & pt, bool isValid)
|
||||
{
|
||||
// TODO(@darina) Implement on new user marks
|
||||
// TEMPORARY {
|
||||
//TempAddBookmarkAsRoutePoint(bm, "Route start point", "placemark-blue",
|
||||
// pt, isValid);
|
||||
// } TEMPORARY
|
||||
// TODO(@darina) Update route.
|
||||
}
|
||||
|
||||
void RoutingManager::SetRouteFinishPoint(BookmarkManager & bm, m2::PointD const & pt, bool isValid)
|
||||
void RoutingManager::RemoveRoutePoint(RouteMarkType type, int8_t intermediateIndex)
|
||||
{
|
||||
// TODO(@darina) Implement on new user marks
|
||||
// TEMPORARY {
|
||||
//TempAddBookmarkAsRoutePoint(bm, "Route end point", "placemark-green",
|
||||
// pt, isValid);
|
||||
// } TEMPORARY
|
||||
ASSERT(m_bmManager != nullptr, ());
|
||||
{
|
||||
UserMarkControllerGuard guard(*m_bmManager, UserMarkType::ROUTING_MARK);
|
||||
RoutePointsLayout routePoints(guard.m_controller);
|
||||
routePoints.RemoveRoutePoint(type, intermediateIndex);
|
||||
}
|
||||
//UpdateRoute();
|
||||
}
|
||||
|
||||
void RoutingManager::MoveRoutePoint(RouteMarkType currentType, int8_t currentIntermediateIndex,
|
||||
RouteMarkType targetType, int8_t targetIntermediateIndex)
|
||||
{
|
||||
ASSERT(m_bmManager != nullptr, ());
|
||||
UserMarkControllerGuard guard(*m_bmManager, UserMarkType::ROUTING_MARK);
|
||||
RoutePointsLayout routePoints(guard.m_controller);
|
||||
routePoints.MoveRoutePoint(currentType, currentIntermediateIndex,
|
||||
targetType, targetIntermediateIndex);
|
||||
|
||||
// TODO(@darina) Update route.
|
||||
}
|
||||
|
||||
void RoutingManager::GenerateTurnNotifications(std::vector<std::string> & turnNotifications)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
// TODO (@darina) TEMPORARY Remove me
|
||||
#include "map/bookmark_manager.hpp"
|
||||
#include "map/routing_mark.hpp"
|
||||
|
||||
#include "routing/route.hpp"
|
||||
#include "routing/routing_session.hpp"
|
||||
|
@ -75,6 +75,8 @@ public:
|
|||
|
||||
RoutingManager(Callbacks && callbacks, Delegate & delegate);
|
||||
|
||||
void SetBookmarkManager(BookmarkManager * bmManager);
|
||||
|
||||
routing::RoutingSession const & RoutingSession() const { return m_routingSession; }
|
||||
routing::RoutingSession & RoutingSession() { return m_routingSession; }
|
||||
void SetRouter(routing::RouterType type);
|
||||
|
@ -159,9 +161,12 @@ public:
|
|||
/// GenerateTurnNotifications shall be called by the client when a new position is available.
|
||||
void GenerateTurnNotifications(std::vector<std::string> & turnNotifications);
|
||||
|
||||
// TODO (@darina) Change interface to add/remove route point
|
||||
void SetRouteStartPoint(BookmarkManager & bm, m2::PointD const & pt, bool isValid);
|
||||
void SetRouteFinishPoint(BookmarkManager & bm, m2::PointD const & pt, bool isValid);
|
||||
void AddRoutePoint(m2::PointD const & pt, bool isMyPosition, RouteMarkType type, int8_t intermediateIndex = 0);
|
||||
void RemoveRoutePoint(RouteMarkType type, int8_t intermediateIndex = 0);
|
||||
void MoveRoutePoint(RouteMarkType currentType, int8_t currentIntermediateIndex,
|
||||
RouteMarkType targetType, int8_t targetIntermediateIndex);
|
||||
void HideRoutePoint(RouteMarkType type, int8_t intermediateIndex = 0);
|
||||
bool CouldAddIntermediatePoint() const;
|
||||
|
||||
void SetRouterImpl(routing::RouterType type);
|
||||
void RemoveRoute(bool deactivateFollowing);
|
||||
|
@ -207,6 +212,7 @@ private:
|
|||
bool IsTrackingReporterEnabled() const;
|
||||
void MatchLocationToRoute(location::GpsInfo & info,
|
||||
location::RouteMatchingInfo & routeMatchingInfo) const;
|
||||
void UpdateRoute();
|
||||
|
||||
RouteBuildingCallback m_routingCallback = nullptr;
|
||||
Callbacks m_callbacks;
|
||||
|
@ -215,6 +221,7 @@ private:
|
|||
routing::RoutingSession m_routingSession;
|
||||
Delegate & m_delegate;
|
||||
tracking::Reporter m_trackingReporter;
|
||||
BookmarkManager * m_bmManager = nullptr;
|
||||
|
||||
std::vector<dp::DrapeID> m_drapeSubroutes;
|
||||
|
||||
|
|
205
map/routing_mark.cpp
Normal file
205
map/routing_mark.cpp
Normal file
|
@ -0,0 +1,205 @@
|
|||
#include "map/routing_mark.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
RouteMarkPoint::RouteMarkPoint(const m2::PointD & ptOrg, UserMarkContainer * container)
|
||||
: UserMark(ptOrg, container)
|
||||
{}
|
||||
|
||||
bool RouteMarkPoint::IsVisible() const
|
||||
{
|
||||
return m_isVisible;
|
||||
}
|
||||
|
||||
void RouteMarkPoint::SetIsVisible(bool isVisible)
|
||||
{
|
||||
m_isVisible = isVisible;
|
||||
}
|
||||
|
||||
void RouteMarkPoint::SetIsMyPosition(bool isMyPosition)
|
||||
{
|
||||
m_isMyPosition = isMyPosition;
|
||||
}
|
||||
|
||||
bool RouteMarkPoint::IsMyPosition() const
|
||||
{
|
||||
return m_isMyPosition;
|
||||
}
|
||||
|
||||
std::string RouteMarkPoint::GetSymbolName() const
|
||||
{
|
||||
switch (m_pointType)
|
||||
{
|
||||
case RouteMarkType::Start:
|
||||
return "placemark-blue";
|
||||
case RouteMarkType::Intermediate:
|
||||
if (m_intermediateIndex == 0)
|
||||
return "placemark-yellow";
|
||||
if (m_intermediateIndex == 1)
|
||||
return "placemark-orange";
|
||||
return "placemark-red";
|
||||
case RouteMarkType::Finish:
|
||||
return "placemark-green";
|
||||
}
|
||||
}
|
||||
|
||||
RouteUserMarkContainer::RouteUserMarkContainer(double layerDepth, Framework & fm)
|
||||
: UserMarkContainer(layerDepth, UserMarkType::ROUTING_MARK, fm)
|
||||
{
|
||||
}
|
||||
|
||||
UserMark * RouteUserMarkContainer::AllocateUserMark(m2::PointD const & ptOrg)
|
||||
{
|
||||
return new RouteMarkPoint(ptOrg, this);
|
||||
}
|
||||
|
||||
int8_t const RoutePointsLayout::kMaxIntermediatePointsCount = 1;
|
||||
|
||||
RoutePointsLayout::RoutePointsLayout(UserMarksController & routeMarks)
|
||||
: m_routeMarks(routeMarks)
|
||||
{}
|
||||
|
||||
RouteMarkPoint * RoutePointsLayout::AddRoutePoint(m2::PointD const & ptOrg, RouteMarkType type,
|
||||
int8_t intermediateIndex)
|
||||
{
|
||||
if (m_routeMarks.GetUserMarkCount() == kMaxIntermediatePointsCount + 2)
|
||||
return nullptr;
|
||||
|
||||
RouteMarkPoint * sameTypePoint = GetRoutePoint(type, intermediateIndex);
|
||||
if (sameTypePoint != nullptr)
|
||||
{
|
||||
if (type == RouteMarkType::Finish)
|
||||
{
|
||||
int8_t const intermediatePointsCount = std::max((int)m_routeMarks.GetUserMarkCount() - 2, 0);
|
||||
sameTypePoint->SetRoutePointType(RouteMarkType::Intermediate);
|
||||
sameTypePoint->SetIntermediateIndex(intermediatePointsCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
int8_t const offsetIndex = type == RouteMarkType::Start ? 0 : intermediateIndex;
|
||||
|
||||
ForEachIntermediatePoint([offsetIndex](RouteMarkPoint * mark)
|
||||
{
|
||||
if (mark->GetIntermediateIndex() >= offsetIndex)
|
||||
mark->SetIntermediateIndex(mark->GetIntermediateIndex() + 1);
|
||||
});
|
||||
|
||||
if (type == RouteMarkType::Start)
|
||||
{
|
||||
sameTypePoint->SetRoutePointType(RouteMarkType::Intermediate);
|
||||
sameTypePoint->SetIntermediateIndex(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
RouteMarkPoint * newPoint = static_cast<RouteMarkPoint*>(m_routeMarks.CreateUserMark(ptOrg));
|
||||
newPoint->SetRoutePointType(type);
|
||||
newPoint->SetIntermediateIndex(intermediateIndex);
|
||||
|
||||
return newPoint;
|
||||
}
|
||||
|
||||
|
||||
bool RoutePointsLayout::RemoveRoutePoint(RouteMarkType type, int8_t intermediateIndex)
|
||||
{
|
||||
RouteMarkPoint * point = nullptr;
|
||||
size_t index = 0;
|
||||
for (size_t sz = m_routeMarks.GetUserMarkCount(); index < sz; ++index)
|
||||
{
|
||||
RouteMarkPoint * mark = static_cast<RouteMarkPoint*>(m_routeMarks.GetUserMarkForEdit(index));
|
||||
if (mark->GetRoutePointType() == type && mark->GetIntermediateIndex() == intermediateIndex)
|
||||
{
|
||||
point = mark;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (point == nullptr)
|
||||
return false;
|
||||
|
||||
if (type == RouteMarkType::Finish)
|
||||
{
|
||||
RouteMarkPoint * lastIntermediate = nullptr;
|
||||
int8_t maxIntermediateIndex = -1;
|
||||
ForEachIntermediatePoint([&lastIntermediate, &maxIntermediateIndex](RouteMarkPoint * mark)
|
||||
{
|
||||
if (mark->GetIntermediateIndex() > maxIntermediateIndex)
|
||||
{
|
||||
lastIntermediate = mark;
|
||||
maxIntermediateIndex = mark->GetIntermediateIndex();
|
||||
}
|
||||
});
|
||||
|
||||
if (lastIntermediate != nullptr)
|
||||
lastIntermediate->SetRoutePointType(RouteMarkType::Finish);
|
||||
}
|
||||
else if (type == RouteMarkType::Start)
|
||||
{
|
||||
ForEachIntermediatePoint([](RouteMarkPoint * mark)
|
||||
{
|
||||
if (mark->GetIntermediateIndex() == 0)
|
||||
mark->SetRoutePointType(RouteMarkType::Start);
|
||||
else
|
||||
mark->SetIntermediateIndex(mark->GetIntermediateIndex() - 1);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
ForEachIntermediatePoint([point](RouteMarkPoint * mark)
|
||||
{
|
||||
if (mark->GetIntermediateIndex() > point->GetIntermediateIndex())
|
||||
mark->SetIntermediateIndex(mark->GetIntermediateIndex() - 1);
|
||||
});
|
||||
}
|
||||
|
||||
m_routeMarks.DeleteUserMark(index);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RoutePointsLayout::MoveRoutePoint(RouteMarkType currentType, int8_t currentIntermediateIndex,
|
||||
RouteMarkType destType, int8_t destIntermediateIndex)
|
||||
{
|
||||
RouteMarkPoint * point = GetRoutePoint(currentType, currentIntermediateIndex);
|
||||
if (point == nullptr)
|
||||
return false;
|
||||
|
||||
m2::PointD const pt = point->GetPivot();
|
||||
bool const isVisible = point->IsVisible();
|
||||
bool const isMyPosition = point->IsMyPosition();
|
||||
|
||||
RemoveRoutePoint(currentType, currentIntermediateIndex);
|
||||
RouteMarkPoint * point2 = AddRoutePoint(pt, destType, destIntermediateIndex);
|
||||
point2->SetIsVisible(isVisible);
|
||||
point2->SetIsMyPosition(isMyPosition);
|
||||
return true;
|
||||
}
|
||||
|
||||
RouteMarkPoint * RoutePointsLayout::GetRoutePoint(RouteMarkType type, int8_t intermediateIndex)
|
||||
{
|
||||
for (size_t i = 0, sz = m_routeMarks.GetUserMarkCount(); i < sz; ++i)
|
||||
{
|
||||
RouteMarkPoint * mark = static_cast<RouteMarkPoint*>(m_routeMarks.GetUserMarkForEdit(i));
|
||||
if (mark->GetRoutePointType() != type)
|
||||
continue;
|
||||
|
||||
if (type == RouteMarkType::Intermediate)
|
||||
{
|
||||
if (mark->GetIntermediateIndex() == intermediateIndex)
|
||||
return mark;
|
||||
}
|
||||
else
|
||||
{
|
||||
return mark;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void RoutePointsLayout::ForEachIntermediatePoint(TRoutePointCallback const & fn)
|
||||
{
|
||||
for (size_t i = 0, sz = m_routeMarks.GetUserMarkCount(); i < sz; ++i)
|
||||
{
|
||||
RouteMarkPoint * mark = static_cast<RouteMarkPoint*>(m_routeMarks.GetUserMarkForEdit(i));
|
||||
if (mark->GetRoutePointType() == RouteMarkType::Intermediate)
|
||||
fn(mark);
|
||||
}
|
||||
}
|
68
map/routing_mark.hpp
Normal file
68
map/routing_mark.hpp
Normal file
|
@ -0,0 +1,68 @@
|
|||
#pragma once
|
||||
|
||||
#include "map/user_mark_container.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
enum class RouteMarkType
|
||||
{
|
||||
Start,
|
||||
Intermediate,
|
||||
Finish
|
||||
};
|
||||
|
||||
class RouteMarkPoint : public UserMark
|
||||
{
|
||||
public:
|
||||
RouteMarkPoint(m2::PointD const & ptOrg, UserMarkContainer * container);
|
||||
virtual ~RouteMarkPoint() {}
|
||||
|
||||
bool IsVisible() const override;
|
||||
void SetIsVisible(bool isVisible);
|
||||
|
||||
std::string GetSymbolName() const override;
|
||||
UserMark::Type GetMarkType() const override { return Type::ROUTING; }
|
||||
|
||||
RouteMarkType GetRoutePointType() const { return m_pointType; }
|
||||
void SetRoutePointType(RouteMarkType type) { m_pointType = type; }
|
||||
|
||||
void SetIntermediateIndex(int8_t index) { m_intermediateIndex = index; }
|
||||
int8_t GetIntermediateIndex() const { return m_intermediateIndex; }
|
||||
|
||||
void SetIsMyPosition(bool isMyPosition);
|
||||
bool IsMyPosition() const;
|
||||
|
||||
private:
|
||||
RouteMarkType m_pointType;
|
||||
int8_t m_intermediateIndex = 0;
|
||||
bool m_isVisible = true;
|
||||
bool m_isMyPosition = false;
|
||||
};
|
||||
|
||||
class RouteUserMarkContainer : public UserMarkContainer
|
||||
{
|
||||
public:
|
||||
RouteUserMarkContainer(double layerDepth, Framework & fm);
|
||||
protected:
|
||||
UserMark * AllocateUserMark(m2::PointD const & ptOrg) override;
|
||||
};
|
||||
|
||||
class RoutePointsLayout
|
||||
{
|
||||
public:
|
||||
static int8_t const kMaxIntermediatePointsCount;
|
||||
|
||||
RoutePointsLayout(UserMarksController & routeMarks);
|
||||
|
||||
RouteMarkPoint * GetRoutePoint(RouteMarkType type, int8_t intermediateIndex = 0);
|
||||
RouteMarkPoint * AddRoutePoint(m2::PointD const & ptOrg, RouteMarkType type, int8_t intermediateIndex = 0);
|
||||
bool RemoveRoutePoint(RouteMarkType type, int8_t intermediateIndex = 0);
|
||||
bool MoveRoutePoint(RouteMarkType currentType, int8_t currentIntermediateIndex,
|
||||
RouteMarkType destType, int8_t destIntermediateIndex);
|
||||
|
||||
private:
|
||||
using TRoutePointCallback = function<void (RouteMarkPoint * mark)>;
|
||||
void ForEachIntermediatePoint(TRoutePointCallback const & fn);
|
||||
|
||||
UserMarksController & m_routeMarks;
|
||||
};
|
|
@ -106,5 +106,6 @@ string DebugPrint(UserMark::Type type)
|
|||
case UserMark::Type::BOOKMARK: return "BOOKMARK";
|
||||
case UserMark::Type::MY_POSITION: return "MY_POSITION";
|
||||
case UserMark::Type::DEBUG_MARK: return "DEBUG_MARK";
|
||||
case UserMark::Type::ROUTING: return "ROUTING";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ public:
|
|||
POI,
|
||||
BOOKMARK,
|
||||
MY_POSITION,
|
||||
ROUTING,
|
||||
DEBUG_MARK
|
||||
};
|
||||
|
||||
|
|
|
@ -21,7 +21,8 @@ enum class UserMarkType
|
|||
SEARCH_MARK,
|
||||
API_MARK,
|
||||
DEBUG_MARK,
|
||||
BOOKMARK_MARK
|
||||
BOOKMARK_MARK,
|
||||
ROUTING_MARK
|
||||
};
|
||||
|
||||
class UserMarksController
|
||||
|
|
|
@ -97,6 +97,8 @@
|
|||
67F183831BD5049500AB1840 /* libminizip.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 67F1837F1BD5049500AB1840 /* libminizip.a */; };
|
||||
67F183841BD5049500AB1840 /* libtess2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 67F183801BD5049500AB1840 /* libtess2.a */; };
|
||||
BB421D6C1E8C0031005BFA4D /* transliteration_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BB421D6A1E8C0026005BFA4D /* transliteration_test.cpp */; };
|
||||
BBD9E2C61EE9D01900DF189A /* routing_mark.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BBD9E2C41EE9D01900DF189A /* routing_mark.cpp */; };
|
||||
BBD9E2C71EE9D01900DF189A /* routing_mark.hpp in Headers */ = {isa = PBXBuildFile; fileRef = BBD9E2C51EE9D01900DF189A /* routing_mark.hpp */; };
|
||||
F627BFC41E8E89B600B1CBF4 /* librouting_common.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F627BFC31E8E89B600B1CBF4 /* librouting_common.a */; };
|
||||
F63421F81DF9BF9100A96868 /* reachable_by_taxi_checker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F63421F61DF9BF9100A96868 /* reachable_by_taxi_checker.cpp */; };
|
||||
F63421F91DF9BF9100A96868 /* reachable_by_taxi_checker.hpp in Headers */ = {isa = PBXBuildFile; fileRef = F63421F71DF9BF9100A96868 /* reachable_by_taxi_checker.hpp */; };
|
||||
|
@ -226,6 +228,8 @@
|
|||
67F183851BD504ED00AB1840 /* libsystem_configuration.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libsystem_configuration.tbd; path = usr/lib/system/libsystem_configuration.tbd; sourceTree = SDKROOT; };
|
||||
67F183871BD5050900AB1840 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
|
||||
BB421D6A1E8C0026005BFA4D /* transliteration_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = transliteration_test.cpp; sourceTree = "<group>"; };
|
||||
BBD9E2C41EE9D01900DF189A /* routing_mark.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = routing_mark.cpp; sourceTree = "<group>"; };
|
||||
BBD9E2C51EE9D01900DF189A /* routing_mark.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = routing_mark.hpp; sourceTree = "<group>"; };
|
||||
F627BFC31E8E89B600B1CBF4 /* librouting_common.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = librouting_common.a; path = "/Users/v.mikhaylenko/mapsme/omim/xcode/routing_common/../../../omim-build/xcode/Debug/librouting_common.a"; sourceTree = "<absolute>"; };
|
||||
F63421F61DF9BF9100A96868 /* reachable_by_taxi_checker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = reachable_by_taxi_checker.cpp; sourceTree = "<group>"; };
|
||||
F63421F71DF9BF9100A96868 /* reachable_by_taxi_checker.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = reachable_by_taxi_checker.hpp; sourceTree = "<group>"; };
|
||||
|
@ -424,6 +428,8 @@
|
|||
F63421F71DF9BF9100A96868 /* reachable_by_taxi_checker.hpp */,
|
||||
F6D2CE7C1EDEB7F500636DFD /* routing_manager.cpp */,
|
||||
F6D2CE7D1EDEB7F500636DFD /* routing_manager.hpp */,
|
||||
BBD9E2C41EE9D01900DF189A /* routing_mark.cpp */,
|
||||
BBD9E2C51EE9D01900DF189A /* routing_mark.hpp */,
|
||||
347B60741DD9926D0050FA24 /* traffic_manager.cpp */,
|
||||
347B60751DD9926D0050FA24 /* traffic_manager.hpp */,
|
||||
348AB57A1D7EE0C6009F8301 /* chart_generator.cpp */,
|
||||
|
@ -504,6 +510,7 @@
|
|||
F6D2CE7F1EDEB7F500636DFD /* routing_manager.hpp in Headers */,
|
||||
670E39411C46C5C700E9C0A6 /* gps_tracker.hpp in Headers */,
|
||||
45580ABF1E2CBD5E00CD535D /* benchmark_tools.hpp in Headers */,
|
||||
BBD9E2C71EE9D01900DF189A /* routing_mark.hpp in Headers */,
|
||||
342D833B1D5233E8000D8AEA /* displacement_mode_manager.hpp in Headers */,
|
||||
F6B283041C1B03320081957A /* gps_track_collection.hpp in Headers */,
|
||||
);
|
||||
|
@ -634,6 +641,7 @@
|
|||
670E39401C46C5C700E9C0A6 /* gps_tracker.cpp in Sources */,
|
||||
6753464A1A4054E800A0A8C3 /* bookmark.cpp in Sources */,
|
||||
45580ABE1E2CBD5E00CD535D /* benchmark_tools.cpp in Sources */,
|
||||
BBD9E2C61EE9D01900DF189A /* routing_mark.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue