diff --git a/OsmAnd-java/src/main/java/net/osmand/util/MapAlgorithms.java b/OsmAnd-java/src/main/java/net/osmand/util/MapAlgorithms.java index 23307babc9..e423e30860 100644 --- a/OsmAnd-java/src/main/java/net/osmand/util/MapAlgorithms.java +++ b/OsmAnd-java/src/main/java/net/osmand/util/MapAlgorithms.java @@ -182,11 +182,20 @@ public class MapAlgorithms { } } + if (outx == rightX || outx == leftX) { + if (outy >= topY && outy <= bottomY) { + bx = outx; + by = outy; + return combine2Points(bx, by); + } + } - if (outx == rightX || outx == leftX || outy == topY || outy == bottomY) { - bx = outx; - by = outy; - //return (((long) bx) << 32) | ((long) by); + if (outy == topY || outy == bottomY) { + if (leftX <= outx && outx <= rightX) { + bx = outx; + by = outy; + return combine2Points(bx, by); + } } return -1L; }