Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confused about different LatLon classes, should there be a combined API? #95

Open
JulianKingman opened this issue Feb 25, 2021 · 0 comments

Comments

@JulianKingman
Copy link

JulianKingman commented Feb 25, 2021

I'm trying to do multiple calculations, and am finding I want to use more than one LatLon class (ie the ones from 'geodesy/latlon-nvector-ellipsoidal.js' and 'geodesy/latlon-ellipsoidal-vincenty.js'). What's the best way to go about doing this?

import LatLonNVector from 'geodesy/latlon-nvector-ellipsoidal.js';
import LatLonVincenty from 'geodesy/latlon-ellipsoidal-vincenty.js'

// do I have to do this twice?
const point1a = new LatLonNVector(52.205, 0.119);
const point1b = new LatLonVincenty(52.205, 0.119);

const point2a = new LatLonNVector(30, 0.5)
const point2b = new LatLonVincenty(30, 0.5)

// Would this accept a Vincenty point? Why doesn't it just take coordinates?
const delta = point1a.deltaTo(point2a)

// I used the NVector one accidentally, will this work, or fail? Are the LatLon types different, or interchangeable?
const distance = point1b.distanceTo(point2a)

Is there a reason the scripts are organized as they are? It kind of seems like there should just be a set of different functions, instead of different LatLon classes, since they only take coordinates and height anyway...

For example it could be like this:

import {getDistance, getDelta} from 'geodesy/ellipsoidal'

// points are simply coordinates, optional height parameter
const point1 = [52.205, 0.119];
const point2 = [30, 0.5];

// functions operate on points
const distance = getDistance(point1, point2);
const delta = getDelta(point1, point2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant