Permalink
Browse files

Reformatting.

  • Loading branch information...
1 parent b8a2353 commit 3bed8a04a2f5228e2cdd8b1f1d6db65cb8fdf7d9 @sramsay committed May 28, 2012
Showing with 786 additions and 786 deletions.
  1. +15 −15 alerts.go
  2. +28 −28 almanac.go
  3. +40 −40 astro.go
  4. +47 −47 conditions.go
  5. +13 −13 forecast.go
  6. +7 −7 forecast7.go
  7. +244 −244 history.go
  8. +14 −14 lookup.go
  9. +107 −107 planner.go
  10. +33 −33 tide.go
  11. +238 −238 wu.go
View
@@ -29,29 +29,29 @@
package main
import (
- "fmt"
+ "fmt"
)
type AlertConditions struct {
- Alerts []Alerts
+ Alerts []Alerts
}
type Alerts struct {
- Date string
- Expires string
- Description string
- Message string
+ Date string
+ Expires string
+ Description string
+ Message string
}
// printAlerts prints the alerts for a given station to standard out
func PrintAlerts(obs *AlertConditions, stationId string) {
- if len(obs.Alerts) == 0 {
- fmt.Println("No active alerts")
- } else {
- fmt.Printf("Station: %s\n", stationId)
- for _, a := range obs.Alerts {
- fmt.Printf("### %s ###\n\nIssued at %s\nExpires at %s\n%s\n",
- a.Description, a.Date, a.Expires, a.Message)
- }
- }
+ if len(obs.Alerts) == 0 {
+ fmt.Println("No active alerts")
+ } else {
+ fmt.Printf("Station: %s\n", stationId)
+ for _, a := range obs.Alerts {
+ fmt.Printf("### %s ###\n\nIssued at %s\nExpires at %s\n%s\n",
+ a.Description, a.Date, a.Expires, a.Message)
+ }
+ }
}
View
@@ -29,58 +29,58 @@
package main
import (
- "fmt"
+ "fmt"
)
type AlmanacConditions struct {
- Almanac Almanac
+ Almanac Almanac
}
type Almanac struct {
- Temp_high Temp_high
- Temp_low Temp_low
+ Temp_high Temp_high
+ Temp_low Temp_low
}
type Temp_high struct {
- Normal Normal
- Record Record
- Recordyear string
+ Normal Normal
+ Record Record
+ Recordyear string
}
type Temp_low struct {
- Normal Normal
- Record Record
- Recordyear string
+ Normal Normal
+ Record Record
+ Recordyear string
}
type Normal struct {
- F string
- C string
+ F string
+ C string
}
type Record struct {
- F string
- C string
+ F string
+ C string
}
// printAlmanac prints the Almanac for a given station to standard out
func PrintAlmanac(obs *AlmanacConditions, stationId string) {
- normalHighF := obs.Almanac.Temp_high.Normal.F
- normalHighC := obs.Almanac.Temp_high.Normal.C
- normalLowF := obs.Almanac.Temp_low.Normal.F
- normalLowC := obs.Almanac.Temp_low.Normal.C
+ normalHighF := obs.Almanac.Temp_high.Normal.F
+ normalHighC := obs.Almanac.Temp_high.Normal.C
+ normalLowF := obs.Almanac.Temp_low.Normal.F
+ normalLowC := obs.Almanac.Temp_low.Normal.C
- recordHighF := obs.Almanac.Temp_high.Record.F
- recordHighC := obs.Almanac.Temp_high.Record.C
- recordHYear := obs.Almanac.Temp_high.Recordyear
- recordLowF := obs.Almanac.Temp_low.Record.F
- recordLowC := obs.Almanac.Temp_low.Record.C
- recordLYear := obs.Almanac.Temp_low.Recordyear
+ recordHighF := obs.Almanac.Temp_high.Record.F
+ recordHighC := obs.Almanac.Temp_high.Record.C
+ recordHYear := obs.Almanac.Temp_high.Recordyear
+ recordLowF := obs.Almanac.Temp_low.Record.F
+ recordLowC := obs.Almanac.Temp_low.Record.C
+ recordLYear := obs.Almanac.Temp_low.Recordyear
- fmt.Printf("Normal high: %s\u00B0 F (%s\u00B0 C)\n", normalHighF, normalHighC)
- fmt.Printf("Record high: %s\u00B0 F (%s\u00B0 C) [%s]\n", recordHighF, recordHighC, recordHYear)
- fmt.Printf("Normal low : %s\u00B0 F (%s\u00B0 C)\n", normalLowF, normalLowC)
- fmt.Printf("Record low : %s\u00B0 F (%s\u00B0 C) [%s]\n", recordLowF, recordLowC, recordLYear)
+ fmt.Printf("Normal high: %s\u00B0 F (%s\u00B0 C)\n", normalHighF, normalHighC)
+ fmt.Printf("Record high: %s\u00B0 F (%s\u00B0 C) [%s]\n", recordHighF, recordHighC, recordHYear)
+ fmt.Printf("Normal low : %s\u00B0 F (%s\u00B0 C)\n", normalLowF, normalLowC)
+ fmt.Printf("Record low : %s\u00B0 F (%s\u00B0 C) [%s]\n", recordLowF, recordLowC, recordLYear)
}
View
@@ -29,63 +29,63 @@
package main
import (
- "fmt"
- "strconv"
+ "fmt"
+ "strconv"
)
type AstroConditions struct {
- Moon_phase Moon_phase
- Sunrise Sunrise
- Sunset Sunset
+ Moon_phase Moon_phase
+ Sunrise Sunrise
+ Sunset Sunset
}
type Moon_phase struct {
- PercentIlluminated string
- AgeOfMoon string
- Sunrise Sunrise
- Sunset Sunset
+ PercentIlluminated string
+ AgeOfMoon string
+ Sunrise Sunrise
+ Sunset Sunset
}
type Sunrise struct {
- Hour string
- Minute string
+ Hour string
+ Minute string
}
type Sunset struct {
- Hour string
- Minute string
+ Hour string
+ Minute string
}
// printAstro prints the lunar and solar informtion for a given station to standard out
func PrintAstro(obs *AstroConditions, stationId string) {
- var age, _ = strconv.Atoi(obs.Moon_phase.AgeOfMoon)
- var moonDesc string
+ var age, _ = strconv.Atoi(obs.Moon_phase.AgeOfMoon)
+ var moonDesc string
- // Calculate traditional description of lunar phase
+ // Calculate traditional description of lunar phase
- switch {
- case age < 2:
- moonDesc = "New moon"
- case age < 6:
- moonDesc = "Waxing crescent"
- case age < 9:
- moonDesc = "First quarter"
- case age < 13:
- moonDesc = "Waxing gibbous"
- case age < 17:
- moonDesc = "Full moon"
- case age < 20:
- moonDesc = "Waning gibbous"
- case age < 24:
- moonDesc = "Last quarter"
- case age < 28:
- moonDesc = "Waning crescent"
- }
- sr := obs.Moon_phase.Sunrise
- ss := obs.Moon_phase.Sunset
- percent := obs.Moon_phase.PercentIlluminated
- fmt.Printf("Moon Phase: %s (%s%% illuminated)\n", moonDesc, percent)
- fmt.Printf("Sunrise : %s:%s\n", sr.Hour, sr.Minute)
- fmt.Printf("Sunset : %s:%s\n", ss.Hour, ss.Minute)
+ switch {
+ case age < 2:
+ moonDesc = "New moon"
+ case age < 6:
+ moonDesc = "Waxing crescent"
+ case age < 9:
+ moonDesc = "First quarter"
+ case age < 13:
+ moonDesc = "Waxing gibbous"
+ case age < 17:
+ moonDesc = "Full moon"
+ case age < 20:
+ moonDesc = "Waning gibbous"
+ case age < 24:
+ moonDesc = "Last quarter"
+ case age < 28:
+ moonDesc = "Waning crescent"
+ }
+ sr := obs.Moon_phase.Sunrise
+ ss := obs.Moon_phase.Sunset
+ percent := obs.Moon_phase.PercentIlluminated
+ fmt.Printf("Moon Phase: %s (%s%% illuminated)\n", moonDesc, percent)
+ fmt.Printf("Sunrise : %s:%s\n", sr.Hour, sr.Minute)
+ fmt.Printf("Sunset : %s:%s\n", ss.Hour, ss.Minute)
}
View
@@ -29,64 +29,64 @@
package main
import (
- "fmt"
- "regexp"
+ "fmt"
+ "regexp"
)
type Conditions struct {
- Current_observation Current
+ Current_observation Current
}
type Current struct {
- Observation_time string
- Observation_location Location
- Station_id string
- Weather string
- Temperature_string string
- Relative_humidity string
- Wind_string string
- Pressure_mb string
- Pressure_in string
- Pressure_trend string
- Dewpoint_string string
- Heat_index_string string
- Windchill_string string
- Visibility_mi string
- Precip_today_string string
+ Observation_time string
+ Observation_location Location
+ Station_id string
+ Weather string
+ Temperature_string string
+ Relative_humidity string
+ Wind_string string
+ Pressure_mb string
+ Pressure_in string
+ Pressure_trend string
+ Dewpoint_string string
+ Heat_index_string string
+ Windchill_string string
+ Visibility_mi string
+ Precip_today_string string
}
type Location struct {
- Full string
+ Full string
}
// printConditions prints the conditions to standard output
func PrintConditions(obs *Conditions) {
- current := obs.Current_observation
- fmt.Printf("Current conditions at %s (%s)\n%s\n",
- current.Observation_location.Full, current.Station_id, current.Observation_time)
- fmt.Println(" Temperature:", current.Temperature_string)
- fmt.Println(" Sky Conditions:", current.Weather)
- fmt.Println(" Wind:", current.Wind_string)
- fmt.Println(" Relative humidity:", current.Relative_humidity)
- pstring := fmt.Sprintf(" Pressure: %s in (%s mb) and", current.Pressure_in, current.Pressure_mb)
- switch current.Pressure_trend {
- case "+":
- fmt.Println(pstring, "rising")
- case "-":
- fmt.Println(pstring, "falling")
- case "0":
- fmt.Println(pstring, "holding steady")
- }
- fmt.Println(" Dewpoint: ", current.Dewpoint_string)
- if current.Heat_index_string != "NA" {
- fmt.Println(" Heat Index: ", current.Heat_index_string)
- }
- if current.Windchill_string != "NA" {
- fmt.Println(" Windchill: ", current.Windchill_string)
- }
- fmt.Printf(" Visibility: %s miles\n", current.Visibility_mi)
- m, _ := regexp.MatchString("0.0", current.Precip_today_string)
- if !m {
- fmt.Println(" Precipitation today: ", current.Precip_today_string)
- }
+ current := obs.Current_observation
+ fmt.Printf("Current conditions at %s (%s)\n%s\n",
+ current.Observation_location.Full, current.Station_id, current.Observation_time)
+ fmt.Println(" Temperature:", current.Temperature_string)
+ fmt.Println(" Sky Conditions:", current.Weather)
+ fmt.Println(" Wind:", current.Wind_string)
+ fmt.Println(" Relative humidity:", current.Relative_humidity)
+ pstring := fmt.Sprintf(" Pressure: %s in (%s mb) and", current.Pressure_in, current.Pressure_mb)
+ switch current.Pressure_trend {
+ case "+":
+ fmt.Println(pstring, "rising")
+ case "-":
+ fmt.Println(pstring, "falling")
+ case "0":
+ fmt.Println(pstring, "holding steady")
+ }
+ fmt.Println(" Dewpoint: ", current.Dewpoint_string)
+ if current.Heat_index_string != "NA" {
+ fmt.Println(" Heat Index: ", current.Heat_index_string)
+ }
+ if current.Windchill_string != "NA" {
+ fmt.Println(" Windchill: ", current.Windchill_string)
+ }
+ fmt.Printf(" Visibility: %s miles\n", current.Visibility_mi)
+ m, _ := regexp.MatchString("0.0", current.Precip_today_string)
+ if !m {
+ fmt.Println(" Precipitation today: ", current.Precip_today_string)
+ }
}
View
@@ -29,33 +29,33 @@
package main
import (
- "fmt"
+ "fmt"
)
type ForecastConditions struct {
- Forecast Forecast
+ Forecast Forecast
}
type Forecast struct {
- Txt_forecast Txt_forecast
+ Txt_forecast Txt_forecast
}
type Txt_forecast struct {
- Date string
- Forecastday []Forecastday
+ Date string
+ Forecastday []Forecastday
}
type Forecastday struct {
- Title string
- Fcttext string
+ Title string
+ Fcttext string
}
// printForecast prints the forecast for a given station to standard out
func PrintForecast(obs *ForecastConditions, stationId string) {
- t := obs.Forecast.Txt_forecast
- fmt.Printf("Forecast for %s\n", stationId)
- fmt.Printf("Issued at %s\n", t.Date)
- for _, f := range t.Forecastday {
- fmt.Printf("%s: %s\n", f.Title, f.Fcttext)
- }
+ t := obs.Forecast.Txt_forecast
+ fmt.Printf("Forecast for %s\n", stationId)
+ fmt.Printf("Issued at %s\n", t.Date)
+ for _, f := range t.Forecastday {
+ fmt.Printf("%s: %s\n", f.Title, f.Fcttext)
+ }
}
Oops, something went wrong.

0 comments on commit 3bed8a0

Please sign in to comment.