Ignore:
Timestamp:
2015-04-19T22:21:21+02:00 (9 years ago)
Author:
simon04
Message:

see #10529 - MapCSS: add :unclosed_multipolygon pseudo-class and >:open_end selector to go from relations to their open end nodes

For example, relation:unclosed_multipolygon >:open_end node matches open end nodes of unclosed multipolygon relations.

File:
1 edited

Legend:

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

    r8236 r8237  
    1616import org.openstreetmap.josm.data.osm.Way;
    1717import org.openstreetmap.josm.data.osm.visitor.AbstractVisitor;
     18import org.openstreetmap.josm.data.osm.visitor.paint.relations.MultipolygonCache;
    1819import org.openstreetmap.josm.gui.mappaint.Environment;
    1920import org.openstreetmap.josm.gui.mappaint.Range;
     
    219220        }
    220221
     222        private class MultipolygonOpenEndFinder extends AbstractFinder {
     223
     224            @Override
     225            public void visit(Way w) {
     226                w.visitReferrers(innerVisitor);
     227            }
     228
     229            public MultipolygonOpenEndFinder(Environment e) {
     230                super(e);
     231            }
     232
     233            private final AbstractVisitor innerVisitor = new AbstractFinder(e) {
     234                @Override
     235                public void visit(Relation r) {
     236                    if (left.matches(e.withPrimitive(r))) {
     237                        final List<Node> openEnds = MultipolygonCache.getInstance().get(Main.map.mapView, r).getOpenEnds();
     238                        final int openEndIndex = openEnds.indexOf((Node) e.osm);
     239                        if (openEndIndex >= 0) {
     240                            e.parent = r;
     241                            e.index = openEndIndex;
     242                            e.count = openEnds.size();
     243                        }
     244                    }
     245                }
     246            };
     247
     248        }
     249
    221250        private final class CrossingFinder extends AbstractFinder {
    222251            private CrossingFinder(Environment e) {
     
    337366                        }
    338367                    }
     368                }
     369            } else if (ChildOrParentSelectorType.CHILD.equals(type)
     370                    && link.conds != null && !link.conds.isEmpty()
     371                    && link.conds.get(0) instanceof Condition.PseudoClassCondition
     372                    && "open_end".equals(((Condition.PseudoClassCondition) link.conds.get(0)).id)) {
     373                if (e.osm instanceof Node) {
     374                    e.osm.visitReferrers(new MultipolygonOpenEndFinder(e));
     375                    return e.parent != null;
    339376                }
    340377            } else if (ChildOrParentSelectorType.CHILD.equals(type)) {
Note: See TracChangeset for help on using the changeset viewer.