Package org.geotools.mbstyle.transform
Class MBStyleTransformer
Object
MBStyleTransformer
Responsible for traverse
MBStyle
and generating StyledLayerDescriptor
.- Author:
- Jody Garnett (Jody Garnett)
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncqlExpressionFromTokens
(String tokenStr) Take a string that may contain Mapbox-style tokens, and convert it to a CQL expression.cqlStringFromTokens
(String tokenStr) Take a string that may contain Mapbox-style tokens, and convert it to a CQL expression string.createExternalGraphicForSprite
(Expression iconName, Expression iconSize, MBStyle styleContext) Takes the name of an icon, and anMBStyle
as a context, and returns an External Graphic referencing the full URL of the image for consumption by theSpriteGraphicFactory
.createExternalGraphicForSprite
(Expression iconName, MBStyle styleContext) Takes the name of an icon, and anMBStyle
as a context, and returns an External Graphic referencing the full URL of the image for consumption by theSpriteGraphicFactory
.static <T> T
requireLiteral
(Expression expression, Class<T> clazz, T fallback, String propertyName, String layerId) Utility method for getting a concrete value out of an expression, used by transformer methods when GeoTools is unable to accept an expression.
-
Field Details
-
mapboxTokenPattern
-
-
Constructor Details
-
MBStyleTransformer
-
-
Method Details
-
createExternalGraphicForSprite
public ExternalGraphic createExternalGraphicForSprite(Expression iconName, Expression iconSize, MBStyle styleContext) Takes the name of an icon, and anMBStyle
as a context, and returns an External Graphic referencing the full URL of the image for consumption by theSpriteGraphicFactory
. (The format of the image will beSpriteGraphicFactory.FORMAT
).- Parameters:
iconName
- The name of the icon inside the spritesheet.iconSize
- The size (scale multiplier) to apply to the icon. (Nullable).styleContext
- The style context in which to resolve the icon name to the full sprite URL (for consumption by theSpriteGraphicFactory
).- Returns:
- An external graphic with the full URL of the mage for the
SpriteGraphicFactory
. - See Also:
-
createExternalGraphicForSprite
Takes the name of an icon, and anMBStyle
as a context, and returns an External Graphic referencing the full URL of the image for consumption by theSpriteGraphicFactory
. (The format of the image will beSpriteGraphicFactory.FORMAT
).- Parameters:
iconName
- The name of the icon inside the spritesheet.styleContext
- The style context in which to resolve the icon name to the full sprite URL (for consumption by theSpriteGraphicFactory
).- Returns:
- An external graphic with the full URL of the mage for the
SpriteGraphicFactory
. - See Also:
-
cqlStringFromTokens
Take a string that may contain Mapbox-style tokens, and convert it to a CQL expression string.E.g., convert "
String with {tokens}
" to a CQL Expression (String) "String with ${tokens}
".See documentation of Mapbox {token} values, linked below.
- Parameters:
tokenStr
- A string with mapbox-style tokens- Returns:
- A CQL Expression
- See Also:
-
cqlExpressionFromTokens
Take a string that may contain Mapbox-style tokens, and convert it to a CQL expression.E.g., convert "
String with {tokens}
" to a CQL Expression: "String with ${tokens}
".See documentation of Mapbox {token} values, linked below.
- Parameters:
tokenStr
- A string with mapbox-style tokens- Returns:
- A CQL Expression
- See Also:
-
requireLiteral
public static <T> T requireLiteral(Expression expression, Class<T> clazz, T fallback, String propertyName, String layerId) Utility method for getting a concrete value out of an expression, used by transformer methods when GeoTools is unable to accept an expression.- If the provided
Expression
is aLiteral
, evaluates it and returns the value. - Otherwise, returns the provided fallback value and logs a warning that dynamic styling is not yet supported for this property.
- Parameters:
expression
- The expressionclazz
- The type to provide as the context for the expression's evaluation.fallback
- The value to return if the expression is not a literalpropertyName
- The name of the property that the expression corresponds to, for logging purposes.layerId
- The ID of the layer that the expression corresponds to, for logging purposes.- Returns:
- The evaluated value of the provided
Expression
, or the provided fallback value.
- If the provided
-
getDefaultFonts
- Returns:
- The list of default font names
-