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?
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.
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
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