| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Database.Esqueleto.Postgis
Description
Haskell bindings for postgres postgis for a good explenation see https://postgis.net/
Make sure to use the correct SpatialType.
Earth spanning applications should use Geography,
local applications should use Geometry because it's more convenient.
You don't have to use Geography if you're only interested in
topological functions such as st_intersects and st_union,
these are indifferent to space distortions,
see https://jappie.me/announcement-esqueleto-postgis-v4.html
if you can't use a function for example when you're using Geography.
there is the option to st_transform_geography.
Synopsis
- data Postgis (spatialType :: SpatialType) point
- = Point point
- | MultiPoint (NonEmpty point)
- | Line (LineString point)
- | Multiline (NonEmpty (LineString point))
- | Polygon (LinearRing point)
- | MultiPolygon (NonEmpty (LinearRing point))
- | Collection (NonEmpty (PostgisGeometry point))
- data SpatialType
- getPoints :: PostgisGeometry point -> NonEmpty point
- st_contains :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Bool)
- st_intersects :: forall (spatialType :: SpatialType) a. SqlExpr (Value (Postgis spatialType a)) -> SqlExpr (Value (Postgis spatialType a)) -> SqlExpr (Value Bool)
- st_within :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Bool)
- st_touches :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Bool)
- st_crosses :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Bool)
- st_disjoint :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Bool)
- st_equals :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Bool)
- st_covers :: forall (spatialType :: SpatialType) a. SqlExpr (Value (Postgis spatialType a)) -> SqlExpr (Value (Postgis spatialType a)) -> SqlExpr (Value Bool)
- st_coveredby :: forall (spatialType :: SpatialType) a. SqlExpr (Value (Postgis spatialType a)) -> SqlExpr (Value (Postgis spatialType a)) -> SqlExpr (Value Bool)
- st_overlaps :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Bool)
- st_containsproperly :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Bool)
- st_3dintersects :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Bool)
- st_relate :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Text)
- st_orderingequals :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Bool)
- st_dfullywithin :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) -> SqlExpr (Value Bool)
- st_pointinsidecircle :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) -> SqlExpr (Value Double) -> SqlExpr (Value Double) -> SqlExpr (Value Bool)
- st_distance :: forall (spatialType :: SpatialType) a. SqlExpr (Value (Postgis spatialType a)) -> SqlExpr (Value (Postgis spatialType a)) -> SqlExpr (Value Double)
- st_dwithin :: forall (spatialType :: SpatialType) a. SqlExpr (Value (Postgis spatialType a)) -> SqlExpr (Value (Postgis spatialType a)) -> SqlExpr (Value Double) -> SqlExpr (Value Bool)
- st_area :: forall (spatialType :: SpatialType) a. SqlExpr (Value (Postgis spatialType a)) -> SqlExpr (Value Double)
- st_perimeter :: forall (spatialType :: SpatialType) a. SqlExpr (Value (Postgis spatialType a)) -> SqlExpr (Value Double)
- st_length :: forall (spatialType :: SpatialType) a. SqlExpr (Value (Postgis spatialType a)) -> SqlExpr (Value Double)
- st_azimuth :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double)
- st_maxdistance :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double)
- st_angle :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double)
- st_closestpoint :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_3dclosestpoint :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_3ddistance :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double)
- st_distancesphere :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double)
- st_frechetdistance :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double)
- st_hausdorffdistance :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double)
- st_length2d :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double)
- st_3dlength :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double)
- st_longestline :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_3dlongestline :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_3dmaxdistance :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double)
- st_minimumclearance :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double)
- st_shortestline :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_3dshortestline :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_x :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double)
- st_y :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double)
- st_npoints :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Int)
- st_numgeometries :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Int)
- st_dimension :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Int)
- st_issimple :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Bool)
- st_isclosed :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Bool)
- st_isvalid :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Bool)
- st_srid :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Int)
- st_boundary :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_coorddim :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Int)
- st_endpoint :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_exteriorring :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_geometryn :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Int) -> SqlExpr (Value (Postgis 'Geometry a))
- st_geometrytype :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Text)
- st_interiorringn :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Int) -> SqlExpr (Value (Postgis 'Geometry a))
- st_iscollection :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Bool)
- st_isempty :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Bool)
- st_ispolygonccw :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Bool)
- st_ispolygoncw :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Bool)
- st_isring :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Bool)
- st_m :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double)
- st_ndims :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Int)
- st_nrings :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Int)
- st_numinteriorrings :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Int)
- st_numpoints :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Int)
- st_pointn :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Int) -> SqlExpr (Value (Postgis 'Geometry a))
- st_startpoint :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_z :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double)
- st_collect :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_makeenvelope :: SqlExpr (Value Double) -> SqlExpr (Value Double) -> SqlExpr (Value Double) -> SqlExpr (Value Double) -> SqlExpr (Value Int) -> SqlExpr (Value (Postgis 'Geometry a))
- st_makeline :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_makepolygon_line :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_addpoint :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Int) -> SqlExpr (Value (Postgis 'Geometry a))
- st_collectionextract :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Int) -> SqlExpr (Value (Postgis 'Geometry a))
- st_flipcoordinates :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_force2d :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_force3d :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_force4d :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_forcecollection :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_forcepolygonccw :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_forcepolygoncw :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_multi :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_normalize :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_reverse :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_segmentize :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) -> SqlExpr (Value (Postgis 'Geometry a))
- st_setpoint :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Int) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_snaptogrid :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) -> SqlExpr (Value (Postgis 'Geometry a))
- st_snap :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) -> SqlExpr (Value (Postgis 'Geometry a))
- st_makevalid :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_isvalidreason :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Text)
- st_setsrid :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Int) -> SqlExpr (Value (Postgis 'Geometry a))
- st_astext :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Text)
- st_asgeojson :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Text)
- st_asewkt :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Text)
- st_geohash :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Text)
- st_union :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_unions :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_centroid :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_buffer :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) -> SqlExpr (Value (Postgis 'Geometry a))
- st_convexhull :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_envelope :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_pointonsurface :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_intersection :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_difference :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_symdifference :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_unaryunion :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_split :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_node :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_buildarea :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_chaikinsmoothing :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_concavehull :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) -> SqlExpr (Value (Postgis 'Geometry a))
- st_delaunaytriangles :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_generatepoints :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Int) -> SqlExpr (Value (Postgis 'Geometry a))
- st_geometricmedian :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_linemerge :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_minimumboundingcircle :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_offsetcurve :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) -> SqlExpr (Value (Postgis 'Geometry a))
- st_reduceprecision :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) -> SqlExpr (Value (Postgis 'Geometry a))
- st_sharedpaths :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_simplify :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) -> SqlExpr (Value (Postgis 'Geometry a))
- st_simplifypreservetopology :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) -> SqlExpr (Value (Postgis 'Geometry a))
- st_voronoilines :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_voronoipolygons :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_translate :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) -> SqlExpr (Value Double) -> SqlExpr (Value (Postgis 'Geometry a))
- st_scale :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) -> SqlExpr (Value Double) -> SqlExpr (Value (Postgis 'Geometry a))
- st_rotate :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) -> SqlExpr (Value (Postgis 'Geometry a))
- st_rotatex :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) -> SqlExpr (Value (Postgis 'Geometry a))
- st_rotatez :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) -> SqlExpr (Value (Postgis 'Geometry a))
- st_expand :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) -> SqlExpr (Value (Postgis 'Geometry a))
- st_lineinterpolatepoint :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) -> SqlExpr (Value (Postgis 'Geometry a))
- st_linelocatepoint :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double)
- st_linesubstring :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) -> SqlExpr (Value Double) -> SqlExpr (Value (Postgis 'Geometry a))
- point :: forall (spatialType :: SpatialType). Double -> Double -> Postgis spatialType PointXY
- point_v :: forall (spatialType :: SpatialType). HasPgType spatialType => Double -> Double -> SqlExpr (Value (Postgis spatialType PointXY))
- st_point :: forall (spatialType :: SpatialType). HasPgType spatialType => SqlExpr (Value Double) -> SqlExpr (Value Double) -> SqlExpr (Value (Postgis spatialType PointXY))
- st_point_xyz :: forall (spatialType :: SpatialType). HasPgType spatialType => SqlExpr (Value Double) -> SqlExpr (Value Double) -> SqlExpr (Value Double) -> SqlExpr (Value (Postgis spatialType PointXYZ))
- st_point_xyzm :: forall (spatialType :: SpatialType). HasPgType spatialType => SqlExpr (Value Double) -> SqlExpr (Value Double) -> SqlExpr (Value Double) -> SqlExpr (Value Double) -> SqlExpr (Value (Postgis spatialType PointXYZM))
- st_transform_geography :: SRID 'Linear -> SqlExpr (Value (Postgis 'Geography a)) -> SqlExpr (Value (Postgis 'Geometry a))
- st_transform_geometry :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geography a))
- data SRID (unit :: SridUnit)
- wgs84 :: SRID 'Degree
- mercator :: SRID 'Linear
- britishNationalGrid :: SRID 'Linear
- data SridUnit
- makePolygon :: (Eq point, Show point) => point -> point -> point -> Seq point -> LinearRing point
- type PostgisGeometry = Postgis 'Geometry
- class HasPgType (spatialType :: SpatialType)
- data PointXY = PointXY {}
- data PointXYZ = PointXYZ {}
- data PointXYZM = PointXYZM {}
Documentation
data Postgis (spatialType :: SpatialType) point Source #
like GeospatialGeometry but not partial, eg no empty geometries.
Also can put an inveriant on dimensions if a function requires it.
for example st_intersects PostgisGeometry PointXY can't work with PostgisGeometry PointXYZ.
PointXY indicates a 2 dimension space, and PointXYZ a three dimension space.
Constructors
| Point point | |
| MultiPoint (NonEmpty point) | |
| Line (LineString point) | |
| Multiline (NonEmpty (LineString point)) | |
| Polygon (LinearRing point) | |
| MultiPolygon (NonEmpty (LinearRing point)) | |
| Collection (NonEmpty (PostgisGeometry point)) |
Instances
data SpatialType Source #
Guarantees we don't accidently mix curved space with flat space. Postgis will catch this too, this just put's it in the type system.
getPoints :: PostgisGeometry point -> NonEmpty point Source #
unwrap postgis geometry so you can for example return it from an API
Spatial relationships
Arguments
| :: SqlExpr (Value (Postgis 'Geometry a)) | geom a |
| -> SqlExpr (Value (Postgis 'Geometry a)) | geom b |
| -> SqlExpr (Value Bool) |
Returns TRUE if geometry A contains geometry B. https://postgis.net/docs/ST_Contains.html
Arguments
| :: forall (spatialType :: SpatialType) a. SqlExpr (Value (Postgis spatialType a)) | geomA or geogA |
| -> SqlExpr (Value (Postgis spatialType a)) | geomB or geogB |
| -> SqlExpr (Value Bool) |
Returns true if two geometries intersect. Geometries intersect if they have any point in common. https://postgis.net/docs/ST_Intersects.html
st_within :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Bool) Source #
Returns TRUE if geometry A is within geometry B.
Tests if every point of A lies inside (interior or boundary of) B.
The inverse of st_contains: st_within a b == st_contains b a.
https://postgis.net/docs/ST_Within.html
st_touches :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Bool) Source #
Returns TRUE if geometry A touches geometry B. They have at least one boundary point in common, but no interior points. https://postgis.net/docs/ST_Touches.html
st_crosses :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Bool) Source #
Returns TRUE if geometry A crosses geometry B. They have some but not all interior points in common. https://postgis.net/docs/ST_Crosses.html
st_disjoint :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Bool) Source #
Returns TRUE if geometry A is disjoint from geometry B.
They do not share any space together, the inverse of st_intersects.
https://postgis.net/docs/ST_Disjoint.html
st_equals :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Bool) Source #
Returns TRUE if geometry A is spatially equal to geometry B. The geometries represent the same region of space regardless of vertex order. https://postgis.net/docs/ST_Equals.html
st_covers :: forall (spatialType :: SpatialType) a. SqlExpr (Value (Postgis spatialType a)) -> SqlExpr (Value (Postgis spatialType a)) -> SqlExpr (Value Bool) Source #
Returns TRUE if geometrygeography A covers geometrygeography B.
No point in B is outside A. Similar to st_contains but does not distinguish boundary and interior.
https://postgis.net/docs/ST_Covers.html
st_coveredby :: forall (spatialType :: SpatialType) a. SqlExpr (Value (Postgis spatialType a)) -> SqlExpr (Value (Postgis spatialType a)) -> SqlExpr (Value Bool) Source #
Returns TRUE if geometrygeography A is covered by geometrygeography B.
No point in A is outside B. The inverse of st_covers.
https://postgis.net/docs/ST_CoveredBy.html
st_overlaps :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Bool) Source #
Returns TRUE if geometry A overlaps geometry B. They share some space but neither contains the other entirely. https://postgis.net/docs/ST_Overlaps.html
st_containsproperly :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Bool) Source #
Returns TRUE if geometry A contains geometry B properly. B must lie entirely inside the interior of A (not touching the boundary). https://postgis.net/docs/ST_ContainsProperly.html
st_3dintersects :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Bool) Source #
Returns TRUE if two 3D geometries intersect. https://postgis.net/docs/ST_3DIntersects.html
st_relate :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Text) Source #
Returns the DE-9IM intersection matrix string for two geometries. https://postgis.net/docs/ST_Relate.html
st_orderingequals :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Bool) Source #
Returns TRUE if two geometries are point-by-point equal in the same order. https://postgis.net/docs/ST_OrderingEquals.html
st_dfullywithin :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) -> SqlExpr (Value Bool) Source #
Returns TRUE if all of the geometries are within the specified distance of one another. https://postgis.net/docs/ST_DFullyWithin.html
Arguments
| :: SqlExpr (Value (Postgis 'Geometry a)) | |
| -> SqlExpr (Value Double) | center_x |
| -> SqlExpr (Value Double) | center_y |
| -> SqlExpr (Value Double) | radius |
| -> SqlExpr (Value Bool) |
Returns TRUE if the point geometry is inside the circle defined by center_x, center_y and radius. https://postgis.net/docs/ST_PointInsideCircle.html
Measurement functions
st_distance :: forall (spatialType :: SpatialType) a. SqlExpr (Value (Postgis spatialType a)) -> SqlExpr (Value (Postgis spatialType a)) -> SqlExpr (Value Double) Source #
calculate the distance between two points https://postgis.net/docs/ST_Distance.html
Arguments
| :: forall (spatialType :: SpatialType) a. SqlExpr (Value (Postgis spatialType a)) | geometry g1 |
| -> SqlExpr (Value (Postgis spatialType a)) | geometry g2 |
| -> SqlExpr (Value Double) | distance of srid |
| -> SqlExpr (Value Bool) |
Returns true if the geometries are within a given distance https://postgis.net/docs/ST_DWithin.html
st_area :: forall (spatialType :: SpatialType) a. SqlExpr (Value (Postgis spatialType a)) -> SqlExpr (Value Double) Source #
Returns the area of a geometry or geography. For geometry, area is in SRID units squared. For geography, area is in square meters. https://postgis.net/docs/ST_Area.html
st_perimeter :: forall (spatialType :: SpatialType) a. SqlExpr (Value (Postgis spatialType a)) -> SqlExpr (Value Double) Source #
Returns the perimeter of a geometry or geography. For geometry, in SRID units. For geography, in meters. https://postgis.net/docs/ST_Perimeter.html
st_length :: forall (spatialType :: SpatialType) a. SqlExpr (Value (Postgis spatialType a)) -> SqlExpr (Value Double) Source #
Returns the 2D length of a linear geometry or geography. For geometry, in SRID units. For geography, in meters. https://postgis.net/docs/ST_Length.html
st_azimuth :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) Source #
Returns the azimuth in radians of the segment from point A to point B. The angle is measured clockwise from north (positive Y axis). https://postgis.net/docs/ST_Azimuth.html
st_maxdistance :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) Source #
Returns the maximum distance between two geometries. The distance of the furthest pair of points. https://postgis.net/docs/ST_MaxDistance.html
st_angle :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) Source #
Returns the angle between two vectors defined by two 2-point linestrings. This is the 2-argument form of ST_Angle which expects linestring inputs. Passing point geometries will result in a NULL return value — use the 3 or 4 point overloads in PostGIS directly if you need point-based angles. https://postgis.net/docs/ST_Angle.html
st_closestpoint :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Returns the 2D point on geom1 closest to geom2. https://postgis.net/docs/ST_ClosestPoint.html
st_3dclosestpoint :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Returns the 3D point on geom1 closest to geom2. https://postgis.net/docs/ST_3DClosestPoint.html
st_3ddistance :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) Source #
Returns the 3D cartesian minimum distance between two geometries. https://postgis.net/docs/ST_3DDistance.html
st_distancesphere :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) Source #
Returns the minimum distance in meters between two lon/lat geometries using a spherical model. https://postgis.net/docs/ST_DistanceSphere.html
st_frechetdistance :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) Source #
Returns the Frechet distance between two geometries. https://postgis.net/docs/ST_FrechetDistance.html
st_hausdorffdistance :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) Source #
Returns the Hausdorff distance between two geometries. https://postgis.net/docs/ST_HausdorffDistance.html
st_length2d :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) Source #
Returns the 2D length of a linear geometry. https://postgis.net/docs/ST_Length2D.html
st_3dlength :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) Source #
Returns the 3D length of a linear geometry. https://postgis.net/docs/ST_3DLength.html
st_longestline :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Returns the 2D longest line between two geometries. https://postgis.net/docs/ST_LongestLine.html
st_3dlongestline :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Returns the 3D longest line between two geometries. https://postgis.net/docs/ST_3DLongestLine.html
st_3dmaxdistance :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) Source #
Returns the 3D maximum distance between two geometries. https://postgis.net/docs/ST_3DMaxDistance.html
st_minimumclearance :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) Source #
Returns the minimum clearance of a geometry, the shortest distance between two distinct vertices. https://postgis.net/docs/ST_MinimumClearance.html
st_shortestline :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Returns the 2D shortest line between two geometries. https://postgis.net/docs/ST_ShortestLine.html
st_3dshortestline :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Returns the 3D shortest line between two geometries. https://postgis.net/docs/ST_3DShortestLine.html
Geometry accessors
st_x :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) Source #
Returns the X coordinate of a point geometry. Only works on points; other geometry types will error. https://postgis.net/docs/ST_X.html
st_y :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) Source #
Returns the Y coordinate of a point geometry. Only works on points; other geometry types will error. https://postgis.net/docs/ST_Y.html
st_npoints :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Int) Source #
Returns the number of points (vertices) in a geometry. Works on any geometry type. https://postgis.net/docs/ST_NPoints.html
st_numgeometries :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Int) Source #
Returns the number of sub-geometries in a geometry collection or multi-type. Returns 1 for single geometries. https://postgis.net/docs/ST_NumGeometries.html
st_dimension :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Int) Source #
Returns the topological dimension of a geometry. 0 for points, 1 for lines, 2 for polygons. https://postgis.net/docs/ST_Dimension.html
st_issimple :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Bool) Source #
Returns TRUE if the geometry has no self-intersections. Points and properly-formed polygons are always simple. https://postgis.net/docs/ST_IsSimple.html
st_isclosed :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Bool) Source #
Returns TRUE if the linestring's start and end points are coincident. For polyhedral surfaces, reports if the surface is areal (open) or volumetric (closed). https://postgis.net/docs/ST_IsClosed.html
st_isvalid :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Bool) Source #
Returns TRUE if the geometry is well-formed and valid per the OGC rules. Points and lines are always valid; polygons need correct ring structure. https://postgis.net/docs/ST_IsValid.html
st_srid :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Int) Source #
Returns the spatial reference identifier (SRID) of the geometry. 0 means no SRID is set. https://postgis.net/docs/ST_SRID.html
st_boundary :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Returns the boundary of a geometry. https://postgis.net/docs/ST_Boundary.html
st_coorddim :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Int) Source #
Returns the coordinate dimension of a geometry (2, 3, or 4). https://postgis.net/docs/ST_CoordDim.html
st_endpoint :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Returns the last point of a linestring. https://postgis.net/docs/ST_EndPoint.html
st_exteriorring :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Returns the exterior ring of a polygon geometry. https://postgis.net/docs/ST_ExteriorRing.html
st_geometryn :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Int) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Returns the Nth sub-geometry of a geometry collection (1-indexed). https://postgis.net/docs/ST_GeometryN.html
st_geometrytype :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Text) Source #
Returns the geometry type as a string (e.g. ST_Polygon). https://postgis.net/docs/ST_GeometryType.html
st_interiorringn :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Int) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Returns the Nth interior ring of a polygon (1-indexed). https://postgis.net/docs/ST_InteriorRingN.html
st_iscollection :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Bool) Source #
Returns TRUE if the geometry is a geometry collection type. https://postgis.net/docs/ST_IsCollection.html
st_isempty :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Bool) Source #
Returns TRUE if the geometry is an empty geometry. https://postgis.net/docs/ST_IsEmpty.html
st_ispolygonccw :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Bool) Source #
Returns TRUE if all polygon rings are oriented counter-clockwise. https://postgis.net/docs/ST_IsPolygonCCW.html
st_ispolygoncw :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Bool) Source #
Returns TRUE if all polygon rings are oriented clockwise. https://postgis.net/docs/ST_IsPolygonCW.html
st_isring :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Bool) Source #
Returns TRUE if the linestring is closed and simple (a ring). https://postgis.net/docs/ST_IsRing.html
st_m :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) Source #
Returns the M coordinate of a point. https://postgis.net/docs/ST_M.html
st_ndims :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Int) Source #
Returns the number of dimensions of a geometry's coordinates (2, 3, or 4). https://postgis.net/docs/ST_NDims.html
st_nrings :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Int) Source #
Returns the number of rings in a polygon (exterior + interior). https://postgis.net/docs/ST_NRings.html
st_numinteriorrings :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Int) Source #
Returns the number of interior rings of a polygon. https://postgis.net/docs/ST_NumInteriorRings.html
st_numpoints :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Int) Source #
Returns the number of points in a linestring. https://postgis.net/docs/ST_NumPoints.html
st_pointn :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Int) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Returns the Nth point in a linestring (1-indexed). https://postgis.net/docs/ST_PointN.html
st_startpoint :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Returns the first point of a linestring. https://postgis.net/docs/ST_StartPoint.html
st_z :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) Source #
Returns the Z coordinate of a point. https://postgis.net/docs/ST_Z.html
Geometry constructors
st_collect :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Aggregate function that collects geometries into a geometry collection. https://postgis.net/docs/ST_Collect.html
Arguments
| :: SqlExpr (Value Double) | xmin |
| -> SqlExpr (Value Double) | ymin |
| -> SqlExpr (Value Double) | xmax |
| -> SqlExpr (Value Double) | ymax |
| -> SqlExpr (Value Int) | srid |
| -> SqlExpr (Value (Postgis 'Geometry a)) |
Creates a rectangular polygon from minimum and maximum coordinates. https://postgis.net/docs/ST_MakeEnvelope.html
st_makeline :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Creates a linestring from two point geometries. https://postgis.net/docs/ST_MakeLine.html
st_makepolygon_line :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Creates a polygon from a closed linestring shell.
Named st_makepolygon_line to avoid collision with makePolygon.
https://postgis.net/docs/ST_MakePolygon.html
Geometry editors
Arguments
| :: SqlExpr (Value (Postgis 'Geometry a)) | linestring |
| -> SqlExpr (Value (Postgis 'Geometry a)) | point |
| -> SqlExpr (Value Int) | position |
| -> SqlExpr (Value (Postgis 'Geometry a)) |
Adds a point to a linestring at a given position (0-indexed). https://postgis.net/docs/ST_AddPoint.html
st_collectionextract :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Int) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Extracts sub-geometries of a specified type from a collection. Type: 1=POINT, 2=LINESTRING, 3=POLYGON. https://postgis.net/docs/ST_CollectionExtract.html
st_flipcoordinates :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Swaps X and Y coordinates. https://postgis.net/docs/ST_FlipCoordinates.html
st_force2d :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Forces the geometry into 2D mode. https://postgis.net/docs/ST_Force2D.html
st_force3d :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Forces the geometry into 3D (XYZ) mode. https://postgis.net/docs/ST_Force3D.html
st_force4d :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Forces the geometry into 4D (XYZM) mode. https://postgis.net/docs/ST_Force4D.html
st_forcecollection :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Converts the geometry into a geometry collection. https://postgis.net/docs/ST_ForceCollection.html
st_forcepolygonccw :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Forces polygon rings to counter-clockwise orientation. https://postgis.net/docs/ST_ForcePolygonCCW.html
st_forcepolygoncw :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Forces polygon rings to clockwise orientation. https://postgis.net/docs/ST_ForcePolygonCW.html
st_multi :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Returns the geometry as a multi-type (e.g. POINT -> MULTIPOINT). https://postgis.net/docs/ST_Multi.html
st_normalize :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Returns the geometry in its canonical (normalized) form. https://postgis.net/docs/ST_Normalize.html
st_reverse :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Returns the geometry with vertex order reversed. https://postgis.net/docs/ST_Reverse.html
st_segmentize :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Segmentizes a geometry so no segment is longer than the given distance. https://postgis.net/docs/ST_Segmentize.html
Arguments
| :: SqlExpr (Value (Postgis 'Geometry a)) | linestring |
| -> SqlExpr (Value Int) | 0-based index |
| -> SqlExpr (Value (Postgis 'Geometry a)) | new point |
| -> SqlExpr (Value (Postgis 'Geometry a)) |
Replaces a point of a linestring at a given 0-based index. https://postgis.net/docs/ST_SetPoint.html
st_snaptogrid :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Snaps all points of a geometry to a regular grid of the given size. https://postgis.net/docs/ST_SnapToGrid.html
st_snap :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Snaps vertices of one geometry to vertices and edges of another within a tolerance. https://postgis.net/docs/ST_Snap.html
Geometry validation
st_makevalid :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Attempts to make an invalid geometry valid without losing vertices. https://postgis.net/docs/ST_MakeValid.html
st_isvalidreason :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Text) Source #
Returns text describing why a geometry is invalid, or "Valid Geometry". https://postgis.net/docs/ST_IsValidReason.html
SRS functions
st_setsrid :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Int) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Sets the SRID on a geometry to a particular integer value. https://postgis.net/docs/ST_SetSRID.html
Geometry output
st_astext :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Text) Source #
Returns the Well-Known Text (WKT) representation of the geometry. https://postgis.net/docs/ST_AsText.html
st_asgeojson :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Text) Source #
Returns the GeoJSON representation of the geometry. https://postgis.net/docs/ST_AsGeoJSON.html
st_asewkt :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Text) Source #
Returns the Extended Well-Known Text (EWKT) representation of the geometry. https://postgis.net/docs/ST_AsEWKT.html
st_geohash :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Text) Source #
Returns a GeoHash representation of the geometry. https://postgis.net/docs/ST_GeoHash.html
Geometry processing
st_union :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
allows union of geometries, eg group a bunch together, https://postgis.net/docs/ST_Union.html for example:
mCombined <- selectOne $ do grid <- from $ tableGrid pure $ st_union $ grid ^. GridGeom select $ do unit <- from $ tableUnit forM_ mCombined $ combined -> where_ $ (unit ^. UnitGeom)st_intersects(val $ unValue combined) pure unit
st_unions :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
st_centroid :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Returns the geometric center (centroid) of a geometry. For polygons this is the center of mass of the surface. https://postgis.net/docs/ST_Centroid.html
st_buffer :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Returns a geometry that is the buffer of the input geometry at a given distance. The buffer is a polygon expanded (or shrunk if negative) from the input by the distance. https://postgis.net/docs/ST_Buffer.html
st_convexhull :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Returns the convex hull of a geometry. The smallest convex polygon that contains the input geometry. https://postgis.net/docs/ST_ConvexHull.html
st_envelope :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Returns the bounding box of a geometry as a geometry (polygon or point). A minimal axis-aligned rectangle that fully contains the input. https://postgis.net/docs/ST_Envelope.html
st_pointonsurface :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Returns a point guaranteed to lie on the surface of the geometry.
Unlike st_centroid, the result is always on or inside the geometry.
https://postgis.net/docs/ST_PointOnSurface.html
st_intersection :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Returns the shared portion of two geometries (their intersection). The result geometry contains only the area common to both inputs. https://postgis.net/docs/ST_Intersection.html
st_difference :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Returns the part of geometry A that does not intersect geometry B. Computes the geometric difference: A minus the shared area of A and B. https://postgis.net/docs/ST_Difference.html
st_symdifference :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Returns the portions of A and B that do not intersect (symmetric difference). https://postgis.net/docs/ST_SymDifference.html
st_unaryunion :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Computes the union of a single geometry (dissolves internal boundaries). https://postgis.net/docs/ST_UnaryUnion.html
st_split :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Splits a geometry by another geometry, returning a collection of geometries. https://postgis.net/docs/ST_Split.html
st_node :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Nodes a set of linestrings, adding intersection points. https://postgis.net/docs/ST_Node.html
st_buildarea :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Creates an areal geometry formed by the constituent linework of the input geometry. https://postgis.net/docs/ST_BuildArea.html
st_chaikinsmoothing :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Returns a smoothed version of the geometry using Chaikin's algorithm. https://postgis.net/docs/ST_ChaikinSmoothing.html
Arguments
| :: SqlExpr (Value (Postgis 'Geometry a)) | |
| -> SqlExpr (Value Double) | target_percent |
| -> SqlExpr (Value (Postgis 'Geometry a)) |
Returns a concave hull of a geometry with a target percent of area. https://postgis.net/docs/ST_ConcaveHull.html
st_delaunaytriangles :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Returns the Delaunay triangulation of a geometry's vertices. https://postgis.net/docs/ST_DelaunayTriangles.html
Arguments
| :: SqlExpr (Value (Postgis 'Geometry a)) | |
| -> SqlExpr (Value Int) | npoints |
| -> SqlExpr (Value (Postgis 'Geometry a)) |
Generates pseudo-random points within a polygon. https://postgis.net/docs/ST_GeneratePoints.html
st_geometricmedian :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Returns the geometric median of a multipoint. https://postgis.net/docs/ST_GeometricMedian.html
st_linemerge :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Merges a collection of linestrings into a single (or fewer) linestrings. https://postgis.net/docs/ST_LineMerge.html
st_minimumboundingcircle :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Returns the minimum bounding circle enclosing a geometry. https://postgis.net/docs/ST_MinimumBoundingCircle.html
st_offsetcurve :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Returns an offset line at a given distance from the input line. https://postgis.net/docs/ST_OffsetCurve.html
st_reduceprecision :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Reduces the precision of coordinates in a geometry to a given grid size. https://postgis.net/docs/ST_ReducePrecision.html
st_sharedpaths :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Returns a collection of shared paths between two linestring/multilinestring geometries. https://postgis.net/docs/ST_SharedPaths.html
st_simplify :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Returns a simplified version of a geometry using the Douglas-Peucker algorithm. https://postgis.net/docs/ST_Simplify.html
st_simplifypreservetopology :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Returns a simplified version of a geometry that preserves topology. https://postgis.net/docs/ST_SimplifyPreserveTopology.html
st_voronoilines :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Returns the Voronoi diagram edges for a set of points. https://postgis.net/docs/ST_VoronoiLines.html
st_voronoipolygons :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Returns the Voronoi diagram polygons for a set of points. https://postgis.net/docs/ST_VoronoiPolygons.html
Affine transformations
Arguments
| :: SqlExpr (Value (Postgis 'Geometry a)) | |
| -> SqlExpr (Value Double) | deltaX |
| -> SqlExpr (Value Double) | deltaY |
| -> SqlExpr (Value (Postgis 'Geometry a)) |
Translates a geometry by given X and Y offsets. https://postgis.net/docs/ST_Translate.html
Arguments
| :: SqlExpr (Value (Postgis 'Geometry a)) | |
| -> SqlExpr (Value Double) | scaleX |
| -> SqlExpr (Value Double) | scaleY |
| -> SqlExpr (Value (Postgis 'Geometry a)) |
Scales a geometry by given X and Y factors. https://postgis.net/docs/ST_Scale.html
Arguments
| :: SqlExpr (Value (Postgis 'Geometry a)) | |
| -> SqlExpr (Value Double) | angle in radians |
| -> SqlExpr (Value (Postgis 'Geometry a)) |
Rotates a geometry around the origin by an angle in radians. https://postgis.net/docs/ST_Rotate.html
Arguments
| :: SqlExpr (Value (Postgis 'Geometry a)) | |
| -> SqlExpr (Value Double) | angle in radians |
| -> SqlExpr (Value (Postgis 'Geometry a)) |
Rotates a geometry around the X axis by an angle in radians. https://postgis.net/docs/ST_RotateX.html
Arguments
| :: SqlExpr (Value (Postgis 'Geometry a)) | |
| -> SqlExpr (Value Double) | angle in radians |
| -> SqlExpr (Value (Postgis 'Geometry a)) |
Rotates a geometry around the Z axis by an angle in radians. https://postgis.net/docs/ST_RotateZ.html
Bounding box
st_expand :: SqlExpr (Value (Postgis 'Geometry a)) -> SqlExpr (Value Double) -> SqlExpr (Value (Postgis 'Geometry a)) Source #
Returns a bounding box expanded in all directions by a given distance. https://postgis.net/docs/ST_Expand.html
Linear referencing
st_lineinterpolatepoint Source #
Arguments
| :: SqlExpr (Value (Postgis 'Geometry a)) | |
| -> SqlExpr (Value Double) | fraction (0.0 to 1.0) |
| -> SqlExpr (Value (Postgis 'Geometry a)) |
Returns a point interpolated along a line at a fractional distance (0.0 to 1.0). https://postgis.net/docs/ST_LineInterpolatePoint.html
Arguments
| :: SqlExpr (Value (Postgis 'Geometry a)) | line |
| -> SqlExpr (Value (Postgis 'Geometry a)) | point |
| -> SqlExpr (Value Double) |
Returns a float between 0 and 1 representing the location of the closest point on a line to a given point. https://postgis.net/docs/ST_LineLocatePoint.html
Arguments
| :: SqlExpr (Value (Postgis 'Geometry a)) | |
| -> SqlExpr (Value Double) | start fraction |
| -> SqlExpr (Value Double) | end fraction |
| -> SqlExpr (Value (Postgis 'Geometry a)) |
Returns the portion of a line between two fractional locations (0.0 to 1.0). https://postgis.net/docs/ST_LineSubstring.html
Points
Arguments
| :: forall (spatialType :: SpatialType). Double | x or longitude |
| -> Double | y or latitude |
| -> Postgis spatialType PointXY |
Arguments
| :: forall (spatialType :: SpatialType). HasPgType spatialType | |
| => SqlExpr (Value Double) | x or longitude |
| -> SqlExpr (Value Double) | y or latitude |
| -> SqlExpr (Value Double) | z elevation/altitude |
| -> SqlExpr (Value Double) | m measure, user defined dimension |
| -> SqlExpr (Value (Postgis spatialType PointXYZM)) |
Transform
st_transform_geography Source #
Arguments
| :: SRID 'Linear | |
| -> SqlExpr (Value (Postgis 'Geography a)) | g1 (library handles the conversion) |
| -> SqlExpr (Value (Postgis 'Geometry a)) |
Project a geography onto a geometry.
allows using of functions such as st_union which only work in flat space (geometry).
https://postgis.net/docs/ST_Transform.html
st_transform_geometry Source #
Arguments
| :: SqlExpr (Value (Postgis 'Geometry a)) | g1 (library handles the conversion) |
| -> SqlExpr (Value (Postgis 'Geography a)) |
project a geometry as a geography, assumes wgs84.
https://postgis.net/docs/ST_Transform.html
SRID
data SRID (unit :: SridUnit) Source #
SRID
you can find your local like this: https://blog.rustprooflabs.com/2020/11/postgis-find-local-srid
geography appears to use wgs84. So I hardcoded the use going from geom to geography as that.
you can use the num instance to put in whatever. however, if you miss a srid please submit a PR.
Instances
| Num (SRID unit) Source # | |
Defined in Database.Esqueleto.Postgis | |
| PersistField (SRID unit) Source # | |
Defined in Database.Esqueleto.Postgis Methods toPersistValue :: SRID unit -> PersistValue # fromPersistValue :: PersistValue -> Either Text (SRID unit) # | |
wgs84 :: SRID 'Degree Source #
default for geography type in postgis. Geodetic CRS: WGS 84 https://epsg.io/4326
mercator :: SRID 'Linear Source #
most maps are in this, it has some large distortions further away from equator https://epsg.io/3857
britishNationalGrid :: SRID 'Linear Source #
if you're in england this is pretty good. https://epsg.io/27700
Diferent SRID come in different units,
important for converting from geograhy to geometry.
Other
makePolygon :: (Eq point, Show point) => point -> point -> point -> Seq point -> LinearRing point Source #
checks if the first point is the last, and if not so makes it so. this is required for inserting into the database
type PostgisGeometry = Postgis 'Geometry Source #
backwards compatibility, initial version only dealt in geometry
class HasPgType (spatialType :: SpatialType) Source #
technical typeclass to bind a spatial type to a string value. because we represent the constructors as a datakind, we need this to go back to a value.
Minimal complete definition
pgType
Re-exports
(GeoPositionWithoutCRS is a catch all for indeterminate CRSs and for expression of positions
before a CRS has been determined
Instances
Instances
| Generic PointXYZ | |||||
Defined in Data.Geospatial.Internal.BasicTypes Associated Types
| |||||
| Show PointXYZ | |||||
| NFData PointXYZ | |||||
Defined in Data.Geospatial.Internal.BasicTypes | |||||
| Eq PointXYZ | |||||
| HasPgType spatialType => PersistField (Postgis spatialType PointXYZ) Source # | |||||
Defined in Database.Esqueleto.Postgis Methods toPersistValue :: Postgis spatialType PointXYZ -> PersistValue # fromPersistValue :: PersistValue -> Either Text (Postgis spatialType PointXYZ) # | |||||
| HasPgType spatialType => PersistFieldSql (Postgis spatialType PointXYZ) Source # | |||||
| type Rep PointXYZ | |||||
Defined in Data.Geospatial.Internal.BasicTypes type Rep PointXYZ = D1 ('MetaData "PointXYZ" "Data.Geospatial.Internal.BasicTypes" "geojson-4.1.3-CvRMTkCmXKrLRGaX0qKQVX" 'False) (C1 ('MetaCons "PointXYZ" 'PrefixI 'True) (S1 ('MetaSel ('Just "_xyzX") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Double) :*: (S1 ('MetaSel ('Just "_xyzY") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Double) :*: S1 ('MetaSel ('Just "_xyzZ") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Double)))) | |||||
Instances
| Generic PointXYZM | |||||
Defined in Data.Geospatial.Internal.BasicTypes Associated Types
| |||||
| Show PointXYZM | |||||
| NFData PointXYZM | |||||
Defined in Data.Geospatial.Internal.BasicTypes | |||||
| Eq PointXYZM | |||||
| HasPgType spatialType => PersistField (Postgis spatialType PointXYZM) Source # | |||||
Defined in Database.Esqueleto.Postgis Methods toPersistValue :: Postgis spatialType PointXYZM -> PersistValue # fromPersistValue :: PersistValue -> Either Text (Postgis spatialType PointXYZM) # | |||||
| HasPgType spatialType => PersistFieldSql (Postgis spatialType PointXYZM) Source # | |||||
| type Rep PointXYZM | |||||
Defined in Data.Geospatial.Internal.BasicTypes type Rep PointXYZM = D1 ('MetaData "PointXYZM" "Data.Geospatial.Internal.BasicTypes" "geojson-4.1.3-CvRMTkCmXKrLRGaX0qKQVX" 'False) (C1 ('MetaCons "PointXYZM" 'PrefixI 'True) ((S1 ('MetaSel ('Just "_xyzmX") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Double) :*: S1 ('MetaSel ('Just "_xyzmY") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Double)) :*: (S1 ('MetaSel ('Just "_xyzmZ") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Double) :*: S1 ('MetaSel ('Just "_xyzmM") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Double)))) | |||||
Orphan instances
| HasPgType spatialType => PersistField (Postgis spatialType PointXY) Source # | |
Methods toPersistValue :: Postgis spatialType PointXY -> PersistValue # fromPersistValue :: PersistValue -> Either Text (Postgis spatialType PointXY) # | |
| HasPgType spatialType => PersistField (Postgis spatialType PointXYZ) Source # | |
Methods toPersistValue :: Postgis spatialType PointXYZ -> PersistValue # fromPersistValue :: PersistValue -> Either Text (Postgis spatialType PointXYZ) # | |
| HasPgType spatialType => PersistField (Postgis spatialType PointXYZM) Source # | |
Methods toPersistValue :: Postgis spatialType PointXYZM -> PersistValue # fromPersistValue :: PersistValue -> Either Text (Postgis spatialType PointXYZM) # | |
| HasPgType spatialType => PersistFieldSql (Postgis spatialType PointXY) Source # | |
| HasPgType spatialType => PersistFieldSql (Postgis spatialType PointXYZ) Source # | |
| HasPgType spatialType => PersistFieldSql (Postgis spatialType PointXYZM) Source # | |