Ticket #17745: 17745.patch
| File 17745.patch, 3.7 KB (added by , 7 years ago) |
|---|
-
src/org/openstreetmap/josm/tools/Geometry.java
1042 1042 1043 1043 /** 1044 1044 * Find all primitives in the given collection which are inside the given polygon. 1045 * Unclosed ways and multipolygon relations with unclosed outer rings are ignored. 1045 1046 * @param primitives the primitives 1046 1047 * @param polygon the polygon 1047 1048 * @return a new list containing the found primitives, empty if polygon is invalid or nothing was found. … … 1060 1061 res.add(p); 1061 1062 } 1062 1063 } else if (p instanceof IWay) { 1063 if (polygonArea == null) { 1064 polygonArea = getArea(polygon.getNodes()); 1064 if (((IWay<?>) p).isClosed()) { 1065 if (polygonArea == null) { 1066 polygonArea = getArea(polygon.getNodes()); 1067 } 1068 if (PolygonIntersection.FIRST_INSIDE_SECOND == polygonIntersection(getArea(((IWay<?>) p).getNodes()), 1069 polygonArea)) { 1070 res.add(p); 1071 } 1065 1072 } 1066 if (PolygonIntersection.FIRST_INSIDE_SECOND == polygonIntersection(getArea(((IWay<?>) p).getNodes()),1067 polygonArea)) {1068 res.add(p);1069 }1070 1073 } else if (p.isMultipolygon()) { 1071 1074 if (polygonArea == null) { 1072 1075 polygonArea = getArea(polygon.getNodes()); … … 1075 1078 boolean inside = true; 1076 1079 // a (valid) multipolygon is inside the polygon if all outer rings are inside 1077 1080 for (PolyData outer : mp.getOuterPolygons()) { 1078 if (PolygonIntersection.FIRST_INSIDE_SECOND != polygonIntersection(getArea(outer.getNodes()), 1079 polygonArea)) { 1081 if (!outer.isClosed() 1082 || PolygonIntersection.FIRST_INSIDE_SECOND != polygonIntersection(getArea(outer.getNodes()), 1083 polygonArea)) { 1080 1084 inside = false; 1081 1085 break; 1082 1086 } … … 1091 1095 1092 1096 /** 1093 1097 * Find all primitives in the given collection which are inside the given multipolygon. Members of the multipolygon are 1094 * ignored. 1098 * ignored. Unclosed ways and multipolygon relations with unclosed outer rings are ignored. 1095 1099 * @param primitives the primitives 1096 1100 * @param multiPolygon the multipolygon relation 1097 1101 * @return a new list containing the found primitives, empty if multipolygon is invalid or nothing was found. … … 1120 1124 res.add(p); 1121 1125 } 1122 1126 } else if (p instanceof Way) { 1123 if ( isPolygonInsideMultiPolygon(((Way) p).getNodes(), outerInner, null)) {1127 if (((IWay<?>) p).isClosed() && isPolygonInsideMultiPolygon(((Way) p).getNodes(), outerInner, null)) { 1124 1128 res.add(p); 1125 1129 } 1126 1130 } else if (p.isMultipolygon()) { … … 1128 1132 boolean inside = true; 1129 1133 // a (valid) multipolygon is inside multiPolygon if all outer rings are inside 1130 1134 for (PolyData outer : mp.getOuterPolygons()) { 1131 if (! isPolygonInsideMultiPolygon(outer.getNodes(), outerInner, null)) {1135 if (!outer.isClosed() || !isPolygonInsideMultiPolygon(outer.getNodes(), outerInner, null)) { 1132 1136 inside = false; 1133 1137 break; 1134 1138 }
