Open Data Portals
CDT can connect to external open data portals and display their datasets as vector layers in the map viewer. Portals are registered in the platform's database, and the frontend fetches and renders datasets directly from the external APIs.
Overview
An OpenDataPortal record stores the connection details for a single portal (name, API URL, data management system type, geographic scope). When a user browses datasets in the map viewer, CDT queries the relevant portals based on the current map location and presents datasets as toggleable layers.
How It Works in CDT
Portal registry
Portals are stored in the database and exposed via the hooks in @collabdt/core/hooks/openDataPortals/. The map viewer queries portals filtered by municipality and country subdivision (ISO 3166-2 code) to surface the most relevant datasets for the visible area.
const { openDataPortals } = useOpenDataPortalsByMunicipalityAndCountrySubdivision(
currentMunicipality,
currentCountrySubdivision
)
Dataset adapters
Each DataManagementSystem has a corresponding adapter that knows how to fetch and normalise data from that system's API:
| System | Value | Adapter |
|---|---|---|
| CKAN | Ckan | ckanDatasets |
| ArcGIS | Arcgis | arcGISDatasets |
| Opendatasoft | Opendatasoft | opendatasoftDatasets |
| Local | — | localDatasets |
| Socrata | Socrata |
The adapters normalise external API responses into a common Dataset type with getFeatures() and getFields() methods. The map viewer calls these to build a GeoJSON Source and render a Layer.
Groups
Portals are tagged with a DatasetGroup:
| Group | Meaning |
|---|---|
Organizational | CDT organization's own hosted datasets |
Municipal | City/municipality-level portals |
Provincial | Province- or territory-level portals (a portal's countrySubdivision) |
National | National/federal portals |
Key Files
| File | Role |
|---|---|
@collabdt/core/hooks/openDataPortals/openDataPortals.ts | Hook exports |
@collabdt/core/hooks/openDataPortals/createOpenDataPortalHooks.ts | SWR hook implementations |
@collabdt/core/types/dbTypes.ts | OpenDataPortal, DatasetGroup, DataManagementSystem types |
@collabdt/core/components/viewers/map/src/MapLayers/src/OpenDataLayers/ | Map layer that renders portal datasets |
Gotchas
- Portal
apiUrlandportalUrlare optional — some portals in the registry may not have API access configured, which will cause dataset fetches to fail silently. - External API rate limits and CORS policies apply. CDT fetches dataset data client-side, so the user's browser must be able to reach the external portal API directly.
countrySubdivisionuses ISO 3166-2 format (e.g.,CA-ON,US-NY). Mismatched formats will cause portal lookup by subdivision to return empty results.