weather-builder
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

weather-builder

This is a module for building images from NWS data.

  • It uses pureimage as an alternative to canvas. Its slower but no native dependencies.

Use stand alone. This creates image.jpg file in the current directory

$ npm install --save weather-builder

The following snippet shows how to use it:

import fs from 'fs';
import { WeatherImage } from 'weather-builder';

// module requires a logger that can be part of a bigger package
// This uses the minimal set of methods to work using just the console.
const logger = {};
logger.info = (...args) => {console.log(...args)};
logger.verbose = (...args) => {console.debug(...args)};
logger.warn = (...args) => {console.warn(...args)};
logger.error = (...args) => {console.error(...args)};

run() {
    const weatherConfig: any = {
        name: "Onset",
        lat: "41.75",
        lon: "-70.644",
        title: "Forecast for Onset, MA",
        days: 5
    }
    
    const weatherImage = new WeatherImage(logger);

    const result = await weatherImage.getImageStream(weatherConfig);

    if (result !== null && result.jpegImg !== null ) {
        fs.writeFileSync('image.jpg', result.jpegImg.data);
    } else {
        logger.error("No jpegImg returned from weatherImage.getImageStream")
    }
}

run();

Readme

Keywords

none

Package Sidebar

Install

npm i weather-builder

Weekly Downloads

3

Version

1.1.0

License

ISC

Unpacked Size

372 kB

Total Files

29

Last publish

Collaborators

  • kfaubel