Fix edge case for points on border

This commit is contained in:
Bertold Van den Bergh 2019-12-13 17:50:39 +01:00
parent 2f1bfdebe2
commit 44fc1ab2ee

View file

@ -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) {