diff --git a/OsmAnd-java/src/net/osmand/util/MapAlgorithms.java b/OsmAnd-java/src/net/osmand/util/MapAlgorithms.java index 44c019b217..7efce5145d 100644 --- a/OsmAnd-java/src/net/osmand/util/MapAlgorithms.java +++ b/OsmAnd-java/src/net/osmand/util/MapAlgorithms.java @@ -301,7 +301,8 @@ public class MapAlgorithms { */ private static int countIntersections(Collection polyNodes, double latitude, double longitude) { int intersections = 0; - if (polyNodes.size() == 0) return 0; + if (polyNodes.size() == 0) + return 0; Node prev = null; Node first = null; Node last = null; @@ -321,6 +322,9 @@ public class MapAlgorithms { } prev = n; } + if(first == null || last == null) { + return 0; + } // special handling, also count first and last, might not be closed, but // we want this! if (OsmMapUtils.ray_intersect_lon(first,