Skip to content
Snippets Groups Projects
Commit af88fa74 authored by icyrizard's avatar icyrizard
Browse files

Plotting is almost possible

parent ecd37581
No related branches found
No related tags found
No related merge requests found
Showing
with 360 additions and 49 deletions
// GET /drfsm/<test_id>/results/izid/<izid>.csv
// for example
// GET /drfsm/5/results/izid/1234.csv
Ext.define('app.Api', {
mixins: ['Ext.mixin.Observable'],
singleton: true,
getIzid: function(lat, lng, area_id) {
var me = this;
var requestName = Ext.Ajax.request({
method: 'GET',
url: 'http://sangkil.science.uva.nl:8003/area/1/izid.json?latlng=' + lat + ',' + lng,
success: function(response, opts){
var result = Ext.decode(response.responseText);
me.fireEvent('gotIzid', result['izid']);
},
failure: function(){
console.log('failed to get izid');
}
});
},
getCsvFile: function(test_id, izid) {
console.log(izid);
console.log()
console.log('/drfsm/'+test_id+'/results/izid/'+izid+'.csv');
var me = this;
var requestName = Ext.Ajax.request({
method: 'GET',
url: 'http://sangkil.science.uva.nl:8003/drfsm/'+test_id+'/results/izid/'+izid+'.csv',
success: function(response, opts){
console.log(opts)
me.fireEvent('gotCsv', response.responseText)
},
failure: function(){
console.log('failed to get csv file');
}
});
}
});
\ No newline at end of file
Ext.define('app.chartData', {
singleton: true,
init: function(){
self.csvFiles = new Array();
},
setCsvFile: function(file){
self.csvFiles.push(file)
}
});
\ No newline at end of file
Ext.define('app.controller.ChartController', {
extend: 'Ext.app.Controller',
requires: ['app.Api'],
config: {
refs: {
Floodchart: {
xtype: 'floodChart',
selector: 'flood-chart',
autoCreate: true,
},
chartData : {
selector: 'flood-chart-id',
autoCreate: true,
},
mapView: 'SimulationMap',
},
control: {
'#mapa': {
maprender: 'addListener'
},
'#closeChart': {
tap: 'closeFloodChart'
}
},
},
init: function(){
me = this;
app.Api.on({
gotIzid: function(izid){
app.Api.getCsvFile(me.getMapView().testId, izid);
},
gotCsv: function(result){
me.plot(result);
}
});
},
addListener: function(){
me = this;
this.getMapView().on({
gotClick: function(event){
app.Api.getIzid(event.latLng.lat(), event.latLng.lng())
}
});
},
plot: function(result){
array = result.split('\n');
store = Ext.getStore('chartStore');
columns = array[0];
volume = [];
time = [];
data = []
for (i = 1; i < array.length; i++)
{
line_clmns = array[i].split(',');
data.push({
time : time.push(parseInt(line_clmns[0]) + i * 100),
volume : volume.push(line_clmns[1])
});
}
console.log(data);
this.openChart();
},
getFile: function(result){
app.Api.getCsvFile(result['izid']);
},
closeFloodChart: function(){
this.getFloodchart().hide();
},
getData: function(latLng){
app.Api.getIzid(latLng.lat(), latLng.lng())
},
openChart: function(){
this.getFloodchart().showBy(this.getMapView());
},
});
\ No newline at end of file
Ext.define('app.controller.Lsm', {
extend: 'Ext.app.Controller',
config: {
refs: {
},
control: {
}
},
//called when the Application is launched, remove if not needed
launch: function(app) {
}
});
\ No newline at end of file
...@@ -111,20 +111,24 @@ Ext.define('app.controller.Main', { ...@@ -111,20 +111,24 @@ Ext.define('app.controller.Main', {
} }
}, },
initiateCities: function(){ init: function() {
this.selectedIndex = [];
/*default simulation type*/
this.SimulType = 'Flood';
this.test_id = null;
},
initiateCities: function() {
this.getSimOptionsButton().show(); this.getSimOptionsButton().show();
}, },
/* first function to call */ /* first function to call */
setMap: function(extmap, map){ setMap: function(extmap, map) {
this.test_id = null;
this.globalMap = map; this.globalMap = map;
this.getMapView().setGlobalMap(extmap, map); this.getMapView().setGlobalMap(extmap, map);
this.selectedIndex = [];
/*default simulation type*/
this.SimulType = 'Flood';
}, },
stopBackwImages: function(button){ stopBackwImages: function(button) {
clearInterval(this.interval); clearInterval(this.interval);
button.hide(); button.hide();
this.getPlayBackw().show(); this.getPlayBackw().show();
...@@ -194,11 +198,9 @@ Ext.define('app.controller.Main', { ...@@ -194,11 +198,9 @@ Ext.define('app.controller.Main', {
* of the simulation panel * of the simulation panel
*/ */
simulate: function(list, index, element, record) { simulate: function(list, index, element, record) {
console.log('simulate call');
var me = this; var me = this;
/*first, remove all images, even if there werent any*/ /*first, remove all images, even if there werent any*/
this.getMapView().removeImages(); this.getMapView().removeImages();
//console.log(this.getOverlay());
/*create reference, cb looses scope of this.*/ /*create reference, cb looses scope of this.*/
var map = this.getMapView(), var map = this.getMapView(),
/*The simulationDetailStore has the details of the get test_id*/ /*The simulationDetailStore has the details of the get test_id*/
...@@ -215,9 +217,11 @@ Ext.define('app.controller.Main', { ...@@ -215,9 +217,11 @@ Ext.define('app.controller.Main', {
*/ */
var cb = function(result){ var cb = function(result){
var timesteps = result['timesteps'] || result['images']; var timesteps = result['timesteps'] || result['images'];
console.log(timesteps); if (timesteps.length > 0){
if (timesteps.length > 0)
map.createOverlayImage(bounds, test_id, timesteps, me.SimulType); map.createOverlayImage(bounds, test_id, timesteps, me.SimulType);
map.testId = result['test_id'];
map.areaId = result['area_id'];
}
} }
var store = Ext.getStore('SimulationDetailsStore'); var store = Ext.getStore('SimulationDetailsStore');
...@@ -230,12 +234,10 @@ Ext.define('app.controller.Main', { ...@@ -230,12 +234,10 @@ Ext.define('app.controller.Main', {
/* The information of the simulation, has data of the time /* The information of the simulation, has data of the time
* steps available, crucial data for the displaying the images. * steps available, crucial data for the displaying the images.
*/ */
//console.log(this.getSimulationOptions().getSelectedCls())
var url = ''; var url = '';
if (this.SimulType == 'Flood') if (this.SimulType == 'Flood')
{ {
url = 'http://sangkil.science.uva.nl:8003/drfsm/'+ test_id +'/info.json'; url = 'http://sangkil.science.uva.nl:8003/drfsm/'+ test_id +'/info.json';
console.log(this.SimulType);
} }
else url = 'http://sangkil.science.uva.nl:8003/lsm/'+ test_id +'/visualization/paru/info.json'; else url = 'http://sangkil.science.uva.nl:8003/lsm/'+ test_id +'/visualization/paru/info.json';
this.requestInfo(test_id, cb, url); this.requestInfo(test_id, cb, url);
...@@ -251,8 +253,6 @@ Ext.define('app.controller.Main', { ...@@ -251,8 +253,6 @@ Ext.define('app.controller.Main', {
*/ */
showList: function(list, index, element, record){ showList: function(list, index, element, record){
this.getSimOptionsButton().hide(); this.getSimOptionsButton().hide();
//console.log(this.getSimulationOptions());
//this.getSimulationOptions().hide();
/*Remove images, even if there werent any*/ /*Remove images, even if there werent any*/
this.getMapView().removeImages(); this.getMapView().removeImages();
/*store center*/ /*store center*/
...@@ -272,15 +272,15 @@ Ext.define('app.controller.Main', { ...@@ -272,15 +272,15 @@ Ext.define('app.controller.Main', {
var store_lsm = Ext.getStore('LsmStore'); var store_lsm = Ext.getStore('LsmStore');
store_lsm.clearFilter(); store_lsm.clearFilter();
store_lsm.filter("area_id", area_id); store_lsm.filter("area_id", area_id);
/* clear filter, if the flters are not cleared, they will
* be filtered on top of each other, resuting in an unwanted /* clear filter, if the filters are not cleared, they will
* state. * be filtered on top of each other, resulting in an unwanted
* state of the store.
*/ */
store.clearFilter(); store.clearFilter();
store.filter("area_id", area_id); store.filter("area_id", area_id);
/*push the side panel, in future create the view somewhere else*/ /*push the side panel, in future create the view somewhere else*/
console.log(this.SimulType);
if (this.SimulType == 'Flood') if (this.SimulType == 'Flood')
{ {
this.setThumb(center); this.setThumb(center);
...@@ -290,7 +290,6 @@ Ext.define('app.controller.Main', { ...@@ -290,7 +290,6 @@ Ext.define('app.controller.Main', {
this.getSidepanel().push(this.getLsmSimulation()); this.getSidepanel().push(this.getLsmSimulation());
/*set thumb images*/ /*set thumb images*/
//this.setThumb(center);
/*the store with details of the of the simulation*/ /*the store with details of the of the simulation*/
var store = Ext.getStore('SimulationDetailsStore'); var store = Ext.getStore('SimulationDetailsStore');
...@@ -300,12 +299,12 @@ Ext.define('app.controller.Main', { ...@@ -300,12 +299,12 @@ Ext.define('app.controller.Main', {
if (selected == false) if (selected == false)
{ {
this.selectedIndex.push(index);
var dikes = null; var dikes = null;
var bounds = record.get('visbounds'); var bounds = record.get('visbounds');
var corners = record.get('corners'); var corners = record.get('corners');
/*Make sure this is not done again*/
this.selectedIndex.push(index);
store.each(function(r) { store.each(function(r) {
dikes = r.get('dikes'); dikes = r.get('dikes');
}); });
......
Ext.define('app.helper.Map', {
xtype: 'MapHelper',
func: function(){
console.log(func);
}
});
\ No newline at end of file
Ext.define('app.store.LsmStore', {
extend: 'Ext.data.Store',
config: {
autoLoad: true,
fields: ['area_id', 'test_id', 'submitted'],
proxy: {
type: 'rest',
url: 'http://sangkil.science.uva.nl:8003/lsm/list.json',
reader: {
type: 'json',
rootProperty: 'simulations'
}
}
}
});
\ No newline at end of file
Ext.define('app.store.SimulationDetailsStore', { Ext.define('app.store.SimulationDetailsStore', {
extend: 'Ext.data.Store', extend: 'Ext.data.Store',
requires: ['app.CustomProxy'], requires: ['Ext.data.proxy.Rest'],
xtype: 'SimulationDetailsStore', xtype: 'SimulationDetailsStore',
config: { config: {
......
Ext.define('app.store.chartStore', {
extend: 'Ext.data.JsonStore',
config : {
fields: ['name', 'data1', 'data2', 'data3', 'data4', 'data5'],
data: [
{'name':'metric one', 'data1':10, 'data2':12, 'data3':14, 'data4':8, 'data5':13},
{'name':'metric two', 'data1':7, 'data2':8, 'data3':16, 'data4':10, 'data5':3},
{'name':'metric three', 'data1':5, 'data2':2, 'data3':14, 'data4':12, 'data5':7},
{'name':'metric four', 'data1':2, 'data2':14, 'data3':6, 'data4':1, 'data5':23},
{'name':'metric five', 'data1':27, 'data2':38, 'data3':36, 'data4':13, 'data5':33}
]
}
});
\ No newline at end of file
...@@ -9,23 +9,117 @@ ...@@ -9,23 +9,117 @@
// }] // }]
// }); // });
var chart = new Ext.chart.Chart({ // var store = new Ext.data.JsonStore({
width: 200, // fields: ['name', 'data1', 'data2', 'data3', 'data4', 'data5'],
height: 200, // data: [
animate: true, // {'name':'metric one', 'data1':10, 'data2':12, 'data3':14, 'data4':8, 'data5':13},
}); // {'name':'metric two', 'data1':7, 'data2':8, 'data3':16, 'data4':10, 'data5':3},
// {'name':'metric three', 'data1':5, 'data2':2, 'data3':14, 'data4':12, 'data5':7},
// {'name':'metric four', 'data1':2, 'data2':14, 'data3':6, 'data4':1, 'data5':23},
// {'name':'metric five', 'data1':27, 'data2':38, 'data3':36, 'data4':13, 'data5':33}
// ]
// });
// var chart = new Ext.chart.Chart({
// //animate: true,
// store: store,
// width: 500,
// height: 200,
// axes: [
// {
// type: "Numeric",
// position: 'left',
// fields: ['data1', 'data2', 'data3', 'data4', 'data5'],
// title: 'Numeric',
// minimum: 0,
// },
// {
// type: 'Category',
// position: 'bottom',
// fields: ['name'],
// title: 'Category',
// label: {
// rotate: {
// degrees: 35
// }
// }
// }
// ],
// series: [{
// type: 'area',
// highlight: false,
// axis: 'left',
// xField: 'name',
// yField: ['data1', 'data2', 'data3', 'data4', 'data5'],
// style: {
// opacity: 0.93
// }
// }]
// });
Ext.define('app.view.Chart', { Ext.define('app.view.Chart', {
extend: 'Ext.chart.Panel', extend: 'Ext.Panel',
id: 'flood-chart', id: 'flood-chart',
xtype: 'floodChart', xtype: 'floodChart',
requires: ['Ext.data.Store'],
config: { config: {
width: 100, width: 520,
height: 100, height: 220,
draggable: true, draggable: true,
items: [chart] items: [{
} xtype: 'chart',
id: 'flood-chart-id',
store: 'chartStore',
width: 500,
height: 200,
axes: [
{
type: "Numeric",
position: 'left',
fields: ['data1', 'data2', 'data3', 'data4', 'data5'],
title: 'Numeric',
minimum: 0,
},
{
type: 'Category',
position: 'bottom',
fields: ['name'],
title: 'Category',
label: {
rotate: {
degrees: 35
}
}
}
],
series: [{
type: 'area',
highlight: false,
axis: 'left',
xField: 'name',
yField: ['data1', 'data2', 'data3', 'data4', 'data5'],
style: {
opacity: 0.93
}
}]
},
{
xtype: 'button',
ui: 'circle ',
id: 'closeChart',
left: -15,
top: -15,
width: 30,
height: 30,
cls: 'closebutton',
style: 'background: url(resources/images/closebutton50.png) no-repeat; background-size: 30px; border: none',
}]
}
}); });
// (function(){ // (function(){
......
...@@ -29,7 +29,7 @@ Ext.define("app.view.List", ...@@ -29,7 +29,7 @@ Ext.define("app.view.List",
items: [ items: [
{ {
title: 'city\'s', title: 'Locations',
id: 'cities', id: 'cities',
xtype: 'list', xtype: 'list',
ui: 'round', ui: 'round',
......
...@@ -22,7 +22,10 @@ Ext.define('app.view.Map', { ...@@ -22,7 +22,10 @@ Ext.define('app.view.Map', {
this.Images = []; this.Images = [];
this.imageIndex = 0; this.imageIndex = 0;
this.imageBounds = null; this.imageBounds = null;
this.play = false; this.play = false;
this.testId = 0;
this.areaId = 0;
this.listener_ref = null;
} }
} }
}, },
...@@ -34,11 +37,6 @@ Ext.define('app.view.Map', { ...@@ -34,11 +37,6 @@ Ext.define('app.view.Map', {
setGlobalMap: function(extmap, map){ setGlobalMap: function(extmap, map){
this.globalMap = map; this.globalMap = map;
this.globalExtMap = extmap; this.globalExtMap = extmap;
google.maps.event.addListener(map, 'click', function(){
console.log('click');
});
//this.globalMap.on('click', );
}, },
setCenterMap: function(center){ setCenterMap: function(center){
...@@ -75,7 +73,7 @@ Ext.define('app.view.Map', { ...@@ -75,7 +73,7 @@ Ext.define('app.view.Map', {
* Bounds: array(4) * Bounds: array(4)
*/ */
createOverlayImage: function(bounds, area_id, timesteps, simulationType) { createOverlayImage: function(bounds, area_id, timesteps, simulationType) {
console.log(timesteps); var me = this;
var url = ''; var url = '';
if (simulationType == 'Flood') if (simulationType == 'Flood')
{ {
...@@ -86,7 +84,6 @@ Ext.define('app.view.Map', { ...@@ -86,7 +84,6 @@ Ext.define('app.view.Map', {
url = 'http://sangkil.science.uva.nl:8003/lsm/' + area_id + '/visualization/paru/map/'; url = 'http://sangkil.science.uva.nl:8003/lsm/' + area_id + '/visualization/paru/map/';
} }
else return false; else return false;
console.log(url);
this.imageIndex = 0; this.imageIndex = 0;
this.imageBounds = new google.maps.LatLngBounds( this.imageBounds = new google.maps.LatLngBounds(
new google.maps.LatLng(bounds[2],bounds[3]), new google.maps.LatLng(bounds[2],bounds[3]),
...@@ -100,29 +97,41 @@ Ext.define('app.view.Map', { ...@@ -100,29 +97,41 @@ Ext.define('app.view.Map', {
//var image = 'http://sangkil.science.uva.nl:8003/drfsm/' + area_id + '/visualization/level/map/' + timesteps[i] + '.png'; //var image = 'http://sangkil.science.uva.nl:8003/drfsm/' + area_id + '/visualization/level/map/' + timesteps[i] + '.png';
var image = new Image(); var image = new Image();
image.src = url + timesteps[i] + '.png'; image.src = url + timesteps[i] + '.png';
console.log(image.src);
this.overlayImages.push(new google.maps.GroundOverlay(image.src, this.imageBounds)); this.overlayImages.push(new google.maps.GroundOverlay(image.src, this.imageBounds));
} }
this.overlayImages[0].setMap(this.globalMap); this.overlayImages[0].setMap(this.globalMap);
this.imageIndex = this.overlayImages.length; this.imageIndex = this.overlayImages.length;
/*remove clickevent and add to new image*/
if (this.listeners_ref != null)
google.maps.event.removeListener(listenerHandle);
this.listeners_ref = google.maps.event.addListener(this.overlayImages[0], 'click', function(event){
me.fireEvent('gotClick', event);
});
}, },
/* set next Image*/ /* set next Image*/
nextImage: function() nextImage: function()
{ {
var me = this;
if (this.overlayImages.length <= 1) if (this.overlayImages.length <= 1)
return; return;
var lastIndex = (this.overlayImages.length + this.imageIndex) % this.overlayImages.length; var lastIndex = (this.overlayImages.length + this.imageIndex) % this.overlayImages.length;
this.imageIndex = (this.overlayImages.length + this.imageIndex + 1) % this.overlayImages.length; this.imageIndex = (this.overlayImages.length + this.imageIndex + 1) % this.overlayImages.length;
//this.imageIndex = (this.overlayImages.length + this.imageIndex + 1) % (this.overlayImages.length); //this.imageIndex = (this.overlayImages.length + this.imageIndex + 1) % (this.overlayImages.length);
console.log(this.imageIndex);
//this.overlayImages[this.imageIndex - 1].setMap(null); //this.overlayImages[this.imageIndex - 1].setMap(null);
this.overlayImages[this.imageIndex].setMap(this.globalMap); this.overlayImages[this.imageIndex].setMap(this.globalMap);
this.overlayImages[lastIndex].setMap(null);
//this.imageIndex = (this.imageIndex + 1) % (this.overlayImages.length);
console.log(this.imageIndex);
if (this.listeners_ref != null)
google.maps.event.removeListener(listenerHandle);
this.listeners_ref = google.maps.event.addListener(this.overlayImages[this.imageIndex], 'click', function(event){
me.fireEvent('gotClick', event);
});
this.overlayImages[lastIndex].setMap(null);
//this.imageIndex = (this.imageIndex + 1) % (this.overlayImages.length)
}, },
/*set prev image*/ /*set prev image*/
...@@ -169,7 +178,7 @@ Ext.define('app.view.Map', { ...@@ -169,7 +178,7 @@ Ext.define('app.view.Map', {
getCurrentImage: function(){ getCurrentImage: function(){
if (this.overlayImages.length > 0) { if (this.overlayImages.length > 0) {
this.overlayImages[this.imageIndex]; this.overlayImages[this.imageIndex];
return this.overlayImages[this.imageIndex].url; return this.overlayImages[this.imageIndex];
} }
}, },
......
Source diff could not be displayed: it is too large. Options to address this: view the blob.
www/resources/images/closebutton20.png

3.63 KiB

www/resources/images/closebutton50.png

5.19 KiB

www/resources/images/clsbtn50.png

6.74 KiB

...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
@include pictos-iconmask('close_overlay'); @include pictos-iconmask('close_overlay');
@include pictos-iconmask('play1'); @include pictos-iconmask('play1');
@include pictos-iconmask('pause'); @include pictos-iconmask('pause');
@include pictos-iconmask('closebutton50');
@include pictos-iconmask('clsbtn50');
@include pictos-iconmask('list'); @include pictos-iconmask('list');
@include sencha-toolbar-ui('darker_blue', #003F69, 'glossy'); @include sencha-toolbar-ui('darker_blue', #003F69, 'glossy');
@include sencha-toolbar-ui('lighter_blue', #00538F, 'glossy'); @include sencha-toolbar-ui('lighter_blue', #00538F, 'glossy');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment