]> gerrit.simantics Code Review - simantics/district.git/blobdiff - org.simantics.maps.server/server/tileserver-mapnik/lib/index.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / server / tileserver-mapnik / lib / index.js
diff --git a/org.simantics.maps.server/server/tileserver-mapnik/lib/index.js b/org.simantics.maps.server/server/tileserver-mapnik/lib/index.js
new file mode 100644 (file)
index 0000000..40a02f1
--- /dev/null
@@ -0,0 +1,33 @@
+"use strict";
+
+module.exports.getInfo = function(source, callback) {
+  return source.getInfo(function(err, _info) {
+    if (err) {
+      return callback(err);
+    }
+
+    var info = {};
+
+    Object.keys(_info).forEach(function(key) {
+      info[key] = _info[key];
+    });
+
+    if (info.vector_layers) {
+      info.format = "pbf";
+      info.scheme = undefined;
+    } else {
+      info.autoscale = true;
+    }
+
+    info.name = info.name || "Untitled";
+    info.center = info.center || [-122.4440, 37.7908, 12];
+    info.bounds = info.bounds || [-180, -85.0511, 180, 85.0511];
+    info.format = info.format || "png";
+    info.minzoom = Math.max(0, info.minzoom | 0);
+    info.maxzoom = info.maxzoom || Infinity;
+
+    info.type = "baselayer";
+
+    return callback(null, info);
+  });
+};