melowntech / vts-browser-js

JavaScript WebGL 3D map rendering engine
BSD 2-Clause "Simplified" License
220 stars 42 forks source link

Point is not visible when we zoom near the surface #121

Closed alam-R closed 5 years ago

alam-R commented 5 years ago

Hi,

We used your example Geodata Basic (https://github.com/Melown/vts-browser-js/wiki/Examples) in order to display a point on the right lat, lon, altitude. Our try is on: https://jsfiddle.net/alamR/jjynbpoL/13/ The problem is that the point is not visible when we zoom near the surface. The real altitude of the point is 333m. In our code we add this point: geodata.addPoint([14.3836691, 50.0485568, 333], 'fix', { 'name' : 'Nice place' }, 'some-place'); But it is not visible (when we zoom near surface)! When we change the altitude around 380m then we can see it. Have we missed something? Thank you in advance!

davidmtech commented 5 years ago

There are two kinds of heights. One which is over ellipsoid and one which over geoid. In this case you are using map where are coordinates provided in navigational spacial system which has heights over ellipsoid. You can take advantage that current map has public spacial system with heights over geoid and convert height by following function:

var newCoords = map.convertCoordsFromPublicToNav([14.3836691, 50.0485568, 333]);

I have modified your example which now gives more accurate results. Final result is also depended on the precision of the point coordinates and on the precision of the terrain geometry: https://jsfiddle.net/mj26qkrw/

More about spatial coordinate systems in VTS can be found there: http://vtsdocs.melown.com/en/latest/reference/concepts.html

alam-R commented 5 years ago

Thank you very much David! Indeed this method solves the problem of the height mismatch. However if you run this method again with the same arguments then the result of the conversion is different for the height!? We have created this demo: https://jsfiddle.net/alamR/9xr5tx63/22/

You could check the console and notice the different values of height every time you click the custom button 'Clickme'.

davidmtech commented 5 years ago

Sorry, I forgot that function for conversion has second parameter which defines whether height is 'fix' or 'float'. Default mode is 'float' and height is computed from currently available data. Usually available data are not best match so more detailed data are loaded on the background. That is reason different values. Fixed function call:

var newCoords = map.convertCoordsFromPublicToNav([14.3836691, 50.0485568, 333], 'fix');

Fixed demos: https://jsfiddle.net/5n97gm3y/ https://jsfiddle.net/mj26qkrw/12/

alam-R commented 5 years ago

Thank you so much David!! Now it is working as expected 👍 👍