Z value on know LAT LONG

Hi all we would like to know if it is possible to get the Z value of a 3D tileset point with known LAT LONG

Thanks
Marco

Hi @marco.rossi,

Thank you for bringing us your question. If this question does not have any private information, do I have your permission to share this thread with the rest of the community?

What exactly do you mean by the Z value? Are you looking for the elevation of a point in a tileset?

Best,
Sam

Hi Sam

Thanks for your feedback.

Sure you can share it over the community.

Correct, I meant the elevation of a point in a tileset when you know LAT & LONG

Best

Marco

···

Da: Sam Rothstein via Cesium Community cesium@discoursemail.com
Inviato: lunedì 31 gennaio 2022 17:08
A: marco.rossi@aeronike.com
Oggetto: [Cesium Community] [PM] Z value on know LAT LONG





|

sam.rothstein Cesium Team
January 31

|

  • | - |

Hi @marco.rossi,

Thank you for bringing us your question. If this question does not have any private information, do I have your permission to share this thread with the rest of the community?

What exactly do you mean by the Z value? Are you looking for the elevation of a point in a tileset?

Best,
Sam


Visit Message or reply to this email to respond to support (38).

To unsubscribe from these emails, click here.

Hi @marco.rossi,

Thank you for the response and the clarifying information. I will make this thread public.

I think the following code snippet should work for your use case:

const samplePos = [Cesium.Cartographic.fromDegrees(-77.13295208170246, 38.674469884794405)];

let promise = Cesium.sampleTerrainMostDetailed(worldTerrain, samplePos);

Cesium.when(promise, () => {
      console.log(samplePos[0].height);
});

Here we are getting a sample position from a latitude and longitude value and then retrieving the elevation.

Best,
Sam

Thank you Sam!

We’ll try it!

Best

Marco

Ing. Marco Rossi

Business Development Manager

marco.rossi@aeronike.com

Aeronike Srl

Ufficio Milano

Mob: +39 347 2516746

www.aeronike.com

www.cityexplorer3d.com

Follow us on

Linkedin - https://www.linkedin.com/company/15204239/

YouTube – https://www.youtube.com/channel/UCZJcl7ujzJWqPcqwJ22NC3Q

Facebook - https://www.facebook.com/aeronikesrl/

Twitter - https://twitter.com/aeronikece3d

Dear Sam,

just a quick feedback on our attempt to implement the code snippet you have shared.

It looks ok on the ground but we are still not able to get the elevation once we instance the 3D Tile.

Any further idea or suggestion to double check on our side?

Thanks a lot

Best

Marco

Hi @marco.rossi,

To the best of my knowledge, the method that I shared returns the elevation of the terrain data at a given latitude and longitude. Are you adding a 3D Tileset on top of the terrain? If so, is it a point cloud dataset?

I know that it is possible to access the height of points in a point cloud:

However, I would have to check in with the rest of the team regarding other types of 3D Tiles.

Best,
Sam

Hi Sam,

yes we are adding a 3D Tileset on top of the terrain.

It’s not a point cloud dataset,

it comes from exporting the 3D texturized mesh in a Cesium 3D tileset format from Skyline Photomesh sw.

Thanks

Marco

@marco.rossi you can try out simple pick, here’s a fragment of code:

var handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK);
handler.setInputAction(function (click){
            if (scene.mode !== Cesium.SceneMode.MORPHING) {
                var pickedObject = scene.pick(click.position);
                var cameraRay = camera.getPickRay(click.position);
                var pickedGlobe = scene.globe.pick(cameraRay, scene);
                console.log(pickedGlobe);
                console.log(pickedObject);  
            };
            if ((Cesium.defined(pickedGlobe)) || (scene.pickPositionSupported && Cesium.defined(pickedObject))){
                var cartesian = (Cesium.defined(pickedObject)  ? scene.pickPosition(click.position) : pickedGlobe);
                console.log(cartesian);
            }
}

Hi @jakubs, thank you for the suggestions! Would the cameraRay intersect with the 3D Tileset or simply the terrain underneath?

Thank you Jakubs,

this code works but as you can read from our first message, we will need a code which will allow us to get the altitude on a 3D tileset from a script which inputs LAT LONG.

While this code you have shared gives the result by clicking the window and not by the script which with known LAT LONG

Thanks

There’s an old StackOverflow answer here;

I’d start there, replacing *.pick() with scene.pickPosition(). Now, a warning; This often doesn’t work if the place in question isn’t in the viewer, or the coordinate conversion isn’t successful (for a variety of reasons, including the amount of sky and horizon, tilt and a few other fun factors). An extended (and dirty) way would be to, in really quick succession (by subscribing to the render cycle points)

  1. capture camera position and pan/tilt/zoom,
  2. in the pre-render, move the camera to where you know your model is picking at, do the picking, and
  3. move camera back to its original

This is of course far from ideal with lots of flickering and spluttering, but with a bit of trickery (capture the canvas, overlay the capture essentially freezing the render underneath), and then removing the overlay could do this without too much flickering (and I’ve in the past played with the internals of the Cesium engine to switch back in render so that post-render is back in its position, but there’s too little precision), but you’d have to play around with how much time is needed between pre-render, picking (which, depending on your picking method, require or enforces a rendering cycle) before buffers are filled in the raster buffers, etc. You might even look at the Cesium engine for rendering to a different buffer for a few cycles, but not sure how tricky that would be.

The best solution would be that scene.pickPosition() could optionally take a Cartesian3 as well as Cartesian2. I’ve seen this request over the years, it might even be on their list?

Cheers,

Alex

1 Like