From 87c372cf139868ec58f3665aa3ffe267fb6a4ce1 Mon Sep 17 00:00:00 2001 From: Christian Heider Nielsen Date: Sun, 10 Dec 2023 18:03:01 +0100 Subject: [PATCH] add extra requirement files --- jord/__init__.py | 2 +- jord/shapely_utilities/grouping.py | 4 ++-- jord/shapely_utilities/lines.py | 21 ++++++++++----------- jord/shapely_utilities/morphology.py | 12 +++--------- jord/shapely_utilities/polygons.py | 8 ++++---- jord/shapely_utilities/rings.py | 15 ++++----------- requirements/requirements_fiona.txt | 1 + requirements/requirements_geopandas.txt | 1 + requirements/requirements_networkx.txt | 1 + requirements/requirements_shapely.txt | 2 ++ 10 files changed, 29 insertions(+), 38 deletions(-) create mode 100644 requirements/requirements_fiona.txt create mode 100644 requirements/requirements_geopandas.txt create mode 100644 requirements/requirements_networkx.txt create mode 100644 requirements/requirements_shapely.txt diff --git a/jord/__init__.py b/jord/__init__.py index 652ef40..7ea7d6c 100755 --- a/jord/__init__.py +++ b/jord/__init__.py @@ -17,7 +17,7 @@ __project__ = "Jord" __author__ = "Christian Heider Lindbjerg" -__version__ = "0.3.0" +__version__ = "0.3.1" __doc__ = r""" .. module:: jord :platform: Unix, Windows diff --git a/jord/shapely_utilities/grouping.py b/jord/shapely_utilities/grouping.py index 6a5da41..f8fd1f8 100644 --- a/jord/shapely_utilities/grouping.py +++ b/jord/shapely_utilities/grouping.py @@ -4,8 +4,8 @@ import shapely from shapely import unary_union -from jord.shapely_utilities import closing -from jord.shapely_utilities.geometry_types import is_multi +from .geometry_types import is_multi +from .morphology import closing __all__ = ["overlap_groups"] diff --git a/jord/shapely_utilities/lines.py b/jord/shapely_utilities/lines.py index cc2a6a3..01c98cf 100755 --- a/jord/shapely_utilities/lines.py +++ b/jord/shapely_utilities/lines.py @@ -23,34 +23,33 @@ import collections import logging from enum import Enum -from typing import List, Iterable, Optional -from typing import Tuple, Sequence, Union +from typing import Iterable, List, Optional, Sequence, Tuple, Union import numpy from shapely.geometry import ( + GeometryCollection, LineString, MultiLineString, MultiPoint, + MultiPolygon, Point, Polygon, - MultiPolygon, - GeometryCollection, + box, ) -from shapely.geometry import box from shapely.geometry.base import BaseGeometry from shapely.ops import linemerge as shapely_linemerge from sorcery import assigned_names from warg import Number, pairs -from jord.shapely_utilities.points import ( - unique_line_points, - nearest_neighbor_within, +from .points import ( azimuth, - shift_point, closest_object, + nearest_neighbor_within, + shift_point, + unique_line_points, ) -from jord.shapely_utilities.polygons import explode_polygons -from jord.shapely_utilities.projection import nearest_geometry +from .polygons import explode_polygons +from .projection import nearest_geometry EPSILON = 1e-6 diff --git a/jord/shapely_utilities/morphology.py b/jord/shapely_utilities/morphology.py index 7e2b291..d138222 100755 --- a/jord/shapely_utilities/morphology.py +++ b/jord/shapely_utilities/morphology.py @@ -17,9 +17,6 @@ def erosion(geom: BaseGeometry, eps: float = 1e-7) -> BaseGeometry: return geom.buffer(-eps) -erode = erosion - - def dilation(geom: BaseGeometry, eps: float = 1e-7) -> BaseGeometry: """ @@ -30,9 +27,6 @@ def dilation(geom: BaseGeometry, eps: float = 1e-7) -> BaseGeometry: return geom.buffer(eps) -dilate = dilation - - def closing(geom: BaseGeometry, eps: float = 1e-7) -> BaseGeometry: """ @@ -43,9 +37,6 @@ def closing(geom: BaseGeometry, eps: float = 1e-7) -> BaseGeometry: return erode(dilate(geom, eps), eps) -close = closing - - def opening(geom: BaseGeometry, eps: float = 1e-7) -> BaseGeometry: """ @@ -57,6 +48,9 @@ def opening(geom: BaseGeometry, eps: float = 1e-7) -> BaseGeometry: # open = opening # keyword clash +erode = erosion +dilate = dilation +close = closing if __name__ == "__main__": diff --git a/jord/shapely_utilities/polygons.py b/jord/shapely_utilities/polygons.py index 2306a41..8f23541 100755 --- a/jord/shapely_utilities/polygons.py +++ b/jord/shapely_utilities/polygons.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- import statistics -from typing import Union, Tuple, List, Sequence, Generator +from typing import Generator, List, Sequence, Tuple, Union from shapely.geometry import ( LineString, @@ -12,10 +12,10 @@ Polygon, ) from shapely.geometry.base import BaseGeometry -from warg import pairs, Number +from warg import Number, pairs -from jord.shapely_utilities.morphology import opening, closing -from jord.shapely_utilities.rings import ensure_ccw_ring, ensure_cw_ring +from .morphology import closing, opening +from .rings import ensure_ccw_ring, ensure_cw_ring __all__ = [ "zero_buffer", diff --git a/jord/shapely_utilities/rings.py b/jord/shapely_utilities/rings.py index 1c09014..50725b1 100755 --- a/jord/shapely_utilities/rings.py +++ b/jord/shapely_utilities/rings.py @@ -1,8 +1,11 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- +from typing import Iterable, Union + +from shapely import LineString, LinearRing, MultiLineString, Point -from shapely import LinearRing +from .projection import line_line_intersection, project_point_to_line __all__ = [ "ensure_ccw_ring", @@ -24,16 +27,6 @@ def ensure_cw_ring(ring: LinearRing) -> LinearRing: return ring -from typing import Iterable, Union - -from shapely import MultiLineString, LineString, Point, LinearRing - -from jord.shapely_utilities.projection import ( - project_point_to_line, - line_line_intersection, -) - - def make_projected_ring( lines: Union[MultiLineString, Iterable[LineString]], ccw: bool = True ) -> LinearRing: diff --git a/requirements/requirements_fiona.txt b/requirements/requirements_fiona.txt new file mode 100644 index 0000000..9d901a6 --- /dev/null +++ b/requirements/requirements_fiona.txt @@ -0,0 +1 @@ +fiona diff --git a/requirements/requirements_geopandas.txt b/requirements/requirements_geopandas.txt new file mode 100644 index 0000000..d956e3b --- /dev/null +++ b/requirements/requirements_geopandas.txt @@ -0,0 +1 @@ +geopandas diff --git a/requirements/requirements_networkx.txt b/requirements/requirements_networkx.txt new file mode 100644 index 0000000..4d07dfe --- /dev/null +++ b/requirements/requirements_networkx.txt @@ -0,0 +1 @@ +networkx diff --git a/requirements/requirements_shapely.txt b/requirements/requirements_shapely.txt new file mode 100644 index 0000000..3a51a89 --- /dev/null +++ b/requirements/requirements_shapely.txt @@ -0,0 +1,2 @@ +pyproj +shapely