I'd like to draw visiblity circles (i.e. solid angle of visibility around a given lat/lon point on a point at a given altitude, projected on the earth surface) and have no problem except when one of the poles is wrapped by the "circle"/projected polygon (in reality, as I use the EPSG:4326 projection, the "circle" is an ellipse with two focal points on the North-South axis, see Tissot's Indicatrix on Wikipedia). In this case (North or south pole is wrapped), the resulting polygon misses a latitude band portion starting from the highest polygon latitude to the 90° latitude (if north pole) or lowest polygon latitude to the -90° latitude (if south pole).
See screenshots below: **- first one: ** what I obtain using Openlayers' ol.geom.Polygon.circular(...) method in the code below:
const vectorLayer4326 = new ol.layer.Vector({
source: new ol.source.Vector(),
style: polygon_style,
});
const radius = 7708025;
let x, y;
x = 0;
for (y = 9; y <= 50; y += 10) {
const circle4326 = ol.geom.Polygon.circular([x, y], radius, 128);
vectorLayer4326.getSource().addFeature(new ol.Feature(circle4326));
}
**- second one: ** what I expect to get (I obtained it using the almost same code as above, but I added a fixing method. What it does is explained below the code snippet):
const vectorLayer4326 = new ol.layer.Vector({
source: new ol.source.Vector(),
style: polygon_style,
});
const radius = 7708025;
let x, y;
x = 0;
for (y = 9; y <= 50; y += 10) {
const circle4326 = **fix_OL_visi_circle_pole_vertices**(ol.geom.Polygon.circular([x, y], radius, 128));
vectorLayer4326.getSource().addFeature(new ol.Feature(circle4326));
The fix_OL_visi_circle_pole_vertices(Polygon) method is a fix I did to correct the Polygon geometry by forcibly adding the "corners" ([-180,90], [180, 90] points for North pole and [-180,-90], [180,-90] points for South pole) when detecting a longitude leap. But obviously, I'd rather have a clean solution
And the Openlayers' map initialization: `
const map4326 = new ol.Map({
layers: [
tiles_layer,
vectorLayer4326
],
target: 'map',
view: new ol.View({
projection: 'EPSG:4326',
center: [0, 0],
zoom: 2,
}),
});
`
I had the same issue with Leaflet, changed tthe projection to EPSG:3395, which solved the geometric problem, but then I couldn't fix the tiles to match the correct latitudes. Looking in every direction, I tried to change the map display technology for OpenLayers when I saw their Tissot indicatrix example, hoping it would support the pole wrapping case. Unfortunately, it had the same issue than Leaflet. So I analyzed the generated geometry and produced the fix described previously.
But as I am not a geographer, I hope there is a solution based on changing projections/transformations from a different projection than Mercator to the EPSG:4326 I use.
Thanks in advance for any help.