view js/datasourceLoader.js @ 4:1b6cde0e4b83 default tip

merger
author Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
date Mon, 12 Oct 2015 08:38:25 +0200
parents b57c7821382f
children
line wrap: on
line source

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);
        }
    }
}