Class Environment


  • public class Environment
    extends java.lang.Object
    Environment is a data object to provide access to various "global" parameters. It is used during processing of MapCSS rules and for the generation of style elements.
    • Field Detail

      • osm

        public IPrimitive osm
        The primitive that is currently evaluated
      • mc

        public MultiCascade mc
        The cascades that are currently evaluated
      • layer

        public java.lang.String layer
        The current MapCSS layer
      • selector

        private final Selector selector
        The selector that is currently being evaluated
      • DEFAULT_LAYER

        public static final java.lang.String DEFAULT_LAYER
        The name of the default layer. It is used if no layer is specified in the MapCSS rule
        See Also:
        Constant Field Values
      • child

        public IPrimitive child
        The same for parent selector. Only one of the 2 fields (parent or child) is not null in any environment.
      • index

        public java.lang.Integer index
        index of node in parent way or member in parent relation. Must be != null in LINK context.
      • count

        public java.lang.Integer count
        count of nodes in parent way or members in parent relation. Must be != null in LINK context.
      • children

        public java.util.Set<IPrimitive> children
        Set of matched children filled by ContainsFinder and CrossingFinder, null if nothing matched
      • crossingWaysMap

        public java.util.Map<IPrimitive,​java.util.Map<java.util.List<Way>,​java.util.List<WaySegment>>> crossingWaysMap
        Crossing ways result from CrossingFinder, filled for incomplete ways/relations
      • intersections

        public java.util.Map<IPrimitive,​java.awt.geom.Area> intersections
        Intersection areas (only filled with CrossingFinder if children is not null)
      • mpAreaCache

        public java.util.Map<IPrimitive,​java.awt.geom.Area> mpAreaCache
        Cache for multipolygon areas, can be null, used with CrossingFinder
      • toMatchForSurrounding

        public java.util.Set<IPrimitive> toMatchForSurrounding
        Can be null, may contain primitives when surrounding objects of the primitives are tested
    • Constructor Detail

      • Environment

        public Environment()
        Creates a new uninitialized environment.
      • Environment

        public Environment​(IPrimitive osm)
        Creates a new environment.
        Parameters:
        osm - OSM primitive
        Since:
        8415, 13810 (signature)
      • Environment

        public Environment​(IPrimitive osm,
                           MultiCascade mc,
                           java.lang.String layer,
                           StyleSource source)
        Creates a new environment.
        Parameters:
        osm - OSM primitive
        mc - multi cascade
        layer - layer
        source - style source
        Since:
        13810 (signature)
      • Environment

        public Environment​(Environment other)
        Creates a clone of the environment other.
        Parameters:
        other - the other environment. Must not be null.
        Throws:
        java.lang.IllegalArgumentException - if param is null
      • Environment

        private Environment​(Environment other,
                            Selector selector)
        Creates a clone of the environment other.
        Parameters:
        other - the other environment. Must not be null.
        selector - the selector for this environment. May be null.
        Throws:
        java.lang.IllegalArgumentException - if param is null
    • Method Detail

      • withPrimitive

        public Environment withPrimitive​(IPrimitive osm)
        Creates a clone of this environment, with the specified primitive.
        Parameters:
        osm - OSM primitive
        Returns:
        A clone of this environment, with the specified primitive
        Since:
        13810 (signature)
        See Also:
        osm
      • withParent

        public Environment withParent​(IPrimitive parent)
        Creates a clone of this environment, with the specified parent.
        Parameters:
        parent - the matching parent object
        Returns:
        A clone of this environment, with the specified parent
        Since:
        13810 (signature)
        See Also:
        parent
      • withParentAndIndexAndLinkContext

        public Environment withParentAndIndexAndLinkContext​(IPrimitive parent,
                                                            int index,
                                                            int count)
        Creates a clone of this environment, with the specified parent, index, and context set to Condition.Context.LINK.
        Parameters:
        parent - the matching parent object
        index - index of node in parent way or member in parent relation
        count - count of nodes in parent way or members in parent relation
        Returns:
        A clone of this environment, with the specified parent, index, and context set to Condition.Context.LINK
        Since:
        6175, 13810 (signature)
        See Also:
        parent, index
      • withChild

        public Environment withChild​(IPrimitive child)
        Creates a clone of this environment, with the specified child.
        Parameters:
        child - the matching child object
        Returns:
        A clone of this environment, with the specified child
        Since:
        13810 (signature)
        See Also:
        child
      • withChildAndIndexAndLinkContext

        public Environment withChildAndIndexAndLinkContext​(IPrimitive child,
                                                           int index,
                                                           int count)
        Creates a clone of this environment, with the specified child, index, and context set to Condition.Context.LINK.
        Parameters:
        child - the matching child object
        index - index of node in parent way or member in parent relation
        count - count of nodes in parent way or members in parent relation
        Returns:
        A clone of this environment, with the specified child, index, and context set to Context#LINK
        Since:
        6175, 13810 (signature)
        See Also:
        child, index
      • withIndex

        public Environment withIndex​(int index,
                                     int count)
        Creates a clone of this environment, with the specified index.
        Parameters:
        index - index of node in parent way or member in parent relation
        count - count of nodes in parent way or members in parent relation
        Returns:
        A clone of this environment, with the specified index
        See Also:
        index
      • withSelector

        public Environment withSelector​(Selector selector)
        Creates a clone of this environment, with the selector set
        Parameters:
        selector - The selector to use
        Returns:
        A clone of this environment, with the specified selector
        Since:
        18757
      • isLinkContext

        public boolean isLinkContext()
        Determines if the context of this environment is Condition.Context.LINK.
        Returns:
        true if the context of this environment is Context#LINK, false otherwise
      • hasParentRelation

        public boolean hasParentRelation()
        Determines if this environment has a relation as parent.
        Returns:
        true if this environment has a relation as parent, false otherwise
        See Also:
        parent
      • getRole

        public java.lang.String getRole()
        Gets the role of the matching primitive in the relation
        Returns:
        The role
      • selector

        public Selector selector()
        Get the selector for this environment
        Returns:
        The selector. May be null.
        Since:
        18757
      • getCascade

        public Cascade getCascade()
        Gets the current cascade for the current layer of this environment
        Returns:
        The cascade
      • getCascade

        public Cascade getCascade​(java.lang.String layer)
        Gets the current cascade for a given layer
        Parameters:
        layer - The layer to use, null to use the layer of the Environment
        Returns:
        The cascade