refactor(app): delegate Fornsok.getNearby to shared KMP client
This commit is contained in:
@@ -27,27 +27,8 @@ object Fornsok {
|
||||
lon: Double,
|
||||
radiusMeters: Int
|
||||
): List<FornsokItem> = withContext(Dispatchers.IO) {
|
||||
|
||||
val bbox = bboxWgs84(lat, lon, radiusMeters)
|
||||
app.klottr.util.AppLog.d(TAG)
|
||||
{ "BBox W,S,E,N = ${fmt6(bbox.w)} ${fmt6(bbox.s)} ${fmt6(bbox.e)} ${fmt6(bbox.n)} (radie=${radiusMeters} m)" }
|
||||
|
||||
val cqlBase =
|
||||
"""boundingBox=/WGS84 "${fmt8(bbox.w)} ${fmt8(bbox.s)} ${fmt8(bbox.e)} ${fmt8(bbox.n)}" AND geoDataExists="j" AND (serviceName="kmr_lamningar" OR serviceName="fmi")"""
|
||||
app.klottr.util.AppLog.d(TAG) { "CQL = $cqlBase"}
|
||||
|
||||
// Fas 1: presentation (snabb)
|
||||
val fast = queryAndParse(cqlBase, usePresentation = true, maxPages = MAX_PAGES_FAST)
|
||||
if (fast.isNotEmpty()) {
|
||||
app.klottr.util.AppLog.d(TAG) { "FÄRDIGA FORNSÖK-OBJEKT (presentation): ${fast.size} st"}
|
||||
return@withContext fast
|
||||
}
|
||||
|
||||
// Fas 2: fullt schema (utan recordSchema)
|
||||
app.klottr.util.AppLog.d(TAG) { "Inga coords via presentation – provar fullt schema (utan recordSchema)."}
|
||||
val full = queryAndParse(cqlBase, usePresentation = false, maxPages = MAX_PAGES_FALLBACK)
|
||||
app.klottr.util.AppLog.d(TAG) { "FÄRDIGA FORNSÖK-OBJEKT (fullt schema): ${full.size} st"}
|
||||
return@withContext full
|
||||
// Delegerar till delad KMP-klient (FornsokShared) – ingen övrig beteendeförändring här.
|
||||
return@withContext FornsokShared.getNearby(lat, lon, radiusMeters)
|
||||
}
|
||||
|
||||
// För detaljrutan från Hittat: hämta titel + desc + coords för ett känt entityUri
|
||||
|
||||
Reference in New Issue
Block a user