This library provides a convinient way to make requests to EDR Servers
This library has not reached 1.0 and is under active development. If you have a question or request, please create an issue.
Creating a new Client
let cli = await new EdrClient().create(
"https://ogc-edr-api.murithigeo.deno.net/",
);Load the conformance classes implemented by server
// The Client will auto prefer HTTP POST support if it finds the class http://www.opengis.net/spec/ogcapi-edr-1/1.1/conf/queries in the list
let confClasses = await cli.conformance();Load the OpenAPI document powering the server
let openapi = await cli["service-desc"]();let Loading all collections
let collections = await cli.collections();Find the collection you want
let collection = collections.find((e) => e.id === "mountains");Loading a specific collection without link object trasversal
let collection = await new CollectionQuery().create(
"https://ogc-edr-api.murithigeo.deno.net/collections/mountains",
);
// An instance can also be loaded the same way
let instance = await new CollectionQuery().create(
"https://ogc-edr-api.murithigeo.deno.net/collections/mountains/",
);Load all items using certain criteria
let query = collection
.items()
.where(...args)
.execute();Query specific itemId
let item = query
.queryItem("Mt Kenya")
.where(...args)
.execute();Load all locations (This expects the endpoint /locations to return a GeoJSON FeatureCollection)
let locations = collection
.locations()
.where(...args)
.execute();Query specific locations
let res = await locations
.queryLocations()
?.where(...args)
.execute();Query trajectory
let res = await collection
?.trajectory()
.where("coords", "LINESTRING(30 2, 40 3)")
.where(...args)
.execute();Making Requests
Most query types have a method execute which returns an HTTP Response object. It does not parse the response
Exceptions are the /locations and /items endpoint which parse the response due to certain expectations
The where method can be chained with each successive value overwriting a previously set value if any
query.where("bbox", [20, 1, 3, 4]).where("datetime", "eq", "2021");As mentioned in the conformance section, POST requests will be preferred via checking for the presence of a confClass. However, this can be overriden via calling
query.where("method", "POST");
// or
query.where("method", "GET");For each data_query, you can restrict the spatiotemporal bounds of the response using the method where
Return data whose temporal field value lies between two dates
query.where("datetime", "between", [
"2000-01-01T00:00:00Z",
"2026-03-24T23:59:99Z",
]);Return data whose temporal value is later than the input
query.where("datetime", "gte", "2000-01-01T00:00:000Z");Return data whose temporal is earlier than the input
query.where("datetime", "lte", "2026-03-23T00:00:00Z");These two methods are equivalent
query
.where("datetime", "gte", "2001-01-01")
.where("datetime", "lte", "2026-03-24");
// Is the same as
query.where("datetime", "between", ["2001-01-01", "2026-03-24"]);Return data whose temporal value is equivalent to input
query.where("datetime", "eq", "2000-01-01");Return data whose elevation field lies between a range
query.where("z", "between", [0, 100]);Return data whose elevation is in a list of heights
query.where("z", "in", [-10, -20]);Filter data using a arithmetic sequence
// The starting point
let min = 10,
// Number of intervals
num = 3,
//Size between intervals
step = 10;
query.where("z", "interval", {
min,
num,
step,
});Get data for single value
query.where("z", "=", 1000);Note: Each successive call of the where("z",...args) will overwrite the z param value
The standard specifies that if no parameter-name value is defined, then data incorporating all parameters is returned. Therefore, you can skip invoking query.where("parameter-name",...args) if you want all of them
Request specific parameters
query.where("parameter-name", "in", ["temperature", "cloudBase"]);Request all parameters except those specified
query.where("parameter-name", "not in", ["depth", "pressure"]);query.where("f", "GeoJSON");For query_type's supporting bbox
// Use a Bounding Box
query.where("bbox",[33, -4, 41, 5])
// Use a GeoJSON Feature, FeatureCollection, Geometry
// Internally calls @turf/bbox to get the Bounding Box
query.where("bbox",{type:"Point",coordinates:[...]})query_type: corridor,trajectory,position,radius, area
There are two ways to go about it
// Use a Well Known Text Representation of Geometry
// string converted to Geometry via betterknown
query.where("coords", "POINT(36 1)");
// Use a GeoJSON Geometry Object
query.where("coords", { type: "Point", coordinates: [36, 1] });Each query type has specific allowed GeoJSON Geometry Types and which improve intellisense
// Position
query.where("coords", "POINT(...)"); // Correct
query.where("coords", "LINESTRING(...)"); // Throws ErrorFor the area query type, you can also specify sampling intervals via the resolution-[x|y]
query.where("resolution-x", 10).where("resolution-y", 20);The corridor query type additionally allows the z-axis sampling
query.where("resolution-z", 20);Corridor-Height and Height-Units
query.where("corridor-height", 20000, "feet");corridor-width and width-units
query.where("corridor-width", 1000, "meters");within and within-units
query.where("within", 1000, "meters");