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

Generate KML files from the "Historical" page #858

Merged
merged 8 commits into from
Jan 30, 2024

Conversation

argilo
Copy link
Contributor

@argilo argilo commented Jan 29, 2024

Log files can be converted to KML using the log_to_kml command-line utility. To make the process simpler, I've added a "Generate KML" button to the "Historical" page:

Screenshot from 2024-01-29 17-13-23

When clicked, a KML file is generated from the selected log files.

To avoid making fastkml and shapely dependencies of auto_rx, I rewrote log_to_kml to generate KML using the standard library's built-in XML support. (It should be possible to eliminate auto_rx's simplekml dependency in the same way, but I'll leave that to another pull request.)

@darksidelemm
Copy link
Member

Nice addition!
I never really intended for code in the utils directory to be called from within auto_rx, so it might be best to move the required functions from there to somewhere in the autorx 'module'. The log_files.py file might be a suitable spot.

@argilo
Copy link
Contributor Author

argilo commented Jan 29, 2024

That sounds like a good idea. I'll take a crack at it.

@argilo
Copy link
Contributor Author

argilo commented Jan 30, 2024

OK, KML generation has now been moved into autorx.log_files.

In order to use that from utils/log_to_kml.py, I had to use a hack to allow an import from the parent directory. Is that OK?

There are a couple leftover print() statements in log_files_to_kml that came from the log_to_kml script. Any opinion on whether we should get rid of those? The bare except is also a bit of a pain, since it swallows up all errors and hides them. I might take a look to see what errors can actually occur in practice. Skipping missing or corrupt log files is probably useful.

@darksidelemm
Copy link
Member

I think most of the print statements should go to logging.debug calls, except those within except blocks. Those should be logging.exception, and should include the exception info to assist with debugging. We should just skip over those broken files though.

@argilo
Copy link
Contributor Author

argilo commented Jan 30, 2024

I replaced the print statements with logging.

@darksidelemm
Copy link
Member

OK, are you happy enough with this for me to merge it in?

@argilo
Copy link
Contributor Author

argilo commented Jan 30, 2024

Yes, I think so. It's working well for me, and I verified that exceptions are logged when they occur.

@darksidelemm
Copy link
Member

Awesome, I'll merge it in!

@darksidelemm darksidelemm merged commit 0ea4558 into projecthorus:testing Jan 30, 2024
1 check passed
@argilo argilo deleted the web-generate-kml branch January 30, 2024 03:49
@argilo
Copy link
Contributor Author

argilo commented Jan 30, 2024

Thanks!

Are you happy with how the ElementTree KML generation turned out? If so, I might take a crack at replacing simplekml with that, which would get rid of a dependency.

@darksidelemm
Copy link
Member

Yeah, it seems to work, so I'd be happy to see the dependency removed!

Ran a few tests on my local station with the new code, seems to work fine! As expected exporting everything takes quite a while. I suspect that at some point the URL for large selections is going to get too big (e.g. if you select all, then de-select one), but oh well.

@darksidelemm
Copy link
Member

Actually it might not be an issue (seems most browsers have stupidly large URL limits), so happy to ignore it for now :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants