projecthorus / chasemapper

Browser-Based High-Altitude Balloon Chase Map
GNU General Public License v3.0
107 stars 24 forks source link

Add the ability to select imperial units on map #18

Closed Reid-n0rc closed 3 years ago

Reid-n0rc commented 4 years ago

It would be useful for us in the US to have the ability to display imperial units to the map display.

darksidelemm commented 4 years ago

This probably won't be high on my priority list... If someone wants to have a crack at it and submit a pull request that would be appreciated...

DnH2016 commented 3 years ago

I can take a look at that. By imperial do you mean miles, feet, feet per second, or do you want to use knots?

Reid-n0rc commented 3 years ago

Miles, feet,etc. You know, the units still in use by only the U.S., Liberia and Myanmar.

On Wed, Dec 23, 2020, 7:38 PM DnH2016 notifications@github.com wrote:

I can take a look at that. By imperial do you mean miles, feet, feet per second, or do you want to use knots?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/projecthorus/chasemapper/issues/18#issuecomment-750698124, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADSKTDQLZANGNHBCIS74QTSWKLQHANCNFSM4TQBJBGA .

DnH2016 commented 3 years ago

For vertical velocity feet per second or feet per minute? At what distance do you want to move from miles to feet? So I can put default values in the config files.

Reid-n0rc commented 3 years ago

Ah I understand the question now. For vertical velocity feet/min would be good. Probably go from feet to miles at about 0.25 miles to start with.

On Wed, Dec 23, 2020, 8:45 PM DnH2016 notifications@github.com wrote:

For vertical velocity feet per second or feet per minute? At what distance do you want to move from miles to feet? So I can put default values in the config files.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/projecthorus/chasemapper/issues/18#issuecomment-750713325, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADSKTHPSB3SED2H2QU5ZRTSWKTNLANCNFSM4TQBJBGA .

DnH2016 commented 3 years ago

OK. I'll set those defaults.

darksidelemm commented 3 years ago

I'd suggest using: Ascent rate: feet/min Altitude: feet (stay in feet, don't transition to miles, that's just too confusing) Horizontal Velocity: Miles/hr Range: feet, then miles, as mentioned above.

Make it a single option in the config file to enable or disable imperial units.

DnH2016 commented 3 years ago

Good. I'll branch.

DnH2016 commented 3 years ago

OK, Most of the work is done, I'll be testing it this morning.

Reid-n0rc commented 3 years ago

Thank you!

On Thu, Dec 24, 2020, 4:49 PM DnH2016 notifications@github.com wrote:

OK, Most of the work is done, I'll be testing it this morning.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/projecthorus/chasemapper/issues/18#issuecomment-751126845, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADSKTBLDU5JIM35G3N7PCLSWPAPBANCNFSM4TQBJBGA .

DnH2016 commented 3 years ago

image

DnH2016 commented 3 years ago

https://github.com/DnH2016/chasemapper

I'd be grateful if you could clone this and give any feedback. It should work with your existing config file, but it will default to metric.

[units]

unitselection = imperial1

If you add these lines into your config file it should work in imperial units as discussed above.

The following lines are optional, but maybe you want to tweak the conversion factors.

Imperial conversion factors

m_to_ft = 3.28084

km_to_miles = 0.621371

secs_to_mins = 0.016666

ms_to_knots = 1.94384

Sensible choice of unit selection (all thresholds set in metric)

This is the threshold for switching from miles to feet, set in meters.

switch_miles_feet = 400

Reid-n0rc commented 3 years ago

I was not able to get it to display in imperial units.

The output from the console is below.

