mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-03 21:53:55 -04:00
Cleaning up some code
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package com.geeksville.mesh.ui
|
||||
|
||||
import android.app.AlertDialog
|
||||
import android.content.DialogInterface
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
@@ -39,7 +38,6 @@ import com.mapbox.maps.extension.style.sources.generated.GeoJsonSource
|
||||
import com.mapbox.maps.extension.style.sources.generated.geoJsonSource
|
||||
import com.mapbox.maps.plugin.animation.MapAnimationOptions
|
||||
import com.mapbox.maps.plugin.animation.flyTo
|
||||
import com.mapbox.maps.plugin.gestures.OnMapClickListener
|
||||
import com.mapbox.maps.plugin.gestures.OnMapLongClickListener
|
||||
import com.mapbox.maps.plugin.gestures.gestures
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
@@ -248,7 +246,6 @@ class MapFragment : ScreenFragment("Map"), Logging {
|
||||
// Note this will not remove the downloaded style pack, instead, it will just mark the resources
|
||||
// not a part of the existing style pack. The resources still exists as disk cache.
|
||||
offlineManager.removeStylePack(mapView?.getMapboxMap()?.getStyle()?.styleURI.toString())
|
||||
|
||||
MapboxMap.clearData(resourceOptions) {
|
||||
it.error?.let { error ->
|
||||
debug(error)
|
||||
@@ -454,10 +451,12 @@ class MapFragment : ScreenFragment("Map"), Logging {
|
||||
5 miles NE,NW,SE,SW from user center point.
|
||||
25 Sq Mile Region
|
||||
*/
|
||||
//____________________________________________________________________________________________
|
||||
val topRight = calculateCoordinate(45.0, point?.latitude()!!, point?.longitude()!!)
|
||||
val topLeft = calculateCoordinate(135.0, point?.latitude()!!, point?.longitude()!!)
|
||||
val bottomLeft = calculateCoordinate(225.0, point?.latitude()!!, point?.longitude()!!)
|
||||
val bottomRight = calculateCoordinate(315.0, point?.latitude()!!, point?.longitude()!!)
|
||||
//____________________________________________________________________________________________
|
||||
|
||||
val pointList = listOf(topRight, topLeft, bottomLeft, bottomRight, topRight)
|
||||
|
||||
@@ -505,18 +504,18 @@ class MapFragment : ScreenFragment("Map"), Logging {
|
||||
|
||||
/**
|
||||
* Find's coordinates (Lat,Lon) a specified distance from given (lat,lon) using degrees to determine direction
|
||||
* @param degrees Angle
|
||||
* @param lat latitude position
|
||||
* @param long longitude position
|
||||
* @param degrees degree of desired position from current position. (center point is 0,0 and desired point, top right corner, is 45 degrees from 0,0)
|
||||
* @param lat latitude position (current position lat)
|
||||
* @param lon longitude position (current position lon)
|
||||
* @return Point
|
||||
*/
|
||||
private fun calculateCoordinate(degrees: Double, lat: Double, long: Double): Point {
|
||||
private fun calculateCoordinate(degrees: Double, lat: Double, lon: Double): Point {
|
||||
val deg = Math.toRadians(degrees)
|
||||
val distancesInMeters =
|
||||
1609.344 * 5 // 1609.344 is 1 mile in meters -> multiplier will be user specified up to a max of 10
|
||||
val radiusOfEarthInMeters = 6378137
|
||||
val x =
|
||||
long + (180 / Math.PI) * (distancesInMeters / radiusOfEarthInMeters) * cos(
|
||||
lon + (180 / Math.PI) * (distancesInMeters / radiusOfEarthInMeters) * cos(
|
||||
deg
|
||||
)
|
||||
val y =
|
||||
@@ -591,6 +590,9 @@ class MapFragment : ScreenFragment("Map"), Logging {
|
||||
.build(), MapAnimationOptions.mapAnimationOptions { duration(1000) })
|
||||
if (userStyleURI != null) {
|
||||
it?.loadStyleUri(userStyleURI.toString())
|
||||
it?.getStyle().also { style ->
|
||||
//TODO: Add box for downloaded region
|
||||
}
|
||||
} else {
|
||||
it?.getStyle().also { style ->
|
||||
style?.removeStyleImage(userPointImageId)
|
||||
|
||||
Reference in New Issue
Block a user