Skip to content

Commit 51679de

Browse files
authored
add recipe for detecting data subscriptions from GDC (#10)
* add recipe for detecting data subscriptions from GDC * adoc, not markdown * fix ref * add note on link channels
1 parent d86e655 commit 51679de

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

cookbook/sections/data-consumers.adoc

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
=== Search the Global Discovery Catalogue
44

5-
The https://wmo-im.github.io/wis2-guide/guide/wis2-guide-DRAFT.html#_2_4_4_global_discovery_catalogue[Global Discovery Catalogue (GDC)] allows for a wide range of query predicates to search for data in WIS2 as per the OGC API - Records - Part 1: Core specification.
5+
The https://wmo-im.github.io/wis2-guide/guide/wis2-guide-APPROVED.html#_2_4_4_global_discovery_catalogue[Global Discovery Catalogue (GDC)] allows for a wide range of query predicates to search for data in WIS2 as per the OGC API - Records - Part 1: Core specification.
66

77
The GDC can be searched via the `/collections/wis2-discovery-metadata/items` endpoint. This endpoint provides a number query parameters as described in the examples below.
88

@@ -50,3 +50,48 @@ Note that the format of `bbox` is comma-separated values in the following order:
5050
- present search results 1-10: `limit=10`
5151
- present search results 11-20: `limit=10&offset=10`
5252
- limit to 3 search results: `limit=3`
53+
54+
=== Finding data subscription services from the Global Discovery Catalogue
55+
56+
The https://wmo-im.github.io/wis2-guide/guide/wis2-guide-DRAFT.html#_2_4_4_global_discovery_catalogue[Global Discovery Catalogue (GDC)] contains both real-time and non real-time data. The https://wmo-im.github.io/wcmp2/standard/wcmp2-STABLE.html[WMO Core Metadata Profile (WCMP2)] allows for description of real-time data via its https://wmo-im.github.io/wcmp2/standard/wcmp2-STABLE.html#_1_19_links_and_distribution_information[distribution information], which data publishers use to describe and define connectivity and subscription information for a given dataset.
57+
58+
A typical WCMP2 distribution link for data subscriptions can be found below:
59+
60+
[source,json]
61+
----
62+
{
63+
"rel": "items",
64+
"href": "mqtts://everyone:everyone@globalbroker.meteo.fr:8883",
65+
"channel": "origin/a/wis2/ca-eccc-msc/data/core/hydrology",
66+
"type": "application/geo+json",
67+
"title": "Data notifications"
68+
}
69+
----
70+
71+
[NOTE]
72+
====
73+
The `channel` property represents WIS2 topic which can be used to subscribe to the `href` property (i.e. the MQTT address) of the Global Broker (GB).
74+
====
75+
76+
Programatically, a GDC client can query the catalogue and filter the results for real-time subscriptions in the following manner:
77+
78+
[source,python]
79+
----
80+
import requests
81+
82+
response = requests.get('https://wis2-gdc.weather.gc.ca/collections/wis2-discovery-metadata/items').json()
83+
84+
85+
def is_wis2_subscription_link(link) -> bool:
86+
if (link['href'].startswith('mqtt') and
87+
link.get('channel', '').startswith(('origin/a/wis2', 'cache/a/wis2'))):
88+
return True
89+
90+
91+
for feature in response['features']:
92+
for link in feature['links']:
93+
if is_wis2_subscription_link(link):
94+
print('WIS2 subscription link')
95+
----
96+
97+
Using the `href` and `channel` properties of a matching link object, a client can connect and subscribe to data notifications for a given dataset.

0 commit comments

Comments
 (0)