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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6cd5875015bfee6d81f04d358796a47694b5aea8fad959bef3c86cced8db6896
4
- data.tar.gz: 2dcbbe4f2fed3cc17b7875a29157c0f2688dc40139655b83677043afd8950528
3
+ metadata.gz: 82a2c8b2c21d67e5d152996defdec6f75ef9e9263a705f21b246be6f4861e176
4
+ data.tar.gz: 6ebb46f72eb51a01d7fc916657d5d1749f8277adecf64cc352e372e02d839023
5
5
  SHA512:
6
- metadata.gz: b7025ec64ed8e092cd88d3d8e7e4f99e5b64cdbe787f08f7d7c4096ae2e5155065d96d4dcdcb3850d89f68063d8a0c43b9b7957749d77897749fbb26d16e9d80
7
- data.tar.gz: a9073f68cc449421fb2dc0bf2f4e3b710d68999418fb6d4b2d551fdf61e9ae592058566a359da352413653b0f3ce107870588d531a93e860d9a5e53aaeed1ddb
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
- return geoname_result if geoname_result
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HasGeoLookup
4
- VERSION = "0.2.2"
4
+ VERSION = "0.2.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_geo_lookup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Edlund