as-geo-web-coordinate
v0.8.0
Published
A small library to handle Geo Web Coordinates
Downloads
19
Readme
as-geo-web-coordinate
An AssemblyScript implementation of converting GeoWebCoordinate
to GPS coordinates. See the spec.
Install
npm install as-geo-web-coordinate
Usage
Convert GPS -> Geo Web Coordinate
import * as GeoWebCoordinate from "as-geo-web-coordinate";
const lon = 110.0;
const lat = 38.0;
const maxLat = (1 << 22) - 1;
const gwCoord: u64 = GeoWebCoordinate.from_gps(lon, lat, maxLat);
Convert Geo Web Coordinate -> GPS Bounding Box
import * as GeoWebCoordinate from "as-geo-web-coordinate";
const maxLat = (1 << 22) - 1;
const maxLon = (1 << 23) - 1;
const gpsCoords = GeoWebCoordinate.to_gps(gwCoord, maxLat, maxLon);
const bl_x = gpsCoords[0][0];
const bl_y = gpsCoords[0][1];
const br_x = gpsCoords[1][0];
const br_y = gpsCoords[1][1];
const tr_x = gpsCoords[2][0];
const tr_y = gpsCoords[2][1];
const tl_x = gpsCoords[3][0];
const tl_y = gpsCoords[3][1];
Tests
See tests for more usage.
npm test