【问题标题】:Openlayers - transform polygon from a specific projection like EPSG:28992Openlayers - 从特定投影转换多边形,如 EPSG:28992
【发布时间】:2020-11-06 10:57:24
【问题描述】:

如何将具有特定投影的简单多边形添加到我的地图?

多边形是有效的,我之前检查过。

coordinatesPolygonInRd = [ [ [173563, 441818], [173063, 441818], [173063, 444318],
      [173563, 444318], [173563, 441818] ] ];

这就是我尝试在将多边形放在地图上之前对其进行转换的方式:

尝试1:

let dutchProjection = new Projection({
  code: 'EPSG:28992',
  extent: [-285401.92, 22598.08, 595402.0, 903402.0],
  worldExtent: [3.2, 50.75, 7.22, 53.7],
  units: 'm'
});
addProjection(dutchProjection);

const geometry = new Polygon( this.coordinatesPolygonInRd).transform( 'EPSG:28992', this.map.getView().getProjection());
this.vectorLayer.getSource().addFeature(new Feature(geometry));

尝试2:

proj4.defs["EPSG:28992"] = "+proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000  +ellps=bessel  +towgs84=565.040,49.910,465.840,-0.40939,0.35971,-1.86849,4.0772 +units=m +no_defs";
register(proj4)
let dutchProjection = GetProjection('EPSG:28992');
const geometry = new Polygon( this.coordinatesPolygonInRd).transform( 'EPSG:28992', this.map.getView().getProjection());
this.vectorLayer.getSource().addFeature(new Feature(geometry));

【问题讨论】:

    标签: openlayers openlayers-6 proj4js angular-openlayers


    【解决方案1】:

    方法2可以,但是你的proj4语法错误,应该是

    proj4.defs("EPSG:28992","+proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000  +ellps=bessel  +towgs84=565.040,49.910,465.840,-0.40939,0.35971,-1.86849,4.0772 +units=m +no_defs");
    

    注册proj4定义后可以随意设置投影范围等。

    【讨论】:

    • Proj4php 是否可以处理多边形,知道吗?
    猜你喜欢
    • 2021-02-18
    • 2017-07-12
    • 2020-06-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多