Parse APRS location from packets that have that information. #26

Open
w1cdn wants to merge 2 commits from aprs_loc into dev
Owner

Closes #10.

Closes #10. - [x] add location of spotter (more command line argument(s)) - [x] only include location if values aren't -9999 - [ ] allow negative numbers in lat/lon CLI https://docs.rs/clap/latest/clap/builder/struct.Arg.html - [ ] cache locations and fill in values when locations aren't parsed out of packets
w1cdn added 1 commit 2025-10-25 04:18:46 +00:00
Author
Owner

Had a thought about a missing piece as I was falling asleep, now I can't remember it!

EDIT: Remembered, it was that I didn't check the lat/lon values against 9999 before sending them on.

Had a thought about a missing piece as I was falling asleep, now I can't remember it! EDIT: Remembered, it was that I didn't check the lat/lon values against 9999 before sending them on.
Author
Owner

Are these values too long? Spothole doesn't seem to pick up all the locations.
"dx_latitude":47.94133333333333,"dx_longitude":-97.02683333333333,

curl seems to work:
curl --request POST --header "Content-Type: application/json" --data '{"dx_call":"M0TRT","time": 1761415746, "freq":14200000, "comment":"Test spot please ignore", "de_call":"M0TRT", "dx_latitude":47.94133333333333, "dx_longitude":-97.02683333333333}' https://spothole.w1cdn.net/api/v1/spot

Are these values too long? Spothole doesn't seem to pick up all the locations. `"dx_latitude":47.94133333333333,"dx_longitude":-97.02683333333333,` curl seems to work: `curl --request POST --header "Content-Type: application/json" --data '{"dx_call":"M0TRT","time": 1761415746, "freq":14200000, "comment":"Test spot please ignore", "de_call":"M0TRT", "dx_latitude":47.94133333333333, "dx_longitude":-97.02683333333333}' https://spothole.w1cdn.net/api/v1/spot `
Author
Owner

I think I was running on two machines at once, one only with locations and one with all UI frames. This was messing up the mapping.

I think I was running on two machines at once, one only with locations and one with all UI frames. This was messing up the mapping.
Author
Owner

Oh things got simpler; you can send an empty string to json lat/lon and it will be interpreted as a bad location by spothole. I thought I would have to send a specific None or null or empty number (whatever that looks like).

Oh things got simpler; you can send an empty string to json lat/lon and it will be interpreted as a bad location by spothole. I thought I would have to send a specific `None` or `null` or empty number (whatever that looks like).
Author
Owner

You can also send lat/lon as strings:

curl --request POST --header "Content-Type: application/json" --data '{"dx_call":"W1CDN","time": 1761447599, "freq":14200000, "comment":"Test spot please ignore", "de_call":"W1CDN", "dx_latitude":"47.94133333333333", "dx_longitude":"-97.02683333333333"}' https://spothole.w1cdn.net/api/v1/spot

And spothole will parse/map right:

  {
    "id": "54b2ca6220eaddc3b263063cb43602cbd87790c9078a3d121aeb3812e2323304",
    "dx_call": "W1CDN",
    "dx_name": "MATTHEW E BURTON-KELLY",
    "dx_country": "United States",
    "dx_flag": "🇺🇸",
    "dx_continent": "NA",
    "dx_dxcc_id": 291,
    "de_dxcc_id": 291,
    "dx_cq_zone": 5,
    "dx_itu_zone": 8,
    "dx_aprs_ssid": null,
    "dx_grid": null,
    "dx_latitude": "47.94133333333333",
    "dx_longitude": "-97.02683333333333",
    "dx_location_source": "SPOT",
    "dx_location_good": true,
    "de_call": "W1CDN",
    "de_country": "United States",
    "de_flag": "🇺🇸",
    "de_continent": "NA",
    "de_grid": "FN42EJ11",
    "de_latitude": 42.38,
    "de_longitude": -71.65,
    "mode": "USB",
    "mode_type": "PHONE",
    "mode_source": "BANDPLAN",
    "freq": 14200000,
    "band": "20m",
    "comment": "Test spot please ignore",
    "qrt": false,
    "sig": null,
    "sig_refs": null,
    "sig_refs_names": null,
    "sig_refs_urls": null,
    "activation_score": null,
    "icon": "desktop",
    "band_color": "#f2c40c",
    "band_contrast_color": "black",
    "time": 1761447599,
    "time_iso": "2025-10-26T02:59:59+00:00",
    "received_time": 1761447642.39335,
    "received_time_iso": "2025-10-26T03:00:42.393350+00:00",
    "source": "API",
    "source_id": null
  },
