Skip to content

Commit

Permalink
turf inside, forecast graphs, fixing ol3 build upgrade issues
Browse files Browse the repository at this point in the history
  • Loading branch information
eflowbeach committed Aug 31, 2016
1 parent 7bb6072 commit 1abfff6
Show file tree
Hide file tree
Showing 11 changed files with 380 additions and 15 deletions.
2 changes: 1 addition & 1 deletion build/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<meta charset="UTF-8" />
<title>Mobile EDD v1.7</title>
<title>Mobile EDD v1.8</title>

<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0" />
<meta name="apple-mobile-web-app-capable" content="yes" />
Expand Down
5 changes: 4 additions & 1 deletion build/resource/mobileedd/libs/flot/flot-combo.js

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions build/resource/mobileedd/libs/mobileeddlibs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions build/script/mobileedd.js

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions source/class/mobileedd/TravelHazards.js
Original file line number Diff line number Diff line change
Expand Up @@ -561,9 +561,8 @@ qx.Class.define("mobileedd.TravelHazards",

// Use departed at time for minute calculation
var roundHour = (departedAt.clone().add(timeTraveled, 'hours').format('m') < 30) ? 0 : 1;

// FIXME
var region = "conus";
var mercatorLL = ol.proj.transform([lon, lat], 'EPSG:4326', 'EPSG:3857');
var region = mobileedd.page.Map.getInstance().getNdfdRegion(mercatorLL);

//var region = me.dataStore.getNdfdRegionFromPoint(lat, lon);

Expand Down Expand Up @@ -849,7 +848,7 @@ qx.Class.define("mobileedd.TravelHazards",

// Get Geometry from LineFeature
var iconFeature = new ol.Feature( {
geometry : new ol.geom.Point(lineFeature.getGeometry().getFlatCoordinates().slice(0, 2))
geometry : new ol.geom.Point(lineFeature.getGeometry().getCoordinates()[0])
});
iconFeature.setProperties(pointProperties);
me.pointSource.addFeature(iconFeature);
Expand Down
3 changes: 3 additions & 0 deletions source/class/mobileedd/config/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ qx.Class.define("mobileedd.config.Config",
mesowestToken : {
init : "a13f6d0a32c842e6815c377e77a64e99"
},
mapQuestKey : {
init : "6hcuidlVtrh41AFzsdKyGxUfuuzz1LAu"
},
obDisplayedField : {
init : "Temperature"
}
Expand Down
298 changes: 297 additions & 1 deletion source/class/mobileedd/page/Forecast.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,54 @@ qx.Class.define("mobileedd.page.Forecast",
this.bus.subscribe("edd.forecast", function(e)
{
var ll = e.getData();
var mercatorLL = ol.proj.transform(ll, 'EPSG:4326', 'EPSG:3857');
var region = mobileedd.page.Map.getInstance().getNdfdRegion(mercatorLL);
var url = "http://preview.weather.gov/edd/resource/edd/ndfd/getNdfdMeteogramData.php?lat=" + mercatorLL[1] + '&lon=' + mercatorLL[0] + '&region=' + region; //conus';// + clickRegion//http://forecast.weather.gov/MapClick.php?lat=" + ll[1] + "&lon=" + ll[0] + "&FcstType=json";
var ndfdReq = new qx.io.request.Jsonp(url);
ndfdReq.setCallbackParam("callback");
ndfdReq.setCache(false);
ndfdReq.addListener("success", function(e)
{
var response = e.getTarget().getResponse();
if (typeof ($) == "undefined")
{
var req = new qx.bom.request.Script();
req.onload = function() {
me.plotData(response);
};
req.open("GET", "resource/mobileedd/libs/flot/flot-combo.js");
req.send();
} else
{
me.plotData(response);
}
})
ndfdReq.send();

//var url = me.c.getSecure() + "://forecast.weather.gov/MapClick.php?lat=" + ll[1] + "&lon=" + ll[1] + "&FcstType=json";

// var clickRegion = me.dataStore.getNdfdRegionFromPoint(lat, lon);

// me.reqNdfdHourlyData.setUrl("resource/edd/ndfd/getNdfdMeteogramData.php?lat=" + lonlat.lat + '&lon=' + lonlat.lon + '&region=' + clickRegion);

// // Send request

// me.reqNdfdHourlyData.send();
var url = "http://forecast.weather.gov/MapClick.php?lat=" + ll[1] + "&lon=" + ll[0] + "&FcstType=json";
var fxReq = new qx.io.request.Jsonp(url);
fxReq.setCallbackParam("callback");
fxReq.setCache(false);
fxReq.addListener("success", function(e)
{
var response = e.getTarget().getResponse();
var html = '';

//var html = '';
var html = '<div id="ftgraph" class="demo-placeholder"></div>';
html += '<div id="fwindgraph" class="demo-placeholder"></div>';
html += '<div id="fprecipgraph" class="demo-placeholder"></div>';
html += '<div id="fqpf" class="demo-placeholder"></div>';
html += '<div id="fwavegraph" class="demo-placeholder"></div>';
html += '<hr>';
var forecastFor = "<b>Forecast for:</b> " + response.location.areaDescription + "<font style=\"padding-left:10px;\">(Elevation: </font>" + response.location.elevation + " ft.)<br>";

//me.resultsWindow.setCaption("NWS Forecast for " + response.location.areaDescription + " (Elevation: " + response.location.elevation + " ft.) " + "Lat: " + response.location.latitude + " Lon: " + response.location.longitude);
Expand Down Expand Up @@ -84,6 +122,264 @@ qx.Class.define("mobileedd.page.Forecast",
fxReq.send();
}, this);
},
plotData : function(response)
{
var me = this;
console.log(response);
var cold = false;
response.t.forEach(function(obj) {
if (obj[1] <= 40) {
cold = true;
}
})
var axisFormat = "ha ddd<br>(M/D)";
$.plot("#ftgraph", [
{
label : "Temperature",
data : response.t,
color : 'red',
lines : {
show : true
}
},
{
label : "Dew Point",
data : response.td,
color : 'green',
lines : {
show : true
}
},
{
label : "32 &deg;F / Freezing",
data : [[response.t[0][0], 32], [response.t[response.t.length - 1][0], 32]],
color : "#5890C4",
dashes : {
show : (cold) ? true : false
},
lines : {
show : false
},
units : "&deg;F"
}],
{
units : '&deg;F',
legend :
{
show : true,
position : 'ne'
},
xaxis :
{
mode : "time",

// min: response.t[0][0],

// max: response.t[response.t.length-1][0],
tickFormatter : function(val, axis) {
return new moment(val).format(axisFormat);
}
},
axisLabels : {
show : true
},
yaxes : [
{
position : 'left',
axisLabel : '°F',
tickFormatter : function(val, axis) {
return val.toFixed(0);
}
}]
});

// Wind
$.plot("#fwindgraph", [
{
label : "Wind Speed",
data : response.windspd,
color : 'purple',
lines : {
show : true
}
},
{
label : "Wind Gust",
data : response.windgust,
color : 'blue',
points : {
show : true
}
}],
{
units : 'mph',
legend :
{
show : true,
position : 'ne'
},
xaxis :
{
mode : "time",
tickFormatter : function(val, axis) {
return new moment(val).format(axisFormat);
}
},
axisLabels : {
show : true
},
yaxes : [
{
position : 'left',
axisLabel : 'mph',
tickFormatter : function(val, axis) {
return val.toFixed(0);
}
}]
});
$.plot("#fqpf", [
{
label : "QPF",
data : response.qpf,
color : '#057100',
bars :
{
show : true,
barWidth : 3600 * 1000 * 6 // * 0.25 * 0.05
}
},
{
label : "Snow",
data : response.snowamt,
color : 'blue',
bars :
{
show : true,
barWidth : 3600 * 1000 * 6 // * 0.25 * 0.05
}
},
{
label : "Ice",
data : response.iceaccum,
color : '#E117E3',
bars :
{
show : true,
barWidth : 3600 * 1000 * 6 // * 0.25 * 0.05
}
}],
{
units : '"',
legend :
{
show : true,
position : 'ne'
},
xaxis :
{
mode : "time",
min : response.t[0][0],
max : response.t[response.t.length - 1][0],
tickFormatter : function(val, axis) {
return new moment(val).format(axisFormat);
}
},
axisLabels : {
show : true
},
yaxes : [
{
min : 0,
position : 'left',
axisLabel : '"',
tickFormatter : function(val, axis) {
return val.toFixed(2);
}
}]
});
$.plot("#fprecipgraph", [
{
label : "Precipitation",
data : response.pop12,
color : '#057100',
lines :
{
show : true,
fill : true

//barWidth : 3600 * 1000 * 12// * 0.25 * 0.05
}
}],
{
units : '%',
legend :
{
show : true,
position : 'ne'
},
xaxis :
{
mode : "time",
tickFormatter : function(val, axis) {
return new moment(val).format(axisFormat);
}
},
axisLabels : {
show : true
},
yaxes : [
{
position : 'left',
axisLabel : '%',
tickFormatter : function(val, axis) {
return val.toFixed(0);
}
}]
});
var marine = false;
response.waveheight.forEach(function(obj) {
if (obj[1] != null) {
marine = true;
}
})
if (marine) {
$('#fwavegraph').show();
} else {
$('#fwavegraph').hide();
}
$.plot("#fwavegraph", [
{
label : "Wave Height",
data : response.waveheight,
color : 'blue',
lines : {
show : true
}
}],
{
units : '"',
legend :
{
show : true,
position : 'ne'
},
xaxis :
{
mode : "time",
tickFormatter : function(val, axis) {
return new moment(val).format(axisFormat);
}
},
axisLabels : {
show : true
},
yaxes : [
{
position : 'left',
axisLabel : 'feet'
}]
});
},

// overridden
_back : function()
Expand Down
Loading

0 comments on commit 1abfff6

Please sign in to comment.