forked from organicmaps/organicmaps
Added URLs for discovery manager
This commit is contained in:
parent
02f15cd105
commit
b3f22d4cf5
6 changed files with 58 additions and 2 deletions
|
@ -180,4 +180,16 @@ Java_com_mapswithme_maps_discovery_DiscoveryManager_nativeDiscover(JNIEnv * env,
|
|||
g_lastRequestId = g_framework->NativeFramework()->Discover(std::move(p), DiscoveryCallback(),
|
||||
std::bind(&OnDiscoveryError, _1, _2));
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_mapswithme_maps_discovery_DiscoveryManager_nativeGetViatorUrl(JNIEnv * env, jclass)
|
||||
{
|
||||
return jni::ToJavaString(env, g_framework->NativeFramework()->GetDiscoveryViatorUrl());
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_mapswithme_maps_discovery_DiscoveryManager_nativeGetLocalExpertsUrl(JNIEnv * env, jclass)
|
||||
{
|
||||
return jni::ToJavaString(env, g_framework->NativeFramework()->GetDiscoveryLocalExpertsUrl());
|
||||
}
|
||||
} // extern "C"
|
||||
|
|
|
@ -77,4 +77,10 @@ enum DiscoveryManager
|
|||
}
|
||||
|
||||
public static native void nativeDiscover(@NonNull DiscoveryParams params);
|
||||
|
||||
@NonNull
|
||||
public static native String nativeGetViatorUrl();
|
||||
|
||||
@NonNull
|
||||
public static native String nativeGetLocalExpertsUrl();
|
||||
}
|
||||
|
|
|
@ -39,6 +39,20 @@ search::SearchParams Manager::GetSearchParams(Manager::Params const & params, It
|
|||
return p;
|
||||
}
|
||||
|
||||
std::string Manager::GetViatorUrl(m2::PointD const & point) const
|
||||
{
|
||||
auto const viatorId = GetCityViatorId(point);
|
||||
if (viatorId.empty())
|
||||
return {};
|
||||
return viator::Api::GetCityUrl(viatorId);
|
||||
}
|
||||
|
||||
std::string Manager::GetLocalExpertsUrl(m2::PointD const & point) const
|
||||
{
|
||||
UNUSED_VALUE(point);
|
||||
return locals::Api::GetLocalsPageUrl();
|
||||
}
|
||||
|
||||
std::string Manager::GetCityViatorId(m2::PointD const & point) const
|
||||
{
|
||||
ASSERT_THREAD_CHECKER(m_threadChecker, ());
|
||||
|
|
|
@ -128,6 +128,9 @@ public:
|
|||
return requestId;
|
||||
}
|
||||
|
||||
std::string GetViatorUrl(m2::PointD const & point) const;
|
||||
std::string GetLocalExpertsUrl(m2::PointD const & point) const;
|
||||
|
||||
private:
|
||||
static search::SearchParams GetSearchParams(Params const & params, ItemType const type);
|
||||
std::string GetCityViatorId(m2::PointD const & point) const;
|
||||
|
|
|
@ -2547,8 +2547,7 @@ discovery::Manager::Params Framework::GetDiscoveryParams(
|
|||
{
|
||||
auto constexpr kRectSideM = 2000.0;
|
||||
discovery::Manager::Params p;
|
||||
auto const currentPosition = GetCurrentPosition();
|
||||
p.m_viewportCenter = currentPosition ? *currentPosition : GetViewportCenter();
|
||||
p.m_viewportCenter = GetDiscoveryViewportCenter();
|
||||
p.m_viewport = MercatorBounds::RectByCenterXYAndSizeInMeters(p.m_viewportCenter, kRectSideM);
|
||||
p.m_curency = clientParams.m_currency;
|
||||
p.m_lang = clientParams.m_lang;
|
||||
|
@ -2557,6 +2556,22 @@ discovery::Manager::Params Framework::GetDiscoveryParams(
|
|||
return p;
|
||||
}
|
||||
|
||||
std::string Framework::GetDiscoveryViatorUrl() const
|
||||
{
|
||||
return m_discoveryManager->GetViatorUrl(GetDiscoveryViewportCenter());
|
||||
}
|
||||
|
||||
std::string Framework::GetDiscoveryLocalExpertsUrl() const
|
||||
{
|
||||
return m_discoveryManager->GetLocalExpertsUrl(GetDiscoveryViewportCenter());
|
||||
}
|
||||
|
||||
m2::PointD Framework::GetDiscoveryViewportCenter() const
|
||||
{
|
||||
auto const currentPosition = GetCurrentPosition();
|
||||
return currentPosition ? *currentPosition : GetViewportCenter();
|
||||
}
|
||||
|
||||
vector<m2::TriangleD> Framework::GetSelectedFeatureTriangles() const
|
||||
{
|
||||
vector<m2::TriangleD> triangles;
|
||||
|
|
|
@ -758,6 +758,12 @@ public:
|
|||
|
||||
discovery::Manager::Params GetDiscoveryParams(discovery::ClientParams && clientParams) const;
|
||||
|
||||
std::string GetDiscoveryViatorUrl() const;
|
||||
std::string GetDiscoveryLocalExpertsUrl() const;
|
||||
|
||||
private:
|
||||
m2::PointD GetDiscoveryViewportCenter() const;
|
||||
|
||||
public:
|
||||
/// Routing Manager
|
||||
RoutingManager & GetRoutingManager() { return m_routingManager; }
|
||||
|
|
Loading…
Add table
Reference in a new issue