image.png
You can also send lat/lon as strings: `curl --request POST --header "Content-Type: application/json" --data '{"dx_call":"W1CDN","time": 1761447599, "freq":14200000, "comment":"Test spot please ignore", "de_call":"W1CDN", "dx_latitude":"47.94133333333333", "dx_longitude":"-97.02683333333333"}' https://spothole.w1cdn.net/api/v1/spot` And spothole will parse/map right: ``` { "id": "54b2ca6220eaddc3b263063cb43602cbd87790c9078a3d121aeb3812e2323304", "dx_call": "W1CDN", "dx_name": "MATTHEW E BURTON-KELLY", "dx_country": "United States", "dx_flag": "🇺🇸", "dx_continent": "NA", "dx_dxcc_id": 291, "de_dxcc_id": 291, "dx_cq_zone": 5, "dx_itu_zone": 8, "dx_aprs_ssid": null, "dx_grid": null, "dx_latitude": "47.94133333333333", "dx_longitude": "-97.02683333333333", "dx_location_source": "SPOT", "dx_location_good": true, "de_call": "W1CDN", "de_country": "United States", "de_flag": "🇺🇸", "de_continent": "NA", "de_grid": "FN42EJ11", "de_latitude": 42.38, "de_longitude": -71.65, "mode": "USB", "mode_type": "PHONE", "mode_source": "BANDPLAN", "freq": 14200000, "band": "20m", "comment": "Test spot please ignore", "qrt": false, "sig": null, "sig_refs": null, "sig_refs_names": null, "sig_refs_urls": null, "activation_score": null, "icon": "desktop", "band_color": "#f2c40c", "band_contrast_color": "black", "time": 1761447599, "time_iso": "2025-10-26T02:59:59+00:00", "received_time": 1761447642.39335, "received_time_iso": "2025-10-26T03:00:42.393350+00:00", "source": "API", "source_id": null }, ``` <img width="494" alt="image.png" src="attachments/a55a1013-f0ba-4007-a492-3381ea2506ce">
796 KiB
w1cdn added 1 commit 2025-10-26 03:46:48 +00:00
Author
Owner

Location caching is next. Deciding whether to finish off this PR with only sending spots with parsed locations (so the map always works) or to leave it as everything for now (and the map locations will be overwritten by UI frames with no location data).

We discussed #11 on Matrix: https://matrix.to/#/!bVjIHuavAgnyyjeDTM:matrix.farpn.net/$bryXVDi7prNeZBnEZwKjf9ysMh19A2D1V-ilO8zbnz0?via=matrix.farpn.net&via=matrix.org&via=im.xoo.sh

Location caching is next. Deciding whether to finish off this PR with only sending spots with parsed locations (so the map always works) or to leave it as everything for now (and the map locations will be overwritten by UI frames with no location data). We discussed #11 on Matrix: https://matrix.to/#/!bVjIHuavAgnyyjeDTM:matrix.farpn.net/$bryXVDi7prNeZBnEZwKjf9ysMh19A2D1V-ilO8zbnz0?via=matrix.farpn.net&via=matrix.org&via=im.xoo.sh
Author
Owner

Quick update on storing and retrieving values:

// Starting from first example at https://rusting.substack.com/p/key-value-store-project

use std:: collections:: HashMap;

fn main() {
let mut loc_store = HashMap:: new();

let lat = 47.94116_f64;
let lon = -97.02683_f64;
let mut loc = vec![lat.to_string(), lon.to_string()];

    // Insert some keys and values
    //loc_store.insert("key1", "valuel"); 
    //loc_store.insert("key2", "value2");
    loc_store.insert("key3", loc);
    // Retrieve the values
    /*
    match loc_store.get("key1") {
        Some(value) => println!("{}: {:?}", "key1", value),
        None => println! ("Key not found"),
    }
    match loc_store.get("key2") {
        Some(value) => println!("{}: {:?}", "key2", value),
        None => println! ("Key not found"),
    }
    */
    match loc_store.get("key3") {
        Some(value) => println!("{}: lat {:?} lon {:?}", "key3", value[0], value[1]),
        None => println! ("Key not found"),
    }
}
Quick update on storing and retrieving values: ``` // Starting from first example at https://rusting.substack.com/p/key-value-store-project use std:: collections:: HashMap; fn main() { let mut loc_store = HashMap:: new(); let lat = 47.94116_f64; let lon = -97.02683_f64; let mut loc = vec![lat.to_string(), lon.to_string()]; // Insert some keys and values //loc_store.insert("key1", "valuel"); //loc_store.insert("key2", "value2"); loc_store.insert("key3", loc); // Retrieve the values /* match loc_store.get("key1") { Some(value) => println!("{}: {:?}", "key1", value), None => println! ("Key not found"), } match loc_store.get("key2") { Some(value) => println!("{}: {:?}", "key2", value), None => println! ("Key not found"), } */ match loc_store.get("key3") { Some(value) => println!("{}: lat {:?} lon {:?}", "key3", value[0], value[1]), None => println! ("Key not found"), } } ```
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin aprs_loc:aprs_loc
git checkout aprs_loc
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: w1cdn/mwtchahrd#26
No description provided.