aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Mapbox/Expression.elm65
-rw-r--r--src/Mapbox/Layer.elm16
2 files changed, 73 insertions, 8 deletions
diff --git a/src/Mapbox/Expression.elm b/src/Mapbox/Expression.elm
index efc2803..31c53c7 100644
--- a/src/Mapbox/Expression.elm
+++ b/src/Mapbox/Expression.elm
@@ -133,6 +133,7 @@ module Mapbox.Expression
, SymbolPlacement
, symbolPlacementPoint
, symbolPlacementLine
+ , symbolPlacementLineCenter
, TextJustify
, textJustifyLeft
, textJustifyCenter
@@ -141,16 +142,41 @@ module Mapbox.Expression
, textTransformNone
, textTransformUppercase
, textTransformLowercase
+ , RasterResampling
+ , rasterResamplingLinear
+ , rasterResamplingNearest
)
{-| Expressions form a little language that can be used to compute values for various layer properties.
It is recommended to import them in the following fashion:
- import Mapbox.Expression as E exposing (str, float, int, true, false)
+ import Mapbox.Expression as E exposing (Expression, CameraExpression, DataExpression, str, float, int, true, false)
This way you can use the language without much syntactic fuss and you have easy access to the literals.
+
+### Example
+
+You'd like to adjust font size of a town based on the number of people who live there. In plain Elm, you might wright the following function:
+
+ sizeByPopulation : Dict String Int -> Int
+ sizeByPopulation properties =
+ Dict.get "population" properties
+ |> Maybe.withDefault 1000
+ |> scale ( 0, 1000 ) ( 9, 20 )
+
+In the expression language you can do this in a similar fassion:
+
+ sizeByPopulation : Expression DataExpression Float
+ sizeByPopulation =
+ E.getProperty "population"
+ |> E.toFloat 1000
+ |> E.interpolate E.Linear
+ [ ( 0, int 9 )
+ , ( 1000, int 20 )
+ ]
+
**Note**: If you are familiar with the JS version of the style spec,
we have made a few changes. Argument order has been switched for many functions to support using pipeline style more naturally. Some functions use overloading in the original, these have been renamed to
not be overloaded. Finally, we have chosen not to represent some parts of the spec that are superflous (especially when used from Elm), namely functions and let-in expressions.
@@ -255,7 +281,7 @@ Control flow:
These are required for various layer properties.
-@docs Anchor, anchorMap, anchorViewport, AnchorAuto, anchorAutoMap, anchorAutoViewport, anchorAutoAuto, Position, positionCenter, positionLeft, positionRight, positionTop, positionBottom, positionTopLeft, positionTopRight, positionBottomLeft, positionBottomRight, TextFit, textFitNone, textFitWidth, textFitHeight, textFitBoth, LineCap, lineCapButt, lineCapRound, lineCapSquare, LineJoin, lineJoinBevel, lineJoinRound, lineJoinMiter, SymbolPlacement, symbolPlacementPoint, symbolPlacementLine, TextJustify, textJustifyLeft, textJustifyCenter, textJustifyRight, TextTransform, textTransformNone, textTransformUppercase, textTransformLowercase
+@docs Anchor, anchorMap, anchorViewport, AnchorAuto, anchorAutoMap, anchorAutoViewport, anchorAutoAuto, Position, positionCenter, positionLeft, positionRight, positionTop, positionBottom, positionTopLeft, positionTopRight, positionBottomLeft, positionBottomRight, TextFit, textFitNone, textFitWidth, textFitHeight, textFitBoth, LineCap, lineCapButt, lineCapRound, lineCapSquare, LineJoin, lineJoinBevel, lineJoinRound, lineJoinMiter, SymbolPlacement, symbolPlacementPoint, symbolPlacementLine, symbolPlacementLineCenter, TextJustify, textJustifyLeft, textJustifyCenter, textJustifyRight, TextTransform, textTransformNone, textTransformUppercase, textTransformLowercase, RasterResampling, rasterResamplingLinear, rasterResamplingNearest
-}
@@ -532,18 +558,28 @@ lineJoinMiter =
Expression (Json.Encode.string "miter")
-{-| -}
+{-| Label placement relative to its geometry.
+-}
type SymbolPlacement
= SymbolPlacement
-{-| -}
+{-| The label is placed at the point where the geometry is located.
+-}
symbolPlacementPoint : Expression exprType SymbolPlacement
symbolPlacementPoint =
Expression (Json.Encode.string "point")
-{-| -}
+{-| The label is placed at the center of the line of the geometry. Can only be used on LineString and Polygon geometries. Note that a single feature in a vector tile may contain multiple line geometries.
+-}
+symbolPlacementLineCenter : Expression exprType SymbolPlacement
+symbolPlacementLineCenter =
+ Expression (Json.Encode.string "line-center")
+
+
+{-| The label is placed along the line of the geometry. Can only be used on LineString and Polygon geometries.
+-}
symbolPlacementLine : Expression exprType SymbolPlacement
symbolPlacementLine =
Expression (Json.Encode.string "line")
@@ -595,6 +631,25 @@ textTransformLowercase =
Expression (Json.Encode.string "lowercase")
+{-| -}
+type RasterResampling
+ = RasterResampling
+
+
+{-| (Bi)linear filtering interpolates pixel values using the weighted average of the four closest original source pixels creating a smooth but blurry look when overscaled.
+-}
+rasterResamplingLinear : Expression exprType RasterResampling
+rasterResamplingLinear =
+ Expression (Json.Encode.string "linear")
+
+
+{-| Nearest neighbor filtering interpolates pixel values using the nearest original source pixel creating a sharp but pixelated look when overscaled.
+-}
+rasterResamplingNearest : Expression exprType RasterResampling
+rasterResamplingNearest =
+ Expression (Json.Encode.string "nearest")
+
+
-- literals
diff --git a/src/Mapbox/Layer.elm b/src/Mapbox/Layer.elm
index ad60292..20e7af5 100644
--- a/src/Mapbox/Layer.elm
+++ b/src/Mapbox/Layer.elm
@@ -126,6 +126,7 @@ module Mapbox.Layer
, rasterBrightnessMax
, rasterBrightnessMin
, rasterContrast
+ , rasterResampling
, rasterFadeDuration
, rasterHueRotate
, rasterOpacity
@@ -201,7 +202,7 @@ Paint properties are applied later in the rendering process. Changes to a paint
### Raster Attributes
-@docs rasterBrightnessMax, rasterBrightnessMin, rasterContrast, rasterFadeDuration, rasterHueRotate, rasterOpacity, rasterSaturation
+@docs rasterBrightnessMax, rasterBrightnessMin, rasterContrast, rasterResampling, rasterFadeDuration, rasterHueRotate, rasterOpacity, rasterSaturation
### Hillshade Attributes
@@ -216,9 +217,8 @@ Paint properties are applied later in the rendering process. Changes to a paint
-}
import Array exposing (Array)
-import Json.Decode
import Json.Encode as Encode exposing (Value)
-import Mapbox.Expression as Expression exposing (Anchor, AnchorAuto, CameraExpression, Color, DataExpression, Expression, LineCap, LineJoin, Position, SymbolPlacement, TextFit, TextJustify, TextTransform)
+import Mapbox.Expression as Expression exposing (Anchor, AnchorAuto, CameraExpression, Color, DataExpression, Expression, LineCap, LineJoin, Position, SymbolPlacement, TextFit, TextJustify, TextTransform, RasterResampling)
{-| Represents a layer.
@@ -1291,6 +1291,16 @@ rasterContrast =
Expression.encode >> Paint "raster-contrast"
+{-| The resampling/interpolation method to use for overscaling, also known as texture magnification filter.
+
+Defaults to `rasterResamplingLinear`.
+
+-}
+rasterResampling : Expression CameraExpression RasterResampling -> LayerAttr Raster
+rasterResampling =
+ Expression.encode >> Paint "raster-resampling"
+
+
{-| Increase or reduce the saturation of the image. Paint property.
Should be between `-1` and `1` inclusive. Defaults to `0`.