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

XCSoar (.CUP) and Winpilot (.DAT) file processing now works #90

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

paynterf
Copy link

XCSoar (.CUP) and Winpilot (.DAT) file processing now works properly. Unfortunately I couldn't figure out how to get the left/right/top/bottom bounds values to show up in the corresponding web page windows, so the map still isn't generated automatically.

As a workaround the calculated bounds are displayed in the 'error' window, and the user can manually transcribe the values to the bounds entry fields and then select the 'select map bounds by hand' option.

@lordfolken lordfolken linked an issue Dec 23, 2024 that may be closed by this pull request
wpnum = 0
for byteline in lines:
wpnum = wpnum + 1
line = byteline.decode('ISO-8859-2') #gfp 241210: added 'ISO-8859-2' decoding for correct cherrypy logging display
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be UTF-8?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried 'UTF-8' and AFAICT, it doesn't handle the accent marks in the Slovenia3 waypoint list. I added the 'Slovenia3.cup' and 'Slovenia3.dat' test files for your consideration (the .DAT file was generated from the .CUP file using a separate Python script to make sure they both contained the exact same coordinates)

I have no problem using UTF-8 vs ISO-8859-2, but some of the characters in Slovenia3.cup won't be displayed properly. I don't think this will affect the bounds calculation either way.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The files you provide contain corrupted data.
Slovenia3.cup: Lines 26, 94, 774, 776.

A CUP file should be utf-8. https://github.com/naviter/seeyou_file_formats/blob/main/CUP_file_format.md

These files should only be included if they serve an automated test case, and then they should be under test/data/cup/filename.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 101 to 104
# cherrypy.log('in for loop: wpnum = %s line = %s' %(wpnum, line))
# cherrypy.log(f'for loop row {wpnum}: {line}')

#check for blank lines or comments
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of debugging code. We don't really want that in the code base.

Copy link
Member

@lordfolken lordfolken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Congrats on figuring out the basic problem. :)

Can you please make a change that is as minimal as possible to fix the cup parsing issue and make a commit for it? No Test files or commented out debug code please, also no excessive logging which isn´t needed for operation.

@paynterf
Copy link
Author

paynterf commented Jan 2, 2025

Let me get my Linux laptop back out and I'll do the changes you requested ;)

@paynterf
Copy link
Author

paynterf commented Jan 2, 2025

Regarding the .CUP file encoding issue, I checked both the Slovenia3.cup and the Slovenia3.cup, and it appears the Slovenia3.cup file is corrupted - at least in my Landscapes/Slovenia3 folder. I did see that Slovenia3.cup is encoded in UTF-8 as you stated, but for some reason the Slovenia2.cup file is encoded as 'ANSI'. In any case I'll change back to UTF-8, but what to do about the corrupted lines in Slovenia3.cup? Can you check Slovenia3.cup on your end? Here is my line for 'Amzs Koa' (which isn't in the Slovenia2.cup file)

"Amzs Ko├Ã",Amzs Koì,4539.139N,01450.914E,470.0m,1,,,,

@paynterf
Copy link
Author

paynterf commented Jan 2, 2025

commit 2abe1a4 (HEAD -> master)
Author: Frank Paynter [email protected]
Date: Wed Jan 1 21:47:37 2025 -0500

Changed decoding to UTF-8, removed logging code, removed test files

@lordfolken
Copy link
Member

Regarding the .CUP file encoding issue, I checked both the Slovenia3.cup and the Slovenia3.cup, and it appears the Slovenia3.cup file is corrupted - at least in my Landscapes/Slovenia3 folder. I did see that Slovenia3.cup is encoded in UTF-8 as you stated, but for some reason the Slovenia2.cup file is encoded as 'ANSI'. In any case I'll change back to UTF-8, but what to do about the corrupted lines in Slovenia3.cup? Can you check Slovenia3.cup on your end? Here is my line for 'Amzs Koa' (which isn't in the Slovenia2.cup file)

"Amzs Ko├Ã",Amzs Koì,4539.139N,01450.914E,470.0m,1,,,,

I also have condor3 and i see the same issue in the Slovenia3.cup file. So its really corrupted.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this cup/dat files for now. While i understand your testing intent, we don't want that in the production code base.

Comment on lines +15 to +22
cherrypy.config.update(
{
"log.screen": True, # Log to stdout
"log.error_file": "error.log", # Log errors to a file
"log.access_file": "access.log", # Log access to a file
}
)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally this runs in a container. The Filesystem is usually readonly. Please remove this configuration.

@@ -57,7 +57,7 @@
<div id="map"/>
<em class="note">Draw the map bounds rectangle by clicking in the map.</em>
<hr/>
<label class="left" for="left">Minimum Longitude:</label><input id="left" type="text" name="left"/><br/>
<label class="left" for="left">Minimum Longitude:</label><input id="left" type="text" name="left" value="43"/><br/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the default value=43?

@@ -33,10 +34,13 @@ def extend(self, wp_list):
def get_bounds(self, offset_distance=15.0):
rc = GeoRect(180, -180, -90, 90)
for wp in self.__list:
# cherrypy.log(f'In list.py: {wp.name}, lat: {wp.lat:.3f}, lon: {wp.lon:.3f}')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove.

Comment on lines +44 to +45
# cherrypy.log(f'In list.py - final rc: left {rc.left:.3f}, right: {rc.right:.3f}, top: {rc.top:.3f}, bot {rc.bottom:.3f}')

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove.

Comment on lines 137 to +139
return waypoint_list

return waypoint_list
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite understand this double return statement?

if first:
first = False
continue
header = "name,code,country,lat,lon,elev,style,rwdir,rwlen,freq,desc"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

beware that the there is a new standard since 2022, that has some additional fields:
https://github.com/naviter/seeyou_file_formats/blob/main/CUP_file_format.md

Maybe xcsoar's parser can serve as a reference:
https://github.com/XCSoar/XCSoar/blob/master/src/Waypoint/WaypointReaderSeeYou.cpp

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.

XCSoar Map Generator Error - cup file upload
2 participants