【问题标题】:How to get elevation data for OpenLayers 3?如何获取 OpenLayers 3 的高程数据?
【发布时间】:2016-09-19 16:48:13
【问题描述】:

我正在尝试创建一个显示海拔热图的栅格图层,红色代表高峰,蓝色代表大海。我试图为此使用 OpenLayer 3 的地理位置(ol.Geolocation),但它返回未定义。我知道 Geolocation 的主要用途是用于实时当前 GPS 定位,但我当然也应该能够将它用于其他位置,不是吗?

否则,是否有任何其他免费服务(除了需要使用 Google 地图的 Google 海拔 API 之外)可以让我根据经度和纬度获取海拔数据?

app.rasterCounter = 0;
var geolocation = new ol.Geolocation({
    projection: map.getView().getProjection()
});
var raster = new ol.source.Raster({
    sources: [bing],
    operation: function(pixels, data) {
        //find the current pixel's location
        var y = Math.floor(app.rasterCounter/map.getSize()[0]);
        var x = Math.floor(app.rasterCounter % map.getSize()[0]);
        //find the pixel's coordinate equivalent
        var coords = map.getCoordinateFromPixel([x, y]);
        var lonlat = ol.proj.toLonLat(coords);
        geolocation.set('position', lonlat);
        //if above sea level, then display a heatmap of the long/lati, otherwise display red
        var pixel = geolocation.getAltitude() > 0 || geolocation.getAltitude() === undefined ? [0, lonlat[0]+100, lonlat[1]+100, 128] : [255, 0, 0, 128];
        app.rasterCounter++;
        return pixel;
    },
    //allow access to the DOM
    threads: 0
});
raster.on('afteroperations', function(e) {app.rasterCounter=0;});

注意:结果上没有红色,因为所有的高度都是未定义的。 :/

【问题讨论】:

    标签: javascript openlayers-3


    【解决方案1】:

    我认为您误解了 Geolocation API 的用途。 Geolocation API 用于根据用户可用的任何传感器(GPS、Wi-Fi、IP 地址等)获取有关当前用户位置的信息。如果可用,它还会返回它们的高度。它不会告诉你特定点的地面高度是多少,这不是它的设计目的。

    您需要的是免费的海拔数据源。如果您只是查询单个点,您可以使用 MapQuest Open Elevation Service - https://open.mapquestapi.com/elevation/ - 它与 Google Maps Elevation 服务非常相似,但没有相同的限制(您应该正确检查这一点,我只是粗略地看了一眼) .如果您想创建地图,您可能需要预先制作的栅格数据,这些数据要么已通过 WMS 或 TMS 服务制作并可用,要么作为您可以自己摄取和渲染的点云。为此,您需要进行自己的研究,这完全取决于您要寻找的领域。例如,在英国,许多基于 LiDAR 的地形模型完全免费提供,并通过https://data.gov.uk 开放。在其他地方,您可能需要研究 NASA 生产的产品。这个网站 - http://gisgeography.com/free-global-dem-data-sources/ - 可能是一个很好的起点。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-08-16
      • 1970-01-01
      • 1970-01-01
      • 2016-12-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多