Changeset 6613 in josm


Ignore:
Timestamp:
2014-01-03T17:47:52+01:00 (5 years ago)
Author:
simon04
Message:

see #9516 - MapCSS: add support for crossing polygon check (area ⧉ area), replace OverlappingAreas test by a corresponding MapCSS test

Location:
trunk
Files:
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/data/validator/geometry.mapcss

    r6611 r6613  
    1616  throwWarning: tr("Building inside building");
    1717}
     18
     19/* Overlapping areas (spatial test) */
     20area[natural =~ /^(water|wetland|coastline)$/], area[landuse=reservoir] {
     21  set water_area;
     22}
     23
     24area.water_area ⧉ area.water_area {
     25  throwWarning: tr("Overlapping Water Areas");
     26}
     27
     28area ⧉ area {
     29  throwOther: tr("Overlapping Areas");
     30}
  • trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java

    r6611 r6613  
    3838import org.openstreetmap.josm.data.validation.tests.NodesDuplicatingWayTags;
    3939import org.openstreetmap.josm.data.validation.tests.OpeningHourTest;
    40 import org.openstreetmap.josm.data.validation.tests.OverlappingAreas;
    4140import org.openstreetmap.josm.data.validation.tests.OverlappingWays;
    4241import org.openstreetmap.josm.data.validation.tests.PowerLines;
     
    110109        TurnrestrictionTest.class, // ID  1801 ..  1899
    111110        DuplicateRelation.class, // ID 1901 .. 1999
    112         OverlappingAreas.class, // ID 2201 .. 2299
    113111        WayConnectedToArea.class, // ID 2301 .. 2399
    114112        NodesDuplicatingWayTags.class, // ID 2401 .. 2499
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParser.jj

    r6611 r6613  
    8181|   < FULLSTOP: "." >
    8282|   < ELEMENT_OF: "∈" >
     83|   < CROSSING: "⧉" >
    8384|   < COMMENT_START: "/*" > : COMMENT
    8485|   < UNEXPECTED_CHAR : ~[] > // avoid TokenMgrErrors because they are hard to recover from
     
    278279        |
    279280            <ELEMENT_OF> { type = Selector.ChildOrParentSelectorType.ELEMENT_OF; }
     281        |
     282            <CROSSING> { type = Selector.ChildOrParentSelectorType.CROSSING; }
    280283        )
    281284        { selLink = new LinkSelector(conditions); }
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java

    r6611 r6613  
    3939
    4040    public static enum ChildOrParentSelectorType {
    41         CHILD, PARENT, ELEMENT_OF
     41        CHILD, PARENT, ELEMENT_OF, CROSSING
    4242    }
    4343
     
    150150        }
    151151
    152         private class ContainsFinder extends AbstractVisitor {
    153             private final Environment e;
    154 
    155             private ContainsFinder(Environment e) {
     152        private abstract class AbstractFinder extends AbstractVisitor {
     153            protected final Environment e;
     154
     155            protected AbstractFinder(Environment e) {
    156156                this.e = e;
    157                 CheckParameterUtil.ensureThat(!(e.osm instanceof Node), "Nodes not supported");
    158157            }
    159158
    160159            @Override
    161160            public void visit(Node n) {
    162                 if (e.child == null && left.matches(e.withPrimitive(n))) {
    163                     if (e.osm instanceof Way && Geometry.nodeInsidePolygon(n, ((Way) e.osm).getNodes())
    164                             || e.osm instanceof Relation && ((Relation) e.osm).isMultipolygon() && Geometry.isNodeInsideMultiPolygon(n, (Relation) e.osm, null)) {
    165                         e.child = n;
    166                     }
    167                 }
    168161            }
    169162
    170163            @Override
    171164            public void visit(Way w) {
    172                 if (e.child == null && left.matches(e.withPrimitive(w))) {
    173                     if (e.osm instanceof Way && Geometry.PolygonIntersection.FIRST_INSIDE_SECOND.equals(Geometry.polygonIntersection(w.getNodes(), ((Way) e.osm).getNodes()))
    174                             || e.osm instanceof Relation && ((Relation) e.osm).isMultipolygon() && Geometry.isPolygonInsideMultiPolygon(w.getNodes(), (Relation) e.osm, null)) {
    175                         e.child = w;
    176                     }
    177                 }
    178165            }
    179166
     
    194181        }
    195182
     183        private class CrossingFinder extends AbstractFinder {
     184            private CrossingFinder(Environment e) {
     185                super(e);
     186                CheckParameterUtil.ensureThat(e.osm instanceof Way, "Only ways are supported");
     187            }
     188
     189            @Override
     190            public void visit(Way w) {
     191                if (e.child == null && left.matches(e.withPrimitive(w))) {
     192                    if (e.osm instanceof Way && Geometry.PolygonIntersection.CROSSING.equals(Geometry.polygonIntersection(w.getNodes(), ((Way) e.osm).getNodes()))) {
     193                        e.child = w;
     194                    }
     195                }
     196            }
     197        }
     198
     199        private class ContainsFinder extends AbstractFinder {
     200            private ContainsFinder(Environment e) {
     201                super(e);
     202                CheckParameterUtil.ensureThat(!(e.osm instanceof Node), "Nodes not supported");
     203            }
     204
     205            @Override
     206            public void visit(Node n) {
     207                if (e.child == null && left.matches(e.withPrimitive(n))) {
     208                    if (e.osm instanceof Way && Geometry.nodeInsidePolygon(n, ((Way) e.osm).getNodes())
     209                            || e.osm instanceof Relation && ((Relation) e.osm).isMultipolygon() && Geometry.isNodeInsideMultiPolygon(n, (Relation) e.osm, null)) {
     210                        e.child = n;
     211                    }
     212                }
     213            }
     214
     215            @Override
     216            public void visit(Way w) {
     217                if (e.child == null && left.matches(e.withPrimitive(w))) {
     218                    if (e.osm instanceof Way && Geometry.PolygonIntersection.FIRST_INSIDE_SECOND.equals(Geometry.polygonIntersection(w.getNodes(), ((Way) e.osm).getNodes()))
     219                            || e.osm instanceof Relation && ((Relation) e.osm).isMultipolygon() && Geometry.isPolygonInsideMultiPolygon(w.getNodes(), (Relation) e.osm, null)) {
     220                        e.child = w;
     221                    }
     222                }
     223            }
     224        }
     225
    196226        @Override
    197227        public boolean matches(Environment e) {
     
    223253                return e.child != null;
    224254
     255            } else if (ChildOrParentSelectorType.CROSSING.equals(type) && e.osm instanceof Way) {
     256                final CrossingFinder crossingFinder = new CrossingFinder(e);
     257                if (((GeneralSelector) right).matchesBase(OsmPrimitiveType.WAY)) {
     258                    crossingFinder.visit(e.osm.getDataSet().searchWays(e.osm.getBBox()));
     259                }
     260                return e.child != null;
    225261            } else if (ChildOrParentSelectorType.CHILD.equals(type)) {
    226262                MatchingReferrerFinder collector = new MatchingReferrerFinder(e);
Note: See TracChangeset for help on using the changeset viewer.