postgis_diesel/
functions.rs

1use crate::sql_types::*;
2use diesel::sql_types::*;
3
4//Topological Relationships****************************************************************
5
6define_sql_function! {
7    /// Tests if two geometries spatially intersect in 3D - only for points, linestrings, polygons, polyhedral surface (area).
8    #[sql_name="ST_3DIntersects"]
9    fn st_3d_intersects(left: Geometry, right: Geometry) -> Bool;
10}
11define_sql_function! {
12    /// Tests if no points of B lie in the exterior of A, and A and B have at least one interior point in common.
13    #[sql_name="ST_Contains"]
14    fn st_contains(left: Geometry, right: Geometry) -> Bool;
15}
16define_sql_function! {
17    /// Tests if B intersects the interior of A but not the boundary or exterior.
18    #[sql_name="ST_ContainsProperly"]
19    fn st_contains_properly(left: Geometry, right: Geometry) -> Bool;
20}
21define_sql_function! {
22    /// Tests if no point in A is outside B
23    #[sql_name="ST_CoveredBy"]
24    fn st_covered_by<G: GeoType>(left: G, right: G) -> Bool;
25}
26define_sql_function! {
27    /// Tests if no point in B is outside A
28    #[sql_name="ST_Covers"]
29    fn st_covers<G: GeoType>(left: G, right: G) -> Bool;
30}
31define_sql_function! {
32    /// Tests if two geometries have some, but not all, interior points in common.
33    #[sql_name="ST_Crosses"]
34    fn st_crosses(left: Geometry, right: Geometry) -> Bool;
35}
36define_sql_function! {
37    /// Tests if two geometries are disjoint (they have no point in common).
38    #[sql_name="ST_Disjoint"]
39    fn st_disjoint(left: Geometry, right: Geometry) -> Bool;
40}
41define_sql_function! {
42    /// Tests if two geometries include the same set of points.
43    #[sql_name="ST_Equals"]
44    fn st_equals(left: Geometry, right: Geometry) -> Bool;
45}
46define_sql_function! {
47    /// Tests if two geometries intersect (they have at least one point in common).
48    #[sql_name="ST_Intersects"]
49    fn st_intersects<G: GeoType>(left: G, right: G) -> Bool;
50}
51define_sql_function! {
52    /// Returns a number indicating the crossing behavior of two LineStrings.
53    #[sql_name="ST_LineCrossingDirection"]
54    fn st_line_crossing_direction(left: Geometry, right: Geometry) -> Integer;
55}
56define_sql_function! {
57    /// Tests if two geometries represent the same geometry and have points in the same directional order.
58    #[sql_name="ST_OrderingEquals"]
59    fn st_ordering_equals(left: Geometry, right: Geometry) -> Bool;
60}
61define_sql_function! {
62    /// Tests if two geometries intersect and have the same dimension, but are not completely contained by each other.
63    #[sql_name="ST_Overlaps"]
64    fn st_overlaps(left: Geometry, right: Geometry) -> Bool;
65}
66define_sql_function! {
67    /// Tests if two geometries have a topological relationship matching an Intersection Matrix pattern.
68    #[sql_name="ST_Relate"]
69    fn st_relate_check(left: Geometry, right: Geometry, intersection_matrix_mattern: Text) -> Bool;
70}
71define_sql_function! {
72    /// Computes Intersection Matrix of two geometries.
73    #[sql_name="ST_Relate"]
74    fn st_relate(left: Geometry, right: Geometry) -> Text;
75}
76define_sql_function! {
77    /// Computes Intersection Matrix of two geometries. The boundary node rule code is: 1: OGC/MOD2, 2: Endpoint, 3: MultivalentEndpoint, 4: MonovalentEndpoint.
78    #[sql_name="ST_Relate"]
79    fn st_relate_bnr(left: Geometry, right: Geometry, boundary_node_rule: Integer) -> Text;
80}
81define_sql_function! {
82    /// Tests if a DE-9IM Intersection Matrix matches an Intersection Matrix pattern
83    #[sql_name="ST_RelateMatch"]
84    fn st_relate_match(intersection_matrix: Text, intersection_matrix_pattern: Text) -> Bool;
85}
86define_sql_function! {
87    /// Tests if two geometries have at least one point in common, but their interiors do not intersect.
88    #[sql_name="ST_Touches"]
89    fn st_touches(left: Geometry, right: Geometry) -> Bool;
90}
91define_sql_function! {
92    /// Tests if no points of A lie in the exterior of B, and A and B have at least one interior point in common.
93    #[sql_name="ST_Within"]
94    fn st_within(left: Geometry, right: Geometry) -> Bool;
95}
96define_sql_function! {
97    /// Tests if A and B are within a given distance.
98    #[sql_name="ST_DWithin"]
99    fn st_d_within<G: GeoType>(left: G, right: G, distance: Double) -> Bool;
100}
101define_sql_function! {
102    /// Computes a geometry covering all points within a given distance from a geometry.
103    #[sql_name="ST_Buffer"]
104    fn st_buffer<G: GeoType>(geometry: G, radius_of_buffer: Double, buffer_style_parameters: Text) -> G;
105}
106define_sql_function! {
107    /// Returns a modified geometry having no segment longer than the given max_segment_length. Distance computation is
108    /// performed in 2d only. For geometry, length units are in units of spatial reference. For geography, units are in
109    /// meters.
110    #[sql_name="ST_Segmentize"]
111    fn st_segmentize<G: GeoType>(geometry: G, max_segment_length: Double) -> G;
112}
113define_sql_function! {
114    /// Divides geometry into parts until a part can be represented using no more than max_vertices.
115    #[sql_name="ST_Subdivide"]
116    fn st_subdivide<G: GeoType>(geometry: G, max_vertices: Integer, grid_size: Float8) -> G;
117}
118define_sql_function! {
119    /// Return the X coordinate of the point, or NULL if not available. Input must be a point.
120    #[sql_name="ST_X"]
121    fn st_x(geometry: Geometry) -> Double;
122}
123define_sql_function! {
124    /// Return the Y coordinate of the point, or NULL if not available. Input must be a point.
125    #[sql_name="ST_Y"]
126    fn st_y(geometry: Geometry) -> Double;
127}