$ python3 horusmapper.py
2021-02-06 18:56:34,779 INFO:Logging - Opened log file ./log_files/20210207-0056Z.log.
2021-02-06 18:56:34,780 INFO:Chase Logger - Started Chase Logger Thread.
2021-02-06 18:56:34,784 INFO:Units:             imperial1
2021-02-06 18:56:34,784 INFO:m_to_f:            3.28084
2021-02-06 18:56:34,785 INFO:km_to_miles:       0.621371
2021-02-06 18:56:34,785 INFO:secs_to_mins:      0.016666
2021-02-06 18:56:34,785 INFO:ms_to_knots:       1.94384
2021-02-06 18:56:34,785 INFO:switch_miles_feet: 400 metres
2021-02-06 18:56:34,786 INFO:Starting Telemetry Horus UDP listener on port 55673
2021-02-06 18:56:34,786 INFO:No car position data source.
Started UDP Listener Thread.
2021-02-06 18:56:34,787 INFO:Starting Chasemapper Server on: http://0.0.0.0:5001/
 * Serving Flask app "horusmapper" (lazy loading)
 * Environment: production
   WARNING: Do not use the development server in a production environment.
   Use a production WSGI server instead.
 * Debug mode: off
2021-02-06 18:56:38,386 INFO:Horus UDP Data: LMS6-8135744, 00:56:52, 38.85411, -94.42118, 30108.8
2021-02-06 18:56:43,392 INFO:Horus UDP Data: LMS6-8135744, 00:56:58, 38.85427, -94.42031, 30141.9

Mapper: image

Config File:

#
# Project Horus Chase-Mapper Configuration File
#
# Copy this file to horusmapper.cfg and modify as required.
#

#
# Telemetry Source Profiles
# Multiple Telemetry source profiles can be defined, and can be selected from
# the web GUI.
#
[profile_selection]
# How many profiles have been defined
profile_count = 2
# Index of the default profile (indexing from 1)
default_profile = 2

[profile_1]
# Profile name - will be shown in the web client.
profile_name = Default
# Telemetry source type:
#  ozimux - Read data in OziMux format
#  horus_udp - Read Horus UDP Broadcast 'Payload Summary' messages
telemetry_source_type = ozimux
# Telemetry source port (UDP)
telemetry_source_port = 8942

# Car Position Source
# none - No Chase-Car GPS
# horus_udp - Read Horus UDP Broadcast 'Car GPS' messages
# serial - Read GPS positions from a serial-connected GPS receiver.
# gpsd - Poll GPSD for positions
car_source_type = none #horus_udp
# Car position source port (UDP) - only used if horus_udp is selected
car_source_port = 55672

# Other profiles can be defined in sections like the following:
[profile_2]
# Example source to take telemetry data from an instance of radiosonde_auto_rx
# emitting Horus UDP packets on port 55673, and accepts car positions from a local
# instance of GPSD
profile_name = auto_rx
telemetry_source_type = horus_udp
telemetry_source_port = 55673
car_source_type = none #gpsd
# Since we are using GPSD, the car_source_port argument is unused, but still has to be defined.
car_source_port = 55672

[gpsd]
# GPSD Host/Port - Only used if selected in a telemetry profile above.
gpsd_host = localhost
gpsd_port = 2947

[gps_serial]
# Serial GPS Settings - Only used if selected in a telemetry profile above.
# GPS serial device (i.e. /dev/ttyUSB0, COM1, etc...)
gps_port = /dev/ttyUSB0
# GPS baud rate
gps_baud = 9600

# Map Defaults
[map]
# Host/port to host webserver on
flask_host = 0.0.0.0
flask_port = 5001

# Default map centre
default_lat = -34.9
default_lon = 138.6

# How long to keep payload data (minutes)
payload_max_age = 180

# ThunderForest API Key
# NOTE: OpenTopoMaps is now available by default, and is a good alternative to ThunderForest's outdoors map.
# If you want to use ThunderForest's Outdoors map (Topographic maps), you will need to
# register for an API key here: https://manage.thunderforest.com/users/sign_up?plan_id=5
# Once you have a key, enter it below:
thunderforest_api_key = none

# Predictor Settings
# Use of the predictor requires installing the CUSF Predictor Python Wrapper from here:
# https://github.com/darksidelemm/cusf_predictor_wrapper
# You also need to compile the predictor binary, and copy it into this directory.
[predictor]
# Enable Predictor (True/False) - This can also be enabled from the web client.
predictor_enabled = False
offline_predictions = False
# Predictor defaults - these can be modified at runtime in the web interface.
default_burst = 30000
default_descent_rate = 5.0

# Predictory Binary Location
# Where to find the built CUSF predictor binary. This will usually be ./pred or pred.exe (on Windows)
pred_binary = ./pred

