diff --git a/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java b/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java
index c8ddc52..d0dc8bc 100644
|
a
|
b
|
package org.openstreetmap.josm.gui.mappaint.mapcss;
|
| 4 | 4 | import java.util.Collection; |
| 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 | |
| 9 | 10 | import org.openstreetmap.josm.Main; |
| … |
… |
import org.openstreetmap.josm.gui.mappaint.Range;
|
| 19 | 20 | import org.openstreetmap.josm.tools.CheckParameterUtil; |
| 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 | |
| 24 | 26 | /** |
| … |
… |
public interface Selector {
|
| 199 | 201 | if (e.child != null) { |
| 200 | 202 | // abort if first match has been found |
| 201 | 203 | break; |
| 202 | | } else if (!e.osm.equals(p) && p.isUsable()) { |
| | 204 | } else if (isPrimitiveUsable(p)) { |
| 203 | 205 | p.accept(this); |
| 204 | 206 | } |
| 205 | 207 | } |
| 206 | 208 | } |
| | 209 | |
| | 210 | public boolean isPrimitiveUsable(OsmPrimitive p) { |
| | 211 | return !e.osm.equals(p) && p.isUsable(); |
| | 212 | } |
| 207 | 213 | } |
| 208 | 214 | |
| 209 | 215 | private final class CrossingFinder extends AbstractFinder { |
| … |
… |
public interface Selector {
|
| 222 | 228 | } |
| 223 | 229 | } |
| 224 | 230 | |
| 225 | | private final class ContainsFinder extends AbstractFinder { |
| | 231 | private class ContainsFinder extends AbstractFinder { |
| 226 | 232 | private ContainsFinder(Environment e) { |
| 227 | 233 | super(e); |
| 228 | 234 | CheckParameterUtil.ensureThat(!(e.osm instanceof Node), "Nodes not supported"); |
| … |
… |
public interface Selector {
|
| 261 | 267 | // nodes cannot contain elements |
| 262 | 268 | return false; |
| 263 | 269 | } |
| | 270 | |
| | 271 | ContainsFinder containsFinder; |
| | 272 | try { |
| | 273 | // if right selector also matches relations and if matched primitive is a way which is part of a multipolygon, |
| | 274 | // use the multipolygon for further analysis |
| | 275 | if (!((GeneralSelector) right).matchesBase(OsmPrimitiveType.RELATION) || !(e.osm instanceof Way)) { |
| | 276 | throw new NoSuchElementException(); |
| | 277 | } |
| | 278 | final Collection<Relation> multipolygons = Utils.filteredCollection(Utils.filter( |
| | 279 | e.osm.getReferrers(), Predicates.hasTag("type", "multipolygon")), Relation.class); |
| | 280 | final Relation multipolygon = multipolygons.iterator().next(); |
| | 281 | if (multipolygon == null) throw new NoSuchElementException(); |
| | 282 | e.osm = multipolygon; |
| | 283 | containsFinder = new ContainsFinder(e) { |
| | 284 | @Override |
| | 285 | public boolean isPrimitiveUsable(OsmPrimitive p) { |
| | 286 | return super.isPrimitiveUsable(p) && !multipolygon.getMemberPrimitives().contains(p); |
| | 287 | } |
| | 288 | }; |
| | 289 | } catch (NoSuchElementException ignore) { |
| | 290 | containsFinder = new ContainsFinder(e); |
| | 291 | } |
| 264 | 292 | e.parent = e.osm; |
| 265 | 293 | |
| 266 | | final ContainsFinder containsFinder = new ContainsFinder(e); |
| 267 | | if (right instanceof GeneralSelector) { |
| 268 | | if (((GeneralSelector) right).matchesBase(OsmPrimitiveType.NODE)) { |
| | 294 | if (left instanceof GeneralSelector) { |
| | 295 | if (((GeneralSelector) left).matchesBase(OsmPrimitiveType.NODE)) { |
| 269 | 296 | containsFinder.visit(e.osm.getDataSet().searchNodes(e.osm.getBBox())); |
| 270 | 297 | } |
| 271 | | if (((GeneralSelector) right).matchesBase(OsmPrimitiveType.WAY)) { |
| | 298 | if (((GeneralSelector) left).matchesBase(OsmPrimitiveType.WAY)) { |
| 272 | 299 | containsFinder.visit(e.osm.getDataSet().searchWays(e.osm.getBBox())); |
| 273 | 300 | } |
| 274 | 301 | } else { |