Skip to content

Commit 6ff9ff9

Browse files
committed
test: add ST_Within spatial query test with explicit SRID handling
address: rgeo/activerecord-postgis-adapter#430
1 parent ac60c3b commit 6ff9ff9

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

test/active_record/connection_adapters/postgis/spatial_queries_test.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,14 @@ def test_geo_safe_where
129129
assert_equal 1, SpatialModel.where("ST_DWITHIN(latlon_geo, ?, 500)", geographic_factory.point(-72.099, 42.099)).count
130130
end
131131

132+
def test_geo_safe_where_with_srids
133+
create_model
134+
center = RGeo::Geos.factory(srid: 4326).point(3.833, 43.698)
135+
polygon = RGeo::Geos.factory(srid: 4326).parse_wkt("POLYGON ((3.9 43.68, 3.8 43.62, 3.77 43.75, 3.9 43.68))")
136+
SpatialModel.create!(polygon: polygon)
137+
assert_equal 1, SpatialModel.where("ST_Within(?, polygon)", center).count
138+
end
139+
132140
private
133141

134142
def create_model
@@ -137,6 +145,7 @@ def create_model
137145
t.column "latlon_geo", :st_point, srid: 4326, geographic: true
138146
t.column "points", :multi_point, srid: 3785
139147
t.column "path", :line_string, srid: 3785
148+
t.column "polygon", :st_polygon, srid: 4326
140149
end
141150
SpatialModel.reset_column_information
142151
end

0 commit comments

Comments
 (0)