has_geo_lookup 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/has_geo_lookup/concern.rb +21 -1
- data/lib/has_geo_lookup/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82a2c8b2c21d67e5d152996defdec6f75ef9e9263a705f21b246be6f4861e176
|
4
|
+
data.tar.gz: 6ebb46f72eb51a01d7fc916657d5d1749f8277adecf64cc352e372e02d839023
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 371d3ec0afad3359fe29606ce113e8747acccad689ea99f9b3717c7e9a8b60210daad34fc1b3b15cc6ddc7670c2571953770e77b8b6bd19a1fdb35b7d6fcabf7
|
7
|
+
data.tar.gz: 2611a686994d9e8c7af9cdcb3102eb9b83f6cad94c0908790c3ca78f2068d15174603b3ceb73b7aaa8424d358469ea1713e88d87c6020b8fb855ca5a8c5714a8
|
@@ -248,7 +248,27 @@ module HasGeoLookup
|
|
248
248
|
|
249
249
|
# Fallback to closest geoname approach
|
250
250
|
geoname_result = closest_county_or_parish
|
251
|
-
|
251
|
+
if geoname_result && geoname_result.record
|
252
|
+
# Try coordinate bridge: use geoname coordinates to find GeoBoundaries match
|
253
|
+
# This improves language consistency (e.g., "Lisbon" → "Lisboa")
|
254
|
+
geoname_lat = geoname_result.record.latitude
|
255
|
+
geoname_lng = geoname_result.record.longitude
|
256
|
+
|
257
|
+
if geoname_lat && geoname_lng
|
258
|
+
# Create temporary checker at geoname coordinates
|
259
|
+
temp_checker = Object.new.extend(HasGeoLookup)
|
260
|
+
temp_checker.define_singleton_method(:latitude) { geoname_lat }
|
261
|
+
temp_checker.define_singleton_method(:longitude) { geoname_lng }
|
262
|
+
|
263
|
+
bridge_boundary = temp_checker.containing_boundary('ADM2')
|
264
|
+
if bridge_boundary
|
265
|
+
return GeoboundaryResult.new(bridge_boundary, geoname_result.distance_km, 'ADM2', bridge_boundary.name)
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
# If coordinate bridge fails, use original geoname result
|
270
|
+
return geoname_result
|
271
|
+
end
|
252
272
|
|
253
273
|
nil
|
254
274
|
end
|