diff options
author | Stefan Wildemann <metalstrolch@users.noreply.github.com> | 2017-12-04 11:53:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-04 11:53:01 +0100 |
commit | 39a8259e6d7d31e120ee5309e6a92760f08e43c9 (patch) | |
tree | c4ec096cf677f31a0c459d920a443b3596c60e9b /navit/transform.c | |
parent | 0898653cefd5b32db8646516c3bf2cce9baa4b15 (diff) | |
parent | 3584d6ece6016969a1a5a8b56879fa9ea4dfc0fe (diff) | |
download | navit-39a8259e6d7d31e120ee5309e6a92760f08e43c9.tar.gz |
Merge branch 'trunk' into icon_goverment_building
Diffstat (limited to 'navit/transform.c')
-rw-r--r-- | navit/transform.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/navit/transform.c b/navit/transform.c index 1c6eeae67..8a6713ab6 100644 --- a/navit/transform.c +++ b/navit/transform.c @@ -1187,6 +1187,14 @@ transform_overflow_possible_if_squared(int count, ...) { return result; } +/** + * @brief Determines the squared Mercator distance between two points. + * + * @param c0 The first coordinate + * @param c1 The second coordinate + * + * @return The squared distance between `c1` and `c2`, or `INT_MAX` if an overflow occurs. + */ int transform_distance_sq(struct coord *c1, struct coord *c2) { @@ -1216,6 +1224,17 @@ transform_distance_sq_pc(struct pcoord *c1, struct pcoord *c2) return transform_distance_sq(&p1, &p2); } +/** + * @brief Determines the point on a line segment that is closest to a reference point, and its distance + * from the reference point. + * + * @param l0 The first coordinate of the line segment + * @param l1 The second coordinate of the line segment + * @param ref The reference point + * @param lpnt Receives the coordinates of the point on the line segment that is closest to `ref`, can be `NULL` + * + * @return The square of the Mercator distance between `ref` and `lpnt`, or `INT_MAX` if an overflow occurred + */ int transform_distance_line_sq(struct coord *l0, struct coord *l1, struct coord *ref, struct coord *lpnt) { @@ -1287,6 +1306,18 @@ transform_distance_line_sq_float(struct coord *l0, struct coord *l1, struct coor return transform_distance_sq_float(&l, ref); } +/** + * @brief Determines the point on a polyline that is closest to a reference point, and its distance + * from the reference point. + * + * @param c An array containing the coordinates of the polyline + * @param count Number of elements in `c` + * @param ref The reference point + * @param lpnt Receives the coordinates of the point on the polyline that is closest to `ref`, can be `NULL` + * @param pos Receives the index of the line segment containing `lpnt`, can be NULL + * + * @return The square of the Mercator distance between `ref` and `lpnt`, or `INT_MAX` if an overflow occurred + */ int transform_distance_polyline_sq(struct coord *c, int count, struct coord *ref, struct coord *lpnt, int *pos) { |