Changeset View
Changeset View
Standalone View
Standalone View
app/src/main/java/it/reyboz/bustorino/map/MapLibreUtils.kt
| Show All 12 Lines | |||||
| import org.maplibre.geojson.Point | import org.maplibre.geojson.Point | ||||
| import org.maplibre.turf.TurfMeasurement | import org.maplibre.turf.TurfMeasurement | ||||
| class MapLibreUtils { | class MapLibreUtils { | ||||
| companion object{ | companion object{ | ||||
| //const val STYLE_BRIGHT_DEFAULT_JSON = "map_style_good_noshops.json" | //const val STYLE_BRIGHT_DEFAULT_JSON = "map_style_good_noshops.json" | ||||
| const val STYLE_VERSATILES_COLORFUL_JSON = "versatiles_colorful_light.json" | const val STYLE_VERSATILES_COLORFUL_JSON = "versatiles_colorful_light.json" | ||||
| const val STYLE_VERSATILES_ECLIPSE_JSON = "versatiles_eclipse_modif.json" //"versatiles_eclipse.json" | |||||
| const val STYLE_OSM_RASTER="openstreetmap_raster.json" | const val STYLE_OSM_RASTER="openstreetmap_raster.json" | ||||
| const val STYLE_VECTOR = STYLE_VERSATILES_COLORFUL_JSON | |||||
| private const val DEBUG_TAG ="BusTO-MapLibreUtils" | private const val DEBUG_TAG ="BusTO-MapLibreUtils" | ||||
| @JvmStatic | @JvmStatic | ||||
| fun getDefaultStyleJson() = STYLE_VECTOR | fun isStyleVector(styleFile: String): Boolean { | ||||
| return when(styleFile){ | |||||
| //be careful to include all the style cases | |||||
| STYLE_OSM_RASTER -> false | |||||
| STYLE_VERSATILES_COLORFUL_JSON -> true | |||||
| STYLE_VERSATILES_ECLIPSE_JSON -> true | |||||
| else -> true | |||||
| } | |||||
| } | |||||
| @JvmStatic | @JvmStatic | ||||
| fun shortestRotation(from: Float, to: Float): Float { | fun shortestRotation(from: Float, to: Float): Float { | ||||
| var delta = (to - from) % 360 | var delta = (to - from) % 360 | ||||
| if (delta > 180) delta -= 360 | if (delta > 180) delta -= 360 | ||||
| if (delta < -180) delta += 360 | if (delta < -180) delta += 360 | ||||
| return from + delta | return from + delta | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 193 Lines • ▼ Show 20 Lines | class LatLngEvaluator : TypeEvaluator<LatLng> { | ||||
| latLng.latitude = startValue.latitude + (endValue.latitude - startValue.latitude) * fraction | latLng.latitude = startValue.latitude + (endValue.latitude - startValue.latitude) * fraction | ||||
| latLng.longitude = startValue.longitude + (endValue.longitude - startValue.longitude) * fraction | latLng.longitude = startValue.longitude + (endValue.longitude - startValue.longitude) * fraction | ||||
| return latLng | return latLng | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| No newline at end of file | No newline at end of file | ||||
Public contents are in Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) or GNU Free Documentation License (at your option) unless otherwise noted. · Contact / Register