# Directory containing GFS model data.
gfs_directory = ./gfs/

# Wind Model Download Command
# Optional command to enable downloading of wind data via a web client button.
# Example: (this will require copying the get_wind_data.py script to this dirctory)
# model_download = python get_wind_data.py --lat=-33 --lon=139 --latdelta=10 --londelta=10 -f 24 -m 0p50 -o gfs
# The gfs directory (above) will be cleared of all .dat files prior to the above command being run.
model_download = none

#
#       Offline Tile Server
#
#       Allows serving of map tiles from a directory.
#       Each subdirectory is assumed to be a separate layer of map tiles, i.e. 'OSM', 'opencyclemap',
#       and is added to the map interface as a separate layer.
#       This feature can be used to serve up FoxtrotGPS's tile cache as layers, usually located in ~/Maps/
#
[offline_maps]
# Enable serving up maps from a directory of map tiles.
tile_server_enabled = False

# Path to map tiles. For FoxtrotGPS, this is usually ~/Maps/
# NOTE: This must be an ABSOLUTE directory, i.e. /home/pi/Maps/ - ~/Maps/ will not work.
tile_server_path = /home/pi/Maps/

#
# Habitat Chase-Car Position Upload
# If you want, this application can upload your chase-car position to the Habhub tracker,
# for those follwing along at home.
# The settings below can be modified from the web interface, but they will default to what is set below on startup.
#
[habitat]
# Enable uploading of chase-car position to Habitat (True / False)
habitat_upload_enabled = False

# Callsign to use when uploading. Note that _chase is automatically appended to this callsign
# i.e. N0CALL will show up as N0CALL_chase on tracker.habhub.org
habitat_call = N0CALL

# Attempt to upload position to habitat every x seconds.
habitat_update_rate = 30

#
# Range Rings
#
[range_rings]
range_rings_enabled = False

# Number of range rings to display. The first ring starts at the spacing set below.
range_ring_quantity = 5

# Spacing between rings, in metres.
range_ring_spacing = 1000

# Weight of the ring, in pixels.
range_ring_weight = 1.5

# Color of the range rings.
# Valid options are: red, black, blue, green, custom
range_ring_color = red

# Custom range ring color, in hexadecimal #RRGGBB
range_ring_custom_color = #FF0000

#
#   Chase Car Speedometer
#
[speedo]
chase_car_speed = True

#
# Bearing Processing
#
[bearings]

# Number of bearings to store
max_bearings = 300

# Maximum age of bearings, in *minutes*.
max_bearing_age = 10

# Car heading speed gate
# Only consider car headings to be valid if the car speed is greater than this value in *kph*
car_speed_gate = 10

# Visual Settings - these can be adjust in the Web GUI during runtime

# Bearing length in km
bearing_length = 10

# Weight of the bearing lines, in pixels.
bearing_weight = 0.5

# Color of the bearings.
# Valid options are: red, black, blue, green, custom
bearing_color = black

# Custom bearing color, in hexadecimal #RRGGBB
bearing_custom_color = #FF0000

[units]

# unitselection allows choice of metric - the default or imperial1 - horizontal miles and feet for short distances, horizontal miles per hour,  vertical feet, vertical feet per minute

#unitselection = metric
unitselection = imperial1

# Imperial conversion factors

m_to_ft = 3.28084
km_to_miles = 0.621371
secs_to_mins = 0.016666
ms_to_knots = 1.94384

# Sensible choice of unit selection (all thresholds set in metric)

# This is the threshold for switching from miles to feet, set in meters.
switch_miles_feet = 400
g7gpr commented 3 years ago

Try changing imperial1 to just imperial - I'll have a look now.

darksidelemm commented 3 years ago

It looks like you're on some intermediate version of chasemapper. Make sure you update, and make your config file from the latest .example file.

Reid-n0rc commented 3 years ago

It looks like you're on some intermediate version of chasemapper. Make sure you update, and make your config file from the latest .example file.

This is from @DnH2016's repo since he made the changes there. Just saw that the pull request is already done #22 I'll get the current version from this repo and try it.

Reid-n0rc commented 3 years ago

Well the sonde is gone for the night, but here's what I'm seeing image

