diff --git a/README.md b/README.md index e7db1ba..640ff9d 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ browser.get_mountpoints() > Form of coordiantes must be `(x, y)` or `(x.x, y.y)` of latitude, longitude. - `maxdist` -> Use `maxdist` to only report stations less than this number of km away from given coordinate. +> Use `maxdist` to only report stations less than this number of km away from given coordinate. Stations lacking coordinates will not be returned. #### Result diff --git a/example.py b/example.py new file mode 100644 index 0000000..81005f1 --- /dev/null +++ b/example.py @@ -0,0 +1,11 @@ +from ntripbrowser import NtripBrowser +import json + +host = "rtk2go.com" +coordinates = (47.1291, 15.2119) +maxdist = 50 #km + +browser = NtripBrowser(host, port=2101, timeout=15, +coordinates=coordinates, maxdist=maxdist) +mp = browser.get_mountpoints() +print(json.dumps(mp, indent=4)) diff --git a/ntripbrowser/ntripbrowser.py b/ntripbrowser/ntripbrowser.py index 36ed263..a5f902b 100644 --- a/ntripbrowser/ntripbrowser.py +++ b/ntripbrowser/ntripbrowser.py @@ -309,7 +309,10 @@ def _trim_outlying(self, ntrip_dictionary): def _trim_outlying_casters(self, ntrip_type_dictionary): def by_distance(row): - return row['Distance'] < self.maxdist + try: + return row['Distance'] < self.maxdist + except Exception: + return False inlying_casters = list(filter(by_distance, ntrip_type_dictionary)) inlying_casters.sort(key=lambda row: row['Distance']) return inlying_casters