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

Fix:#1218 #1219

Open
wants to merge 29 commits into
base: trunk
Choose a base branch
from
Open

Fix:#1218 #1219

wants to merge 29 commits into from

Conversation

OLFDB
Copy link
Contributor

@OLFDB OLFDB commented Jan 14, 2023

Fixing the bookmark issue and making UTM coordinates working.

Examples:
utm32U: 674499.306 5328063.675
utmref32UPU:74499.306 28063.675

Added coordinates.rst taking over the wiki page and adding description for UTM coordinates.

@OLFDB
Copy link
Contributor Author

OLFDB commented Jan 14, 2023

@jkoan: Could you link the coordinates.rst from configuration.rst? Don't know how to do that.

Comment on lines 82 to 95
printf("invalid zone field '%c' in '%s'",zone_field,name);
return projection_none;
}
i-=12;
dbg(lvl_debug,"zone_field %d",i);
printf("zone_field %d",i);
baserow=i*887.6/100;
utm_offset->x=zone*1000000;
i=utmref_letter(square_x);
utm_offset->x+=((i%8)+1)*100000;
i=utmref_letter(square_y);
dbg(lvl_debug,"baserow %d",baserow);
printf("baserow %d",baserow);
if (!(zone % 2))
i-=5;
dbg(lvl_debug,"i=%d",i);
printf("i=%d",i);
Copy link
Member

Choose a reason for hiding this comment

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

why printf instead of dbg?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was a leftover from the standalone test app I did. Changed to dbg.

