Code Monkey home page Code Monkey logo

node-sphericalmercator's Introduction

Build Status

node-sphericalmercator provides projection math for converting between mercator meters, screen pixels (of 256x256 or configurable-size tiles), and latitude/longitude.

Compatible with nodejs packages and in-browser.

API

Datatypes are assumed to be arrays: lon, lat is [lon, lat], and x, y is [x, y].

// By default, precomputes up to z30
var merc = new SphericalMercator({
    size: 256
});

px(ll, zoom)

Convert lat, lon to screen pixel x, y from 0, 0 origin, a certain zoom level. The inverse of ll

ll(px, zoom)

Convert screen pixel value to lon, lat, at a certain zoom level. The inverse of px

bbox(x, y, zoom, tms_style, srs)

Convert tile xyz value to bbox of the form [w, s, e, n]

  • x {Number} x (longitude) number.
  • y {Number} y (latitude) number.
  • zoom {Number} zoom.
  • tms_style {Boolean} whether to compute using tms-style. (optional, default false)
  • srs {String} projection for resulting bbox (WGS84|900913). (optional, default 4326)

Returns bbox array of values in form [w, s, e, n].

xyz(bbox, zoom, tms_style, srs)

Convert bbox to xyx bounds

  • bbox {Number} bbox in the form [w, s, e, n].
  • zoom {Number} zoom.
  • tms_style {Boolean} whether to compute using tms-style. (optional, default false)
  • srs {String} projection of input bbox (WGS84|900913). (optional, default 4326)

Returns {Object} XYZ bounds containing minX, maxX, minY, maxY properties.

forward(ll)

Convert lon, lat values to mercator x, y

inverse(xy)

Convert mercator x, y values to lon, lat

node-sphericalmercator's People

Contributors

kkaefer avatar rclark avatar tmcw avatar

Watchers

 avatar  avatar

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.