Is the measure in 3D Available for JS 4.0 ?

Regards,

Jawadh

Is the measure in 3D Available for JS 4.0 ?

Regards,

Jawadh

if you see on JS API 4.0 functionallity matrix Measurement is Coming soon.

Functionality matrix | ArcGIS API for JavaScript 4.0

so we are waiting for measurement on 3D API.

In the meantime, you can use the geometry engine for measurements. geometryEngine | API Reference | ArcGIS API for JavaScript 4.3 or geometryEngineAsync | API Reference | ArcGIS API for JavaScript 4.3

Hi Thomas,

do you mean it's possible now to measure in 3D using GeometryEngine? I had look the Javascript APIs but couldn't find anything specifically about measure in 3D. could you please direct me to some examples? Thanks.

It depends on what you mean by "measure in 3D."

You can measure the distance between 2 points using the geometry engine: JS Bin - Collaborative JavaScript Debugging

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

- 1 person found this helpful
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.

- 1 person found this helpful
Hey Jack,

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.

Sure enough, the esri/views/3d/externalRenderers module exposes this functionality. Normally this module is for creating your own scene and placing it in the same rendering pipeline as the main scene, but you should also be able to use it for coordinate conversions to (and from) ECEF. This functionality is implemented in webGL, which means inputs and outputs are a bit weird: externalRenderers | API Reference | ArcGIS API for JavaScript 4.3

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.

Here's an example of how you could find the distance between two points with the same long/lat but a different z: JS Bin - Collaborative JavaScript Debugging

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.

if you see on JS API 4.0 functionallity matrix Measurement is Coming soon.

Functionality matrix | ArcGIS API for JavaScript 4.0

so we are waiting for measurement on 3D API.