Skip to content

Commit

Permalink
add support for "filter":"all"
Browse files Browse the repository at this point in the history
  • Loading branch information
javier-jimenez-shaw-pix4d committed Jan 14, 2025
1 parent d729261 commit dbd9262
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 47 deletions.
11 changes: 1 addition & 10 deletions data/World/America/USA/fprn.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,7 @@
"last_update": "2024-12-09",
"streams": [
{
"filter": {
"lat_lon_bboxes": [
[
167.65,
14.92,
-63.88,
74.71
]
]
},
"filter": "all",
"crss": [
{
"id": "EPSG:6319",
Expand Down
73 changes: 63 additions & 10 deletions dist/ntrip-catalog.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,45 @@
"release": 0,
"comment": "This file has been automatically generated by a script. Update the 'data' folder if any change is needed.",
"entries": [
{
"name": "AUSCORS",
"description": "Geoscience Australia AUSCORS NTRIP Broadcaster",
"urls": [
"https://ntrip.data.gnss.ga.gov.au:443",
"http://ntrip.data.gnss.ga.gov.au:2101"
],
"reference": {
"url": "https://gnss.ga.gov.au/stream",
"comments": "Also provides base stations outside of Australia"
},
"last_update": "2025-01-13",
"streams": [
{
"filter": {
"countries": [
"AUS"
]
},
"crss": [
{
"id": "EPSG:7843",
"name": "GDA2020"
}
],
"comments": "Broadcast Coordinates: Stations within Australia - GDA2020"
},
{
"filter": "all",
"crss": [
{
"id": "EPSG:9989",
"name": "ITRF2020"
}
],
"comments": "Broadcast Coordinates: Station outside of Australia - ITRF2020"
}
]
},
{
"name": "FPRN",
"description": "Florida Primary Reference Network",
Expand All @@ -16,16 +55,7 @@
"last_update": "2024-12-09",
"streams": [
{
"filter": {
"lat_lon_bboxes": [
[
167.65,
14.92,
-63.88,
74.71
]
]
},
"filter": "all",
"crss": [
{
"id": "EPSG:6319",
Expand Down Expand Up @@ -146,6 +176,29 @@
}
]
},
{
"name": "SPSLUX",
"description": "Satellite Positioning System Luxembourg",
"urls": [
"http://stream.spslux.lu:5005"
],
"reference": {
"url": "https://act.public.lu/fr/gps-reseaux/spslux1/spsluxgeodeticdatum.html"
},
"last_update": "2025-01-13",
"streams": [
{
"filter": "all",
"crss": [
{
"id": "EPSG:7931",
"name": "ETRF2000",
"epoch": 2020.82
}
]
}
]
},
{
"name": "Topnet Live Europe",
"description": "Topcon NTRIP service in Europe",
Expand Down
15 changes: 12 additions & 3 deletions schemas/v0.1/entries.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
"description": "Item to match a stream from the sourcetable with a CRS.",
"properties": {
"filter": {
"type": "object",
"description": "Criterion to filter in the sourcetable",
"oneOf": [
{
Expand All @@ -63,6 +62,13 @@
},
{
"$ref": "#/$defs/countries_def"
},
{
"type": "string",
"enum": [
"all"
],
"description": "Matches all the streams. Use with caution."
}
]
},
Expand Down Expand Up @@ -168,6 +174,9 @@
},
"description": "Bounding box, in degrees, with the order: West, South, East, North."
},
"all_def": {
"type": "string"
},
"mountpoints_def": {
"type": "object",
"properties": {
Expand All @@ -177,7 +186,7 @@
"items": {
"type": "string"
},
"description": "Matches the 'Mountpoint' field in the Stream",
"description": "Matches the 'Mountpoint' field in the stream",
"additionalProperties": false
}
},
Expand Down Expand Up @@ -211,7 +220,7 @@
"items": {
"type": "string"
},
"description": "Matches the 'Country Code' field in the Stream"
"description": "Matches the 'Country Code' field in the stream"
}
},
"required": [
Expand Down
51 changes: 27 additions & 24 deletions scripts/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,32 @@ def point_in_bbox(point_lat, point_lon, bbox):
return point_lon >= bbox[0] and point_lon <= bbox[2]


def _crss_from_stream(stream, mountpoint, url, server_streams):
crss = stream["crss"]
stream_filter = stream["filter"]
if stream_filter == "all":
return crss
elif "mountpoints" in stream_filter:
if mountpoint in stream_filter["mountpoints"]:
return crss
else:
if not server_streams:
server_streams += get_streams_from_server(url)
line = get_str_line_from_server(server_streams, mountpoint)
if not line or len(line) < 10:
return None
country = line[8]
base_lat = float(line[9])
base_lon = normalize_lon(float(line[10]))

if country in stream_filter.get("countries", []):
return crss

for bbox in stream_filter.get("lat_lon_bboxes", []):
if point_in_bbox(base_lat, base_lon, bbox):
return crss


def filter_crs(
json_entry,
url,
Expand All @@ -107,33 +133,10 @@ def filter_by_rover(crss):
return crs
return None

def crss_from_stream(stream, server_streams):
crss = stream["crss"]
stream_filter = stream["filter"]
if "mountpoints" in stream_filter:
if mountpoint in stream_filter["mountpoints"]:
return crss
else:
if not server_streams:
server_streams += get_streams_from_server(url)
line = get_str_line_from_server(server_streams, mountpoint)
if not line or len(line) < 10:
return None
country = line[8]
base_lat = float(line[9])
base_lon = normalize_lon(float(line[10]))

if country in stream_filter.get("countries", []):
return crss

for bbox in stream_filter.get("lat_lon_bboxes", []):
if point_in_bbox(base_lat, base_lon, bbox):
return crss

server_streams = [*sourcetable_lines_splitted] if sourcetable_lines_splitted else []

for stream in json_entry["streams"]:
crss = crss_from_stream(stream, server_streams)
crss = _crss_from_stream(stream, mountpoint, url, server_streams)
if crss:
crs = filter_by_rover(crss)
if crs:
Expand Down

0 comments on commit dbd9262

Please sign in to comment.