GithubHelp home page GithubHelp logo

alexander-travov / synop_canvas Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 2.0 1.54 MB

Draw SYNOP messages on HTML canvas.

HTML 3.66% JavaScript 96.34%
synop canvas javascript meteorology weather-map wmo openlayers

synop_canvas's Introduction

synop_canvas

SYNOP example

Draw SYNOP messages on HTML canvas.

Tilemaps from https://github.com/alexander-travov/synop_tilemap

OpenLayers integration

var ImageCanvasSource = ol.source.ImageCanvas
var fromLonLat = ol.proj.fromLonLat
var containsCoordinate = ol.extent.containsCoordinate

var synops = [...] // SYNOPs array

var canvas = document.createElement('canvas')

var synopSource = new ImageCanvasSource({
    canvasFunction: function draw (extent, resolution, pixelRatio, size, projection) {
        size[0] = Math.ceil(size[0])
        size[1] = Math.ceil(size[1])
        canvas.width = size[0]
        canvas.height = size[1]
    
        var minx = extent[0], miny = extent[1], maxx = extent[2], maxy = extent[3]
        var width = maxx - minx, height = maxy - miny
        var ctx = canvas.getContext('2d')
    
        for (var i = 0; i < synops.length; i++) {
            var synop = synops[i]
            var coord = fromLonLat([synop.lon, synop.lat], projection)
            if (!containsCoordinate(extent, coord)) continue
            var x = size[0] * (coord[0] - extent[0]) / (extent[2] - extent[0])
            var y = size[1] * (1 - (coord[1] - extent[1]) / (extent[3] - extent[1]))
            drawSynop(ctx, x, y, synop)
        }
        return canvas
    }
})

meteorad screenshot

synop_canvas's People

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

nourou6 mostamndi

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.