diff --git a/library/zonedetect.c b/library/zonedetect.c index 6f800f4..b34a486 100644 --- a/library/zonedetect.c +++ b/library/zonedetect.c @@ -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) {