Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wizyma/lnglattolocalecartesian
Convert coordinates to locale cartesian to use with webgl or others
https://github.com/wizyma/lnglattolocalecartesian
Last synced: about 2 months ago
JSON representation
Convert coordinates to locale cartesian to use with webgl or others
- Host: GitHub
- URL: https://github.com/wizyma/lnglattolocalecartesian
- Owner: Wizyma
- License: mit
- Created: 2021-05-30T08:10:36.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-06-09T07:56:59.000Z (over 3 years ago)
- Last Synced: 2024-10-28T16:03:12.807Z (about 2 months ago)
- Language: TypeScript
- Size: 106 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![](https://img.shields.io/npm/v/converter-locale-cartesian?style=for-the-badge)
# LngLatToLocaleCartesian
Convert coordinates to locale cartesian to use with webgl or others. This assume that you are using coordinates to draw polygons on a map (building or something else) and that you wish to use those points somewhere else (Three.js / D3, etc.)## Installation
```sh
# yarn
$ yarn add converter-locale-cartesian# npm
$ npm i converter-locale-cartesian
```## Usage
```js
const center = [15.434, 19.0933]
const geometry = [{
"lat": 22.31759647466327,
"lng": 113.93006706496337
},
{
"lat": 22.317262482317403,
"lng": 113.93019349413271
},
{
"lat": 22.317159427034767,
"lng": 113.93023250571464
},
{
"lat": 22.316962246238706,
"lng": 113.93030714497549
},]const lngLatToLocaleCartesian = LngLatToLocaleCartesian(center)
const points = geometry.map(({ lat, lng }) => {
const converted = lngLatToLocaleCartesian.converter(lng, lat);
return [converted.x, converted.y, converted.z]
}))
```