diff --git a/src/com/hourlyweather/web/ForecastSymbolUtil.java b/src/com/hourlyweather/web/ForecastSymbolUtil.java deleted file mode 100644 index f64e324..0000000 --- a/src/com/hourlyweather/web/ForecastSymbolUtil.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.hourlyweather.web; - -import java.util.ArrayList; -import java.util.List; - -import com.hourlyweather.forecast.ForecastHour; - -/** - * Handles the forecast image resource selection for forecast hours - * - * @author dave - * - */ -public class ForecastSymbolUtil { - private static final List nightForecastSymbols = new ArrayList(); - private static final String IMG_DIR = "/images/weather/"; - - static { - nightForecastSymbols.add("LIGHTRAINSUN"); - nightForecastSymbols.add("LIGHTRAINTHUNDERSUN"); - nightForecastSymbols.add("PARTLYCLOUD"); - nightForecastSymbols.add("SLEETSUN"); - nightForecastSymbols.add("SNOWSUN"); - nightForecastSymbols.add("SUN"); - } - - /** - * returns the url to the associated symbol resource for a forecast hour - * - * @param forecastHour - * @return - */ - public static String getForecastSymbol(ForecastHour forecastHour) { - // if its night time check the night symbols first - if (!forecastHour.isSunUp()) - if (nightForecastSymbols.contains(forecastHour.getSymbol())) - return IMG_DIR + "night_" - + forecastHour.getSymbol().toLowerCase() + ".png"; - - return IMG_DIR + forecastHour.getSymbol().toLowerCase() + ".png"; - } -} diff --git a/src/com/hourlyweather/web/HourlyWeatherByCity.java b/src/com/hourlyweather/web/HourlyWeatherByCity.java deleted file mode 100644 index d4e7ecf..0000000 --- a/src/com/hourlyweather/web/HourlyWeatherByCity.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.hourlyweather.web; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.jsp.JspWriter; - -import org.joda.time.DateTime; - -import com.hourlyweather.forecast.ForecastBackFillUtil; -import com.hourlyweather.forecast.HourlyForecast; -import com.hourlyweather.yrno.forecast.ForecastFetcher; - -public class HourlyWeatherByCity { - public static void writeHourlyForecast(HttpServletRequest request, - JspWriter writer) throws Exception { - String city = (String) request.getAttribute("city"); - - // get the location for the requested city - Location location = CityLocationUtil.getLocation(city); - - // if the cities location wasn't found then alert the user - // TODO: error - if (location == null) - throw new Exception(city + " wasn't found."); - - // get the forecast - HourlyForecast forecast = new HourlyForecast(location.getLat(), - location.getLon(), new DateTime(), 36, location.getTimeZone()); - - // get the forecast - ForecastFetcher.getHourlyForecast(forecast); - // back fill the unpopulated forecast entries - ForecastBackFillUtil.backfillForecast(forecast); - - // write the forecast for the requested city - HourlyForecastBuilder.writeForecast(forecast, writer); - } -} - diff --git a/src/com/hourlyweather/web/HourlyWeatherByCityForward.java b/src/com/hourlyweather/web/HourlyWeatherByCityForward.java index f2d2b13..17c9048 100644 --- a/src/com/hourlyweather/web/HourlyWeatherByCityForward.java +++ b/src/com/hourlyweather/web/HourlyWeatherByCityForward.java @@ -20,8 +20,17 @@ protected void doGet(HttpServletRequest request, city = city.replaceAll("%20", " "); request.setAttribute("city", city); + Location location = CityLocationUtil.getLocation(city); + + if (location == null) + throw new LocationException(city + " wasn't found."); + + request.setAttribute("lat", location.getLat()); + request.setAttribute("lon", location.getLon()); + request.setAttribute("timeOffset", location.getTimeZone()); + RequestDispatcher dispatcher = getServletContext() - .getRequestDispatcher("/hourlyWeatherByCity.jsp"); + .getRequestDispatcher("/"); dispatcher.forward(request, response); } } diff --git a/src/com/hourlyweather/web/HourlyWeatherByLocationServlet.java b/src/com/hourlyweather/web/HourlyWeatherByLocationServlet.java index 411d74b..5c0cba6 100644 --- a/src/com/hourlyweather/web/HourlyWeatherByLocationServlet.java +++ b/src/com/hourlyweather/web/HourlyWeatherByLocationServlet.java @@ -36,9 +36,9 @@ public void doGet(HttpServletRequest req, HttpServletResponse resp) return; } - // get the forecast + // get the forecast for a full week HourlyForecast forecast = new HourlyForecast(lat, - lon, new DateTime(), 36, timezoneOffset); + lon, new DateTime(), 168, timezoneOffset); // get the forecast ForecastFetcher.getHourlyForecast(forecast); diff --git a/src/com/hourlyweather/web/LocationException.java b/src/com/hourlyweather/web/LocationException.java index dd97f1c..94cfe1a 100644 --- a/src/com/hourlyweather/web/LocationException.java +++ b/src/com/hourlyweather/web/LocationException.java @@ -4,4 +4,6 @@ public class LocationException extends ServletException { private static final long serialVersionUID = 1L; + + public LocationException(String msg) {super(msg);} } diff --git a/war/WEB-INF/web.xml b/war/WEB-INF/web.xml index ac74236..d20fae2 100644 --- a/war/WEB-INF/web.xml +++ b/war/WEB-INF/web.xml @@ -4,23 +4,24 @@ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> - - HourlyWeatherByCity - com.hourlyweather.web.HourlyWeatherByCityForward - HourlyWeatherByLocation com.hourlyweather.web.HourlyWeatherByLocationServlet + + + HourlyWeatherByCity + com.hourlyweather.web.HourlyWeatherByCityForward + - HourlyWeatherByLocation - /HourlyWeatherByLocation + HourlyWeatherByCity + /forecast/* - HourlyWeatherByCity - /city/* + HourlyWeatherByLocation + /HourlyWeatherByLocation diff --git a/war/hourlyWeatherByCity.jsp b/war/hourlyWeatherByCity.jsp deleted file mode 100644 index 93d9ace..0000000 --- a/war/hourlyWeatherByCity.jsp +++ /dev/null @@ -1,51 +0,0 @@ -<%@ page contentType="text/html;charset=UTF-8" language="java" %> -<%@ page import="com.hourlyweather.web.HourlyWeatherByCity" %> -<%@ page import="com.hourlyweather.web.CityLocationUtil" %> - - - - - - - - - - - - Hour Weather, your location aware hourly forecast - - - -

Hour Weather

-
where you are for when you're there
-
<% HourlyWeatherByCity.writeHourlyForecast(request, out); %>
- - -
Check out Hourly Weather on your Andoid phone!
- -
-
- <% boolean alt = false; - for(String city : CityLocationUtil.getLocations()) { %> - ><%= city %> - <% alt = !alt; } %> -
- - - \ No newline at end of file diff --git a/war/hourlyWeatherByLocation.jsp b/war/hourlyWeatherByLocation.jsp index 7c201e2..b2ce045 100644 --- a/war/hourlyWeatherByLocation.jsp +++ b/war/hourlyWeatherByLocation.jsp @@ -31,6 +31,8 @@ color:#333; } + a {color: #333;} + h2 { font-size:15px; display:inline; @@ -102,7 +104,7 @@ #forecast { min-height: 500px; - margin-top:-20px; + margin-top:-50px; } .controls { @@ -121,13 +123,6 @@ float:left; } - .hour { - background:rgb(250,250,250); - overflow:auto; - padding:5px 0; - border-bottom: 2px solid rgb(230,230,230); - } - .day-start { background:#d8f6ea; line-height: 80px; @@ -136,6 +131,69 @@ font-size:20px; } + #links { + float:right; + text-align:right; + margin-top:-30px; + } + + #links a { + text-decoration:none; + background: white; + border-radius: 5px; + padding:5px; + } + + #links a:hover { + padding:8px; + } + + #links a.selected { + padding:8px; + } + + #forecast .day { + display:block; + color:#333; + height:150px; + text-decoration:none; + } + #forecast .day:hover {background:#E7CCB2;} + + .day .date { + float:left; + width: 150px; + } + + #forecast .day div {text-align:center; width: 166px; float:left} + .day .date {padding-top: 30px;} + .day .date .day-of-week {font-size: 25px;} + .day .date .month {font-size: 16px;} + .day .date .day-of-month {font-size: 40px;} + .day .date .day-of-month span {font-size: 12px;} + + #forecast .day .icon.single .symbol {height: 105px;width:105px;margin-top:10px;background-size: 1629px 445px;} + .day .icon.single .symbol.right {display:none} + + .day .icon.double .symbol.left {width:75px;} + .day .icon.double .symbol.right {width:75px;} + + #forecast .day div.wind {width: 250px} + #forecast .day div.temp {width: 250px} + #forecast .day div.precip {} + .day label {display:block; padding-top: 40px;} + .day .val {font-size: 25px; padding-top: 20px; display:block} + + .hour { + padding:5px 0; + } + + .row { + background:rgb(250,250,250); + overflow:auto; + border-bottom: 2px solid rgb(230,230,230); + } + .hour.alt {background: #dcefff} .hour.night {background:#d8dfe4; border-bottom: 2px solid rgb(200,200,220);} @@ -376,13 +434,17 @@