Ticket #18561: 18561.patch
File 18561.patch, 2.4 KB (added by , 4 years ago) |
---|
-
src/org/openstreetmap/josm/tools/Geometry.java
1041 1041 } 1042 1042 1043 1043 /** 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. 1044 * Find all primitives in the given collection which are inside the given 1045 * polygon. 1046 * 1046 1047 * @param primitives the primitives 1047 * @param polygon the polygon 1048 * @return a new list containing the found primitives, empty if polygon is invalid or nothing was found. 1049 * @since 15069 1048 * @param polygon the closed way or multipolygon relation 1049 * @return a new list containing the found primitives, empty if polygon is 1050 * invalid or nothing was found. 1051 * @see Geometry#filterInsidePolygon 1052 * @see Geometry#filterInsideMultipolygon 1053 * @since xxx 1050 1054 */ 1055 public static List<IPrimitive> filterInsideAnyPolygon(Collection<IPrimitive> primitives, IPrimitive polygon) { 1056 if (polygon instanceof IWay<?>) { 1057 return filterInsidePolygon(primitives, (IWay<?>) polygon); 1058 } else if (polygon instanceof Relation) { 1059 return filterInsideMultipolygon(primitives, (Relation) polygon); 1060 } 1061 return Collections.emptyList(); 1062 } 1051 1063 1052 public static List<IPrimitive> filterInsidePolygon(List<IPrimitive> primitives, IWay<?> polygon) { 1064 /** 1065 * Find all primitives in the given collection which are inside the given 1066 * polygon. Unclosed ways and multipolygon relations with unclosed outer rings 1067 * are ignored. 1068 * 1069 * @param primitives the primitives 1070 * @param polygon the polygon 1071 * @return a new list containing the found primitives, empty if polygon is 1072 * invalid or nothing was found. 1073 * @since 15069 (for {@link List} of {@code primitives}, xxx for a 1074 * {@link Collection} of {@code primitives}) 1075 */ 1076 public static List<IPrimitive> filterInsidePolygon(Collection<IPrimitive> primitives, IWay<?> polygon) { 1053 1077 List<IPrimitive> res = new ArrayList<>(); 1054 1078 if (!polygon.isClosed() || polygon.getNodesCount() <= 3) 1055 1079 return res;