[android] Improve AA route simulator.

Signed-off-by: Viktor Govako <viktor.govako@gmail.com>
This commit is contained in:
Viktor Govako
2025-09-20 20:22:45 -03:00
committed by x7z4w
parent 9912d19302
commit e73c37a5dd
7 changed files with 60 additions and 11 deletions

View File

@@ -1241,16 +1241,32 @@ JNIEXPORT jobject JNICALL Java_app_organicmaps_sdk_Framework_nativeGetRouteFollo
return CreateRoutingInfo(env, info, rm);
}
JNIEXPORT jobjectArray JNICALL Java_app_organicmaps_sdk_Framework_nativeGetRouteJunctionPoints(JNIEnv * env, jclass)
JNIEXPORT jobjectArray JNICALL Java_app_organicmaps_sdk_Framework_nativeGetRouteJunctionPoints(JNIEnv * env, jclass,
jdouble maxDistM)
{
vector<geometry::PointWithAltitude> junctionPoints;
if (!frm()->GetRoutingManager().RoutingSession().GetRouteJunctionPoints(junctionPoints))
vector<geometry::PointWithAltitude> points;
if (!frm()->GetRoutingManager().RoutingSession().GetRouteJunctionPoints(points))
{
LOG(LWARNING, ("Can't get the route junction points"));
return nullptr;
}
return CreateJunctionInfoArray(env, junctionPoints);
vector<geometry::PointWithAltitude> result;
result.reserve(points.size());
result.push_back(points[0]);
for (size_t i = 1; i < points.size(); ++i)
{
double const dist = ms::DistanceOnEarth(points[i - 1].ToLatLon(), points[i].ToLatLon());
if (dist > maxDistM)
{
int const steps = static_cast<int>(dist / maxDistM) + 1;
for (int s = 1; s < steps; ++s)
result.push_back(points[i - 1].Interpolate(points[i], static_cast<double>(s) / steps));
}
result.push_back(points[i]);
}
return CreateJunctionInfoArray(env, result);
}
JNIEXPORT jintArray JNICALL Java_app_organicmaps_sdk_Framework_nativeGenerateRouteAltitudeChartBits(

View File

@@ -2,8 +2,6 @@
#include "app/organicmaps/sdk/core/jni_helper.hpp"
#include "geometry/point_with_altitude.hpp"
#include <vector>
jobjectArray CreateJunctionInfoArray(JNIEnv * env, std::vector<geometry::PointWithAltitude> const & junctionPoints)
@@ -15,7 +13,7 @@ jobjectArray CreateJunctionInfoArray(JNIEnv * env, std::vector<geometry::PointWi
return jni::ToJavaArray(env, junctionClazz, junctionPoints,
[](JNIEnv * env, geometry::PointWithAltitude const & pointWithAltitude)
{
auto & point = pointWithAltitude.GetPoint();
return env->NewObject(junctionClazz, junctionConstructor, mercator::YToLat(point.y), mercator::XToLon(point.x));
auto const & ll = pointWithAltitude.ToLatLon();
return env->NewObject(junctionClazz, junctionConstructor, ll.m_lat, ll.m_lon);
});
}