ALKMaps.Style

This class represents a UserStyle obtained from a SLD, containing styling rules.

Summary
ALKMaps.StyleThis class represents a UserStyle obtained from a SLD, containing styling rules.
Properties
id{String} A unique id for this session.
name{String}
title{String} Title of this style (set if included in SLD)
description{String} Description of this style (set if abstract is included in SLD)
layerName{String} name of the layer that this style belongs to, usually according to the NamedLayer attribute of an SLD document.
isDefault{Boolean}
rules{Array(ALKMaps.Rule)}
context{Object} An optional object with properties that symbolizers’ property values should be evaluated against.
defaultStyle{Object} hash of style properties to use as default for merging rule-based style symbolizers onto.
defaultsPerSymbolizer{Boolean} If set to true, the defaultStyle will extend the symbolizer of every rule.
propertyStyles{Hash of Boolean} cache of style properties that need to be parsed for propertyNames.
Constructor
ALKMaps.StyleCreates a UserStyle.
Functions
destroynullify references to prevent circular references and memory leaks
createSymbolizercreates a style by applying all feature-dependent rules to the base style.
applySymbolizer
createLiteralscreates literals for all style properties that have an entry in <this.propertyStyles>.
findPropertyStylesLooks into all rules for this style and the defaultStyle to collect all the style hash property names containing ${...}
addPropertyStyles
addRulesAdds rules to this style.
setDefaultStyleSets the default style for this style object.
getSymbolizerPrefixReturns the correct symbolizer prefix according to the geometry type of the passed geometry
cloneClones this style.
createLiteralconverts a style value holding a combination of PropertyName and Literal into a Literal, taking the property values from the passed features.
Constants
ALKMaps.Style.SYMBOLIZER_PREFIXES{Array} prefixes of the sld symbolizers.

Properties

id

{String} A unique id for this session.

name

{String}

title

{String} Title of this style (set if included in SLD)

description

{String} Description of this style (set if abstract is included in SLD)

layerName

{String} name of the layer that this style belongs to, usually according to the NamedLayer attribute of an SLD document.

isDefault

{Boolean}

rules

{Array(ALKMaps.Rule)}

context

{Object} An optional object with properties that symbolizers’ property values should be evaluated against.  If no context is specified, feature.attributes will be used

defaultStyle

{Object} hash of style properties to use as default for merging rule-based style symbolizers onto.  If no rules are defined, createSymbolizer will return this style.  If defaultsPerSymbolizer is set to true, the defaultStyle will only be taken into account if there are rules defined.

defaultsPerSymbolizer

{Boolean} If set to true, the defaultStyle will extend the symbolizer of every rule.  Properties of the defaultStyle will also be used to set missing symbolizer properties if the symbolizer has stroke, fill or graphic set to true.  Default is false.

propertyStyles

{Hash of Boolean} cache of style properties that need to be parsed for propertyNames.  Property names are keys, values won’t be used.

Constructor

ALKMaps.Style

Creates a UserStyle.

Parameters

style{Object} Optional hash of style properties that will be used as default style for this style object.  This style applies if no rules are specified.  Symbolizers defined in rules will extend this default style.
options{Object} An optional object with properties to set on the style.

Valid options

rules{Array(ALKMaps.Rule)} List of rules to be added to the style.

Returns

{ALKMaps.Style}

Functions

destroy

destroy: function()

nullify references to prevent circular references and memory leaks

createSymbolizer

createSymbolizer: function(feature)

creates a style by applying all feature-dependent rules to the base style.

Parameters

feature{ALKMaps.Feature} feature to evaluate rules for

Returns

{Object} symbolizer hash

applySymbolizer

applySymbolizer: function(rule,
style,
feature)

Parameters

rule{ALKMaps.Rule}
style{Object}
feature{<OpenLayer.Feature.Vector>}

Returns

{Object} A style with new symbolizer applied.