navit/coord.c Outdated
else {
str_pro = projection_from_name(proj, &offset);
if (str_pro == projection_none) {
dbg(lvl_debug, "Unknown projection: %s\n", proj);
Copy link
Member

Choose a reason for hiding this comment

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

why change from error to debug? error seems to be fitting here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to error again.

navit/coord.c Outdated
@@ -39,6 +39,9 @@
* @returns the coordinate
*/

int projection_enum_size[projection_enumsize];
Copy link
Member

Choose a reason for hiding this comment

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

Unused?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

projection_garmin, /*!< Garmin projection */
projection_screen, /*!< Screen projection */
projection_utm, /*!< UTM projection */
projection_enumsize
Copy link
Member

Choose a reason for hiding this comment

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

as the above is unused this isn't needed as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed projection_enumsize.

navit/coord.c Outdated
Comment on lines 43 to 44
#define PROJASSTRING(x) (x==0?"projection_none":x==1?"projection_mg":x==2?"projection_garmin":x==3?"projection_screen":x==4?"projection_utm":"UNKNOWN")

Copy link
Member

Choose a reason for hiding this comment

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

Isn't this what projection_to_name is doing already?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. Removed the macro and used projection_to_name.

navit/coord.c Outdated
Comment on lines 249 to 250
dbg(lvl_debug, "str='%s' x=%f y=%f c=%d\n", str, lng, lat, ret);
dbg(lvl_debug, "rest='%s'\n", str + ret);
Copy link
Member

Choose a reason for hiding this comment

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

Why all the line returns? dbg should add those itself?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is original code. It is shown here as there were spaces inserted by eclipse formatter.

@jkoan
Copy link
Member

jkoan commented Jan 20, 2023

@jkoan: Could you link the coordinates.rst from configuration.rst? Don't know how to do that.

Yep, that's possible like here with :doc:`path/file_without_suffix`

@OLFDB
Copy link
Contributor Author

OLFDB commented Jan 21, 2023

There was an issue with using the format '4808.2356 N 1134.5252 E' I have made testcases for the coordinate formats listed below. 65535 means the struct coord *result has not changed, so no coordinates have been set.

Testing all allowed coordinate types and conversions:

Testcases

Longitude / Latitude in decimal degrees to projection_none

enter('-33.355300,6.334000',none,0x7ff7bfefef90)
str='-33.355300,6.334000' x=6.334000 y=-33.355300 c=19
rest=''
ret=19 delta=0 ret_str=''

length: 19

X: 65535
Y: 65535

Longitude / Latitude in decimal degrees to projection_mg

enter('-33.355300,6.334000',mg,0x7ff7bfefef90)
str='-33.355300,6.334000' x=6.334000 y=-33.355300 c=19
rest=''
ret=19 delta=0 ret_str=''

length: 19

X: 704308
Y: -3938147

Longitude / Latitude in decimal degrees to projection_garmin

enter('-33.355300,6.334000',garmin,0x7ff7bfefef90)
str='-33.355300,6.334000' x=6.334000 y=-33.355300 c=19
rest=''
ret=19 delta=0 ret_str=''

length: 19

X: 295185
Y: -1554469

Longitude / Latitude in decimal degrees to projection_utm

enter('-33.355300,6.334000',utm,0x7ff7bfefef90)
str='-33.355300,6.334000' x=6.334000 y=-33.355300 c=19
rest=''
ret=19 delta=0 ret_str=''

length: 19

X: 65535
Y: 65535

Latitude / Longitude from Google Maps to projection_none

enter('52.678595, 13.572752',none,0x7ff7bfefef90)
str='52.678595, 13.572752' x=13.572752 y=52.678595 c=20
rest=''
ret=20 delta=0 ret_str=''

length: 20

X: 65535
Y: 65535

Latitude / Longitude from Google Maps to projection_mg

enter('52.678595, 13.572752',mg,0x7ff7bfefef90)
str='52.678595, 13.572752' x=13.572752 y=52.678595 c=20
rest=''
ret=20 delta=0 ret_str=''

length: 20

X: 1509221
Y: 6916019

Latitude / Longitude from Google Maps to projection_garmin

enter('52.678595, 13.572752',garmin,0x7ff7bfefef90)
str='52.678595, 13.572752' x=13.572752 y=52.678595 c=20
rest=''
ret=20 delta=0 ret_str=''

length: 20

X: 632536
Y: 2455000

Latitude / Longitude from Google Maps to projection_utm

enter('52.678595, 13.572752',utm,0x7ff7bfefef90)
str='52.678595, 13.572752' x=13.572752 y=52.678595 c=20
rest=''
ret=20 delta=0 ret_str=''

length: 20

X: 65535
Y: 65535

Latitude / Longitude in degrees and minutes to projection_none

enter('4808.2356 N 1134.5252 E',none,0x7ff7bfefef90)
str='4808.2356 N 1134.5252 E'
args=4
lat=4808.235600 N lon=1134.525200 E
projection=none str_pro=0 projection_none=0
transform_from_geo(48.137260,11.575420)
result 0xffff,0xffff
str='4808.2356 N 1134.5252 E' x=34.525200 ns=N y=8.235600 ew=E c=23
rest=''
ret=23 delta=0 ret_str=''

length: 23

X: 65535
Y: 65535

Latitude / Longitude in degrees and minutes to projection_mg

enter('4808.2356 N 1134.5252 E',mg,0x7ff7bfefef90)
str='4808.2356 N 1134.5252 E'
args=4
lat=4808.235600 N lon=1134.525200 E
projection=mg str_pro=0 projection_none=0
transform_from_geo(48.137260,11.575420)
result 0x13a3d7,0x5d6d6d
str='4808.2356 N 1134.5252 E' x=34.525200 ns=N y=8.235600 ew=E c=23
rest=''
ret=23 delta=0 ret_str=''

length: 23

X: 1287127
Y: 6122861

Latitude / Longitude in degrees and minutes to projection_garmin

enter('4808.2356 N 1134.5252 E',garmin,0x7ff7bfefef90)
str='4808.2356 N 1134.5252 E'
args=4
lat=4808.235600 N lon=1134.525200 E
projection=garmin str_pro=0 projection_none=0
transform_from_geo(48.137260,11.575420)
result 0x83b3d,0x223b1e
str='4808.2356 N 1134.5252 E' x=34.525200 ns=N y=8.235600 ew=E c=23
rest=''
ret=23 delta=0 ret_str=''

length: 23

X: 539453
Y: 2243358

Latitude / Longitude in degrees and minutes to projection_utm

enter('4808.2356 N 1134.5252 E',utm,0x7ff7bfefef90)
str='4808.2356 N 1134.5252 E'
args=4
lat=4808.235600 N lon=1134.525200 E
projection=utm str_pro=0 projection_none=0
transform_from_geo(48.137260,11.575420)
result 0xffff,0xffff
str='4808.2356 N 1134.5252 E' x=34.525200 ns=N y=8.235600 ew=E c=23
rest=''
ret=23 delta=0 ret_str=''

length: 23

X: 65535
Y: 65535

Mercator coordinates to projection_none

enter('0x13a3d7 0x5d6d6d',none,0x7ff7bfefef90)
str='0x13a3d7 0x5d6d6d' x=0x13a3d7 y=0x5d6d6d c=17
rest=''
ret=17 delta=0 ret_str=''

length: 17

X: 1287127
Y: 6122861

Mercator coordinates to projection_mg

enter('0x13a3d7 0x5d6d6d',mg,0x7ff7bfefef90)
str='0x13a3d7 0x5d6d6d' x=0x13a3d7 y=0x5d6d6d c=17
rest=''
ret=17 delta=0 ret_str=''

length: 17

X: 1287127
Y: 6122861

Mercator coordinates to projection_garmin

enter('0x13a3d7 0x5d6d6d',garmin,0x7ff7bfefef90)
str='0x13a3d7 0x5d6d6d' x=0x13a3d7 y=0x5d6d6d c=17
rest=''
ret=17 delta=0 ret_str=''

length: 17

X: 539453
Y: 2243358

Mercator coordinates to projection_utm

enter('0x13a3d7 0x5d6d6d',utm,0x7ff7bfefef90)
str='0x13a3d7 0x5d6d6d' x=0x13a3d7 y=0x5d6d6d c=17
rest=''
ret=17 delta=0 ret_str=''

length: 17

X: 1287127
Y: 6122861

Mercator coordinates with 'mg:' to projection_none

enter('mg: 0x13a3d7 0x5d6d6d',none,0x7ff7bfefef90)
projection=mg
str='0x13a3d7 0x5d6d6d' x=0x13a3d7 y=0x5d6d6d c=17
rest=''
ret=21 delta=4 ret_str=''

length: 21

X: 1287127
Y: 6122861

Mercator coordinates with 'mg:' to projection_mg

enter('mg: 0x13a3d7 0x5d6d6d',mg,0x7ff7bfefef90)
projection=mg
str='0x13a3d7 0x5d6d6d' x=0x13a3d7 y=0x5d6d6d c=17
rest=''
ret=21 delta=4 ret_str=''

length: 21

X: 1287127
Y: 6122861

Mercator coordinates with 'mg:' to projection_garmin

enter('mg: 0x13a3d7 0x5d6d6d',garmin,0x7ff7bfefef90)
projection=mg
str='0x13a3d7 0x5d6d6d' x=0x13a3d7 y=0x5d6d6d c=17
rest=''
ret=21 delta=4 ret_str=''

length: 21

X: 539453
Y: 2243358

Mercator coordinates with 'mg:' to projection_utm

enter('mg: 0x13a3d7 0x5d6d6d',utm,0x7ff7bfefef90)
projection=mg
str='0x13a3d7 0x5d6d6d' x=0x13a3d7 y=0x5d6d6d c=17
rest=''
ret=21 delta=4 ret_str=''

length: 21

X: 1287127
Y: 6122861

UTM coordinates to projection_none

enter('utm32N: 674661 5328114',none,0x7ff7bfefef90)
projection=utm32N
ret=23 delta=8 ret_str=''

length: 23

X: 32674661
Y: 5328114

UTM coordinates to projection_mg

enter('utm32N: 674661 5328114',mg,0x7ff7bfefef90)
projection=utm32N
ret=23 delta=8 ret_str=''

length: 23

X: 1261533
Y: 6113717

UTM coordinates to projection_garmin

enter('utm32N: 674661 5328114',garmin,0x7ff7bfefef90)
projection=utm32N
ret=23 delta=8 ret_str=''

length: 23

X: 528726
Y: 2240800

UTM coordinates to projection_utm

enter('utm32N: 674661 5328114',utm,0x7ff7bfefef90)
projection=utm32N
ret=23 delta=8 ret_str=''

length: 23

X: 32674661
Y: 5328114

UTMRef coordinates to projection_none

enter('utmref32UMD:74 03',none,0x7ff7bfefef90)
projection=utmref32UMD
zone_field 6baserow 53i=-2ret=17 delta=12 ret_str=''

length: 17

X: 32400074
Y: 5800003

UTMRef coordinates to projection_mg

enter('utmref32UMD:74 03',mg,0x7ff7bfefef90)
projection=utmref32UMD
zone_field 6baserow 53i=-2ret=17 delta=12 ret_str=''

length: 17

X: 837654
Y: 6854379

UTMRef coordinates to projection_garmin

enter('utmref32UMD:74 03',garmin,0x7ff7bfefef90)
projection=utmref32UMD
zone_field 6baserow 53i=-2ret=17 delta=12 ret_str=''

length: 17

X: 351072
Y: 2439277

UTMRef coordinates to projection_utm

enter('utmref32UMD:74 03',utm,0x7ff7bfefef90)
projection=utmref32UMD
zone_field 6baserow 53i=-2ret=17 delta=12 ret_str=''

length: 17

X: 32400074
Y: 5800003

@OLFDB OLFDB requested a review from jkoan January 28, 2023 04:24
@@ -0,0 +1,84 @@
## Coordinates in Navit
Copy link
Member

Choose a reason for hiding this comment

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

I just happen now to see that you used markdown instead of reStructuredText which results in no headline found here and not format here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just updated coordinates.rst to be in rst format (at least I choose export reStructuredText in Typora to create it). Added some lines for Google Maps coordinates as well.

@jkoan
Copy link
Member

jkoan commented Jan 31, 2023

There was an issue with using the format '4808.2356 N 1134.5252 E' I have made testcases for the coordinate formats listed below. 65535 means the struct coord *result has not changed, so no coordinates have been set.

Testing all allowed coordinate types and conversions:

[...]

I will take you tests, convert them into unittests and check the before and after. Afterwards i will merge this. The code itself looks valid :-) thx

@jkoan jkoan linked an issue Feb 25, 2023 that may be closed by this pull request
@AgentSmith0
Copy link

Any updates on merging this?

This format is used internally by Navit, but is probably not very useful
for other purposes.

Google Maps Format
Copy link
Contributor

Choose a reason for hiding this comment

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

That makes it sound like Google invented this format. Can’t we put this more nicely (e.g. decimal WGS84 lat/lon)? Also, since this is closely related to the other WGS84 formats, why not move it closer to them?


.. code::

48.137260, 11.575420
Copy link
Contributor

Choose a reason for hiding this comment

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

Since there is another WGS84 decimal format, albeit with longitude before latitude, how does Navit know which of the two is meant (i.e. order of coordinates)? Or, what do I need to pay attention to when supplying these coordinates so Navit interprets them correctly (avoiding coordinates being swapped)?


- mg - the projection used by Map&Guide (the default)

- garmin - "Garmin" projection (TODO: When would it be useful?)
Copy link
Contributor

Choose a reason for hiding this comment

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

AFAIK this is for legacy reasons: Navit was started around 2002 (source code was released later). Note that this predates OSM – the first versions used commercial map data, including Garmin. Hence there would have been a need to support their coordinate system. This probably also explains why Navit internally uses mg rather than WGS84.

@jkoan
Copy link
Member

jkoan commented Mar 27, 2023

Any updates on merging this?

This PR conflicts with the changes in #1221 and if i throw together the tests from you and the other PR both PR's have failing cases.
I haven't found the time to look into it more deeply, sorry for the delay.

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.

Crash when setting first destination
4 participants