Skip to content

Commit a56e576

Browse files
committed
Convert paths to dp
Signed-off-by: Kyle Corry <[email protected]>
1 parent b6c0445 commit a56e576

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

app/src/main/java/com/kylecorry/trail_sense/shared/extensions/GeoJsonExtensions.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ fun GeoJsonFeature.Companion.lineString(
172172
GEO_JSON_PROPERTY_NAME to name,
173173
GEO_JSON_PROPERTY_LINE_STYLE to lineStyle.stringId,
174174
GEO_JSON_PROPERTY_COLOR to color,
175-
GEO_JSON_PROPERTY_STROKE_WEIGHT to DEFAULT_LINE_STRING_STROKE_WEIGHT_PX * thicknessScale,
175+
GEO_JSON_PROPERTY_STROKE_WEIGHT to DEFAULT_LINE_STRING_STROKE_WEIGHT_DP * thicknessScale,
176176
),
177177
boundingBox = bounds?.let { createBoundingBox(it) }
178178
)
@@ -273,4 +273,4 @@ const val GEO_JSON_PROPERTY_SIZE_UNIT = "sizeUnit"
273273
const val GEO_JSON_PROPERTY_SIZE_UNIT_PIXELS = "px"
274274
const val GEO_JSON_PROPERTY_SIZE_UNIT_DENSITY_PIXELS = "dp"
275275
const val GEO_JSON_PROPERTY_SIZE_UNIT_METERS = "m"
276-
const val DEFAULT_LINE_STRING_STROKE_WEIGHT_PX = 6f
276+
const val DEFAULT_LINE_STRING_STROKE_WEIGHT_DP = 2.25f

app/src/main/java/com/kylecorry/trail_sense/shared/map_layers/ui/layers/geojson/features/GeoJsonLineStringRenderer.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import com.kylecorry.sol.math.interpolation.Interpolation
2020
import com.kylecorry.sol.science.geology.CoordinateBounds
2121
import com.kylecorry.sol.units.Coordinate
2222
import com.kylecorry.trail_sense.shared.canvas.LineClipper
23-
import com.kylecorry.trail_sense.shared.extensions.DEFAULT_LINE_STRING_STROKE_WEIGHT_PX
23+
import com.kylecorry.trail_sense.shared.extensions.DEFAULT_LINE_STRING_STROKE_WEIGHT_DP
2424
import com.kylecorry.trail_sense.shared.extensions.drawLines
2525
import com.kylecorry.trail_sense.shared.extensions.getColor
2626
import com.kylecorry.trail_sense.shared.extensions.getLineStyle
@@ -152,7 +152,7 @@ class GeoJsonLineStringRenderer : FeatureRenderer() {
152152
it.getColor() ?: Color.WHITE,
153153
it.getLineStyle() ?: LineStyle.Solid,
154154
(it.getStrokeWeight()
155-
?: DEFAULT_LINE_STRING_STROKE_WEIGHT_PX) / DEFAULT_LINE_STRING_STROKE_WEIGHT_PX,
155+
?: DEFAULT_LINE_STRING_STROKE_WEIGHT_DP) / DEFAULT_LINE_STRING_STROKE_WEIGHT_DP,
156156
path,
157157
projection.center,
158158
projection.metersPerPixel
@@ -209,6 +209,8 @@ class GeoJsonLineStringRenderer : FeatureRenderer() {
209209
filterEpsilon = drawer.dp(2f)
210210
}
211211
val scale = map.layerScale
212+
// Paths were originally 6px, so convert that to the default dp size
213+
val dpScale = drawer.dp(DEFAULT_LINE_STRING_STROKE_WEIGHT_DP) / 6f
212214
synchronized(lock) {
213215
for (path in reducedPaths) {
214216
if (path.line.isEmpty()) {
@@ -229,7 +231,7 @@ class GeoJsonLineStringRenderer : FeatureRenderer() {
229231
factory.create(LineStyle.Solid).draw(
230232
drawer,
231233
backgroundColor,
232-
strokeScale = 0.75f * relativeScale * scale / path.thicknessScale
234+
strokeScale = dpScale * 0.75f * relativeScale * scale / path.thicknessScale
233235
) {
234236
if (shouldRenderWithDrawLines) {
235237
lines(path.line)
@@ -242,7 +244,7 @@ class GeoJsonLineStringRenderer : FeatureRenderer() {
242244
pathDrawer.draw(
243245
drawer,
244246
path.color,
245-
strokeScale = relativeScale * scale / path.thicknessScale
247+
strokeScale = dpScale * relativeScale * scale / path.thicknessScale
246248
) {
247249
if (shouldRenderWithDrawLines) {
248250
lines(path.line)

0 commit comments

Comments
 (0)