# Distance calculation?

Hi

i have played a little bit with DistanceCalculation.How can you reset the flag “is3D()” even though I have a 3d point list?

how can i do this with 3D Pointlist to compare the results?

double distance_xx=pointList.calcDistance(new DistanceCalcEarth());

double distance_xx=pointList.calcDistance(new DistancePlaneProjection());

double distance2D=pointList.calcDistance(new DistanceCalc2D());

double distance3D=pointList.calcDistance(new DistanceCalc3D());

public double calcDistance(DistanceCalc calc) {

for(int i = 0; i < this.size; ++i) {
if(i > 0) {
if(this.is3D) {
dist += distCalc3D.calcDist(prevLat, prevLon, prevEle, this.latitudes[i], this.longitudes[i], this.elevations[i]);
} else {
dist += calc.calcDist(prevLat, prevLon, this.latitudes[i], this.longitudes[i]);
}
}

Thanks
Achim

What do you mean? Do you stumbled over a potential bug or what do you want to achieve?

In your calcDistance(…) subroutine is the Flag “this.is3D” already true for a 3D Pointlist with elevation and i can not change the Calc Algo like pointList.calcDistance(new DistanceCalc2D());

I just for fun to compare the different distance calculations.

Or how can I calculate from a 3D Pointlist the different distances otherwise?

Why not enable and disable elevation and compare this?

mean you

hopper…setElevation(true) or hopper…setElevation(false)…that would be clear to me. But then i must create the Poinlist twice (2D and 3D).

but i have as standard setElevation(true) and have then 3D Poinlist with my elevation charts.

My question is how can i calculate the different distances from a 3D Pointlist (lat,long, ele).

If that not possible, ignore the question.

On import the appropriate distance is calculated with the code you showed initially. But this is not done ‘on the fly’. To calculate this on the fly you can just use the code you like … or maybe I misunderstood the question.

sorry, a last question:

i have copied my 3D Pointlist (pointlist) to a 2D Pointlist (pList) and this is my result in the Debugger:

double x1= pList.calcDistance(new DistanceCalc2D()); x1= 0.3855872335501685
double x2= pointList.calcDistance(new DistanceCalc3D()); x2=30152.54823432891
double x3= pList.calcDistance(new DistanceCalcEarth()); x3=30146.312544324857
double x4= pList.calcDistance(new DistancePlaneProjection()); x4=30146.31255861596

why is x1 0.3…and not 30146.3…

What i’m doing wrong?

2D has probably a wrong name, but it calculates the distance in euclidian space (see source) e.g. if you use meters for x|y as coordinates instead of lat|lon, useful e.g. for mapping an indoor space with own coordinates or for unit tests