Skip to content

Commit

Permalink
fix: check for duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
merydian committed Aug 9, 2024
1 parent d5ede0c commit c5774dd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ORStools/proc/directions_points_layer_proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,12 @@ def sort(f):

try:
if optimization_mode is not None:
# check for duplicate points
if len(points) != len(set(points)):
raise exceptions.DuplicateError(
"There are duplicate points in the input layer, which need to be removed."
)

params = get_params_optimize(points, profile, optimization_mode)
response = ors_client.request("/optimization", {}, post_json=params)

Expand Down
8 changes: 8 additions & 0 deletions ORStools/utils/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,11 @@ def __str__(self):
return self.status
else:
return f"{self.status} ({self.message})"


class DuplicateError(Exception):
def __init__(self, message=None):
self.message = message

def __str__(self):
return self.message

0 comments on commit c5774dd

Please sign in to comment.