LiveAtlas/src/leaflet/projection/DynmapProjection.ts

26 lines
627 B
TypeScript
Raw Normal View History

2020-12-12 22:04:56 +00:00
import {Util, LatLng, Class} from 'leaflet';
import {Coordinate} from "@/dynmap";
export interface DynmapProjectionOptions {}
export interface DynmapProjection {
2020-12-12 22:04:56 +00:00
locationToLatLng(location: Coordinate): LatLng;
latLngToLocation(latLng: LatLng, y: number): Coordinate;
}
2020-12-12 22:04:56 +00:00
export class DynmapProjection extends Class {
2020-12-01 23:20:38 +00:00
constructor(options?: DynmapProjectionOptions) {
super();
2020-12-12 22:04:56 +00:00
Util.setOptions(this, options);
}
2020-12-12 22:04:56 +00:00
locationToLatLng(location: Coordinate): LatLng {
return new LatLng(location.x, location.z);
}
2020-12-12 22:04:56 +00:00
latLngToLocation(latLng: LatLng, y: number): Coordinate {
2020-12-01 23:20:38 +00:00
return {x: latLng.lat, y, z: latLng.lng};
}
}