Skip to content

Instantly share code, notes, and snippets.

@ChadiEM
Last active October 15, 2023 08:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChadiEM/688c9a1a135fcebbbb3332e9cd8e8c82 to your computer and use it in GitHub Desktop.
Save ChadiEM/688c9a1a135fcebbbb3332e9cd8e8c82 to your computer and use it in GitHub Desktop.
Airparif Map and Pollution Index in Paris & Ile de France

Preview

Preview

Installation

smashing install 688c9a1a135fcebbbb3332e9cd8e8c82

Usage

<li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
    <div data-id="airparif" data-view="Airparif" data-title="Airparif"></div>
</li>
class Dashing.Airparif extends Dashing.Widget
<h1 data-bind="title" data-showif="title"></h1>
<img data-bind-src="image" alt="Airparif"/>
<p class="updated-at" data-bind="updatedAtMessage"></p>
require 'open-uri'
url = 'https://magellan.airparif.asso.fr/geoserver/apisHorAir/wms?&service=WMS&request=GetMap&layers=apisHorAir%3Aindice_api&styles=indice&format=image%2Fpng8&transparent=true&version=1.3&tiled=true&authkey=7d2a2d15-2887-2d22-3754-bb93ac846ad6&width=1024&height=768&crs=EPSG%3A3857&bbox=160357,6126721,397357,6316721#1685873158'
SCHEDULER.every '5m', first_in: 0 do
image = nil
begin
URI.open(url) do |io|
image = io.read
end
rescue StandardError => e
puts("ERROR: Unable to download Airparif map: #{e}")
next
end
send_event('airparif',
image: "data:image/png;base64,#{Base64.encode64(image)}")
end
// ----------------------------------------------------------------------------
// Sass declarations
// ----------------------------------------------------------------------------
$background-color: #50A4AF;
// ----------------------------------------------------------------------------
// Widget-airparif styles
// ----------------------------------------------------------------------------
.widget-airparif {
background-color: $background-color;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment