[gnome-maps/wip/jonasdn/service: 2/2] debug add way to load service file from file
- From: Jonas Danielsson <jonasdn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/jonasdn/service: 2/2] debug add way to load service file from file
- Date: Fri, 12 Aug 2016 19:33:49 +0000 (UTC)
commit 6bd2db151429652e76cdc1fc601e423582487996
Author: Jonas Danielsson <jonas threetimestwo org>
Date: Fri Aug 12 21:33:18 2016 +0200
debug add way to load service file from file
service.json | 27 +++++++++++++++++++++++++++
src/application.js | 13 +++++++++++++
src/mapSource.js | 16 ++++++++++++++--
3 files changed, 54 insertions(+), 2 deletions(-)
---
diff --git a/service.json b/service.json
new file mode 100644
index 0000000..0dfa028
--- /dev/null
+++ b/service.json
@@ -0,0 +1,27 @@
+{
+ "street": {
+ "id": "Mapbox-v1",
+ "name": "Mapbox street tiles",
+ "license": "Imagery and map information provided by Mapbox and Open Street Map",
+ "license_uri": "http://www.openstreetmap.org/copyright",
+ "min_zoom_level": 0,
+ "max_zoom_level": 19,
+ "tile_size": 256,
+ "uri":
"https://api.mapbox.com/styles/v1/mapbox/streets-v9/tiles/256/#Z#/#X#/#Y#?access_token=pk.eyJ1IjoiZ25vbWUtbWFwcyIsImEiOiJjaXF3a3lwbXkwMDJwaTBubmZlaGk4cDZ6In0.8aukTfgjzeqATA8eNItPJA&",
+ "attribution_logo":
"iVBORw0KGgoAAAANSUhEUgAAAIIAAAAoCAMAAAAFWtJHAAAAwFBMVEUAAAAAAAAAAABtbW0AAAAAAAAAAAAAAAAAAAAAAAClpaUAAADp6ekAAAD5+fna2toAAAAMDAzv7+/Nzc0AAAA2Njb8/Pz9/f3T09MAAAAAAAD7+/sAAAArKyuxsbH39/fs7OwbGxuIiIjz8/N8fHyenp7u7u74+PgAAAC8vLxWVlbx8fF1dXXl5eVcXFyUlJTQ0NDFxcVCQkLAwMC4uLj19fXo6OjW1tarq6ve3t77+/vi4uL6+vrKysrNzc3///8w7gSSAAAAP3RSTlMAOQNdPSYBPyw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pQVQgpvc0Ph+gsKlAnKg1+vEHsw5LKciLKCAJobiWBzYFGbCKpHqkZZrxBFHEASyFI59vJPCskcwNVGOWZAOqsrR+pKbaNeAMT1CixMEtlnsqopNxUMzVJT3tY35aXZm6a6Y9QhwMN6BUJWbE1lhbMO1WehkO7poO0sK7em9MJGxp1XSbC1gtugzzSLQmGsX7VntJGSwsPZ2d2z3bIPKzdoOp3Wzqt8G4XyMVUoFIxLx1S7+piaHtCvR3FeRVsq0GFdp9C5TbGpcNqsPqyHKxcfd14h21KhuLKUFU4f3osrC7F6uV3WXFnadL7wyAPeKDXw2RoJCO5GY4DouYvb/gepVXheLoewzPseQG9N/vzilrMIjoStE3++zvle4eSurw7XEe76ynI4aq+v7lEyt1x5awiFlFLQbHKIpabnM3eJLym4Szzzc/du7SU+zOXv9UNpECH7IoH/gecURPlN9vdQpeD47yhIFNX0U0QgvID9nENm+yxk/xb+AGAjNfRZuk9qAAAAAElFTkSuQmCC",
+ "max_connections": 8
+ },
+
+ "aerial": {
+ "id": "Mapbox-v1",
+ "name": "Mapbox street tiles",
+ "license": "Imagery and map information provided by Mapbox and Open Street Map",
+ "license_uri": "http://www.openstreetmap.org/copyright",
+ "min_zoom_level": 0,
+ "max_zoom_level": 19,
+ "tile_size": 256,
+ "uri":
"https://api.mapbox.com/styles/v1/mapbox/satellite-v9/tiles/256/#Z#/#X#/#Y#?access_token=pk.eyJ1IjoiZ25vbWUtbWFwcyIsImEiOiJjaXF3a3lwbXkwMDJwaTBubmZlaGk4cDZ6In0.8aukTfgjzeqATA8eNItPJA&",
+ "attribution_logo":
"iVBORw0KGgoAAAANSUhEUgAAAIIAAAAoCAMAAAAFWtJHAAAAwFBMVEUAAAAAAAAAAABtbW0AAAAAAAAAAAAAAAAAAAAAAAClpaUAAADp6ekAAAD5+fna2toAAAAMDAzv7+/Nzc0AAAA2Njb8/Pz9/f3T09MAAAAAAAD7+/sAAAArKyuxsbH39/fs7OwbGxuIiIjz8/N8fHyenp7u7u74+P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ikKT3GBHCnXwydgmCC0tRwCnGQ2Wp6Be71yNIWfQSkOl9vAI1SBCNWrwC01RROgX7BuT2HI4r7tFAw086p/NwZEdOEa7R1uAFuNmQPuKAEAjYNQ0CyeoUEWHYBnpQVQgpvc0Ph+gsKlAnKg1+vEHsw5LKciLKCAJobiWBzYFGbCKpHqkZZrxBFHEASyFI59vJPCskcwNVGOWZAOqsrR+pKbaNeAMT1CixMEtlnsqopNxUMzVJT3tY35aXZm6a6Y9QhwMN6BUJWbE1lhbMO1WehkO7poO0sK7em9MJGxp1XSbC1gtugzzSLQmGsX7VntJGSwsPZ2d2z3bIPKzdoOp3Wzqt8G4XyMVUoFIxLx1S7+piaHtCvR3FeRVsq0GFdp9C5TbGpcNqsPqyHKxcfd14h21KhuLKUFU4f3osrC7F6uV3WXFnadL7wyAPeKDXw2RoJCO5GY4DouYvb/gepVXheLoewzPseQG9N/vzilrMIjoStE3++zvle4eSurw7XEe76ynI4aq+v7lEyt1x5awiFlFLQbHKIpabnM3eJLym4Szzzc/du7SU+zOXv9UNpECH7IoH/gecURPlN9vdQpeD47yhIFNX0U0QgvID9nENm+yxk/xb+AGAjNfRZuk9qAAAAAElFTkSuQmCC",
+ "max_connections": 8
+ }
+}
diff --git a/src/application.js b/src/application.js
index 5a452ee..31e684f 100644
--- a/src/application.js
+++ b/src/application.js
@@ -56,6 +56,7 @@ let checkInManager = null;
let contactStore = null;
let osmEdit = null;
let normalStartup = true;
+let service = null;
const _ensuredTypes = [WebKit2.WebView,
OSMTypeSearchEntry.OSMTypeSearchEntry];
@@ -101,6 +102,13 @@ const Application = new Lang.Class({
_("A path to a local tiles directory structure"),
null);
+ this.add_main_option('service',
+ 0,
+ GLib.OptionFlags.NONE,
+ GLib.OptionArg.STRING,
+ _("A path to a local service.json file"),
+ null);
+
this.connect('handle-local-options', (function(app, options) {
if (options.contains('local')) {
let variant = options.lookup_value('local', null);
@@ -108,6 +116,11 @@ const Application = new Lang.Class({
normalStartup = false;
}
+ if (options.contains('service')) {
+ service = options.lookup_value('service', null).deep_unpack();
+ log(service);
+ }
+
return -1;
}).bind(this));
},
diff --git a/src/mapSource.js b/src/mapSource.js
index 25e9526..cfe5060 100644
--- a/src/mapSource.js
+++ b/src/mapSource.js
@@ -26,6 +26,7 @@ const Gtk = imports.gi.Gtk;
const Lang = imports.lang;
const Soup = imports.gi.Soup;
+const Application = imports.application;
const Utils = imports.utils;
let _tileService = null;
@@ -51,6 +52,11 @@ const AttributionLogo = new Lang.Class({
}
});
+function _getLocalTileService() {
+ let buffer = Utils.readFile(Application.service);
+ return JSON.parse(buffer);
+}
+
function _getTileService() {
let user_agent = 'gnome-maps/' + pkg.version;
let session = new Soup.Session({ user_agent : user_agent });
@@ -121,7 +127,10 @@ function _createCachedSource(source) {
}
function createAerialSource() {
- _tileService = _getTileService();
+ if (Application.service)
+ _tileService = _getLocalTileService();
+ else
+ _tileService = _getTileService();
if (_tileService) {
_attributionData = _tileService.aerial.attribution_logo;
return _createCachedSource(_tileService.aerial);
@@ -131,7 +140,10 @@ function createAerialSource() {
};
function createStreetSource() {
- _tileService = _getTileService();
+ if (Application.service)
+ _tileService = _getLocalTileService();
+ else
+ _tileService = _getTileService();
if (_tileService) {
_attributionData = _tileService.street.attribution_logo;
return _createCachedSource(_tileService.street);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]