Giter Club home page Giter Club logo

datapoint-js's Introduction

DataPoint for JavaScript Build Status

A JavaScript library for accessing weather data via the Met Office's open data API known as DataPoint.

Disclaimer: This module is in no way part of the DataPoint project/service. This module is intended to simplify the use of DataPoint for JavaScript projects. No support for this module is provided by the Met Office and may break as the DataPoint service grows/evolves. The author will make reasonable efforts to keep it up to date and fully featured.

Features

  • List forecast/observation sites
  • Get nearest forecast/observation site from longitude and latitiude
  • Get the following 5 day forecast types for any site
  • Daily (Two timesteps, midday and midnight UTC)
  • 3 hourly (Eight timesteps, every 3 hours starting at midnight UTC)
  • Get hourly observations for the last 48 hours
  • Get regional forecasts for the next 30 days (Grouped in four timesteps)

Installation

NodeJS

npm install datapoint-js

Manual

Download the contents /src (for node) and include them in your project.

Example Usage

Node

var datapoint = require('datapoint-js')

datapoint.set_key("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")

site = datapoint.get_nearest_forecast_site(-0.124626, 51.500728)

forecast = datapoint.get_forecast_for_site(site.id, "3hourly")

current_timestep = forecast.days[0].timesteps[0]

console.log("Temperature is " + current_timestep.temperature.value + "°" + current_timestep.temperature.units + " in " + site.name)

Output

Temperature is 15°C in London

Contributing changes

Please feel free to submit issues and pull requests.

To work on the project simply clone the project and run npm install.

This project uses gulp as its task runner and can be used to browserify the code and generate the documentation.

Documentation

Documentation can be automatically generated using JSDoc by running gulp document.

License

GPL v3

datapoint-js's People

Contributors

crammers avatar jacobtomlinson avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

rossburton

datapoint-js's Issues

Cinema

It's raining, here are the cinema listings.

Bug in example

var obs_site = datapoint.get_nearest_obs_site(lon, lat)
var forecast_site = datapoint.get_nearest_obs_site(lon, lat)

I think you meant get_nearest_forecast_site in the second line.

Requirements

High level requirements:

  • Works in the browser
  • Works in node
  • Has minimal dependancies (if any)
  • Install with Bower (moved to #4)
  • Install with npm (moved to #3)

Features:

  • Get all sites
  • Get nearest site
  • Get forecast for site (3hourly and daily)
  • Text forecast element

Synchronous requests

Browser shows warning

Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/.

Obs for multiple IDs

Datapoint API allows "all" and comma separated list of IDs. Maybe add this functionality to get_obs_for_site.

Or catch the resulting error. i.e.

TypeError: Cannot read property 'length' of undefined
at Object.module.exports.clean_days (/Users/mike/Documents/openshift/nodejs/node_modules/datapoint-js/src/obs.js:30:33)
at Object.module.exports.get_obs_for_site (/Users/mike/Documents/openshift/nodejs/node_modules/datapoint-js/src/obs.js:21:27)
at Object.module.exports.get_obs_for_site (/Users/mike/Documents/openshift/nodejs/node_modules/datapoint-js/src/datapoint.js:73:16)

Documentation

Add docstrings and generate documentation from them.

Change API base url

You may not always want to access DataPoint directly. In some cases you may want to put your own cache in front to avoid hammering the API.

It needs to be possible to override the baseurl with a custom one to point it at your own cache.

Install with npm

The repository has been initialised with a package.json but ti needs to be deployed to npm.

"name" as name for "$" variable

If I was going to pick a descriptive name for the obs timestep value '$' I'd probably go with "minutes". "name" looks like a mistake.

Is bower necessary?

Having a /dist directory which has to be updated manually using gulp build and then be committed to the repo is unpleasant.

Ideally all deployments would be done by Travis when a release is tagged.

As bower doesn't work this way then maybe it should be dropped and npm used exclusively.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.