Is the measure in 3D Available for JS 4.0 ?
if you see on JS API 4.0 functionallity matrix Measurement is Coming soon.
so we are waiting for measurement on 3D API.
Thanks for the response,
I hope they release it very soon
me too, there is a lot of functionality coming on next release, so we are waiting......
Well it's almost about a year now for that "Coming soon" be there. don't think a year long of time could be called "soon" for a basic 3D function. very disappointed. To me web scene is a half baked product that I would not even refer to my users.
It depends on what you mean by "measure in 3D."
That example uses the geodesicLength method, so it includes the earth's curvature. There are also planar methods that don't. Measuring in 3D isn't really any different from measuring in 2D as long as you're measuring along the surface of the earth.
Things get more complicated if you're interested in finding the distance between two points with z values. I agree that this is an area where the JS API lacks support.
so this won't help us measuring 3D object or distance between any two points that not on the ground. WTH
I'm by no means an expert in this area but here's a brief rundown of my understanding.
To start with, I would say that all of these measurements are approximations. None of them take variations in elevation into account (obviously). My understanding is that, for very sensitive measurements, other methods are used.
That said, you can get pretty good approximations of the great-circle distance between two points on the earth's surface using the geometry engine. If you have two points with a longitude, latitude, and altitude, the geometry engine won't help (it appears to ignore the altitude), but you have some other options.
One of them is to take the average of the altitudes of the two points and find the great-circle distance between the two new points. In practice this gives reasonably good results. The farther the distance between the two points, the greater the error. I would say this is acceptable for most normal use cases.
Another is to convert from a long, lat, z coordinate system into a 3 dimensional cartesian coordinate system (ECEF is a commonly used one). Once you have two points in ECEF, you can use the distance formula to calculate the straight-line distance between the two points:
let d = Math.sqrt(Math.pow(x1-x2, 2) + Math.pow(y1-y2, 2) + Math.pow(z1-z2, 2))
Here's a stackoverflow question and answer that provides some code that may be helpful if you want to implement either of these options: geometry - Taking altitude into account when calculating geodesic distance - Stack Overflow
Hi Thomas, thanks for your reply. that gave me some light. The first method probably won't work for measuring vertical distance, but I'll give a try on the second method you mentioned. appreciated.
I was thinking about this and I realized that there must be a way to transform between ECEF and long/lat/z in the JS API.
Coordinates are input as an array like this: [longitude1, latitude1, z1, longitude2, latitude2, z2, ...] for as many points as you like. The results will be output in an array with [x1, y1, z1, x2, y2, z2, ...] in meters. You can pass in an empty array and the results be placed in that. You specify the starting index (in your input array) and how many points you want to transform in the function params.
This should work for any two points with long/lat/z (must be wgs84 or web mercator), but keep in mind it's the straight line distance, which isn't always what you want. There's also going to be some error here, but, in general, I think this should be pretty good. Also, ECEF is in meters, so the output distance will all be in meters.
Retrieving data ...