postgis_diesel/
functions_nullable.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: Nullable<Geometry>, right: Nullable<Geometry>) -> Nullable<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: Nullable<Geometry>, right: Nullable<Geometry>) -> Nullable<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: Nullable<Geometry>, right: Nullable<Geometry>) -> Nullable<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: Nullable<G>, right: Nullable<G>) -> Nullable<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: Nullable<G>, right: Nullable<G>) -> Nullable<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: Nullable<Geometry>, right: Nullable<Geometry>) -> Nullable<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: Nullable<Geometry>, right: Nullable<Geometry>) -> Nullable<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: Nullable<Geometry>, right: Nullable<Geometry>) -> Nullable<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: Nullable<G>, right: Nullable<G>) -> Nullable<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: Nullable<Geometry>, right: Nullable<Geometry>) -> Nullable<Integer>;
55}
56define_sql_function! {
57    /// Tests if two geometries represent the same Nullable<Geometry> and have points in the same directional order.
58    #[sql_name="ST_OrderingEquals"]
59    fn st_ordering_equals(left: Nullable<Geometry>, right: Nullable<Geometry>) -> Nullable<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: Nullable<Geometry>, right: Nullable<Geometry>) -> Nullable<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: Nullable<Geometry>, right: Nullable<Geometry>, intersection_matrix_mattern: Nullable<Text>) -> Nullable<Bool>;
70}
71define_sql_function! {
72    /// Computes Intersection Matrix of two geometries.
73    #[sql_name="ST_Relate"]
74    fn st_relate(left: Nullable<Geometry>, right: Nullable<Geometry>) -> Nullable<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: Nullable<Geometry>, right: Nullable<Geometry>, boundary_node_rule: Nullable<Integer>) -> Nullable<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: Nullable<Text>, intersection_matrix_pattern: Nullable<Text>) -> Nullable<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: Nullable<Geometry>, right: Nullable<Geometry>) -> Nullable<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: Nullable<Geometry>, right: Nullable<Geometry>) -> Nullable<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: Nullable<G>, right: Nullable<G>, distance: Nullable<Double>) -> Nullable<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: Nullable<G>, radius_of_buffer: Nullable<Double>, buffer_style_parameters: Text) -> Nullable<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: Nullable<G>, max_segment_length: Double) -> Nullable<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: Nullable<G>, max_vertices: Integer, grid_size: Float8) -> Nullable<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: Nullable<Geometry>) -> Nullable<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: Nullable<Geometry>) -> Nullable<Double>;
127}