class SphericalMercator

Defined in:

sphericalmercator.cr

Constant Summary

A = 6378137.0

900913 properties.

D2R = Math::PI / 180
DEFAULT_SIZE = 256.as(Int32)
MAXEXTENT = 20037508.342789244
R2D = 180 / Math::PI
VERSION = "0.1.0"

Constructors

Instance Method Summary

Constructor Detail

def self.new(size : Int32 = DEFAULT_SIZE) #

[View source]

Instance Method Detail

def bbox(x, y, zoom, tms_style = false, srs = "WGS84") #

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.
  • srs {String} projection for resulting bbox (WGS84|900913).
  • return {Array} bbox array of values in form [w, s, e, n].

[View source]
def convert(bbox, to = "WGS84") #

Convert projection of given bbox.

  • #bbox {Number} bbox in the form [w, s, e, n].
  • to {String} projection of output bbox (WGS84|900913). Input bbox assumed to be the "other" projection.
  • @return {Object} bbox with reprojected coordinates.

[View source]
def forward(ll) #

Convert lon/lat values to 900913 x/y.


[View source]
def inverse(xy) #

Convert 900913 x/y values to lon/lat.


[View source]
def ll(px, zoom) #

Convert screen pixel value to lon lat

  • #px {Array} [x, y] array of geographic coordinates.
  • zoom {Number} zoom level.

[View source]
def px(ll, zoom) #

[View source]
def xyz(bbox, zoom, tms_style = false, srs = "WGS84") #

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.
  • srs {String} projection of input bbox (WGS84|900913).
  • @return {Object} XYZ bounds containing minX, maxX, minY, maxY properties.

[View source]