0.2.10 • Published 7 months ago

@mmit/latlong v0.2.10

Weekly downloads
463
License
MIT
Repository
github
Last release
7 months ago

LatLong - Lightweight library for common latitude and longitude calculation

Live-Example | GitHub-Home

This library supports both, the "Haversine" and the "Vincenty" algorithm.

"Haversine" is a bit faster but "Vincenty" is far more accurate!

Catmull-Rom algorithm is used for smoothing out the path.

Basic usage

Distance

    const distance = new Distance();
    
    // km = 423
    const km = distance.as(LengthUnit.Kilometer,
     new LatLng(52.518611,13.408056),new LatLng(51.519475,7.46694444));
    
    // meter = 422591.551
    const meter = distance.distance(
        new LatLng(52.518611,13.408056),
        new LatLng(51.519475,7.46694444)
        );

Offset

    const distance = new Distance();
    const distanceInMeter = Math.round(EARTH_RADIUS * Math.PI / 4));
    
    const p1 = new LatLng(0.0, 0.0);
    const p2 = distance.offset(p1, distanceInMeter, 180);
    
    // LatLng(latitude:-45.219848, longitude:0.0)
    console.log(p2.round());
    
    // 45° 13' 11.45" S, 0° 0' 0.00" O
    console.log(p2.toSexagesimal());
            

Path smoothing

    // zigzag is a list of coordinates
    const path = new Path.from(zigzag);
    
    // Result is below
    const steps = path.equalize(8,smoothPath: true);

For more - check out my tests

0.2.10

7 months ago

0.2.7

8 months ago

0.2.6

8 months ago

0.2.9

8 months ago

0.2.8

8 months ago

0.2.5

12 months ago

0.2.4

3 years ago

0.2.1

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago