Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forecast coordinates are ridiculously accurate #191

Closed
caphector opened this issue Aug 12, 2023 · 5 comments
Closed

Forecast coordinates are ridiculously accurate #191

caphector opened this issue Aug 12, 2023 · 5 comments
Labels
bug Something isn't working
Milestone

Comments

@caphector
Copy link

Describe the bug
I am using the OWM forecast; when the forecast is generated the page incudes GPS coordinates with 10+ decimal places of precision. These coordinates are too accurate to be useful; all that's needed is a general area and that can be done with four places coordinate precision like the page footer.

Expected behavior
~3-4 decimal places of precision

Screenshots
Untitled

@caphector caphector added the bug Something isn't working label Aug 12, 2023
@Daveiano Daveiano added this to the 3.4.0 milestone Aug 12, 2023
@Daveiano
Copy link
Owner

It seems that these are the exact coordinates provided to WeeWX in weewx.conf at [Station] - latitude and [Station] - longitude, at least that's the case for me.

I added a format of 4 decimal places in skins/weewx-wdc/includes/forecast-table.inc:

-    for $wloc
+    #set $wloc_list = $wloc.split(',')
+    #set $format_string = "{0:.3f}"
+    for $format_string.format($float($wloc_list[0])), $format_string.format($float($wloc_list[1]))

See ad9dcbe

Feel free to test the change by editing the template file! Otherwise, it will be included in the next release.

@caphector
Copy link
Author

Thanks! I wasn't sure if the coords were from weewx.conf; I thought I had tested publishing after updating my weewx.conf, but I must have failed a step.

In any case, I tried the code and it only prints three places which should look better under the Forecast table.

@Daveiano
Copy link
Owner

Yes, sorry I meant to write "3 places"

Daveiano added a commit that referenced this issue Nov 3, 2023
@dave9997
Copy link

dave9997 commented Jan 4, 2024

It seems that these are the exact coordinates provided to WeeWX in weewx.conf at [Station] - latitude and [Station] - longitude, at least that's the case for me.

I added a format of 4 decimal places in skins/weewx-wdc/includes/forecast-table.inc:

-    for $wloc
+    #set $wloc_list = $wloc.split(',')
+    #set $format_string = "{0:.3f}"
+    for $format_string.format($float($wloc_list[0])), $format_string.format($float($wloc_list[1]))

See ad9dcbe

Feel free to test the change by editing the template file! Otherwise, it will be included in the next release.

Hi @Daveiano,
new user here. I had to manually revert this patch on a freshly installed v.3.4.0 or otherwise got no index.html, with the following trace:

weewx[2270] ERROR weewx.cheetahgenerator: Evaluation of template /etc/weewx/skins/weewx-wdc/index.html.tmpl failed with exception '<class 'Val
Jan 05 00:09:56 raspberrypi python3[2270]: weewx[2270] ERROR weewx.cheetahgenerator: **** Ignoring template /etc/weewx/skins/weewx-wdc/index.html.tmpl
Jan 05 00:09:56 raspberrypi python3[2270]: weewx[2270] ERROR weewx.cheetahgenerator: **** Reason: could not convert string to float: 'geocode=45.434072'
Jan 05 00:09:56 raspberrypi python3[2270]: weewx[2270] ERROR weewx.cheetahgenerator: **** Traceback (most recent call last):
Jan 05 00:09:56 raspberrypi python3[2270]: weewx[2270] ERROR weewx.cheetahgenerator: **** File "/usr/share/weewx/weewx/cheetahgenerator.py", line 348, in generate
Jan 05 00:09:56 raspberrypi python3[2270]: weewx[2270] ERROR weewx.cheetahgenerator: **** unicode_string = compiled_template.respond()
Jan 05 00:09:56 raspberrypi python3[2270]: weewx[2270] ERROR weewx.cheetahgenerator: **** File "cheetah__etc_weewx_skins_weewx_wdc_index_html_tmpl_1704409132_5401943_64216.py", line
Jan 05 00:09:56 raspberrypi python3[2270]: weewx[2270] ERROR weewx.cheetahgenerator: **** File "/usr/lib/python3/dist-packages/Cheetah/Template.py", line 1707, in _handleCheetahInclu
Jan 05 00:09:56 raspberrypi python3[2270]: weewx[2270] ERROR weewx.cheetahgenerator: **** self._CHEETAH__cheetahIncludes[_includeID].respond(trans)
Jan 05 00:09:56 raspberrypi python3[2270]: weewx[2270] ERROR weewx.cheetahgenerator: **** File "_etc_weewx_skins_weewx_wdc_includes_body_alternative_inc.py", line 286, in respond
Jan 05 00:09:56 raspberrypi python3[2270]: weewx[2270] ERROR weewx.cheetahgenerator: **** File "/usr/lib/python3/dist-packages/Cheetah/Template.py", line 1707, in _handleCheetahInclu
Jan 05 00:09:56 raspberrypi python3[2270]: weewx[2270] ERROR weewx.cheetahgenerator: **** self._CHEETAH__cheetahIncludes[_includeID].respond(trans)
Jan 05 00:09:56 raspberrypi python3[2270]: weewx[2270] ERROR weewx.cheetahgenerator: **** File "_etc_weewx_skins_weewx_wdc_includes_forecast_inc.py", line 256, in respond
Jan 05 00:09:56 raspberrypi python3[2270]: weewx[2270] ERROR weewx.cheetahgenerator: **** File "/usr/lib/python3/dist-packages/Cheetah/Template.py", line 1707, in _handleCheetahInclu
Jan 05 00:09:56 raspberrypi python3[2270]: weewx[2270] ERROR weewx.cheetahgenerator: **** self._CHEETAH__cheetahIncludes[_includeID].respond(trans)
Jan 05 00:09:56 raspberrypi python3[2270]: weewx[2270] ERROR weewx.cheetahgenerator: **** File "cheetah__etc_weewx_skins_weewx_wdc_includes_forecast_table_inc_1704409796_6408846_6211
Jan 05 00:09:56 raspberrypi python3[2270]: weewx[2270] ERROR weewx.cheetahgenerator: **** File "cheetah__etc_weewx_skins_weewx_wdc_includes_forecast_table_inc_1704409796_6408846_6211
Jan 05 00:09:56 raspberrypi python3[2270]: weewx[2270] ERROR weewx.cheetahgenerator: **** File "", line 1, in
Jan 05 00:09:56 raspberrypi python3[2270]: weewx[2270] ERROR weewx.cheetahgenerator: **** ValueError: could not convert string to float: 'geocode=45.434072'

@Daveiano
Copy link
Owner

Daveiano commented Jan 6, 2024

Hi @dave9997, the error was also noticed when the last version was released, see here: #218 (comment)

Here is a quick fix that should help to solve the issue - these changes will be included in the next release: 884be1a

Background: Every forecast provider provides the data in another format.

Daveiano added a commit that referenced this issue Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants