[gnome-maps/gnome-3-32] geoJSONSource: Use tile size from downloaded service



commit 633a16c112390c8d730f3e932f164aa37bcb641a
Author: Marcus Lundblad <ml update uu se>
Date:   Tue May 21 22:54:57 2019 +0200

    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 4c596c2..48fe9e2 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) => {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]