Skip to content

Commit

Permalink
Merge pull request #24 from johnlepikhin/feat/st_buffer
Browse files Browse the repository at this point in the history
Added function ST_Buffer()
  • Loading branch information
vitaly-m authored Apr 6, 2024
2 parents 53988fb + 387f94f commit 3557c14
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,23 @@ sql_function! {
#[sql_name="ST_DWithin"]
fn st_d_within<G: GeoType>(left: G, right: G, distance: Double) -> Bool;
}
sql_function! {
/// Computes a geometry covering all points within a given distance from a geometry.
#[sql_name="ST_Buffer"]
fn st_buffer<G: GeoType>(geometry: G, radius_of_buffer: Double, buffer_style_parameters: Text) -> G;
}
sql_function! {
/// Returns a modified geometry having no segment longer than the given max_segment_length. Distance computation is
/// performed in 2d only. For geometry, length units are in units of spatial reference. For geography, units are in
/// meters.
#[sql_name="ST_Segmentize"]
fn st_segmentize<G: GeoType>(geometry: G, max_segment_length: Double) -> G;
}
sql_function! {
/// Divides geometry into parts until a part can be represented using no more than max_vertices.
#[sql_name="ST_Subdivide"]
fn st_subdivide<G: GeoType>(geometry: G, max_vertices: Integer, grid_size: Float8) -> G;
}

pub type St3DIntersects<GeomA, GeomB> = st_3d_intersects::HelperType<GeomA, GeomB>;
pub type StContains<GeomA, GeomB> = st_contains::HelperType<GeomA, GeomB>;
Expand All @@ -119,3 +136,8 @@ pub type StRelateMatch<GeomA, GeomB> = st_relate_match::HelperType<GeomA, GeomB>
pub type StTouches<GeomA, GeomB> = st_touches::HelperType<GeomA, GeomB>;
pub type StWithin<GeomA, GeomB> = st_within::HelperType<GeomA, GeomB>;
pub type StDWithin<G, GeomA, GeomB, Distance> = st_d_within::HelperType<G, GeomA, GeomB, Distance>;
pub type StBuffer<G, Geom, Radius, Text> = st_buffer::HelperType<G, Geom, Radius, Text>;
pub type StSegmentize<G, Geom, MaxSegmentLength> =
st_segmentize::HelperType<G, Geom, MaxSegmentLength>;
pub type StSubdivide<G, Geom, MaxVertices, GridSize> =
st_subdivide::HelperType<G, Geom, MaxVertices, GridSize>;
22 changes: 22 additions & 0 deletions src/functions_nullable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,23 @@ sql_function! {
#[sql_name="ST_DWithin"]
fn st_d_within<G: GeoType>(left: Nullable<G>, right: Nullable<G>, distance: Nullable<Double>) -> Nullable<Bool>;
}
sql_function! {
/// Computes a geometry covering all points within a given distance from a geometry.
#[sql_name="ST_Buffer"]
fn st_buffer<G: GeoType>(geometry: Nullable<G>, radius_of_buffer: Nullable<Double>, buffer_style_parameters: Text) -> Nullable<G>;
}
sql_function! {
/// Returns a modified geometry having no segment longer than the given max_segment_length. Distance computation is
/// performed in 2d only. For geometry, length units are in units of spatial reference. For geography, units are in
/// meters.
#[sql_name="ST_Segmentize"]
fn st_segmentize<G: GeoType>(geometry: Nullable<G>, max_segment_length: Double) -> Nullable<G>;
}
sql_function! {
/// Divides geometry into parts until a part can be represented using no more than max_vertices.
#[sql_name="ST_Subdivide"]
fn st_subdivide<G: GeoType>(geometry: Nullable<G>, max_vertices: Integer, grid_size: Float8) -> Nullable<G>;
}

pub type St3DIntersects<GeomA, GeomB> = st_3d_intersects::HelperType<GeomA, GeomB>;
pub type StContains<GeomA, GeomB> = st_contains::HelperType<GeomA, GeomB>;
Expand All @@ -119,3 +136,8 @@ pub type StRelateMatch<GeomA, GeomB> = st_relate_match::HelperType<GeomA, GeomB>
pub type StTouches<GeomA, GeomB> = st_touches::HelperType<GeomA, GeomB>;
pub type StWithin<GeomA, GeomB> = st_within::HelperType<GeomA, GeomB>;
pub type StDWithin<G, GeomA, GeomB, Distance> = st_d_within::HelperType<G, GeomA, GeomB, Distance>;
pub type StBuffer<G, Geom, Radius, Text> = st_buffer::HelperType<G, Geom, Radius, Text>;
pub type StSegmentize<G, Geom, MaxSegmentLength> =
st_segmentize::HelperType<G, Geom, MaxSegmentLength>;
pub type StSubdivide<G, Geom, MaxVertices, GridSize> =
st_subdivide::HelperType<G, Geom, MaxVertices, GridSize>;

0 comments on commit 3557c14

Please sign in to comment.