New config file from the master branch of this repo

#
# Project Horus Chase-Mapper Configuration File
#
# Copy this file to horusmapper.cfg and modify as required.
#

#
# Telemetry Source Profiles
# Multiple Telemetry source profiles can be defined, and can be selected from
# the web GUI.
#
[profile_selection]
# How many profiles have been defined
profile_count = 2
# Index of the default profile (indexing from 1)
default_profile = 2

[profile_1]
# An example configuration which displays telemetry from auto_rx, and obtains chase car positions from GPSD.
# Profile name - will be shown in the web client.
profile_name = auto-rx
# Telemetry source type:
#  ozimux - Read data in OziMux format (TELEMETRY,HH:MM:SS,lat,lon,alt\n)
#  horus_udp - Read Horus UDP Broadcast 'Payload Summary' messages, as emitted by auto_rx and the horus-gui software.
telemetry_source_type = horus_udp
# Telemetry source port (UDP)  (auto_rx defauts to 55673)
telemetry_source_port = 55673

# Car Position Source
# none - No Chase-Car GPS
# horus_udp - Read Horus UDP Broadcast 'Car GPS' messages
# serial - Read GPS positions from a serial-connected GPS receiver.
# gpsd - Poll GPSD for positions.
car_source_type = none #gpsd
# Car position source port (UDP) - only used if horus_udp is selected, but still needs to be provided.
car_source_port = 12345

# Other profiles can be defined in sections like the following:
[profile_2]
# Example profile to take telemetry data from an instance of horus-gui, which defaults to
# emitting hrous_udp messages on port 55672, and using a Serial-connected GPS, with settings defined further below.
# The horusdemodlib command-line utilites emit telemetry on the same port, so this profile will work with that too.
profile_name = horus-gui
telemetry_source_type = horus_udp
telemetry_source_port = 55672

# Car Position Source
car_source_type = none #serial
# Since we are using a serial GPS, the car_source_port argument isn't used, but still has to be defined.
# Make sure to update the gps_serial settings further down in the configuration file!
car_source_port = 55672

# If you want add more profiles, you can do so here, e.g.
# [profile_3]
# ...
# [profile_4]
# ...

[gpsd]
# GPSD Host/Port - Only used if selected in a telemetry profile above.
gpsd_host = localhost
gpsd_port = 2947

[gps_serial]
# Serial GPS Settings - Only used if selected in a telemetry profile above.
# GPS serial device (i.e. /dev/ttyUSB0, COM1, etc...)
gps_port = /dev/ttyUSB0
# GPS baud rate
gps_baud = 9600

# Map Defaults
[map]
# Host/port to host webserver on
flask_host = 0.0.0.0
flask_port = 5001

# Default map centre
default_lat = -34.9
default_lon = 138.6

# How long to keep payload data (minutes)
payload_max_age = 180

# ThunderForest API Key
# NOTE: OpenTopoMaps is now available by default, and is a good alternative to ThunderForest's outdoors map.
# If you still want to use ThunderForest's Outdoors map (Topographic maps), you will need to
# register for an API key here: https://manage.thunderforest.com/users/sign_up?plan_id=5
# Once you have a key, enter it below:
thunderforest_api_key = none

# Predictor Settings
# By default this will attempt to get predictions from the online Tawhiri Predictions API.
# Optionally, you can enable offline predictions below.
[predictor]
# Enable Predictor (True/False) - This can also be enabled from the web client.
predictor_enabled = True

# Predictor defaults - these can be modified at runtime in the web interface.
default_burst = 30000
default_descent_rate = 5.0

# Offline Predictions
# Use of the offline predictor requires installing the CUSF Predictor Python Wrapper from here:
# https://github.com/darksidelemm/cusf_predictor_wrapper
# You also need to compile the predictor binary, and copy it into this directory.
#
# Note: This setting turns offline predictions *on* by default, which assumes there is a valid
# GFS dataset already present and available.
# If you will be using the 'Download Model' button, then leave this at False, and Offline predictions
# will be enabled once a valid model is available.
offline_predictions = False

# Predictory Binary Location
# Where to find the built CUSF predictor binary. This will usually be ./pred or pred.exe (on Windows)
pred_binary = ./pred

