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

Limit decimal digits #8

Open
matburnham opened this issue Mar 21, 2023 · 0 comments
Open

Limit decimal digits #8

matburnham opened this issue Mar 21, 2023 · 0 comments

Comments

@matburnham
Copy link

I'm working with latitudes and longitudes in SeeYou CUP format. This is a simple CSV format, but with a somewhat specific DDMM.MMM latitude and longitude format.

For example:

name,code,country,lat,lon,elev,style,rwdir,rwlen,rwwidth,freq,desc,userdata,pics
"Wycombe Air Park - Booker","EGTB",GB,5136.684N,00048.479W,156m,5,,,,

Within this, the lat field is encoded:

Latitude is a field of length 9, where 1-2 characters are degrees, 3-4 characters are minutes, 5 decimal point,
6-8 characters are decimal minutes and 9th character is either N or S. The ellipsoid used is WGS-1984

Char 0 Char 1 Char 2 Char 3 Char 4 Char 5 Char 6 Char 7 Char 8
5 1 0 7 . 8 3 0 N | S
$10^1$ Degrees $10^0$ Degrees $10^1$ Minutes $10^0$ Minutes . $10^{-1}$ Minutes $10^{-2}$ Minutes $10^{-3}$ Minutes N | S

I can get very close to what I want, but end up with excessive decimal digits:

>>> latlon.LatLon(51.61140,-0.80798).to_string('%d%%M%%H%')
('5136.6840000000002N', '048.47879999999918W')

Even the example in latlon.py#L123 gives me similar behaviour:

>>> palmyra = LatLon(5.8833, -162.0833)
>>> palmyra.to_string('D')
('5.8833', '-162.0833')
>>> palmyra.to_string('H% %D')
('N 5.8833', 'W 162.0833')
>>> palmyra.to_string('d%_%M')
('5_52.99800000000001', '-162_4.998000000000502')

It would be great if there were a way to specify the number of digits in the format string, and also leading zeros.

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

No branches or pull requests

1 participant