Changeset 8833 in josm


Ignore:
Timestamp:
2015-10-07T22:50:30+02:00 (9 years ago)
Author:
simon04
Message:

fix #11939 - MapCSS: fix parent_tag() in ∈ and ⧉ tests

Location:
trunk
Files:
1 added
2 edited

Legend:

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

    r8741 r8833  
    256256            @Override
    257257            public void visit(Way w) {
    258                 if (e.child == null && left.matches(new Environment(w))) {
     258                if (e.child == null && left.matches(new Environment(w).withParent(e.osm))) {
    259259                    if (e.osm instanceof Way && Geometry.PolygonIntersection.CROSSING.equals(
    260260                            Geometry.polygonIntersection(w.getNodes(), ((Way) e.osm).getNodes()))) {
     
    273273            @Override
    274274            public void visit(Node n) {
    275                 if (e.child == null && left.matches(new Environment(n))) {
     275                if (e.child == null && left.matches(new Environment(n).withParent(e.osm))) {
    276276                    if (e.osm instanceof Way && Geometry.nodeInsidePolygon(n, ((Way) e.osm).getNodes())
    277277                            || e.osm instanceof Relation && (
     
    284284            @Override
    285285            public void visit(Way w) {
    286                 if (e.child == null && left.matches(new Environment(w))) {
     286                if (e.child == null && left.matches(new Environment(w).withParent(e.osm))) {
    287287                    if (e.osm instanceof Way && Geometry.PolygonIntersection.FIRST_INSIDE_SECOND.equals(
    288288                            Geometry.polygonIntersection(w.getNodes(), ((Way) e.osm).getNodes()))
  • trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/ChildOrParentSelectorTest.groovy

    r8774 r8833  
    22package org.openstreetmap.josm.gui.mappaint.mapcss
    33
    4 import org.openstreetmap.josm.gui.mappaint.MultiCascade;
    5 
    6 import static org.junit.Assert.*
     4import org.openstreetmap.josm.data.osm.OsmPrimitiveType
     5import org.openstreetmap.josm.gui.mappaint.MultiCascade
     6import org.openstreetmap.josm.io.OsmReader
    77
    88import java.util.logging.Logger
     
    182182        assert selector.matches(e)
    183183    }
     184
     185    @Test
     186    public void testContains() throws Exception {
     187        def ds = OsmReader.parseDataSet(new FileInputStream("data_nodist/amenity-in-amenity.osm"), null)
     188        def css = parse("node[tag(\"amenity\") = parent_tag(\"amenity\")] ∈ *[amenity] {}")
     189        assert css.matches(new Environment(ds.getPrimitiveById(123, OsmPrimitiveType.WAY)))
     190        assert css.matches(new Environment(ds.getPrimitiveById(123, OsmPrimitiveType.RELATION)))
     191    }
    184192}
Note: See TracChangeset for help on using the changeset viewer.