windelsis
v1.5.1
Published
`Windelsis` is a JavaScript library that visualizes weather data on interactive maps using Leaflet. It provides tools to render temperature, precipitation, and wind velocity layers, as well as utilities for grid-based weather data management.
Maintainers
Readme
Windelsis 
Windelsis is a JavaScript library that visualizes weather data on interactive maps using Leaflet. It provides tools to render temperature, precipitation, and wind velocity layers, as well as utilities for grid-based weather data management.
Features
- Weather Layers: Visualize temperature, precipitation, and wind velocity on a map.
- Interactive Map: Built on Leaflet, allowing zooming, panning, and interaction with weather data.
- Customizable: Supports custom color scales, grid resolutions, and weather data sources.
- API Integration: Fetch weather data from APIs (like Open-Meteo in the demo).
Installation
To use Windelsis in your project, install windelsis, or you can build the library and include it in your application.
Build the Library
- Install dependencies:
npm install - Build the library
npm run build
npm install
npm install windelsisExample
Use Windelsis to create a map with weather layers:
const { MapManager } = Windelsis;
const mapManager = new MapManager(map, fetch_function, options);map
Can either be:
- A string: Represents the ID of the HTML element where the Leaflet map will be created.
- An instance of
L.Map: Pass an existing Leaflet map instance if the map is already created.
This flexibility allows you to let Windelsis handle map creation or integrate it with an existing Leaflet map setup.
fetch_function
This function retrieves weather data based on two parameters:
- Array of GridPoint objects: Each object includes
latitudeandlongitude. - Options object: Specifies the type of request (e.g., current weather, forecast).
It must return data in the same order as received. If fetch_function is null, the library defaults to openMeteoApiCaller from apiService.js, which fetches data from the Open-Meteo API without requiring an API key.
This flexible approach allows you to source weather data from any provider, such as a database or a meteorological API.
options
The options parameter is an object that configures the behavior of the MapManager instance. It supports the following properties:
center([latitude, longitude], required):- The initial geographical center of the map.
zoom(number, required):- The initial zoom level of the map.
randomData(boolean, optional):- If
true, the map will generate random weather data for testing purposes. - Default:
false.
- If
demoMode(boolean, optional):- If
true, enables demo mode with preconfigured settings for testing. - Default:
false.
- If
windyParameters(object, optional):- Configuration for the wind visualization layer.
- Properties:
maxVelocity(number): Maximum wind velocity for the visualization.velocityScale(number): Scale factor for wind velocity.particleAge(number): Lifespan of particles in frames.lineWidth(number): Width of the wind lines.particleMultiplier(number): Multiplier for the number of particles.frameRate(number): Frame rate for the animation.
maxBounds([[lat1, lng1], [lat2, lng2]], optional):- Defines the geographical bounds that restrict the map's view using two diagonally opposite corners of the rectangle.
- Default:
null(no bounds).
pointDistance(number, optional):- Specifies the minimum distance in ° between grid points for weather data. Will ignore maxGridPoints if set.
- Default:
null(if not set, windelsis calculates it based on maxGrindPoints and the limits of the map).
maxGridPoints(number, optional):- Sets the maximum number of grid points to be processed for weather data visualization.
- Default:
600.
Get Weather functions
mapManager.getCurrentData()
//for now can fetch just one date for forecast
mapManager.getForecastData(forecastDate, forecastDate)
mapManager.getHourlyForecast(forecastDate, forecastDate, forecastTime)Testing
Open the demo files in your browser. I use the Live Server extension in Visual Studio Code for a quick local server setup.
Reference
windelsis is possible because of things like:
License
This project is licensed under the MIT License.
