|
1 | 1 | # Core Logic |
2 | 2 |
|
3 | | -In order to obtain the pin point weather data, earth location is a required parameter. For this, the longitude and latitude would surfice programmatically. For the interactive option, a physical postal address (partial address of City, State, Country) is needed. Optionally, you could also register with google map service (*additional charge will incur*). Then, integrate google-map API where the user can point to location on the map to trigger locolized weather report. |
| 3 | +To obtain the pinpoint weather data, earth location is a required parameter. For this, the longitude and latitude would suffice programmatically. For the interactive option, a physical postal address (partial address of City, State, or Country) is required. Optionally, you could also register with the google map service (*additional charge will incur*). Then, integrate google-map API where the user can point to a location on the map to trigger a localized weather report. |
4 | 4 |
|
5 | | -* The geolocation of a known address can be obtained by using the client-side javascript [Windows Navigator](https://www.w3schools.com/jsref/obj_navigator.asp). Your browser uses different types and sources of information to identify your location. These include your IP address, geolocation via HTML5 in your browser, and your PC's language and time settings. For more detail how Navigator.geolocation is determined, [read more here](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/getCurrentPosition). |
| 5 | +* The geolocation of a known address can be obtained by using the client-side javascript [Windows Navigator](https://www.w3schools.com/jsref/obj_navigator.asp). Your browser uses different types and sources of information to identify your location. These include your IP address, geolocation via HTML5 in your browser, and your PC's language and time settings. For more detail on how Navigator.geolocation is determined, [read more here](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/getCurrentPosition). |
6 | 6 |
|
7 | 7 | Sample code for client-side geolocation: |
8 | 8 |
|
@@ -31,7 +31,7 @@ Sample code for client-side geolocation: |
31 | 31 |
|
32 | 32 | and **API_ACCESS_KEY** can be obtained from registering with an API provider. |
33 | 33 |
|
34 | | -* With the return JSON object representing the weather data, you wrap the individual data objects in grid to make it user friendly. |
| 34 | +* With the return JSON object representing the weather data, you wrap the individual data objects in a grid to make it user-friendly. |
35 | 35 |
|
36 | 36 | <br /> |
37 | 37 |
|
@@ -59,7 +59,7 @@ Replace freecodecamp proxy URI (file: public/scripts.js) for weather data provid |
59 | 59 |
|
60 | 60 | **Decision:** |
61 | 61 |
|
62 | | -You would want to live free and die harder, let's make the client calls the server whose in turn requests weather data and sends responses back. The client then can parse the response into a grid for display. This means, the server will need to provide GET requests! |
| 62 | +You would want to live free and die harder, let's make the client calls the server which in turn requests weather data and sends responses back. The client then can parse the response into a grid for display. This means the server will need to provide GET requests! |
63 | 63 |
|
64 | 64 | --- |
65 | 65 |
|
|
84 | 84 |
|
85 | 85 | <strong><span style="color:gray; font-size:18px"> Staying within the Free Tier Limit</span> </strong> |
86 | 86 |
|
87 | | -A typical free daily allowance cycle consists of up to 1000 free API queries. In which case, the user has to wait until the begining of the next free tier cycle. To avoid being charged, this source code has a *a server-side accounting logic* to pause querying the weathercrossing API once its periodic allowance has been reached. Unpause is automatic once the clock rolls to the begin of a new daily free tier cycle. |
| 87 | +A typical free daily allowance cycle consists of up to 1000 free API queries. In this case, the user has to wait until the beginning of the next free tier cycle. To avoid being charged, this source code has a *a server-side accounting logic* to pause querying the weathercrossing API once its periodic allowance has been reached. Unpause is automatic once the clock rolls to the beginning of a new daily free tier cycle. |
88 | 88 |
|
89 | 89 | >*Potential development needed to notify the server admin if demands grew and if there are ways to monetize it.* |
90 | 90 |
|
91 | 91 | <strong><span style="color:gray; font-size:18px">Caching the Weather Data</span></strong> |
92 | 92 |
|
93 | | -Weather forecast data from `visualcrossing.com` typically contains infomation spanning 15 days, each day contains 24 hourly objects. Additional queries within the same period would usually resulted in the same data. We need to cache this information so not to incur needless and sometimes costly API calls. |
| 93 | +Weather forecast data from `visualcrossing.com` typically contains information spanning 15 days, each day contains 24 hourly objects. Additional queries within the same period would usually result in the same data. We need to cache this information so as not to incur needless and sometimes costly API calls. |
94 | 94 |
|
95 | 95 | We could elect to use the DOM Storage API, also called the [Web Storage API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API) methods: `Window.sessionStorage` where data persists as long as the session is running, or `Window.localStorage` which has no expiration. Note: when the last private tab is closed, data stored in the localStorage object of a site opened in a private tab or incognito mode is cleared. |
96 | 96 |
|
97 | 97 | <br /> |
98 | 98 |
|
99 | | -<span style="color:green">**IMPORTANT:**</span> Web Storage API needs to be implemented on the the browser side (client with the DOM). In this case, we make sure to place the javascript script at the bottom of HTML body section. |
| 99 | +<span style="color:green">**IMPORTANT:**</span> Web Storage API needs to be implemented on the browser side (client with the DOM). In this case, we make sure to place the javascript script at the bottom of the HTML body section. |
100 | 100 |
|
101 | 101 | >Another option is to use no-sql storage such as `redis`. A topic not in the scope of this exercise. |
102 | 102 |
|
@@ -152,10 +152,10 @@ A sample of Web Storage API test: |
152 | 152 |
|
153 | 153 | ## Next Phases |
154 | 154 |
|
155 | | -The followings are potential developments in subsequent iterations to this weather report project: |
| 155 | +The followings are potential developments in subsequent iterations of this weather report project: |
156 | 156 |
|
157 | 157 | * Integrate the server with auth0 and/or passport authentication |
158 | 158 |
|
159 | | -* Registered members have access to full blown dashboard with maritime alerts, historical weather data, extended forecast, etc. |
| 159 | +* Registered members have access to a full-blown dashboard with maritime alerts, historical weather data, extended forecasts, etc. |
160 | 160 |
|
161 | 161 | * Build and make mobile apps available to subscribed members. |
0 commit comments