esqueleto-postgis 2.1.0 → 2.2.0
raw patch · 5 files changed
+46/−3 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Database.Esqueleto.Postgis: st_dwithin :: SqlExpr (Value (PostgisGeometry a)) -> SqlExpr (Value (PostgisGeometry a)) -> SqlExpr (Value Double) -> SqlExpr (Value Bool)
Files
- Changelog.md +3/−0
- Readme.md +1/−1
- esqueleto-postgis.cabal +1/−1
- src/Database/Esqueleto/Postgis.hs +12/−0
- test/Test.hs +29/−1
Changelog.md view
@@ -1,5 +1,8 @@ # Change log for esqueleto-postgis project +## Version 2.2.0 +* add st_dwithin to find stuf within a range+ ## Version 2.1.0 * add st_unions
Readme.md view
@@ -1,5 +1,5 @@ [](https://jappieklooster.nl/tag/haskell.html)-[](https://github.com/jappeace/esqueleto-postgis/actions)+[](https://github.com/jappeace/esqueleto-postgis/actions) [](https://discord.gg/Hp4agqy) [](https://hackage.haskell.org/package/esqueleto-postgis)
esqueleto-postgis.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: esqueleto-postgis-version: 2.1.0+version: 2.2.0 homepage: https://github.com/jappeace/esqueleto-postgis#readme bug-reports: https://github.com/jappeace/esqueleto-postgis/issues author: Jappie Klooster
src/Database/Esqueleto/Postgis.hs view
@@ -14,6 +14,7 @@ st_intersects, st_union, st_unions,+ st_dwithin, -- * points point,@@ -247,6 +248,17 @@ SqlExpr (Value Bool) st_contains a b = unsafeSqlFunction "ST_CONTAINS" (a, b) +-- | Returns true if the geometries are within a given distance+-- https://postgis.net/docs/ST_DWithin.html+st_dwithin ::+ -- | geometry g1+ SqlExpr (Value (PostgisGeometry a)) ->+ -- | geometry g2+ SqlExpr (Value (PostgisGeometry a)) ->+ -- | distance of srid+ SqlExpr (Value Double) ->+ SqlExpr (Value Bool)+st_dwithin a b c = unsafeSqlFunction "ST_DWithin" (a, b, c) -- | allows union of geometries, eg group a bunch together, -- https://postgis.net/docs/ST_Union.html
test/Test.hs view
@@ -275,7 +275,35 @@ where_ $ (unit ^. UnitGeom) `st_intersects` (val $ unValue combined) pure unit - entityVal <$> result @?= [Unit {unitGeom = Point (PointXY {_xyX = 1.0, _xyY = 1.0})}, Unit {unitGeom = Point (PointXY {_xyX = 1.0, _xyY = 2.0})}, Unit {unitGeom = Point (PointXY {_xyX = 2.0, _xyY = 2.0})}]+ entityVal <$> result @?= [Unit {unitGeom = Point (PointXY {_xyX = 1.0, _xyY = 1.0})}, Unit {unitGeom = Point (PointXY {_xyX = 1.0, _xyY = 2.0})}, Unit {unitGeom = Point (PointXY {_xyX = 2.0, _xyY = 2.0})}],+ testCase ("st_dwithin finds it wihtin range") $ do+ result <- runDB $ do+ _ <-+ insert $+ Unit+ { unitGeom = point 1 1+ }++ select $ do+ unit <- from $ table @Unit+ where_ $ st_dwithin (unit ^. UnitGeom) (st_point (val 1) (val 0)) (val 1)+ pure unit++ entityVal <$> result @?= [Unit {unitGeom = Point (PointXY {_xyX = 1.0, _xyY = 1.0})} ],+ testCase ("st_dwithin doesn't finds it out range") $ do+ result <- runDB $ do+ _ <-+ insert $+ Unit+ { unitGeom = point 1 1+ }++ select $ do+ unit <- from $ table @Unit+ where_ $ st_dwithin (unit ^. UnitGeom) (st_point (val 2) (val 0)) (val 1)+ pure unit++ entityVal <$> result @?= [] ] ]