| Safe Haskell | None |
|---|---|
| Language | Haskell98 |
Database.RethinkDB.Geospatial
- fill :: Expr line => line -> ReQL
- geoJSON :: Expr geojson => geojson -> ReQL
- toGeoJSON :: Expr geo => geo -> ReQL
- getIntersecting :: (Expr geo, Expr table) => geo -> Index -> table -> ReQL
- getNearest :: (Expr point, Expr table) => point -> Index -> table -> ReQL
- includes :: (Expr area, Expr geo) => geo -> area -> ReQL
- intersects :: (Expr a, Expr b) => a -> b -> ReQL
- line :: Expr points => points -> ReQL
- point :: (Expr longitude, Expr latitude) => longitude -> latitude -> ReQL
- polygon :: Expr points => points -> ReQL
- polygonSub :: (Expr polygon, Expr hole) => hole -> polygon -> ReQL
- circle :: (Expr point, Expr radius) => point -> radius -> ReQL
- distance :: (Expr a, Expr b) => a -> b -> ReQL
- maxResults :: ReQL -> Attribute a
- maxDist :: ReQL -> Attribute a
- unit :: Unit -> Attribute a
- numVertices :: ReQL -> Attribute a
- data Unit
- = Meter
- | Kilometer
- | Mile
- | NauticalMile
- | Foot
Documentation
Get the doctests ready
>>>:set -XOverloadedStrings>>>:load Database.RethinkDB.NoClash>>>import qualified Database.RethinkDB as R>>>import Control.Exception>>>let try' x = (try x `asTypeOf` return (Left (undefined :: SomeException))) >> return ()>>>h <- fmap (use "doctests") $ connect "localhost" 28015 def>>>try' $ run' h $ dbCreate "doctests">>>try' $ run' h $ tableCreate "places">>>try' $ run' h $ table "places" # insert ["location" := point (-120) 60]>>>try' $ run' h $ table "places" # insert ["location" := point (-122) 43]>>>try' $ run' h $ table "places" # insert ["location" := point (-91) 44, "area" := polygon [[-124,30],[-113,54],[-80,44]]]>>>try' $ run' h $ table "places" # ex indexCreate ["geo":=True] "location" (!"location")>>>try' $ run' h $ table "places" # ex indexCreate ["geo":=True] "geo" (!"area")
fill :: Expr line => line -> ReQL Source #
Convert a line object into a polygon
>>>run' h $ fill $ line [[-122,37], [-120,39], [-121,38]]Polygon<[[-122,37],[-120,39],[-121,38],[-122,37]]>
geoJSON :: Expr geojson => geojson -> ReQL Source #
Convert a GeoJSON object into a RethinkDB geometry object
>>>run' h $ geoJSON ["type" := "Point", "coordinates" := [-45,80]]Point<-45,80>
toGeoJSON :: Expr geo => geo -> ReQL Source #
Convert a RethinkDB geometry object into a GeoJSON object
>>>run' h $ toGeoJSON $ point (-122.423246) 37.779388{"coordinates":[-122.423246,37.779388],"type":"Point"}
getIntersecting :: (Expr geo, Expr table) => geo -> Index -> table -> ReQL Source #
Search a geospatial index for intersecting objects
>>>run' h $ table "places" # getIntersecting (point (-122) 37) (Index "geo")[]
getNearest :: (Expr point, Expr table) => point -> Index -> table -> ReQL Source #
Query a geospatial index for the nearest matches
>>>run' h $ table "places" # getNearest (point (-122) 37) (Index "location")[]>>>run' h $ table "places" # ex getNearest [maxResults 5, maxDist 10, unit Kilometer] (point (-122) 37) (Index "location")[]
includes :: (Expr area, Expr geo) => geo -> area -> ReQL Source #
Test whether a geometry object includes another
>>>run' h $ circle (point (-122) 37) 5000 # includes (point (-120) 48)false
intersects :: (Expr a, Expr b) => a -> b -> ReQL Source #
Test if two geometry objects intersects
>>>run' h $ intersects (line [[-122,37],[-120,48]]) (line [[-120,49],[-122,48]])false
line :: Expr points => points -> ReQL Source #
Create a line object
>>>run' h $ line [[-73,45],[-122,37]]Line<[-73,45],[-122,37]>
point :: (Expr longitude, Expr latitude) => longitude -> latitude -> ReQL Source #
Create a point objects
>>>run' h $ point (-73) 40Point<-73,40>
polygon :: Expr points => points -> ReQL Source #
Create a polygon object
>>>run' h $ polygon [[-73,45],[-122,37],[-73,40]]Polygon<[[-73,45],[-122,37],[-73,40],[-73,45]]>
polygonSub :: (Expr polygon, Expr hole) => hole -> polygon -> ReQL Source #
Punch a hole in a polygon
>>>run' h $ (polygon [[-73,45],[-122,37],[-73,40]]) # polygonSub (polygon [[-73.2,40.1],[-73.2,40.2],[-73.3,40.1]])Polygon<[[-73,45],[-122,37],[-73,40],[-73,45]],[[-73.2,40.1],[-73.2,40.2],[-73.3,40.1],[-73.2,40.1]]>
circle :: (Expr point, Expr radius) => point -> radius -> ReQL Source #
Create a polygon approximating a circle
>>>run' h $ ex circle [numVertices 6, unit Kilometer] (point (-73) 40) 100Polygon<[[-73,39.099310036015424],[-74.00751390838496,39.54527799206398],[-74.02083610406069,40.445812561599965],[-73,40.900549591978255],[-71.97916389593931,40.445812561599965],[-71.99248609161504,39.54527799206398],[-73,39.099310036015424]]>
distance :: (Expr a, Expr b) => a -> b -> ReQL Source #
Distance between a point and another geometry object
run' h $ distance (point (-73) 40) (point (-122) 37)
- 467303546 > run' h $ ex distance [unit Mile] (point (-73) 40) (point (-122) 37)
- 5460282596796
maxResults :: ReQL -> Attribute a Source #
Optional argument for getNearest
numVertices :: ReQL -> Attribute a Source #
Optional argument for circle