summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--navit/route.c32
-rw-r--r--navit/route.h1
2 files changed, 32 insertions, 1 deletions
diff --git a/navit/route.c b/navit/route.c
index 056b270ac..63bb3f2a0 100644
--- a/navit/route.c
+++ b/navit/route.c
@@ -42,8 +42,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#if 0
#include <math.h>
+#if 0
#include <assert.h>
#include <unistd.h>
#include <sys/time.h>
@@ -394,6 +394,36 @@ rp_iterator_end(struct route_graph_point_iterator *it) {
}
}
+static void
+route_path_get_distances(struct route_path *path, struct coord *c, int count, int *distances)
+{
+ int i;
+ for (i = 0 ; i < count ; i++)
+ distances[i]=INT_MAX;
+ while (path) {
+ struct route_path_segment *seg=path->path;
+ while (seg) {
+ for (i = 0 ; i < count ; i++) {
+ int dist=transform_distance_polyline_sq(seg->c, seg->ncoords, &c[i], NULL, NULL);
+ if (dist < distances[i])
+ distances[i]=dist;
+ }
+ seg=seg->next;
+ }
+ path=path->next;
+ }
+ for (i = 0 ; i < count ; i++) {
+ if (distances[i] != INT_MAX)
+ distances[i]=sqrt(distances[i]);
+ }
+}
+
+void
+route_get_distances(struct route *this, struct coord *c, int count, int *distances)
+{
+ return route_path_get_distances(this->path2, c, count, distances);
+}
+
/**
* @brief Destroys a route_path
*
diff --git a/navit/route.h b/navit/route.h
index 6834d5b84..7a9eefbdc 100644
--- a/navit/route.h
+++ b/navit/route.h
@@ -96,6 +96,7 @@ struct map_selection *route_rect(int order, struct coord *c1, struct coord *c2,
void route_set_destinations(struct route *this_, struct pcoord *dst, int count, int async);
int route_get_destinations(struct route *this_, struct pcoord *pc, int count);
int route_get_destination_count(struct route *this_);
+void route_get_distances(struct route *this, struct coord *c, int count, int *distances);
void route_set_destination(struct route *this_, struct pcoord *dst, int async);
void route_append_destination(struct route *this_, struct pcoord *dst, int async);
void route_remove_nth_waypoint(struct route *this_, int n);