Skip to content

Commit d00ce53

Browse files
committed
Location: Add support for Thai Wifi location
1 parent cbb8dcf commit d00ce53

File tree

1 file changed

+23
-1
lines changed
  • play-services-location/core/provider/src/main/kotlin/org/microg/gms/location/network/wifi

1 file changed

+23
-1
lines changed

play-services-location/core/provider/src/main/kotlin/org/microg/gms/location/network/wifi/MovingWifiHelper.kt

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ private val MOVING_WIFI_HOTSPOTS = setOf(
9090
"SBB-FREE",
9191
"SWISS Connect",
9292
"Edelweiss Entertainment",
93+
// Thailand
94+
"THAI Wireless IFE",
9395
// United Kingdom
9496
"Avanti_Free_WiFi",
9597
"CrossCountryWiFi",
@@ -487,6 +489,26 @@ class MovingWifiHelper(private val context: Context) {
487489
}
488490
}
489491

492+
private val SOURCE_FP3D_THAI_IFE = object : MovingWifiLocationSource("https://tha.mediasuite.zii.aero:8483/fp3d_logs/last") {
493+
override fun parse(location: Location, data: ByteArray): Location {
494+
val json = JSONObject(data.decodeToString())
495+
if (!json.optBoolean("positionValid")) throw RuntimeException("GPS not valid")
496+
location.accuracy = 100f
497+
location.latitude = json.getDouble("presentLat")
498+
location.longitude = json.getDouble("presentLon")
499+
json.optLong("time").takeIf { it != 0L }?.let { location.time = it * 1000 }
500+
json.optDouble("groundSpeedKnots").takeIf { !it.isNaN() }?.let {
501+
location.speed = (it * KNOTS_TO_METERS_PER_SECOND).toFloat()
502+
LocationCompat.setSpeedAccuracyMetersPerSecond(location, location.speed * 0.1f)
503+
}
504+
json.optDouble("trueHeading").takeIf { !it.isNaN() }?.let {
505+
location.bearing = it.toFloat()
506+
LocationCompat.setBearingAccuracyDegrees(location, 90f)
507+
}
508+
return location
509+
}
510+
}
511+
490512
private val MOVING_WIFI_HOTSPOTS_LOCALLY_RETRIEVABLE: Map<String, List<MovingWifiLocationSource>> = mapOf(
491513
"WIFIonICE" to listOf(SOURCE_WIFI_ON_ICE),
492514
"OEBB" to listOf(SOURCE_OEBB_2, SOURCE_OEBB_1),
@@ -514,7 +536,7 @@ class MovingWifiHelper(private val context: Context) {
514536
"agilis-Wifi" to listOf(SOURCE_HOTSPLOTS),
515537
"Austrian FlyNet" to listOf(SOURCE_AUSTRIAN_FLYNET_EUROPE),
516538
"EurostarTrainsWiFi" to listOf(SOURCE_OMBORD),
539+
"THAI Wireless IFE" to listOf(SOURCE_FP3D_THAI_IFE)
517540
)
518541
}
519542
}
520-

0 commit comments

Comments
 (0)