Skip to content

Commit

Permalink
Merge pull request #217 from xhwhis/main
Browse files Browse the repository at this point in the history
upgrade geos to 9.0
  • Loading branch information
michaelkirk authored Jun 25, 2024
2 parents b680d12 + 605832a commit ab5486a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ gdal-sys = "0.9"
geo = "0.26.0"
geo-types = { version = "0.7.11", default-features = false }
geojson = { version = "0.24.1", default-features = false }
geos = "8.3"
geos = "9.0"
gpx = { version = "0.9", default-features = false }
hex = "0.4"
kdbush = "0.2"
Expand Down
10 changes: 5 additions & 5 deletions geozero/src/geos/geos_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::error::{GeozeroError, Result};
use crate::{CoordDimensions, GeomProcessor, GeozeroGeometry};
use geos::{CoordSeq, Geom, Geometry as GGeometry, GeometryTypes};

impl GeozeroGeometry for geos::Geometry<'_> {
impl GeozeroGeometry for geos::Geometry {
fn process_geom<P: GeomProcessor>(&self, processor: &mut P) -> Result<()> {
process_geom(self, processor)
}
Expand Down Expand Up @@ -39,7 +39,7 @@ pub fn process_geom<P: GeomProcessor>(ggeom: &GGeometry, processor: &mut P) -> R
process_geom_n(ggeom, 0, processor)
}

fn process_geom_n<'a, P: GeomProcessor, G: Geom<'a>>(
fn process_geom_n<P: GeomProcessor, G: Geom>(
ggeom: &G,
idx: usize,
processor: &mut P,
Expand Down Expand Up @@ -128,7 +128,7 @@ fn process_coord_seq<P: GeomProcessor>(
Ok(())
}

fn process_point<'a, P: GeomProcessor, G: Geom<'a>>(
fn process_point<P: GeomProcessor, G: Geom>(
ggeom: &G,
idx: usize,
processor: &mut P,
Expand All @@ -139,7 +139,7 @@ fn process_point<'a, P: GeomProcessor, G: Geom<'a>>(
process_coord_seq(&cs, idx, processor)
}

fn process_linestring<'a, P: GeomProcessor, G: Geom<'a>>(
fn process_linestring<P: GeomProcessor, G: Geom>(
ggeom: &G,
tagged: bool,
idx: usize,
Expand All @@ -154,7 +154,7 @@ fn process_linestring<'a, P: GeomProcessor, G: Geom<'a>>(
processor.linestring_end(tagged, idx)
}

fn process_polygon<'a, P: GeomProcessor, G: Geom<'a>>(
fn process_polygon<P: GeomProcessor, G: Geom>(
ggeom: &G,
tagged: bool,
idx: usize,
Expand Down
20 changes: 10 additions & 10 deletions geozero/src/geos/geos_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ use crate::{FeatureProcessor, GeomProcessor, PropertyProcessor};
use geos::{CoordDimensions, CoordSeq, GResult, Geometry as GGeometry};

/// Generator for GEOS geometry type.
pub struct GeosWriter<'a> {
pub(crate) geom: GGeometry<'a>,
pub struct GeosWriter {
pub(crate) geom: GGeometry,
srid: Option<i32>,
// CoordSeq for Points, Lines and Rings
cs: Vec<CoordSeq<'a>>,
cs: Vec<CoordSeq>,
// Polygons or MultiPolygons
polys: Vec<GGeometry<'a>>,
polys: Vec<GGeometry>,
}

impl<'a> GeosWriter<'a> {
impl GeosWriter {
pub fn new() -> Self {
Self::default()
}
Expand All @@ -21,12 +21,12 @@ impl<'a> GeosWriter<'a> {
.push(CoordSeq::new(len as u32, CoordDimensions::TwoD)?);
Ok(())
}
pub fn geometry(&self) -> &GGeometry<'a> {
pub fn geometry(&self) -> &GGeometry {
&self.geom
}
}

impl<'a> Default for GeosWriter<'a> {
impl Default for GeosWriter {
fn default() -> Self {
GeosWriter {
geom: GGeometry::create_empty_point().unwrap(),
Expand All @@ -37,7 +37,7 @@ impl<'a> Default for GeosWriter<'a> {
}
}

impl GeomProcessor for GeosWriter<'_> {
impl GeomProcessor for GeosWriter {
fn srid(&mut self, srid: Option<i32>) -> Result<()> {
self.srid = srid;
Ok(())
Expand Down Expand Up @@ -168,8 +168,8 @@ impl GeomProcessor for GeosWriter<'_> {
}
}

impl PropertyProcessor for GeosWriter<'_> {}
impl FeatureProcessor for GeosWriter<'_> {}
impl PropertyProcessor for GeosWriter {}
impl FeatureProcessor for GeosWriter {}

#[cfg(test)]
#[cfg(feature = "with-geojson")]
Expand Down
6 changes: 3 additions & 3 deletions geozero/src/geos/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ pub(crate) mod conversion {
/// Convert to GEOS geometry.
pub trait ToGeos {
/// Convert to GEOS geometry.
fn to_geos(&self) -> Result<geos::Geometry<'_>>;
fn to_geos(&self) -> Result<geos::Geometry>;
}

impl<T: GeozeroGeometry> ToGeos for T {
fn to_geos(&self) -> Result<geos::Geometry<'_>> {
fn to_geos(&self) -> Result<geos::Geometry> {
let mut geos = GeosWriter::new();
self.process_geom(&mut geos)?;
Ok(geos.geom)
Expand All @@ -32,7 +32,7 @@ mod wkb {
use crate::wkb::{FromWkb, WkbDialect};
use std::io::Read;

impl FromWkb for geos::Geometry<'_> {
impl FromWkb for geos::Geometry {
fn from_wkb<R: Read>(rdr: &mut R, dialect: WkbDialect) -> Result<Self> {
let mut geos = GeosWriter::new();
crate::wkb::process_wkb_type_geom(rdr, &mut geos, dialect)?;
Expand Down

0 comments on commit ab5486a

Please sign in to comment.