3 Commits

Author SHA1 Message Date
Felix Spöttel
3cc3c30e03 Bump version to v0.2.1 for release 2022-07-01 18:52:00 +02:00
Felix Spöttel
c9d36c6bf3 feat: print success output 2022-07-01 18:51:25 +02:00
Felix Spöttel
62da0806c7 fix: debug prints 2022-07-01 18:48:17 +02:00
2 changed files with 8 additions and 10 deletions

View File

@@ -8,10 +8,6 @@ import geoclustering.encoding as encoding
import geoclustering.io as io
def print_debug(s):
click.secho(s, fg="bright_black")
@click.command(
help="Tool to cluster geolocations. A cluster is created when a certain number of points (--size) each are within a given distance (--distance) of at least one other point in the cluster. Input is supplied as a csv file. At a minimum, each row needs to have a 'lat' and a 'lon' column. Other rows are reflected to the output."
)
@@ -54,19 +50,19 @@ def print_debug(s):
@click.option("--debug", is_flag=True, help="Print debug output.")
@click.argument("filename", type=click.Path(exists=True))
def main(distance, size, output, filename, algorithm, open, debug):
if debug:
print_debug(f"Reading input from {Path(filename).absolute()}")
def print_debug(s):
if debug:
click.secho(s, fg="bright_black")
df = io.read_csv_file(filename)
if debug:
print_debug(f"Read {len(df)} valid coordinates")
print_debug(f"Read {len(df)} valid coordinates from {Path(filename).absolute()}")
clusters = clustering.cluster_locations(
df=df, algorithm=algorithm, radius_km=distance, min_cluster_size=size
)
if not bool(clusters):
click.echo("Did not find clusters matching input parameters.")
click.secho("Did not find clusters matching input parameters.", fg="yellow")
return
print_debug(f"Found {len(clusters)} valid clusters using {algorithm}")
@@ -83,6 +79,8 @@ def main(distance, size, output, filename, algorithm, open, debug):
print_debug(f"Opening visualization in default browser")
webbrowser.open_new_tab("file://" + str(vis.absolute()))
click.secho("Clustering completed.", fg="green")
if __name__ == "__main__":
main()

View File

@@ -2,7 +2,7 @@ _MAJOR = "0"
_MINOR = "2"
# On main and in a nightly release the patch should be one ahead of the last
# released build.
_PATCH = "0"
_PATCH = "1"
# This is mainly for nightly builds which have the suffix ".dev$DATE". See
# https://semver.org/#is-v123-a-semantic-version for the semantics.
_SUFFIX = ""