d3 / d3-geo-projection

Extended geographic projections for d3-geo.
https://observablehq.com/collection/@d3/d3-geo-projection
Other
1.1k stars 201 forks source link

Count Number Of Visible Objects Within Projection #184

Closed tman16 closed 4 years ago

tman16 commented 4 years ago

Hi there

I am using d3 celestial with the d3 geo projection clip Orthographic, is there a way to count the total number of visible stars on displayed within the projection?

I believe the starting point would be using this:

Celestial.container.selectAll(".star").each(function(d) { if (Celestial.clip(d.geometry.coordinates)) {

// Count number of visible stars after clip here

} });

Any help would be much appreciated

Thank you!

Fil commented 4 years ago

I often use if (path({type:"Point", coordinates})) { … } to test is a point is clipped or visible. It works with points, lines, polygons… if they are invisible their path is null.

https://observablehq.com/d/f47471e0f1baf340