Changeset 7285 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2014-07-03T20:42:42+02:00 (10 years ago)
Author:
simon04
Message:

see #10211 - fix CCE when using ∈ and ⧉ in mappaint styles

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java

    r7280 r7285  
    277277                    // if right selector also matches relations and if matched primitive is a way which is part of a multipolygon,
    278278                    // use the multipolygon for further analysis
    279                     if (!((GeneralSelector) right).matchesBase(OsmPrimitiveType.RELATION) || !(e.osm instanceof Way)) {
     279                    if (!(e.osm instanceof Way)
     280                            || (right instanceof OptimizedGeneralSelector
     281                            && !((OptimizedGeneralSelector) right).matchesBase(OsmPrimitiveType.RELATION))) {
    280282                        throw new NoSuchElementException();
    281283                    }
     
    295297                e.parent = e.osm;
    296298
    297                 if (left instanceof GeneralSelector) {
    298                     if (((GeneralSelector) left).matchesBase(OsmPrimitiveType.NODE)) {
     299                if (left instanceof OptimizedGeneralSelector) {
     300                    if (((OptimizedGeneralSelector) left).matchesBase(OsmPrimitiveType.NODE)) {
    299301                        containsFinder.visit(e.osm.getDataSet().searchNodes(e.osm.getBBox()));
    300302                    }
    301                     if (((GeneralSelector) left).matchesBase(OsmPrimitiveType.WAY)) {
     303                    if (((OptimizedGeneralSelector) left).matchesBase(OsmPrimitiveType.WAY)) {
    302304                        containsFinder.visit(e.osm.getDataSet().searchWays(e.osm.getBBox()));
    303305                    }
     
    312314                e.parent = e.osm;
    313315                final CrossingFinder crossingFinder = new CrossingFinder(e);
    314                 if (((GeneralSelector) right).matchesBase(OsmPrimitiveType.WAY)) {
     316                if (right instanceof OptimizedGeneralSelector
     317                        && ((OptimizedGeneralSelector) right).matchesBase(OsmPrimitiveType.WAY)) {
    315318                    crossingFinder.visit(e.osm.getDataSet().searchWays(e.osm.getBBox()));
    316319                }
     
    471474        }
    472475       
    473         public boolean matchesBase(OsmPrimitiveType type) {
    474             if ("*".equals(base)) {
    475                 return true;
    476             } else if (OsmPrimitiveType.NODE.equals(type)) {
    477                 return "node".equals(base);
    478             } else if (OsmPrimitiveType.WAY.equals(type)) {
    479                 return "way".equals(base) || "area".equals(base);
    480             } else if (OsmPrimitiveType.RELATION.equals(type)) {
    481                 return "area".equals(base) || "relation".equals(base) || "canvas".equals(base);
    482             }
    483             return false;
    484         }
    485 
    486         public boolean matchesBase(OsmPrimitive p) {
    487             if (!matchesBase(p.getType())) {
    488                 return false;
    489             } else {
    490                 if (p instanceof Relation) {
    491                     if ("area".equals(base)) {
    492                         return ((Relation) p).isMultipolygon();
    493                     } else if ("canvas".equals(base)) {
    494                         return p.get("#canvas") != null;
    495                     }
    496                 }
    497                 return true;
    498             }
    499         }
    500 
    501         public boolean matchesBase(Environment e) {
    502             return matchesBase(e.osm);
    503         }
    504        
    505476        public boolean matchesConditions(Environment e) {
    506477            return super.matches(e);
     
    565536        }
    566537
     538        public boolean matchesBase(OsmPrimitiveType type) {
     539            if ("*".equals(base)) {
     540                return true;
     541            } else if (OsmPrimitiveType.NODE.equals(type)) {
     542                return "node".equals(base);
     543            } else if (OsmPrimitiveType.WAY.equals(type)) {
     544                return "way".equals(base) || "area".equals(base);
     545            } else if (OsmPrimitiveType.RELATION.equals(type)) {
     546                return "area".equals(base) || "relation".equals(base) || "canvas".equals(base);
     547            }
     548            return false;
     549        }
     550
     551        public boolean matchesBase(OsmPrimitive p) {
     552            if (!matchesBase(p.getType())) {
     553                return false;
     554            } else {
     555                if (p instanceof Relation) {
     556                    if ("area".equals(base)) {
     557                        return ((Relation) p).isMultipolygon();
     558                    } else if ("canvas".equals(base)) {
     559                        return p.get("#canvas") != null;
     560                    }
     561                }
     562                return true;
     563            }
     564        }
     565
     566        public boolean matchesBase(Environment e) {
     567            return matchesBase(e.osm);
     568        }
     569
    567570        @Override
    568571        public Selector optimizedBaseCheck() {
Note: See TracChangeset for help on using the changeset viewer.