开源GIS相关Gis专辑

Mapbox大数据量渲染策略

2018-11-15  本文已影响3人  上岸躲雨

在使用mapbox渲染大数据的情况下可以采用以下策略来提高渲染效率。

GeoJSON source参数设置

high-tolerance 3.50

数据清理

清理前

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {
        "objectid": 1,
        "id": 1,
        "uniqueid": "1695.00",
        "address": "230",
        "suffix": " ",
        "street": "Stratford Ave",
        "onstr": "Friendship Ave",
        "fromstr": "Stratford Ave",
        "tostr": "Fairmount St /S",
        "side": "Side",
        "site": "1",
        "spp": "Acer platanoides",
        "dbh": 5,
        "cond": "Good",
        "trunks": 1,
        "mt": "Training Prune",
        "observe": "None",
        "hardscape": "N",
        "inspect": "N",
        "klir": "Vehicle",
        "utilities": "Y",
        "grow": "Tree Lawn",
        "spacesize": 2,
        "loctype": "Street",
        "pghdbsdeTree_Keeperarea": 8,
        "staff": "Kara Masak",
        "inv_date": "2005-02-14T00:00:00.000Z",
        "inv_time": " ",
        "inspect_dt": "2005-02-14T00:00:00.000Z",
        "inspect_tm": "10:18:32",
        "active": 1
      },
      "geometry": {
        "type": "Point",
        "coordinates": [
          -79.9334671524,
          40.4611126031
        ]
      }
    }
    // additional features
  ]
}

清理后:

{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"dbh":5},"geometry":{"type":"Point","coordinates":[-79.93345,40.46111]}}]}

使用GeoJSON Url

使用geojson url能够减小浏览器的内存开销。使用js对象将geojson塞进source会增加内存开销。

map.addSource('some id', {
  type: 'geojson',
  data: 'https://mydomain.mydata.geojson'
});

设置Symbol--> layers--> icon-allow-overlap

如果icon-allow-overlap为true,即使图标与其他先前绘制的符号发生碰撞,该图标也将可见(所有点可见)。同时能够在平移和缩放密集点的时候,能够提高图层的渲染速度。

false-allow-icon-overlap true-allow-icon-overlap

超大文件处理

如果超大文件(超过500,000)可以使用以下方法来提高渲染速度。

数据源切分

可以将原有的数据切分成2到3部分,能够将加载与渲染能力提高1倍或3倍。 例子

使用矢量切片

将geojson数据转换成矢量切片,能够减小文件的大小,提高渲染效率。

上一篇下一篇

猜你喜欢

热点阅读