createLiterals

createLiterals: function(style,
feature)

creates literals for all style properties that have an entry in <this.propertyStyles>.

Parameters

style{Object} style to create literals for.  Will be modified inline.
feature{Object}

Returns

{Object} the modified style

findPropertyStyles

findPropertyStyles: function()

Looks into all rules for this style and the defaultStyle to collect all the style hash property names containing ${...} strings that have to be replaced using the createLiteral method before returning them.

Returns

{Object} hash of property names that need createLiteral parsing.  The name of the property is the key, and the value is true;

addPropertyStyles

addPropertyStyles: function(propertyStyles,
symbolizer)

Parameters

propertyStyles{Object} hash to add new property styles to.  Will be modified inline
symbolizer{Object} search this symbolizer for property styles

Returns

{Object} propertyStyles hash

addRules

addRules: function(rules)

Adds rules to this style.

Parameters

rules{Array(ALKMaps.Rule)}

setDefaultStyle

setDefaultStyle: function(style)

Sets the default style for this style object.

Parameters

style{Object} Hash of style properties

getSymbolizerPrefix

getSymbolizerPrefix: function(geometry)

Returns the correct symbolizer prefix according to the geometry type of the passed geometry

Parameters

geometry{ALKMaps.Geometry}

Returns

{String} key of the according symbolizer

clone

clone: function()

Clones this style.

Returns

{ALKMaps.Style} Clone of this style.

createLiteral

ALKMaps.Style.createLiteral = function(value,
context,
feature,
property)

converts a style value holding a combination of PropertyName and Literal into a Literal, taking the property values from the passed features.

Parameters

value{String} value to parse.  If this string contains a construct like “foo ${bar}”, then “foo “ will be taken as literal, and “${bar}” will be replaced by the value of the “bar” attribute of the passed feature.
context{Object} context to take attribute values from
feature{ALKMaps.Feature.Vector} optional feature to pass to ALKMaps.String.format for evaluating functions in the context.
property{String} optional, name of the property for which the literal is being created for evaluating functions in the context.

Returns

{String} the parsed value.  In the example of the value parameter above, the result would be “foo valueOfBar”, assuming that the passed feature has an attribute named “bar” with the value “valueOfBar”.

Constants

ALKMaps.Style.SYMBOLIZER_PREFIXES

{Array} prefixes of the sld symbolizers.  These are the same as the main geometry types

Contains convenience functions for string manipulation.
This class represents an SLD Rule, as being used for rule-based SLD styling.
{Object} hash of style properties to use as default for merging rule-based style symbolizers onto.
destroy: function()
nullify references to prevent circular references and memory leaks
createSymbolizer: function(feature)
creates a style by applying all feature-dependent rules to the base style.
applySymbolizer: function(rule,
style,
feature)
createLiterals: function(style,
feature)
creates literals for all style properties that have an entry in this.propertyStyles.
findPropertyStyles: function()
Looks into all rules for this style and the defaultStyle to collect all the style hash property names containing ${...}
addPropertyStyles: function(propertyStyles,
symbolizer)
addRules: function(rules)
Adds rules to this style.
setDefaultStyle: function(style)
Sets the default style for this style object.
getSymbolizerPrefix: function(geometry)
Returns the correct symbolizer prefix according to the geometry type of the passed geometry
clone: function()
Clones this style.
ALKMaps.Style.createLiteral = function(value,
context,
feature,
property)
converts a style value holding a combination of PropertyName and Literal into a Literal, taking the property values from the passed features.
{Boolean} If set to true, the defaultStyle will extend the symbolizer of every rule.
Creates a UserStyle.
Features are combinations of geography and attributes.
A Geometry is a description of a geographic object.
Vector features use the ALKMaps.Geometry classes as geometry description.
format: function(template,
context,
args)
Given a string with tokens in the form ${token}, return a string with tokens replaced with properties from the given context object.
Close