# Directory containing GFS model data.
gfs_directory = ./gfs/

# Wind Model Download Command
# Optional command to enable downloading of wind data via a web client button.
# Example: (this will require copying the get_wind_data.py script to this dirctory)
# model_download = python3 get_wind_data.py --lat=-33 --lon=139 --latdelta=10 --londelta=10 -f 24 -m 0p50 -o gfs
# The gfs directory (above) will be cleared of all .dat files prior to the above command being run.
model_download = none

#
#       Offline Tile Server
#
#       Allows serving of map tiles from a directory.
#       Each subdirectory is assumed to be a separate layer of map tiles, i.e. 'OSM', 'opencyclemap',
#       and is added to the map interface as a separate layer.
#       This feature can be used to serve up FoxtrotGPS's tile cache as layers, usually located in ~/Maps/
#
[offline_maps]
# Enable serving up maps from a directory of map tiles.
tile_server_enabled = False

# Path to map tiles. For FoxtrotGPS, this is usually ~/Maps/
# NOTE: This must be an ABSOLUTE directory, i.e. /home/pi/Maps/ , using ~/Maps/ will not work.
tile_server_path = /home/pi/Maps/

#
# Habitat Chase-Car Position Upload
# If you want, this application can upload your chase-car position to the Habhub tracker,
# for those follwing along at home.
# The settings below can be modified from the web interface, but they will default to what is set below on startup.
#
[habitat]
# Enable uploading of chase-car position to Habitat (True / False)
habitat_upload_enabled = False

# Callsign to use when uploading. Note that _chase is automatically appended to this callsign
# i.e. N0CALL will show up as N0CALL_chase on tracker.habhub.org
habitat_call = N0CALL

# Attempt to upload position to habitat every x seconds.
habitat_update_rate = 30

#
# Range Rings
#
[range_rings]
range_rings_enabled = False

# Number of range rings to display. The first ring starts at the spacing set below.
range_ring_quantity = 5

# Spacing between rings, in metres.
range_ring_spacing = 1000

# Weight of the ring, in pixels.
range_ring_weight = 1.5

# Color of the range rings.
# Valid options are: red, black, blue, green, custom
range_ring_color = red

# Custom range ring color, in hexadecimal #RRGGBB
range_ring_custom_color = #FF0000

#
#   Chase Car Speedometer
#
[speedo]
chase_car_speed = True

#
# Bearing Processing
#
[bearings]

# Number of bearings to store
max_bearings = 300

# Maximum age of bearings, in *minutes*.
max_bearing_age = 10

# Car heading speed gate
# Only consider car headings to be valid if the car speed is greater than this value in *kph*
car_speed_gate = 10

# Visual Settings - these can be adjust in the Web GUI during runtime

# Bearing length in km
bearing_length = 10

# Weight of the bearing lines, in pixels.
bearing_weight = 0.5

# Color of the bearings.
# Valid options are: red, black, blue, green, custom
bearing_color = black

# Custom bearing color, in hexadecimal #RRGGBB
bearing_custom_color = #FF0000

[units]

# unitselection allows choice of metric - the default or imperial - horizontal miles and feet for short distances, horizontal miles per hour,  vertical feet, vertical feet per minute
# this is applied only to the indications and to the range ring settings

#unitselection = metric
unitselection = imperial

# Sensible choice of unit selection (all thresholds set in metric)

# This is the threshold for switching from miles to feet, set in metres.
switch_miles_feet = 400

[history]

# Enable load of last position from log files (True/False)
reload_last_position = False
DnH2016 commented 3 years ago

Hi, have you refreshed your browser?

Reid-n0rc commented 3 years ago

Hi, have you refreshed your browser?

Well this is embarrassing. When I did an F5 in chrome, nothing changed. Incognito browser showed imperial units. Sorry for the trouble.

DnH2016 commented 3 years ago

No trouble at all. Thanks for testing - I wonder why chrome acts differently? I'll check that out.

DnH2016 commented 3 years ago

I could not repeat that - my install of chrome works with an F5. Happy hunting.

Reid-n0rc commented 3 years ago

Thanks for your help!