thegreenwebfoundation / grid-aware-websites

A library to enable developers to implement grid awareness in their websites
Other
8 stars 0 forks source link

Support latitude and longitude as inputs #4

Open fershad opened 4 days ago

fershad commented 4 days ago

The Electricity Maps API allows us to pass either a zone or lat and lon values when querying for power breakdown or grid intensity. Currently the gridAwarePower and gridAwareCO2e functions only use the zone (Alpha 2 ISO country code).

Desired state

It should be possible to pass in either the zone or lat and lon values into either of the functions.

The likeliest easy solution would be to accept these values in an options object passed into each function. An alternate approach would be to have a config step where the user defines which location type (zone/lat + lon) they want to use.

fershad commented 3 days ago

One way this might work is if the zone could be either a string or an object.

In the case it is an object, we could then check for the lat and lon keys inside. In the case it is a string, the current functionality would prevail.