This repository has been archived by the owner on Jul 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
LocationManagerUtils.getGnssStatusAsFlow
- Loading branch information
Showing
14 changed files
with
468 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
app/src/main/kotlin/com/sanmer/geomag/model/gnss/GnssType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.sanmer.geomag.model.gnss | ||
|
||
import androidx.core.location.GnssStatusCompat | ||
|
||
enum class GnssType { | ||
NAVSTAR, | ||
GLONASS, | ||
BEIDOU, | ||
QZSS, | ||
GALILEO, | ||
IRNSS, | ||
SBAS, | ||
UNKNOWN; | ||
|
||
companion object { | ||
val GnssType.code: String get() { | ||
return when (this) { | ||
NAVSTAR -> "US" | ||
GLONASS -> "RU" | ||
BEIDOU -> "CN" | ||
QZSS -> "JP" | ||
GALILEO -> "EU" | ||
IRNSS -> "IN" | ||
else -> "UNKNOWN" | ||
} | ||
} | ||
|
||
fun Int.toGnssType(): GnssType { | ||
return when (this) { | ||
GnssStatusCompat.CONSTELLATION_GPS -> NAVSTAR | ||
GnssStatusCompat.CONSTELLATION_GLONASS -> GLONASS | ||
GnssStatusCompat.CONSTELLATION_BEIDOU -> BEIDOU | ||
GnssStatusCompat.CONSTELLATION_QZSS -> QZSS | ||
GnssStatusCompat.CONSTELLATION_GALILEO -> GALILEO | ||
GnssStatusCompat.CONSTELLATION_IRNSS -> IRNSS | ||
GnssStatusCompat.CONSTELLATION_SBAS -> SBAS | ||
else -> UNKNOWN | ||
} | ||
} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
app/src/main/kotlin/com/sanmer/geomag/model/gnss/Satellite.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.sanmer.geomag.model.gnss | ||
|
||
import androidx.core.location.GnssStatusCompat | ||
import com.sanmer.geomag.model.gnss.GnssType.Companion.code | ||
import com.sanmer.geomag.model.gnss.GnssType.Companion.toGnssType | ||
import com.sanmer.geomag.model.gnss.SbasType.Companion.code | ||
import com.sanmer.geomag.model.gnss.SbasType.Companion.toSbasType | ||
|
||
data class Satellite( | ||
val id: Int, | ||
val type: Int, | ||
val cn0: Float, | ||
val elevation: Float, | ||
val azimuth: Float | ||
) { | ||
val gnssType = type.toGnssType() | ||
|
||
val isSbas = gnssType == GnssType.SBAS | ||
val sbasType = id.toSbasType() | ||
|
||
val code get() = if (isSbas) { | ||
sbasType.code | ||
} else { | ||
gnssType.code | ||
} | ||
|
||
val name get() = if (isSbas) { | ||
sbasType.name | ||
} else { | ||
gnssType.name | ||
} | ||
|
||
|
||
override fun toString(): String { | ||
return "ID: $id, C/N0: $cn0, Elev: ${elevation}º, Azim: ${azimuth}º" | ||
} | ||
|
||
constructor(status: GnssStatusCompat, index: Int) : this( | ||
id = status.getSvid(index), | ||
type = status.getConstellationType(index), | ||
cn0 = status.getCn0DbHz(index), | ||
elevation = status.getElevationDegrees(index), | ||
azimuth = status.getAzimuthDegrees(index) | ||
) | ||
} |
47 changes: 47 additions & 0 deletions
47
app/src/main/kotlin/com/sanmer/geomag/model/gnss/SbasType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.sanmer.geomag.model.gnss | ||
|
||
enum class SbasType { | ||
WAAS, | ||
EGNOS, | ||
MSAS, | ||
GAGAN, | ||
SDCM, | ||
BDSBAS, | ||
SOUTHPAN, | ||
UNKNOWN; | ||
|
||
companion object { | ||
val SbasType.code: String get() { | ||
return when (this) { | ||
WAAS -> "US" | ||
EGNOS -> "EU" | ||
MSAS -> "JP" | ||
GAGAN -> "IN" | ||
SDCM -> "RU" | ||
BDSBAS -> "CN" | ||
SOUTHPAN -> "AU" | ||
UNKNOWN -> "UNKNOWN" | ||
} | ||
} | ||
|
||
fun Int.toSbasType(): SbasType { | ||
return if (this == 120 || this == 123 || this == 126 || this == 136) { | ||
EGNOS | ||
} else if (this == 125 || this == 140 || this == 141) { | ||
SDCM | ||
} else if (this == 130 || this == 143 || this == 144) { | ||
BDSBAS | ||
} else if (this == 131 || this == 133 || this == 135 || this == 138) { | ||
WAAS | ||
} else if (this == 127 || this == 128 || this == 139) { | ||
GAGAN | ||
} else if (this == 129 || this == 137) { | ||
MSAS | ||
} else if (this == 122) { | ||
SOUTHPAN | ||
} else { | ||
UNKNOWN | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.