Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Light side of the earth #14

Open
Foaly opened this issue Jul 21, 2019 · 2 comments
Open

Light side of the earth #14

Foaly opened this issue Jul 21, 2019 · 2 comments

Comments

@Foaly
Copy link

Foaly commented Jul 21, 2019

Hello!
Thank you very much for this handy library! I was wondering about a feature request that I think would be a useful addition. I have a dark map so using a dark overlay make the map even darker and is hard to distinguish the terminator. I would much rather visualize the light/day side with a white overlay.
How hard would it be to calculate the "inverse" Polygon? Could this possible be added?

@Foaly
Copy link
Author

Foaly commented Jul 21, 2019

I was able to implement this using Leaflets polygon cutout feature:

let terminatorConfig = {
  stroke: false,
  fillColor: '#FFFFFF',
  fillOpacity: 0.15
};

// get the coordinates of the terminator and flatten them from an array of objects to an array of arrays
let terminatorCoords = L.terminator().getLatLngs()[0].map( function(obj) {
  return [ obj.lat, obj.lng ];
});

// create the inverse of the terminator to highlight the day side
L.polygon(
  [[[ 90, -300],
    [ 90,  300],
    [-90,  300],
    [-90, -300]], //outer rect
   terminatorCoords], // terminator cutout
   terminatorConfig
).addTo(map);

It's a little hacky, but it shows that it is possible to arrive at the inverse of the polygon. So mathematically it should only be some clever subtraction. I think it would still be cool to have a helper function in the library that does it for you :)

@joergdietrich
Copy link
Owner

I'll keep this in mind but it´s not a priority item for me. Feel free to submit a pull request, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants