Ignore:
Timestamp:
2014-01-03T11:12:16+01:00 (12 years ago)
Author:
simon04
Message:

see #9516 - MapCSS: add basic support for a "contains" expression

The current syntax is outer ∋ inner, e.g., way[building?] ∋ node[building?].

This implementation is known to be inefficient since, for every match on the right side, it checks all primitives of the dataset for a match.

Nevertheless, this implementation allows mappers to write specific MapCSS-based tests involving this spatial operator.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParser.jj

    r6561 r6607  
    8080|   < CARET: "^" >
    8181|   < FULLSTOP: "." >
     82|   < CONTAINS: "∋" >
    8283|   < COMMENT_START: "/*" > : COMMENT
    8384|   < UNEXPECTED_CHAR : ~[] > // avoid TokenMgrErrors because they are hard to recover from
     
    262263Selector child_selector() :
    263264{
    264     boolean parentSelector = false;
     265    Selector.ChildOrParentSelectorType type = null;
    265266    Condition c;
    266267    List<Condition> conditions = new ArrayList<Condition>();
     
    272273    selLeft=selector() w()
    273274    (
    274         ( <GREATER> { parentSelector = false; } | <LESS> { parentSelector = true; } )
    275         ( ( c=condition(Context.LINK) | c=class_or_pseudoclass(Context.LINK) ) { conditions.add(c); } )*
     275        (
     276            ( <GREATER> { type = Selector.ChildOrParentSelectorType.CHILD; } | <LESS> { type = Selector.ChildOrParentSelectorType.PARENT; } )
     277            ( ( c=condition(Context.LINK) | c=class_or_pseudoclass(Context.LINK) ) { conditions.add(c); } )*
     278        |
     279            <CONTAINS> { type = Selector.ChildOrParentSelectorType.CONTAINS; }
     280        )
    276281        { selLink = new LinkSelector(conditions); }
    277282        w()
    278283        selRight=selector() w()
    279284    )?
    280     { return selRight != null ? new ChildOrParentSelector(selLeft, selLink, selRight, parentSelector) : selLeft; }
     285    { return selRight != null ? new ChildOrParentSelector(selLeft, selLink, selRight, type) : selLeft; }
    281286}
    282287
Note: See TracChangeset for help on using the changeset viewer.