has_geo_lookup 0.2.1 → 0.2.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6cd5875015bfee6d81f04d358796a47694b5aea8fad959bef3c86cced8db6896
|
4
|
+
data.tar.gz: 2dcbbe4f2fed3cc17b7875a29157c0f2688dc40139655b83677043afd8950528
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7025ec64ed8e092cd88d3d8e7e4f99e5b64cdbe787f08f7d7c4096ae2e5155065d96d4dcdcb3850d89f68063d8a0c43b9b7957749d77897749fbb26d16e9d80
|
7
|
+
data.tar.gz: a9073f68cc449421fb2dc0bf2f4e3b710d68999418fb6d4b2d551fdf61e9ae592058566a359da352413653b0f3ce107870588d531a93e860d9a5e53aaeed1ddb
|
@@ -54,12 +54,12 @@ class Geoboundary < ActiveRecord::Base
|
|
54
54
|
}
|
55
55
|
|
56
56
|
scope :containing_point, ->(latitude, longitude) {
|
57
|
-
where("ST_Contains(boundary, ST_GeomFromText(?, 4326))", "POINT(#{
|
57
|
+
where("ST_Contains(boundary, ST_GeomFromText(?, 4326))", "POINT(#{latitude} #{longitude})")
|
58
58
|
}
|
59
59
|
|
60
60
|
# Check if this boundary contains the given coordinates
|
61
61
|
#
|
62
|
-
# Uses
|
62
|
+
# Uses MySQL ST_Contains function to perform precise geometric containment
|
63
63
|
# testing against the boundary polygon.
|
64
64
|
#
|
65
65
|
# @param latitude [Float] Latitude in decimal degrees
|
@@ -72,7 +72,7 @@ class Geoboundary < ActiveRecord::Base
|
|
72
72
|
def contains_point?(latitude, longitude)
|
73
73
|
return false unless latitude && longitude && boundary
|
74
74
|
|
75
|
-
point_wkt = "POINT(#{
|
75
|
+
point_wkt = "POINT(#{latitude} #{longitude})"
|
76
76
|
|
77
77
|
self.class.connection.select_value(
|
78
78
|
"SELECT ST_Contains(ST_GeomFromText(?), ST_GeomFromText(?, 4326)) AS contains",
|
@@ -45,13 +45,13 @@ class Metro < ActiveRecord::Base
|
|
45
45
|
scope :containing_point, ->(latitude, longitude) {
|
46
46
|
joins(:geoboundaries)
|
47
47
|
.where("ST_Contains(geoboundaries.boundary, ST_GeomFromText(?, 4326))",
|
48
|
-
"POINT(#{
|
48
|
+
"POINT(#{latitude} #{longitude})")
|
49
49
|
.distinct
|
50
50
|
}
|
51
51
|
|
52
52
|
# Check if this metro contains the given coordinates
|
53
53
|
#
|
54
|
-
# Uses
|
54
|
+
# Uses MySQL spatial queries against all associated geoboundaries to determine
|
55
55
|
# if the point falls within any boundary that defines this metropolitan area.
|
56
56
|
#
|
57
57
|
# @param latitude [Float] Latitude in decimal degrees
|
@@ -68,7 +68,7 @@ class Metro < ActiveRecord::Base
|
|
68
68
|
# Check if point is contained within any of the metro's boundaries
|
69
69
|
geoboundaries.joins("INNER JOIN geoboundaries gb ON gb.id = geoboundaries.id")
|
70
70
|
.where("ST_Contains(gb.boundary, ST_GeomFromText(?, 4326))",
|
71
|
-
"POINT(#{
|
71
|
+
"POINT(#{latitude} #{longitude})")
|
72
72
|
.exists?
|
73
73
|
rescue => e
|
74
74
|
Rails.logger.warn "Error checking metro point containment: #{e.message}"
|