Added the maps-module to the iwmlib.
Migrated a ot of the content from the tuesch to the iwmlib. This is before the decoupeling of the layers.
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import Projection from './projection.js'
|
||||
|
||||
/**
|
||||
* This is a projection file, that grants access to the
|
||||
* MERCATOR projection.
|
||||
*
|
||||
* Regulary only few Projections will be used in one
|
||||
* project, therefore only required one's should be
|
||||
* loaded.
|
||||
*/
|
||||
|
||||
export default class Mercator extends Projection {
|
||||
forward(coords) {
|
||||
let lat = coords.x
|
||||
let lng = coords.y
|
||||
|
||||
const PI_180 = Math.PI / 180.0
|
||||
const PI_4 = Math.PI * 4
|
||||
|
||||
const sinLatitude = Math.sin(lat * PI_180)
|
||||
let y = 0.5 - Math.log((1 + sinLatitude) / (1 - sinLatitude)) / PI_4
|
||||
let x = (lng + 180) / 360
|
||||
|
||||
y = y < 0 ? 0 : y > 1 ? 1 : y
|
||||
|
||||
return new PIXI.Point(x, y)
|
||||
}
|
||||
|
||||
backward(point) {
|
||||
let lng = point.x * 360 - 180
|
||||
let lat = (Math.asin(-2 / (Math.exp(4 * Math.PI * (0.5 - point.y)) + 1) + 1) * 180) / Math.PI
|
||||
|
||||
return new PIXI.Point(lat, lng)
|
||||
}
|
||||
|
||||
toString() {
|
||||
return 'Mercator Projection'
|
||||
}
|
||||
|
||||
get maxViewport() {
|
||||
return { min: new PIXI.Point(-85, -180), max: new PIXI.Point(85, 180) }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user