mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
fix: check placeBindings for null instead of checking each destructured value
This commit is contained in:
parent
d6d8155cee
commit
e46f35a90b
1 changed files with 26 additions and 28 deletions
|
|
@ -587,37 +587,35 @@ ${"wd:" + place.wikiDataEntityId}"""
|
||||||
val placeBindings = runQuery(leftLatLng, rightLatLng)
|
val placeBindings = runQuery(leftLatLng, rightLatLng)
|
||||||
if (placeBindings != null) {
|
if (placeBindings != null) {
|
||||||
for ((item1, label, location, clas) in placeBindings) {
|
for ((item1, label, location, clas) in placeBindings) {
|
||||||
if (item1 != null && label != null && clas != null) {
|
val input = location.value
|
||||||
val input = location.value
|
val pattern = Pattern.compile(
|
||||||
val pattern = Pattern.compile(
|
"Point\\(([-+]?[0-9]*\\.?[0-9]+) ([-+]?[0-9]*\\.?[0-9]+)\\)"
|
||||||
"Point\\(([-+]?[0-9]*\\.?[0-9]+) ([-+]?[0-9]*\\.?[0-9]+)\\)"
|
)
|
||||||
)
|
val matcher = pattern.matcher(input)
|
||||||
val matcher = pattern.matcher(input)
|
|
||||||
|
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
val longStr = matcher.group(1)
|
val longStr = matcher.group(1)
|
||||||
val latStr = matcher.group(2)
|
val latStr = matcher.group(2)
|
||||||
val itemUrl = item1.value
|
val itemUrl = item1.value
|
||||||
val itemName = label.value.replace("&", "&")
|
val itemName = label.value.replace("&", "&")
|
||||||
val itemLatitude = latStr
|
val itemLatitude = latStr
|
||||||
val itemLongitude = longStr
|
val itemLongitude = longStr
|
||||||
val itemClass = clas.value
|
val itemClass = clas.value
|
||||||
|
|
||||||
val formattedItemName = if (!itemClass.isEmpty())
|
val formattedItemName = if (!itemClass.isEmpty())
|
||||||
"$itemName ($itemClass)"
|
"$itemName ($itemClass)"
|
||||||
else
|
else
|
||||||
itemName
|
itemName
|
||||||
|
|
||||||
val gpxEntry =
|
val gpxEntry =
|
||||||
("""
|
("""
|
||||||
<wpt lat="$itemLatitude" lon="$itemLongitude">
|
<wpt lat="$itemLatitude" lon="$itemLongitude">
|
||||||
<name>$itemName</name>
|
<name>$itemName</name>
|
||||||
<url>$itemUrl</url>
|
<url>$itemUrl</url>
|
||||||
</wpt>""")
|
</wpt>""")
|
||||||
gpxString = gpxString + gpxEntry
|
gpxString = gpxString + gpxEntry
|
||||||
} else {
|
} else {
|
||||||
Timber.e("No match found")
|
Timber.e("No match found")
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue