UNPKG

@ciag/sentinel-hub-wms

Version:

a API to create the sentinel ogs requests, and tools to apply on the data

52 lines 1.82 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); // top-left reference point class LagLngXY { constructor(pMinLat, pMinLng, pMaxLat, pMaxLng) { this.pMin = { lat: null, lng: null, perX: null, perY: null, pos: null, scrX: 0, scrY: 0, }; // bottom-right reference point this.pMax = { lat: null, lng: null, perX: null, perY: null, pos: null, scrX: 1024, scrY: 780, }; this.radius = 6.371; this.pMax.lat = pMaxLat; this.pMax.lng = pMaxLng; this.pMin.lat = pMinLat; this.pMin.lng = pMinLng; this.pMin.pos = this.latlngToGlobalXY(this.pMin.lat, this.pMin.lng); this.pMax.pos = this.latlngToGlobalXY(this.pMax.lat, this.pMax.lng); } latlngToGlobalXY(lat, lng) { let x = this.radius * lng * Math.cos((this.pMin.lat + this.pMax.lat) / 2); let y = this.radius * lat; return { x: x, y: y }; } latlngToScreenXY(lat, lng) { let pos = this.latlngToGlobalXY(lat, lng); pos["perX"] = ((pos.x - this.pMin.pos.x) / (this.pMax.pos.x - this.pMin.pos.x)); pos["perY"] = ((pos.y - this.pMin.pos.y) / (this.pMax.pos.y - this.pMin.pos.y)); return { x: ((this.pMin.scrX + (this.pMax.scrX - this.pMin.scrX) * pos["perX"]) - this.pMax.scrX) * -1, y: this.pMin.scrY + (this.pMax.scrY - this.pMin.scrY) * pos["perY"] }; } getBobxConnors() { return [[this.pMin.lat, this.pMin.lng], [this.pMax.lat, this.pMax.lng]]; } } exports.LagLngXY = LagLngXY; //# sourceMappingURL=LagLngXY.js.map