【问题标题】:Open Layer calculate length and width of extent in miles and reverse开放层以英里和反向计算范围的长度和宽度
【发布时间】:2021-03-06 22:41:17
【问题描述】:

OpenLayer - 6.4.3

需要计算当前 EXTENT 的 LENGTH 和 WIDTH 以英里为单位。

然后将 x 英里添加到计算的 LENGTH 和 WIDTH。

然后从新的LENGTH和WIDTH中得到新的extent,中心与初始extent相同。

const extent_initial = this.map.getView().calculateExtent(this.map.getSize());

// get the Length and width in miles from 'extent_inital' 

// add x miles to Length and Width 
// so Length_new = Length + x , Width_new = Width + x
// Calculate new Extent with Length_new and Width_new and extent_inital center


提前致谢

【问题讨论】:

    标签: angular angular8 openlayers-6 extent


    【解决方案1】:

    您想要的精度取决于您使用的投影以及该投影中范围的大小。

    虽然投影时这是一个矩形,但由于地球的形状,顶部(北纬 60 度)的宽度(以英里为单位)仅为底部(赤道)宽度的一半。

    因此,这在规模接近恒定的小范围内效果最佳。计算范围中心以英里为单位的比例尺,然后您可以得到以英里为单位的中心线的宽度和高度。

    const center = ol.extent.getCenter(extent_initial);
    
    const pointResolutionInMiles = ol.proj.getPointResolution(this.map.getView().getProjection(), 1, center, 'ft')  / 5280;
    
    const widthInMiles = ol.extent.getWidth(extent_initial) * pointResolutionInMiles;
    
    const heightInMiles = ol.extent.getHeight(extent_initial) * pointResolutionInMiles;
    

    要创建一个新范围,您可以在每个方向(顶部、底部、左侧、右侧)缓冲初始范围,以便将宽度和高度增加x,您需要在每个边缘处有一个 x / 2 英里的缓冲区,这必须转换回投影单位:

    const extent_new = ol.extent.buffer(extent_initial, (x / 2) / pointResolutionInMiles);
    

    【讨论】:

      猜你喜欢
      • 2014-04-30
      • 1970-01-01
      • 2021-04-24
      • 2016-10-25
      • 1970-01-01
      • 2011-09-10
      • 1970-01-01
      • 1970-01-01
      • 2020-10-13
      相关资源
      最近更新 更多