有什么自动方法可以在 openlayers 中发现 epsg 代码和 proj4 到 geojson 文件?

Is there any automatic way to discover epsg code and proj4 to geojson file in openlayers?

我有一个项目可以加载一些 geojson 文件,然后在 openlayers 地图中绘制。我使用来自 Blumenau/Santa Catarina/Brazil (city/state/country) 的示例文件效果很好,但是当我从巴西城市上传新文件时,他们在地图中看到了位移。

上传文件到我的网站时,有什么方法可以自动定义 proj4 参数和 epsg 代码吗?实际上,该页面只是上传文件并用新名称定义它,而没有改变它的数据。 当我尝试上传 Santo Andre/Sao Paulo/Brazil 数据时,它是在巴西的其他州绘制的,但使用的是 Santo Andre 城市格式。

<link rel="stylesheet" href="https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v5.3.0/css/ol.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.5.0/proj4.js"></script>

proj4.defs('EPSG:32722', '+proj=utm +zone=22 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ');
ol.proj.proj4.register(proj4);

{% load static %}

var suscetibilidadeDeslizamento = new ol.layer.Vector({
                                      source: new ol.source.Vector({
                                        format: new ol.format.GeoJSON({dataProjection: 'EPSG:32722'}),
                                        url: '{% static deslizamento %}'
                                      }),
                                      style: style,
                                      opacity: 0.3
                                    });
var map = new ol.Map({
                          target: 'map',
                          layers: [

                            new ol.layer.Tile({
                                source: new ol.source.OSM()
                              }),
                                    suscetibilidadeDeslizamento

                          ],
                          view: new ol.View({
                            center: ol.proj.fromLonLat([-49, -27]),
                            zoom: 5
                          })
                        });

这是绘制的 Blumenau 数据。数据:https://raw.githubusercontent.com/tiagoferneda/files/master/SuscetibilidadeInundacaoBlumenau.json

这是绘制在 Terra Boa 市上空的 Santo Andre 数据,与正确位置相去甚远。数据:https://raw.githubusercontent.com/tiagoferneda/files/master/SuscetibilidadeInundacaoSantoAndre.json

在创建 ol.layer.Vector 之前尝试阅读 JSON 的 CRS,然后添加相应的 proj4 参数。

你应该看看 this OpenLayers example 它从 EPSG.io

动态加载 proj4 参数的地方