From 5e18b46347d778b9c0696f7b90ca12748f2c5dd2 Mon Sep 17 00:00:00 2001 From: Marcus Lundblad Date: Tue, 21 May 2019 22:54:57 +0200 Subject: geoJSONSource: Use tile size from downloaded service Rather that using a hard-coded tile size, use a size matching the tile size as specified by the downloaded service definition. Fixes #180 --- src/geoJSONSource.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/geoJSONSource.js b/src/geoJSONSource.js index 5f9c26e2..3e432509 100644 --- a/src/geoJSONSource.js +++ b/src/geoJSONSource.js @@ -28,13 +28,11 @@ const Geojsonvt = imports.geojsonvt.geojsonvt; const Location = imports.location; const Place = imports.place; const PlaceMarker = imports.placeMarker; +const Service = imports.service; const Utils = imports.utils; const GeoJSONStyle = imports.geoJSONStyle; const MapView = imports.mapView; - -const TILE_SIZE = 256; - const TileFeature = { POINT: 1, LINESTRING: 2, POLYGON: 3 }; @@ -48,6 +46,7 @@ class GeoJSONSource extends Champlain.TileSource { this._mapView = params.mapView; this._markerLayer = params.markerLayer; this._bbox = new Champlain.BoundingBox(); + this._tileSize = Service.getService().tiles.street.tile_size; } get bbox() { @@ -55,7 +54,7 @@ class GeoJSONSource extends Champlain.TileSource { } vfunc_get_tile_size() { - return TILE_SIZE; + return this._tileSize; } vfunc_get_max_zoom_level() { @@ -211,17 +210,17 @@ class GeoJSONSource extends Champlain.TileSource { parse(json) { this._parseInternal(json); - this._tileIndex = Geojsonvt.geojsonvt(json, { extent: TILE_SIZE, + this._tileIndex = Geojsonvt.geojsonvt(json, { extent: this._tileSize, maxZoom: 20 }); this._clampBBox(); } _renderTile(tile) { let tileJSON = this._tileIndex.getTile(tile.zoom_level, tile.x, tile.y); - let content = new Clutter.Canvas({ width: TILE_SIZE, - height: TILE_SIZE }); - tile.content = new Clutter.Actor({ width: TILE_SIZE, - height: TILE_SIZE, + let content = new Clutter.Canvas({ width: this._tileSize, + height: this._tileSize }); + tile.content = new Clutter.Actor({ width: this._tileSize, + height: this._tileSize, content: content }); content.connect('draw', (canvas, cr) => { -- cgit v1.2.1