diff js/datasourceLoader.js @ 0:b57c7821382f

initial
author Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
date Thu, 28 May 2015 10:28:12 +0200
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/js/datasourceLoader.js	Thu May 28 10:28:12 2015 +0200
@@ -0,0 +1,33 @@
+var DataSourceLoader = function(type, source, description) {
+    this.Type = type;
+    this.Source = source;
+    this.Description = description;
+
+    this.loadDataset = function() {
+        if (this.Type == "kml") {
+            var mpiwg_geobrowser_kmlFile = GeoTemConfig.getKml(this.Source);
+            var dataSet = new Dataset(GeoTemConfig.loadKml(mpiwg_geobrowser_kmlFile), this.Description);
+            GeoTemConfig.addDataset(dataSet);
+        }
+        else if (this.Type == "mysql") {
+            function stringToXML(text){
+                if (window.ActiveXObject){
+                    var doc = new ActiveXObject("Microsoft.XMLDOM");
+                    doc.async = "false";
+                    doc.loadXML(text);
+                } else {
+                    var parser = new DOMParser();
+                    var doc = parser.parseFromString(text, "text/xml");
+                }
+                return doc;
+            }
+            var mpiwg_geobrowser_kmlFile = stringToXML(this.Source);
+            var dataSet = new Dataset(GeoTemConfig.loadKml(mpiwg_geobrowser_kmlFile), this.Description);
+            GeoTemConfig.addDataset(dataSet);
+        }
+        else if (this.Type == "json") {
+            var dataSet = new Dataset(GeoTemConfig.loadJson(this.Source), this.Description);
+            GeoTemConfig.addDataset(dataSet);
+        }
+    }
+}
\ No newline at end of file