Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.23 KB | None | 0 0
  1. var tilePixels = new Projection({
  2. code: "EPSG:3857"
  3. // code: 'TILE_PIXELS',
  4. // units: 'tile-pixels'
  5. });
  6.  
  7. var url = 'assets/geojson/agriculture.geojson';
  8. fetch(url).then(function(response) {
  9. return response.json();
  10. }).then(function(json) {
  11. var tileIndex = geojsonvt(json, {
  12. maxZoom: 14,
  13. tolerance: 3,
  14. extent: 4096,
  15. buffer: 64,
  16. debug: 1,
  17. lineMetrics: false,
  18. promoteId: null,
  19. generateId: false,
  20. indexMaxZoom: 5,
  21. indexMaxPoints: 100000
  22. });
  23. var vectorSource = new VectorTileSource({
  24. format: new GeoJSON(),
  25. tileLoadFunction: function(tile) {
  26. var format = tile.getFormat();
  27. var tileCoord = tile.getTileCoord();
  28. var data = tileIndex.getTile(tileCoord[0], tileCoord[1], -tileCoord[2] - 1);
  29.  
  30. var features = format.readFeatures(
  31. JSON.stringify({
  32. type: 'FeatureCollection',
  33. features: data ? data.features : []
  34. }, replacer)
  35. );
  36. tile.setLoader(function() {
  37. tile.setFeatures(features);
  38. tile.setProjection(tilePixels);
  39. });
  40. },
  41. url: 'data:' // arbitrary url, we don't use it in the tileLoadFunction
  42. });
  43. var vectorLayer = new VectorTileLayer({
  44. source: vectorSource
  45. });
  46. that.map.addLayer(vectorLayer);
  47. });
  48.  
  49. 0: Feature
  50. dispatching_: {}
  51. disposed_: false
  52. geometryChangeKey_: {bindTo: Feature, callOnce: false, listener: ƒ, target: Polygon, type: "change", …}
  53. geometryName_: "geometry"
  54. id_: undefined
  55. listeners_: {change:geometry: Array(1)}
  56. ol_lm: {change:geometry: Array(1)}
  57. ol_uid: "38"
  58. pendingRemovals_: {}
  59. revision_: 2
  60. styleFunction_: undefined
  61. style_: null
  62. values_:
  63. AREA_HA: "0.53804709057583"
  64. CLASS: "AGRICULTURE"
  65. SHAPE_Area: "5380.4709057583"
  66. SHAPE_Length: "352.045733732799"
  67. geometry: Polygon
  68. dispatching_: {}
  69. disposed_: false
  70. ends_: [74]
  71. extentRevision_: -1
  72. extent_: (4) [Infinity, Infinity, -Infinity, -Infinity]
  73. flatCoordinates: (74) [5992922, 1487, 5992964, 1441, 5992982, 1378, 5992980, 1259, 5992875, 694, 5992807, 268, 5992751, 0, 5992574, 0, 5992503, 240, 5992386, 1020, 5992361, 1297, 5992373, 1462, 5992390, 1588, 5992337, 1652, 5992252, 1727, 5992156, 1781, 5992081, 1812, 5992023, 1804, 5991973, 1767, 5991896, 1604, 5991775, 1214, 5991772, 1081, 5991788, 901, 5991836, 585, 5991849, 460, 5991976, 210, 5992048, 757, 5992146, 963, 5992249, 1064, 5992375, 1105, 5992577, 1129, 5992689, 1175, 5992769, 1268, 5992848, 1392, 5992852, 1520, 5992877, 1527, 5992922, 1487]
  74. flatInteriorPointRevision_: -1
  75. flatInteriorPoint_: null
  76. layout: "XY"
  77. listeners_: {change: Array(1)}
  78. maxDeltaRevision_: -1
  79. maxDelta_: -1
  80. ol_lm: {change: Array(1)}
  81. ol_uid: "37"
  82. orientedFlatCoordinates_: null
  83. orientedRevision_: -1
  84. pendingRemovals_: {}
  85. revision_: 2
  86. simplifiedGeometryCache: {1531607591.9622366: Polygon}
  87. simplifiedGeometryMaxMinSquaredTolerance: 0
  88. simplifiedGeometryRevision: 2
  89. stride: 2
  90. values_: {}
  91. __proto__: SimpleGeometry
  92. __proto__: Object
  93. __proto__: BaseObject
  94.  
  95. GeoJSON {dataProjection: Projection, defaultFeatureProjection: null, geometryName_: undefined, extractGeometryName_: undefined}
  96. dataProjection: Projection
  97. axisOrientation_: "enu"
  98. canWrapX_: false
  99. code_: "EPSG:31982"
  100. defaultTileGrid_: null
  101. extent_: null
  102. getPointResolutionFunc_: undefined
  103. global_: false
  104. metersPerUnit_: undefined
  105. units_: "m"
  106. worldExtent_: null
  107. __proto__: Object
  108. defaultFeatureProjection: null
  109. extractGeometryName_: undefined
  110. geometryName_: undefined
  111. __proto__: JSONFeature
  112.  
  113. preprocess data: 16.31201171875ms
  114. index: maxZoom: 5, maxPoints: 100000
  115. features: 25, points: 5731
  116. generate tiles: 5.870849609375ms
  117. tiles generated: 1 {"z0":1}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement