pysnapping 0.2.0__tar.gz → 0.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. {pysnapping-0.2.0 → pysnapping-0.2.1}/PKG-INFO +1 -1
  2. {pysnapping-0.2.0 → pysnapping-0.2.1}/pysnapping/__init__.py +27 -0
  3. {pysnapping-0.2.0 → pysnapping-0.2.1}/pysnapping/snap.py +9 -6
  4. {pysnapping-0.2.0 → pysnapping-0.2.1}/pysnapping.egg-info/PKG-INFO +1 -1
  5. {pysnapping-0.2.0 → pysnapping-0.2.1}/.editorconfig +0 -0
  6. {pysnapping-0.2.0 → pysnapping-0.2.1}/.gitignore +0 -0
  7. {pysnapping-0.2.0 → pysnapping-0.2.1}/.gitlab-ci.yml +0 -0
  8. {pysnapping-0.2.0 → pysnapping-0.2.1}/.pre-commit-config.yaml +0 -0
  9. {pysnapping-0.2.0 → pysnapping-0.2.1}/LICENSE +0 -0
  10. {pysnapping-0.2.0 → pysnapping-0.2.1}/MANIFEST.in +0 -0
  11. {pysnapping-0.2.0 → pysnapping-0.2.1}/README.md +0 -0
  12. {pysnapping-0.2.0 → pysnapping-0.2.1}/dev-requirements.in +0 -0
  13. {pysnapping-0.2.0 → pysnapping-0.2.1}/dev-requirements.txt +0 -0
  14. {pysnapping-0.2.0 → pysnapping-0.2.1}/pyproject.toml +0 -0
  15. {pysnapping-0.2.0 → pysnapping-0.2.1}/pysnapping/linear_referencing.py +0 -0
  16. {pysnapping-0.2.0 → pysnapping-0.2.1}/pysnapping/py.typed +0 -0
  17. {pysnapping-0.2.0 → pysnapping-0.2.1}/pysnapping/test/__init__.py +0 -0
  18. {pysnapping-0.2.0 → pysnapping-0.2.1}/pysnapping/test/complex_trip.geojson +0 -0
  19. {pysnapping-0.2.0 → pysnapping-0.2.1}/pysnapping/test/conftest.py +0 -0
  20. {pysnapping-0.2.0 → pysnapping-0.2.1}/pysnapping/test/test_linear_referencing.py +0 -0
  21. {pysnapping-0.2.0 → pysnapping-0.2.1}/pysnapping/test/test_snap.py +0 -0
  22. {pysnapping-0.2.0 → pysnapping-0.2.1}/pysnapping/test/test_util.py +0 -0
  23. {pysnapping-0.2.0 → pysnapping-0.2.1}/pysnapping/util.py +0 -0
  24. {pysnapping-0.2.0 → pysnapping-0.2.1}/pysnapping.egg-info/SOURCES.txt +0 -0
  25. {pysnapping-0.2.0 → pysnapping-0.2.1}/pysnapping.egg-info/dependency_links.txt +0 -0
  26. {pysnapping-0.2.0 → pysnapping-0.2.1}/pysnapping.egg-info/requires.txt +0 -0
  27. {pysnapping-0.2.0 → pysnapping-0.2.1}/pysnapping.egg-info/top_level.txt +0 -0
  28. {pysnapping-0.2.0 → pysnapping-0.2.1}/requirements.txt +0 -0
  29. {pysnapping-0.2.0 → pysnapping-0.2.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pysnapping
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: Snap points to a line string keeping a given order or spacing intact
5
5
  Author-email: Alexander Held | geOps <alexander.held@geops.com>
6
6
  Maintainer-email: Alexander Held | geOps <alexander.held@geops.com>
@@ -1,6 +1,11 @@
1
+ import typing
1
2
  from enum import Enum
2
3
 
3
4
  import pyproj
5
+ import numpy as np
6
+
7
+ if typing.TYPE_CHECKING:
8
+ from numpy.typing import ArrayLike
4
9
 
5
10
 
6
11
  EPSG4326 = pyproj.CRS.from_epsg(4326)
@@ -25,6 +30,28 @@ class SnappingError(ValueError):
25
30
  pass
26
31
 
27
32
 
33
+ class BadShortestDistances(SnappingError):
34
+ bad_indices: np.ndarray
35
+ bad_distances: np.ndarray
36
+ max_allowed_distance: float
37
+
38
+ def __init__(
39
+ self,
40
+ bad_indices: "ArrayLike",
41
+ distances: "ArrayLike",
42
+ max_allowed_distance: float,
43
+ ) -> None:
44
+ self.bad_indices = np.array(bad_indices, dtype=int)
45
+ self.bad_distances = np.asarray(distances, dtype=float)[self.bad_indices]
46
+ self.max_allowed_distance = max_allowed_distance
47
+ message = (
48
+ f"The shortest distances {self.bad_distances} between points at indices "
49
+ f"{self.bad_indices} and the trajectory are greater than "
50
+ f"{max_allowed_distance:g} meters."
51
+ )
52
+ super().__init__(message)
53
+
54
+
28
55
  class ExtrapolationError(ValueError):
29
56
  pass
30
57
 
@@ -27,6 +27,7 @@ from .util import (
27
27
  )
28
28
  from . import (
29
29
  SnappingError,
30
+ BadShortestDistances,
30
31
  ExtrapolationError,
31
32
  EPSG4326,
32
33
  EPSG4978,
@@ -443,12 +444,14 @@ class TrajectoryTrip(XYZDMixin):
443
444
  See `SnappingParams` for an explanation how the snapping is done and how it can
444
445
  be controlled.
445
446
  """
446
- max_shortest_distance = self.projected_points.cartesian_distances.max()
447
- if max_shortest_distance > params.max_shortest_distance:
448
- raise SnappingError(
449
- "at least one shortest distance between a point and the trajectory is "
450
- f"greater than {params.max_shortest_distance:g} meters "
451
- f"(maximum is {max_shortest_distance:g} meters)",
447
+ bad_indices = np.nonzero(
448
+ self.projected_points.cartesian_distances > params.max_shortest_distance
449
+ )[0]
450
+ if bad_indices.size:
451
+ raise BadShortestDistances(
452
+ bad_indices,
453
+ self.projected_points.cartesian_distances,
454
+ params.max_shortest_distance,
452
455
  )
453
456
  fallback = False
454
457
  reverse_order_allowed = params.reverse_order_allowed and bool(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pysnapping
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: Snap points to a line string keeping a given order or spacing intact
5
5
  Author-email: Alexander Held | geOps <alexander.held@geops.com>
6
6
  Maintainer-email: Alexander Held | geOps <alexander.held@geops.com>
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes