Skip to content

Commit

Permalink
add oneway arrows
Browse files Browse the repository at this point in the history
  • Loading branch information
westnordost committed Apr 10, 2024
1 parent 696c4d5 commit 0399454
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 4 deletions.
8 changes: 7 additions & 1 deletion Dsl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,11 @@ data class Symbol(
val color: String? = null,
val padding: Number? = null,
val placement: String? = null,
val spacing: Number? = null,
val spacing: String? = null,
val opacity: String? = null,
val size: String? = null,
val rotate: Number? = null,
val rotationAlignment: String? = null,
) : Paint {
override fun toJson() = listOfNotNull(
"\"type\": \"symbol\"",
Expand All @@ -155,9 +158,12 @@ data class Symbol(
"\"layout\": {" +
listOfNotNull(
"\"icon-image\": \"$image\"",
size?.let { "\"icon-size\": $it" },
spacing?.let { "\"symbol-spacing\": $it" },
placement?.let { "\"symbol-placement\": \"$it\"" },
padding?.let { "\"icon-padding\": $it" },
rotate?.let { "\"icon-rotate\": $it" },
rotationAlignment?.let { "\"icon-rotation-alignment\": \"$it\"" },
).joinToString() +
"}",
).joinToString()
Expand Down
10 changes: 7 additions & 3 deletions Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -414,13 +414,16 @@ fun createStyle(name: String, accessToken: String, languages: List<String>, colo
Layer("oneway-arrows",
src = "road",
filter = listOf(isLines, tagIs("oneway", true)),
minZoom = 16.0,
minZoom = 17.0,
paint = Symbol(
image = "oneway",
image = "oneway-arrow",
size = byZoom(17.0 to 0.25, 24.0 to 16.0),
color = colors.onewayArrow,
padding = 5,
placement = "line",
spacing = 200
spacing = byZoom(17.0 to 200.0, 24.0 to 25600.0),
rotate = 90,
rotationAlignment = "map"
)
),

Expand Down Expand Up @@ -508,6 +511,7 @@ fun createStyle(name: String, accessToken: String, languages: List<String>, colo
"transition": { "duration": 300, "delay": 0 },
"light": { "intensity": 0.2 },
"glyphs": "https://api.jawg.io/glyphs/{fontstack}/{range}.pbf",
"sprite": "https://streetcomplete.app/map-jawg/sprites",
"layers": [
{ "id": "background", "type": "background", "paint": {"background-color": "${colors.earth}"}},
${layers.joinToString(",\n ") { it.toJson() }}
Expand Down
3 changes: 3 additions & 0 deletions demo/sprites.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"oneway-arrow": {"width": 32, "height": 56, "x": 0, "y": 0, "pixelRatio": 1, "sdf": true }
}
Binary file added demo/sprites.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions demo/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"oneway-arrow": {"width": 64, "height": 112, "x": 0, "y": 0, "pixelRatio": 2, "sdf": true }
}
Binary file added demo/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0399454

Please sign in to comment.