Added satellite visibility and phase to MapFragment.kt #62

This commit is contained in:
Arty Bishop committed 2022-03-09 13:22:20 +00:00
1 parent 7fdc939450
commit 488fe352cd
6 files changed
+45 -6

No files matched your search

@@ -28,5 +28,7 @@ data class MapData(
val altitude: Double,
val velocity: Double,
val qthLoc: String,
val osmPos: GeoPos
val osmPos: GeoPos,
val phase: Double,
val eclipsed: Boolean
)
@@ -208,6 +208,14 @@ class MapFragment : Fragment(R.layout.fragment_map) {
String.format(getString(R.string.map_latitude), mapData.osmPos.lat)
mapDataLon.text =
String.format(getString(R.string.map_longitude), mapData.osmPos.lon)
mapDataPhase.text = String.format(getString(R.string.map_phase), mapData.phase)
if (mapData.eclipsed) {
val eclipsed = getString(R.string.map_eclipsed)
mapDataVisibility.text = String.format(getString(R.string.map_visibility), eclipsed)
} else {
val visible = getString(R.string.map_visible)
mapDataVisibility.text = String.format(getString(R.string.map_visibility), visible)
}
}
binding.mapView.invalidate()
}
@@ -162,9 +162,11 @@ class MapViewModel @Inject constructor(
val osmLon = clipLon(satPos.longitude.toDegrees())
val osmPos = GeoPos(osmLat, osmLon)
val qthLoc = QthConverter.positionToQth(osmPos.lat, osmPos.lon) ?: "-- --"
val phase = satPos.phase.toDegrees()
val visibility = satPos.eclipsed
val satData = MapData(
satellite, satellite.data.catnum, satellite.data.name, satPos.distance,
satPos.altitude, satPos.getOrbitalVelocity(), qthLoc, osmPos
satPos.altitude, satPos.getOrbitalVelocity(), qthLoc, osmPos, phase, visibility
)
_mapData.postValue(satData)
}
+23 -4
View File
@@ -89,16 +89,36 @@
android:layout_height="match_parent">
<TextView
android:id="@+id/map_data_lat"
android:id="@+id/map_data_visibility"
style="@style/WorldMapText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="6dp"
android:text="@string/map_latitude"
android:text="@string/map_visibility"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/map_data_phase"
style="@style/WorldMapText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:text="@string/map_phase"
app:layout_constraintBaseline_toBaselineOf="@+id/map_data_visibility"
app:layout_constraintEnd_toEndOf="parent" />
<TextView
android:id="@+id/map_data_lat"
style="@style/WorldMapText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:text="@string/map_latitude"
app:layout_constraintStart_toStartOf="@+id/map_data_visibility"
app:layout_constraintTop_toBottomOf="@+id/map_data_visibility" />
<TextView
android:id="@+id/map_data_lon"
style="@style/WorldMapText"
@@ -126,10 +146,9 @@
style="@style/WorldMapText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:text="@string/map_altitude"
app:layout_constraintBaseline_toBaselineOf="@+id/map_data_lat"
app:layout_constraintEnd_toEndOf="parent" />
app:layout_constraintEnd_toEndOf="@+id/map_data_phase" />
<TextView
android:id="@+id/map_data_dst"
+4
View File
@@ -104,6 +104,10 @@
<string name="map_latitude">Широта: %.1f°</string>
<string name="map_longitude">Долгота: %.1f°</string>
<string name="map_qth">QTH Локатор: %s</string>
<string name="map_visible">Видимый</string>
<string name="map_eclipsed">В тени</string>
<string name="map_visibility">Видимость: %s</string>
<string name="map_phase">Фаза: %.1f°</string>
<string name="map_altitude">Высота: %.0fкм</string>
<string name="map_distance">Дистанция: %.0fкм</string>
<string name="map_velocity">Скорость: %.2fкм/с</string>
+4
View File
@@ -105,6 +105,10 @@
<string name="map_latitude">Latitude: %.1f°</string>
<string name="map_longitude">Longitude: %.1f°</string>
<string name="map_qth">QTH Locator: %s</string>
<string name="map_visible">Visible</string>
<string name="map_eclipsed">Eclipsed</string>
<string name="map_visibility">Visibility: %s</string>
<string name="map_phase">Phase: %.1f°</string>
<string name="map_altitude">Altitude: %.0f km</string>
<string name="map_distance">Distance: %.0f km</string>
<string name="map_velocity">Velocity: %.2f km/s</string>