# HG changeset patch # User StefanFunk # Date 1346335689 0 # Node ID 4fb15c3e0e8908c5b34488bd7bef3ce61c0a6444 # Parent 7bf904a68ce7fe2e17e27ee2f5e0fc1611847e44 - added some robustness: timespan and longitude/latitude values must not be ordered anymore. git-svn-id: http://dev.dariah.eu/svn/repos/eu.dariah.de/ap1/sti-gwt-dariah-geobrowser@88 f2b5be40-def6-11e0-8a09-b3c1cc336c6b diff -r 7bf904a68ce7 -r 4fb15c3e0e89 war/scripts/sti/STICore.js --- a/war/scripts/sti/STICore.js Fri Jul 20 12:55:58 2012 +0000 +++ b/war/scripts/sti/STICore.js Thu Aug 30 14:08:09 2012 +0000 @@ -1,6 +1,6 @@ /** * defines the core component of the Spatio Temporal Interface - * + * * @constructor */ function STICore(){ @@ -36,8 +36,8 @@ }, /** - * refines the given data by creating a new history entry - */ + * refines the given data by creating a new history entry + */ refine: function(){ if (this.refining > -2) { var contains = false; @@ -70,8 +70,8 @@ }, /** - * refines the given data by creating a new history entry - */ + * refines the given data by creating a new history entry + */ refineByTime: function(minTime,maxTime){ var minDate = new Date(parseInt(minTime)); var maxDate = new Date(parseInt(maxTime)); @@ -98,8 +98,8 @@ }, /** - * refines a given dataset by a given text snippet - */ + * refines a given dataset by a given text snippet + */ refineByText: function(text,index){ this.reset(); var dataset = this.history[this.historyIndex].dataSets[index]; @@ -113,9 +113,11 @@ }, /** - * adds selected elements of a specific dataset as a new dataset - * @param {int} id the id of the dataset - */ + * adds selected elements of a specific dataset as a new dataset + * + * @param {int} + * id the id of the dataset + */ storeSelected: function(id){ var dataSets = this.history[this.historyIndex].dataSets; if( dataSets.length == 4 ){ @@ -140,8 +142,8 @@ }, /** - * Adds a dataset to the actual history entry - */ + * Adds a dataset to the actual history entry + */ addDataSet: function( dataSet ){ var oldDataSets = this.history[this.historyIndex].dataSets; var newDataSets = oldDataSets.concat(dataSet); @@ -151,21 +153,24 @@ }, /** - * Sets the widgets for the core component - * - * @param {STIMap} map the javascript object of the map widget - * @param {STITimeplot} plot the javascript object of the timeplot widget - */ + * Sets the widgets for the core component + * + * @param {STIMap} + * map the javascript object of the map widget + * @param {STITimeplot} + * plot the javascript object of the timeplot widget + */ setElements: function(map, timeplot){ this.map = map; this.timeplot = timeplot; }, /** - * initializes the core component for the Spatio Temporal Interface. - * here, the handling of the search interface is defined (including undo, refine and clear selection button). - * furthermore, the elements (map, timeplot, tables) are instanciated. - */ + * initializes the core component for the Spatio Temporal Interface. here, + * the handling of the search interface is defined (including undo, refine + * and clear selection button). furthermore, the elements (map, timeplot, + * tables) are instanciated. + */ initialize: function(){ var context = this; @@ -255,14 +260,18 @@ }, /** - * constructs an url to a dynamic datasource with the specific user input as attribute - * @param {int} ds the datasource index - * @param {String} input the user input - */ + * constructs an url to a dynamic datasource with the specific user input as + * attribute + * + * @param {int} + * ds the datasource index + * @param {String} + * input the user input + */ retrieveKml: function(ds,input){ var url = this.sources[ds].url; -// var tags = input.replace(/[^a-zA-Z0-9]/g,","); -// url += tags; +// var tags = input.replace(/[^a-zA-Z0-9]/g,","); +// url += tags; url += input; /* test for csv flag in request parameters (see datasources.json) */ @@ -428,10 +437,13 @@ }, /** - * parses the kml-file which includes the results for a given search request - * @param {File} kmlFile - * @param {String} term the term identifier for the resulting dataset - */ + * parses the kml-file which includes the results for a given search request + * + * @param {File} + * kmlFile + * @param {String} + * term the term identifier for the resulting dataset + */ parseKml: function(kmlFile,term,ds){ var core = this; if( this.blocked ){ @@ -455,11 +467,14 @@ }, /** - * converts the csv-file, then parses the kml-file which includes the - * results for a given search request - * @param {File} csvFile - * @param {String} term the term identifier for the resulting dataset - */ + * converts the csv-file, then parses the kml-file which includes the + * results for a given search request + * + * @param {File} + * csvFile + * @param {String} + * term the term identifier for the resulting dataset + */ parseCsv: function(csvFile,term,ds){ var core = this; if( this.blocked ){ @@ -491,7 +506,12 @@ for (var i = 1; i < csvArray.length; i++) { var innerArray = csvArray[i]; kmlString += '\t\t\n'; - /* loop inner array */ + /* declare few variables */ + var timespanBegin = ""; + var timespanEnd = ""; + var longitude = ""; + var latitude = ""; + /* loop inner array */ for (var j = 0; j < innerArray.length; j++) { /* Name */ if (usedHeaders[j] == expectedHeaders[0]) { @@ -506,33 +526,40 @@ kmlString += '\t\t\t' + innerArray[j] + '\n'; } /* TimeStamp */ - if (usedHeaders[j] == expectedHeaders[5] && innerArray[j] != null) { + if (usedHeaders[j] == expectedHeaders[5]) { kmlString += '\t\t\t\n' + '\t\t\t\t' + innerArray[j] + '\n' + '\t\t\t\n'; } /* TimeSpan:begin */ - if (usedHeaders[j] == expectedHeaders[6] && innerArray[j] != null) { - kmlString += '\t\t\t\n' + - '\t\t\t\t' + innerArray[j] + '\n'; + if (usedHeaders[j] == expectedHeaders[6]) { + timespanBegin = innerArray[i]; } /* TimeSpan:end */ - if (usedHeaders[j] == expectedHeaders[7] && innerArray[j] != null) { - kmlString += '\t\t\t\t' + innerArray[j] + '\n' + - '\t\t\t\n'; + if (usedHeaders[j] == expectedHeaders[7]) { + timespanBegin = innerArray[i]; } - /* Longitude */ - if (usedHeaders[j] == expectedHeaders[3]) { - kmlString += '\t\t\t\n' + - '\t\t\t\t' + innerArray[j]; - } - /* Latitude */ - if (usedHeaders[j] == expectedHeaders[4]) { - kmlString += ',' + innerArray[j] + - '\n' + - '\t\t\t\n'; + /* Longitude */ + if (usedHeaders[j] == expectedHeaders[3]) { + longitude = innerArray[j]; + } + /* Latitude */ + if (usedHeaders[j] == expectedHeaders[4]) { + latitude = innerArray[j]; } } + /* set timespan:begin und timespan:end */ + kmlString += '\t\t\t\n' + + '\t\t\t\t' + timespanBegin + '\n' + + '\t\t\t\t' + timespanEnd + '\n' + + '\t\t\t\n'; + /* set longitude and latitude */ + kmlString += '\t\t\t\n' + + '\t\t\t\t' + + longitude +',' + latitude + + '\n' + + '\t\t\t\n';. + /* end Placemark */ kmlString += '\t\t\n'; } kmlString += '\t\n'; @@ -550,10 +577,13 @@ }, /** - * updates the timeplot and table element. - * its called from the STIMap object, when objects on the map had been selected by featureSelect or polygon. - * @param {boolean} hover true, if there was a hover selection - */ + * updates the timeplot and table element. its called from the STIMap + * object, when objects on the map had been selected by featureSelect or + * polygon. + * + * @param {boolean} + * hover true, if there was a hover selection + */ updateTimeAndTable: function(hover){ updateTables(hover); this.timeplot.polesBySlices(); @@ -561,9 +591,9 @@ }, /** - * updates the map, timeplot and table element. - * its called from the STITable object, when a text selection has been done - */ + * updates the map, timeplot and table element. its called from the STITable + * object, when a text selection has been done + */ updateMapAndTimeAndTable: function(index){ updateTables(hover); this.timeplot.polesBySlices(); @@ -572,9 +602,9 @@ }, /** - * updates the timeplot and map element. - * its called from the STITable object, when objects in one of the tables had been selected. - */ + * updates the timeplot and map element. its called from the STITable + * object, when objects in one of the tables had been selected. + */ updateTimeAndMap: function(){ this.map.updateMap(); this.timeplot.polesBySlices(); @@ -582,10 +612,13 @@ }, /** - * updates the table and map element. - * its called from the STITimeplot object, when objects in the timeplot had been selected by timestamp or -range. - * @param {boolean} hover true, if there was a hover selection - */ + * updates the table and map element. its called from the STITimeplot + * object, when objects in the timeplot had been selected by timestamp or + * -range. + * + * @param {boolean} + * hover true, if there was a hover selection + */ updateTableAndMap: function(hover){ updateTables(hover); this.map.updateMap(); @@ -593,9 +626,10 @@ }, /** - * initializes the sti components (map, timeplot, table) depending on the top masks of the data sets. - * its called after a new search was performed, refining or undo button had been clicked - */ + * initializes the sti components (map, timeplot, table) depending on the + * top masks of the data sets. its called after a new search was performed, + * refining or undo button had been clicked + */ initElements: function(){ this.reset(); var dataSets = this.history[this.historyIndex].dataSets; @@ -611,9 +645,11 @@ }, /** - * deletes a data set with specific index - * @param {int} index the index of the data set to delete - */ + * deletes a data set with specific index + * + * @param {int} + * index the index of the data set to delete + */ deleteDataSet: function(index){ var color = colors[index]; colors.splice(index, 1); @@ -631,18 +667,22 @@ }, /** - * Switches to another history entry with the given index - * @param {int} index the index of the history entry to load - */ + * Switches to another history entry with the given index + * + * @param {int} + * index the index of the history entry to load + */ switchThroughHistory: function( index ){ this.historyIndex = index; this.initElements(); }, /** - * Adds a new history entry containing actual datasets - * @param {HistoryEntry} historyEntry the history entry to add - */ + * Adds a new history entry containing actual datasets + * + * @param {HistoryEntry} + * historyEntry the history entry to add + */ addHistoryEntry: function( historyEntry ){ this.history = this.history.slice(0,this.historyIndex+1); this.history.push(historyEntry); @@ -651,9 +691,11 @@ }, /** - * adds an element to the user individual data set - * @param {DataObject} object the data object to add - */ + * adds an element to the user individual data set + * + * @param {DataObject} + * object the data object to add + */ addElement: function(object){ if (this.individualDataSet == null) { this.individualDataSet = new DataSet([], "individual", 0); @@ -667,8 +709,9 @@ }, /** - * resets the core within all elements and data objects to non-selection-status - */ + * resets the core within all elements and data objects to + * non-selection-status + */ reset: function(){ this.refining = -2; var dataSets = this.history[this.historyIndex].dataSets; @@ -684,8 +727,8 @@ }, /** - * Security hover unselection of elements if browser events got stucked - */ + * Security hover unselection of elements if browser events got stucked + */ undoHover: function(update){ this.map.hoverUnselect(); @@ -699,8 +742,10 @@ var mapZoom = this.map.openlayersMap.getZoom(); var data = []; // store complete history in data --> flow of history events - // history event can be: loading/deleting dataset, refinement by timerange/polygon at specific zoom level/point at specific zoom level, a loaded link history (this) - // flag for the ability to display stored history or not + // history event can be: loading/deleting dataset, refinement by + // timerange/polygon at specific zoom level/point at specific zoom + // level, a loaded link history (this) + // flag for the ability to display stored history or not }, lockScreen: function(){ @@ -724,7 +769,9 @@ /** * defines a history entry - * @param {DataSet[]} dataSets the datasets of this history entry + * + * @param {DataSet[]} + * dataSets the datasets of this history entry * * @constructor */