mirror of
https://github.com/BertoldVdb/ZoneDetect.git
synced 2026-03-25 08:45:56 +00:00
Fix edge case for points on border
This commit is contained in:
parent
2f1bfdebe2
commit
44fc1ab2ee
1 changed files with 6 additions and 5 deletions
|
|
@ -691,13 +691,14 @@ static ZDLookupResult ZDPointInPolygon(const ZoneDetect *library, uint32_t polyg
|
|||
b = (float)pointLat - a * (float)pointLon;
|
||||
}
|
||||
|
||||
int onStraight = ZDPointInBox(pointLat, latFixedPoint, prevLat, pointLon, lonFixedPoint, prevLon);
|
||||
if(lineIsStraight && (onStraight || windingNeedCompare)) {
|
||||
if(distanceSqrMin) *distanceSqrMin = 0;
|
||||
return ZD_LOOKUP_ON_BORDER_SEGMENT;
|
||||
}
|
||||
|
||||
/* Jumped two quadrants. */
|
||||
if(windingNeedCompare) {
|
||||
if(lineIsStraight) {
|
||||
if(distanceSqrMin) *distanceSqrMin = 0;
|
||||
return ZD_LOOKUP_ON_BORDER_SEGMENT;
|
||||
}
|
||||
|
||||
/* Check if the target is on the border */
|
||||
const int32_t intersectLon = (int32_t)(((float)latFixedPoint - b) / a);
|
||||
if(intersectLon >= lonFixedPoint-1 && intersectLon <= lonFixedPoint+1) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue