public class MBStyleTransformer extends Object
MBStyle
and generating StyledLayerDescriptor
.Modifier and Type | Field and Description |
---|---|
protected static Pattern |
mapboxTokenPattern |
Constructor and Description |
---|
MBStyleTransformer(MBObjectParser parse) |
Modifier and Type | Method and Description |
---|---|
Expression |
cqlExpressionFromTokens(String tokenStr)
Take a string that may contain Mapbox-style tokens, and convert it to a CQL expression.
|
String |
cqlStringFromTokens(String tokenStr)
Take a string that may contain Mapbox-style tokens, and convert it to a CQL expression
string.
|
ExternalGraphic |
createExternalGraphicForSprite(Expression iconName,
Expression iconSize,
MBStyle styleContext)
Takes the name of an icon, and an
MBStyle as a context, and returns an External
Graphic referencing the full URL of the image for consumption by the SpriteGraphicFactory . |
ExternalGraphic |
createExternalGraphicForSprite(Expression iconName,
MBStyle styleContext)
Takes the name of an icon, and an
MBStyle as a context, and returns an External
Graphic referencing the full URL of the image for consumption by the SpriteGraphicFactory . |
List<String> |
getDefaultFonts() |
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.
|
protected static final Pattern mapboxTokenPattern
public MBStyleTransformer(MBObjectParser parse)
public ExternalGraphic createExternalGraphicForSprite(Expression iconName, Expression iconSize, MBStyle styleContext)
MBStyle
as a context, and returns an External
Graphic referencing the full URL of the image for consumption by the SpriteGraphicFactory
. (The format of the image will be SpriteGraphicFactory.FORMAT
).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 the SpriteGraphicFactory
).SpriteGraphicFactory
.SpriteGraphicFactory
public ExternalGraphic createExternalGraphicForSprite(Expression iconName, MBStyle styleContext)
MBStyle
as a context, and returns an External
Graphic referencing the full URL of the image for consumption by the SpriteGraphicFactory
. (The format of the image will be SpriteGraphicFactory.FORMAT
).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 the SpriteGraphicFactory
).SpriteGraphicFactory
.SpriteGraphicFactory
public String cqlStringFromTokens(String tokenStr)
E.g., convert "String with {tokens}
" to a CQL Expression (String) "
String with ${tokens}
".
See documentation of Mapbox {token} values, linked below.
tokenStr
- A string with mapbox-style tokenspublic Expression cqlExpressionFromTokens(String tokenStr)
E.g., convert "String with {tokens}
" to a CQL Expression: "
String with ${tokens}
".
See documentation of Mapbox {token} values, linked below.
tokenStr
- A string with mapbox-style tokenspublic static <T> T requireLiteral(Expression expression, Class<T> clazz, T fallback, String propertyName, String layerId)
Expression
is a Literal
, evaluates it and returns the
value.
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.Expression
, or the provided fallback
value.Copyright © 1996–2022 Geotools. All rights reserved.