Changeset 7169 in josm for trunk/src/org
- Timestamp:
- 2014-05-22T20:11:33+02:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java
r7166 r7169 5 5 import java.util.Collections; 6 6 import java.util.List; 7 import java.util.NoSuchElementException; 7 8 import java.util.regex.PatternSyntaxException; 8 9 … … 20 21 import org.openstreetmap.josm.tools.Geometry; 21 22 import org.openstreetmap.josm.tools.Pair; 23 import org.openstreetmap.josm.tools.Predicates; 22 24 import org.openstreetmap.josm.tools.Utils; 23 25 … … 204 206 // abort if first match has been found 205 207 break; 206 } else if ( !e.osm.equals(p) && p.isUsable()) {208 } else if (isPrimitiveUsable(p)) { 207 209 p.accept(this); 208 210 } 209 211 } 212 } 213 214 public boolean isPrimitiveUsable(OsmPrimitive p) { 215 return !e.osm.equals(p) && p.isUsable(); 210 216 } 211 217 } … … 227 233 } 228 234 229 private finalclass ContainsFinder extends AbstractFinder {235 private class ContainsFinder extends AbstractFinder { 230 236 private ContainsFinder(Environment e) { 231 237 super(e); … … 266 272 return false; 267 273 } 274 275 ContainsFinder containsFinder; 276 try { 277 // if right selector also matches relations and if matched primitive is a way which is part of a multipolygon, 278 // use the multipolygon for further analysis 279 if (!((GeneralSelector) right).matchesBase(OsmPrimitiveType.RELATION) || !(e.osm instanceof Way)) { 280 throw new NoSuchElementException(); 281 } 282 final Collection<Relation> multipolygons = Utils.filteredCollection(Utils.filter( 283 e.osm.getReferrers(), Predicates.hasTag("type", "multipolygon")), Relation.class); 284 final Relation multipolygon = multipolygons.iterator().next(); 285 if (multipolygon == null) throw new NoSuchElementException(); 286 containsFinder = new ContainsFinder(e.withPrimitive(multipolygon)) { 287 @Override 288 public boolean isPrimitiveUsable(OsmPrimitive p) { 289 return super.isPrimitiveUsable(p) && !multipolygon.getMemberPrimitives().contains(p); 290 } 291 }; 292 } catch (NoSuchElementException ignore) { 293 containsFinder = new ContainsFinder(e); 294 } 268 295 e.parent = e.osm; 269 296 270 final ContainsFinder containsFinder = new ContainsFinder(e); 271 if (right instanceof GeneralSelector) { 272 if (((GeneralSelector) right).matchesBase(OsmPrimitiveType.NODE)) { 297 if (left instanceof GeneralSelector) { 298 if (((GeneralSelector) left).matchesBase(OsmPrimitiveType.NODE)) { 273 299 containsFinder.visit(e.osm.getDataSet().searchNodes(e.osm.getBBox())); 274 300 } 275 if (((GeneralSelector) right).matchesBase(OsmPrimitiveType.WAY)) {301 if (((GeneralSelector) left).matchesBase(OsmPrimitiveType.WAY)) { 276 302 containsFinder.visit(e.osm.getDataSet().searchWays(e.osm.getBBox())); 277 303 }
Note:
See TracChangeset
for help on using the changeset viewer.