1

I have my map object created like this:

new ol.Map({
    ...
    view: new ol.View({
        center: ol.proj.transform([15,49], 'EPSG:4326', 'EPSG:3857'),
        zoom: 10,
        minZoom: 7,
        maxZoom: 18,
        extent: ol.proj.transformExtent([11.8, 48.4, 19.2, 51.2], 'EPSG:4326', 'EPSG:3857')
    })
});

Let's say I have a big polygon "A" ( see the picture below ). I have a smaller polygon "B", which sticks to one side of the polygon "A". An external system calculates polygon "B" coordinates using WGS coordinates - points "pt1" and "pt2" are positioned on connection between point "pt3" and "pt4". When I draw both polygon on my map, points "pt1" and "pt2" are not positioned on connection between point "pt3" and "pt4". I think, it's because OpenLayers connect points "pt3" and "pt4" by direct line. This connection is straight line on the globe, so on my map, it should be curve. And that's why, I think, the polygon "B" is not aligned with the polygon "A" although it is on the globe. Is there a way, how to fix this?

enter image description here

user3523426
  • 836
  • 3
  • 11
  • 26
  • I think it's some projection accuracy issue. instead of project from WGS84 to Web Mercator set map default projection to WGS84 or EPSG:4326. – Mahdi Mahmoodian Nov 05 '19 at 10:30
  • Neither EPSG:4326 nor EPSG:3857 will show the true position on the globe of a line between two vertices. For that you will need to connect the vertices with great circle geometry. If one projection (e.g. EPSG:4326) shows an intersection on a flat map (even though on a real globe that might not be correct) to reproduce the effect in another projection you would need to split the linestrings into small segments and reproject each of those. See https://gis.stackexchange.com/questions/308871/why-is-there-a-transformation-shift-distortion-of-1-5km-in-openlayers-5-3-0-goi – Mike Nov 05 '19 at 10:58

0 Answers0