summaryrefslogtreecommitdiff
path: root/src/mbgl/util
diff options
context:
space:
mode:
authorzmiao <miao.zhao@mapbox.com>2020-03-04 11:38:50 +0200
committerzmiao <miao.zhao@mapbox.com>2020-03-05 20:53:16 +0200
commitaa0c9c267f1ab5abe9f9756e300f61edabac4a31 (patch)
tree48a6b46ef713057c50145b72c8a6579b880fecd7 /src/mbgl/util
parentc69d3b46b12655533aaee5740eba25f5bf7b11de (diff)
downloadqtlocation-mapboxgl-aa0c9c267f1ab5abe9f9756e300f61edabac4a31.tar.gz
[core] Fix within expression serialization + fix within expression equal operator
Diffstat (limited to 'src/mbgl/util')
-rw-r--r--src/mbgl/util/geometry_within.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/mbgl/util/geometry_within.cpp b/src/mbgl/util/geometry_within.cpp
index d6340fc14e..4a0a5cce11 100644
--- a/src/mbgl/util/geometry_within.cpp
+++ b/src/mbgl/util/geometry_within.cpp
@@ -9,7 +9,11 @@ bool rayIntersect(const Point<double>& p, const Point<double>& p1, const Point<d
return ((p1.y > p.y) != (p2.y > p.y)) && (p.x < (p2.x - p1.x) * (p.y - p1.y) / (p2.y - p1.y) + p1.x);
}
+// check if point p in on line segment with end points p1 and p2
bool onBoundary(const Point<double>& p, const Point<double>& p1, const Point<double>& p2) {
+ // requirements of point p on line segment:
+ // 1. colinear: cross product of vector p->p1(x1, y1) and vector p->p2(x2, y2) equals to 0
+ // 2. p is between p1 and p2
const auto x1 = p.x - p1.x;
const auto y1 = p.y - p1.y;
const auto x2 = p.x - p2.x;