Listing/Counting Geometries in View


I am loading a number of polygons (which represent buildings) via CZML. Once the CZML is loaded, users can enter search criteria to re-load the CZML based on the parameters, which will either create more or fewer polygons. I’d like to be able to tell if there are any polygons in the current camera view. If there are, I will leave the camera where it is. If not, I want to flyTo the czml datasource.

So, basic question is, how can I count the geometries in the camera view extent, which have been created via CZML, to ensure a certain number are in view?

Many thanks,


There’s no easy way to do what you want. Cesium doesn’t actually know what entities are on screen at any given time. You might be able to cobble something together by iterating over the entities, getting the polygon positions (or just center point) and then determine if that point is on screen, but that will be a pretty slow process and I’m not sure if it will really give you the result you’re looking for,

Thank you Matthew. I’ll think through some other ways I can solve the problem.