Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 11 additions & 0 deletions example.py
Original file line number Diff line number Diff line change
@@ -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))
5 changes: 4 additions & 1 deletion ntripbrowser/ntripbrowser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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