Changeset 15107 in josm for trunk/src/org
- Timestamp:
- 2019-05-25T07:23:25+02:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/Geometry.java
r15069 r15107 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 … … 1061 1062 } 1062 1063 } else if (p instanceof IWay) { 1063 if (polygonArea == null) { 1064 polygonArea = getArea(polygon.getNodes()); 1065 } 1066 if (PolygonIntersection.FIRST_INSIDE_SECOND == polygonIntersection(getArea(((IWay<?>) p).getNodes()), 1067 polygonArea)) { 1068 res.add(p); 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 } 1069 1072 } 1070 1073 } else if (p.isMultipolygon()) { … … 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; … … 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 … … 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 } … … 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;
Note:
See TracChangeset
for help on using the changeset viewer.