Changeset 15730 in josm
- Timestamp:
- 2020-01-19T14:14:46+01:00 (5 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java
r15717 r15730 343 343 if (toCheck == null || toCheck.isEmpty()) 344 344 return; 345 346 if (e.osm instanceof IWay) { 347 for (IPrimitive p : Geometry.filterInsidePolygon(toCheck, (IWay<?>) e.osm)) { 348 addToChildren(e, p); 349 } 350 } else if (e.osm instanceof Relation && e.osm.isMultipolygon()) { 351 for (IPrimitive p : Geometry.filterInsideMultipolygon(toCheck, (Relation) e.osm)) { 352 addToChildren(e, p); 353 } 345 for (IPrimitive p : Geometry.filterInsideAnyPolygon(toCheck, e.osm)) { 346 addToChildren(e, p); 354 347 } 355 348 } -
trunk/src/org/openstreetmap/josm/tools/Geometry.java
r15586 r15730 1043 1043 /** 1044 1044 * Find all primitives in the given collection which are inside the given polygon. 1045 * 1046 * @param primitives the primitives 1047 * @param polygon the closed way or multipolygon relation 1048 * @return a new list containing the found primitives, empty if polygon is invalid or nothing was found. 1049 * @see Geometry#filterInsidePolygon 1050 * @see Geometry#filterInsideMultipolygon 1051 * @since 15730 1052 */ 1053 public static List<IPrimitive> filterInsideAnyPolygon(Collection<IPrimitive> primitives, IPrimitive polygon) { 1054 if (polygon instanceof IWay<?>) { 1055 return filterInsidePolygon(primitives, (IWay<?>) polygon); 1056 } else if (polygon instanceof Relation && polygon.isMultipolygon()) { 1057 return filterInsideMultipolygon(primitives, (Relation) polygon); 1058 } 1059 return Collections.emptyList(); 1060 } 1061 1062 /** 1063 * Find all primitives in the given collection which are inside the given polygon. 1045 1064 * Unclosed ways and multipolygon relations with unclosed outer rings are ignored. 1065 * 1046 1066 * @param primitives the primitives 1047 1067 * @param polygon the polygon 1048 1068 * @return a new list containing the found primitives, empty if polygon is invalid or nothing was found. 1049 * @since 15069 1050 */ 1051 1052 public static List<IPrimitive> filterInsidePolygon(List<IPrimitive> primitives, IWay<?> polygon) { 1069 * @since 15069 (for {@link List} of {@code primitives}, 15730 for a {@link Collection} of {@code primitives}) 1070 */ 1071 public static List<IPrimitive> filterInsidePolygon(Collection<IPrimitive> primitives, IWay<?> polygon) { 1053 1072 List<IPrimitive> res = new ArrayList<>(); 1054 1073 if (!polygon.isClosed() || polygon.getNodesCount() <= 3)
Note:
See TracChangeset
for help on using the changeset viewer.