bte-projection
TypeScript icon, indicating that this package has built-in type declarations

1.3.2 • Public • Published

bte-projection

A javascript/typescript package that is a re-written version of T++ mod's projection files.

How to use

javascript:

const { BTE_PROJECTION } = require('bte-projection')

let coordinate = { lat: 40.74843814459844, lon: -73.98566440289457 };

let converted = BTE_PROJECTION.fromGeo(coordinate);
console.log(`In-game X coordinate: ${converted.x}`);
console.log(`In-game Z coordinate: ${converted.y}`);

let distortion = BTE_PROJECTION.getDistortion(coordinate);
console.log(`Distortion amount: ${distortion.value}`);

typescript:

import { BTE_PROJECTION, XYCoord, GeoCoord } from 'bte-projection'

let coordinate: XYCoord = { x: -8525873.069135161, y: -6026164.9710848285 };
let converted: GeoCoord = BTE_PROJECTION.toGeo(coordinate);

console.log(`Latitude: ${converted.lat}`);
console.log(`Longitude: ${converted.lon}`);

Projection JSON:

import { GeographicProjection, fromProjectionJSON } from 'bte-projection'

const projection: GeographicProjection = fromProjectionJSON({
    scale: {
        delegate: {
            flip_vertical: {
                delegate: {
                    bte_conformal_dymaxion: {}
                }
            }
        },
        x: 7318261.522857145,
        y: 7318261.522857145
    }
});

let converted = projection.toGeo({ x: -8525873.069135161, y: -6026164.9710848285 });
console.log(`Latitude: ${converted.lat}`);
console.log(`Longitude: ${converted.lon}`);

Custom projection:

import { SinusoidalProjection, SwapAxesProjectionTransform, fromProjectionJSON } from 'bte-projection'

// Both projection1 and projection2 here are the same
const projection1 = new SwapAxesProjectionTransform({
    delegate: new SinusoidalProjection()
});
const projection2 = fromProjectionJSON('"swap_axes": {"delegate": {"sinusoidal": {}}}');

Package Sidebar

Install

npm i bte-projection

Weekly Downloads

0

Version

1.3.2

License

MIT

Unpacked Size

1.89 MB

Total Files

48

Last publish

Collaborators

  • m4ndeokyi