问题描述
在我们的应用程序中,我们有一个后端,该后端在地图的某个区域上进行一些栅格处理,然后将图像发送回基于OL的前端,该前端将在指定的范围内插入图像.
In our application we have a backend that does some raster processing on a region of a map and sends back an image to the OL-based frontend which inserts the image at the specified extent.
要处理的多边形以GeoJSON-coords(EPSG:4326)的形式发送到后端,然后将其转换为矩形投影(在这种情况下为EPSG:3035),进行处理并将热映射结果发送回给前端作为PNG编码的图像,将服务器端重新投影到EPSG:3857(以匹配基于OSM的背景图的投影).然后使用ImageStatic对象将图像插入ImageLayer中,该对象的范围由后端(转换为EPSG:3857的图像的EPSG:3035转换的边界框)计算.
The polygon to process is sent as GeoJSON-coords (EPSG:4326) to the backend which then transforms the polygon to a rectangular projection (EPSG:3035 in this case), does the processing and sends the heatmapped results back to the frontend as a PNG-encoded image, reprojected server-side to EPSG:3857 (to match the projection of our OSM-based background map). The image is then inserted in an ImageLayer using an ImageStatic object, whose extent is computed by the backend (the EPSG:3035-transformed bounding box of the image transformed to EPSG:3857).
除了在斯堪的纳维亚半岛最北部的多边形外,此方法都可以正常工作.例如,将EPSG:3857的范围为[1684632.9133543067,9544855.787615912,2902401.684702249,10831736.048522325]的图像添加到地图后,将通过以下方式可视化:
This works fine, except for polygons in the far north of Scandinavia. For instance, the image whose extent in EPSG:3857 is [1684632.9133543067,9544855.787615912,2902401.684702249,10831736.048522325] is visualized the following way when added to the map:
理想的结果是图像遵循阴影多边形的东南边界.相反,它歪斜并向东北延伸.
The desirable result is for the image to follow the south-eastern boundaries of the shadowed polygon. Instead it is skewed and stretched out to the north-east.
我非常感谢您提出任何想法和建议,以了解为什么它无法按预期进行.
I would be very grateful for any ideas and pointers as to why this is not working as expected.
推荐答案
我通过尽可能多地裁剪要重新投影的图像来解决了这个问题.然后,所得到的包络要小得多,从而消除了失真.感谢提示@Ian!
I solved this by cropping the image to be reprojected as much as possible. The resulting envelope is then much smaller which did away with the distortions. Thanks for hint @Ian!
这篇关于远北放置的静态图像被拉伸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!