forked from codeforboston/home-energy-analysis-tool
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add file field to EnergyUseHistory Co-authored-by: Camden Blatchly <[email protected]> Co-authored-by: hectorbenitez19 <[email protected]> * fix typo on livingArea (wrongly livingSpace) to allow submitting, trial of Pyodide, commented Co-authored-by: Hector Benitez <[email protected]> Co-authored-by: plocket <[email protected]> Co-authored-by: Steve Breit <[email protected]> Co-authored-by: thatoldplatitude <[email protected]> --------- Co-authored-by: plocket <[email protected]> Co-authored-by: Camden Blatchly <[email protected]> Co-authored-by: hectorbenitez19 <[email protected]> Co-authored-by: plocket <[email protected]> Co-authored-by: Steve Breit <[email protected]> Co-authored-by: thatoldplatitude <[email protected]>
- Loading branch information
1 parent
793cacc
commit 8e8a939
Showing
8 changed files
with
367 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const BASE_URL = "https://geocoding.geo.census.gov"; | ||
const ADDRESS_ENDPOINT = "/geocoder/locations/address"; | ||
const params = new URLSearchParams(); | ||
|
||
class GeocodeUtil { | ||
|
||
/** | ||
* | ||
* @param {*} street | ||
* @param {*} city | ||
* @param {*} state | ||
* @returns x,y {x,y} lon/lat. If the given address was valid. I've implemented 0 handling here. | ||
* This is the happiest of paths, with hardcoded values also... | ||
*/ | ||
async getLL(address) { | ||
params.append("onelineaddress",address); | ||
params.append("format","json"); | ||
params.append("benchmark",2020); | ||
|
||
let url = new URL(BASE_URL+ADDRESS_ENDPOINT+"?"+params.toString()); | ||
let rezzy = await fetch(url); | ||
let jrez = await rezzy.json(); | ||
let coordz = jrez.result.addressMatches[0].coordinates; | ||
console.log(coordz); | ||
return coordz; | ||
} | ||
} | ||
|
||
export default GeocodeUtil; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { time } from "console"; | ||
|
||
const BASE_URL = "https://archive-api.open-meteo.com"; | ||
const WHATEVER_PATH = "/v1/archive"; | ||
const params = new URLSearchParams(); | ||
|
||
class WeatherUtil { | ||
|
||
async getThatWeathaData(longitude,latitude,startDate, endDate) { | ||
params.append("latitude",latitude); | ||
params.append("longitude",longitude); | ||
params.append("daily","temperature_2m_max"); | ||
params.append("timezone","America/New_York"); | ||
params.append("start_date",startDate); | ||
params.append("end_date",endDate); | ||
params.append("temperature_unit","fahrenheit"); | ||
|
||
let url = new URL(BASE_URL+WHATEVER_PATH+"?"+params.toString()); | ||
let rezzy = await fetch(url); | ||
let jrez = await rezzy.json(); | ||
let dates = []; | ||
jrez.daily.time.forEach(timeStr => { | ||
dates.push(new Date(timeStr)); | ||
}); | ||
let temperatures = jrez.daily.temperature_2m_max | ||
// console.log({dates,temperatures}); | ||
return {dates,temperatures}; | ||
} | ||
} | ||
|
||
export default WeatherUtil; |
Oops, something went wrong.