diff --git a/README.md b/README.md index ebba63b567..af7d457033 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Current vehicle position from gpsd or directly from NMEA (GPS) sensors. \ Optimal routes and directions spoken in 70+ languages. \ Points of interest (POIs) in many formats. -Help and more info available on [the wiki](https://navit.readthedocs.io/en/v0.5.6/). \ +Help and more info available on [the wiki](https://wiki.navit-project.org/index.php/Main_Page). \ The [Reporting Bugs](http://wiki.navit-project.org/index.php/Reporting_Bugs) document helps you file issues. Maps diff --git a/docs/configuration/coordinates.rst b/docs/configuration/coordinates.rst new file mode 100644 index 0000000000..a127f299ec --- /dev/null +++ b/docs/configuration/coordinates.rst @@ -0,0 +1,136 @@ +Coordinates in Navit +==================== + +Various parts of Navit will read geographical coordinates provided as +text: + +- the `textfile `__ + map format + +- the "center=" attribute in the configuration file + +- some Navit commands (e.g. set_position), which can be invoked via + the `internal + GUI `__ or the + `Dbus `__ bindings + +- the files for bookmarks and last map position (bookmarks.txt and + center.txt) + +This page documents the coordinate systems and formats that Navit will +accept. + +Supported coordinate systems and formats +======================================== + +.. _longitude--latitude-in-decimal-degrees: + +Longitude / Latitude in decimal degrees +--------------------------------------- + +Longitude / latitude in degrees can be specified as signed decimal +fractions: + +.. code:: + + -33.3553 6.334 + +That would be about 33° West, 6° North. Note that in this format +longitude comes first. The coordinates are assumed to be based on WGS84 +(the coordinate system used by the GPS system, and by practically all +common navigation systems). + +.. _latitude--longitude-in-degrees-and-minutes: + +Latitude / Longitude in degrees and minutes +------------------------------------------- + +Latitude / Longitude can also be specified in degress and minutes with +compass directions (N/S, E/W): + +.. code:: + + 4808 N 1134 E + +Latitude and longitude are multiplied by 100, so the position above +corresponds to 48°8' N, 11°34' (Munich). + +For greater precision you can write the minutes as decimal fractions: + +.. code:: + + 4808.2356 N 1134.5252 E + +That is 48°8.2356' N 11°34.5252' E, the center of the Marienplatz in +Munich. + +Notes: + +- This format is rather unusual (because it uses arcminutes, but not + arcseconds). It is probably easier to just use decimal fractions of + degrees. + +- The spaces are relevant for parsing. Use exactly one space between + the number and the letter N/S/E/W. + +Cartesian coordinates +--------------------- + +Internally, Navit uses a cartesian coordinate system induced by a +Mercator projection. Coordinates are written as hexadecimal integers: + +.. code:: + + 0x13a3d7 0x5d6d6d + +or specifying a projection: + +.. code:: + + mg: 0x13a3d7 0x5d6d6d + +That is again 48°8.2356' N 11°34.5252' E. The part up to and including +the colon is optional, it names the projection to use. Possible values: + +- mg - the projection used by Map&Guide (the default) + +- garmin - "Garmin" projection (TODO: When would it be useful?) + +This format is used internally by Navit, but is probably not very useful +for other purposes. + +Google Maps Format +------------------ + +.. code:: + + 48.137260, 11.575420 + +That is again 48°8.2356' N 11°34.5252' E. The values are comma +separated. You can pick such values from Google Maps with right click on +a location and then click on the coordinate in the context menu. This is +useful when planning a route online by creating a waypoint file. + +UTM coordinates +--------------- + +Navit can read coordinates in the `Universal Transverse Mercator +coordinate +system `__ +(UTM). + +.. code:: + + utm32U: 674499.306 5328063.675 + +.. code:: + + utmref32UPU:74499.306 28063.675 + +Development notes +================= + +The coordinates are parsed in function coord_parse() in coord.c. This +code is used everywhere where Navit parses coordinates, except for the +manual coordinate input in the Internal GUI (which uses its own format +and parsing function). diff --git a/docs/configuration/general.rst b/docs/configuration/general.rst index 34b201d614..52813adaaa 100644 --- a/docs/configuration/general.rst +++ b/docs/configuration/general.rst @@ -18,7 +18,7 @@ On Navit's very first startup, it needs a **center** to look at on the map. By d center="11.5666 48.1333" -Coordinates can be written in different formats; see [[Coordinate_format]] for the full list. +Coordinates can be written in different formats; see :doc:`coordinates` for the full list. To determine a specific latitude and longitude for your location you can use http://itouchmap.com/latlong.html. Usually, changing the "center" setting is not necessary, since it is only used during the first start. On subsequent starts, Navit will remember the last map position (stored in "center.txt") and ignore the "center" setting. diff --git a/navit/attr.h b/navit/attr.h index 5eed1718f4..cae591ffd6 100644 --- a/navit/attr.h +++ b/navit/attr.h @@ -28,7 +28,28 @@ extern "C" { enum item_type; -#include "attr_type_def.h" +/** + * Attribute type values, created using macro magic. + */ +enum attr_type { +#define ATTR2(x,y) attr_##y=x, +#define ATTR(x) attr_##x, + + /* Special macro for unused attribute types. Creates a placeholder entry + * in the enum so the following values do not change. */ +#define ATTR_UNUSED ATTR_UNUSED_L(__LINE__) +#define ATTR_UNUSED_L(x) ATTR_UNUSED_WITH_LINE_NUMBER(x) +#define ATTR_UNUSED_WITH_LINE_NUMBER(x) ATTR_UNUSED_##x, + +#include "attr_def.h" + +#undef ATTR_UNUSED_WITH_LINE_NUMBER +#undef ATTR_UNUSED_L +#undef ATTR_UNUSED + +#undef ATTR2 +#undef ATTR +}; enum attr_format { attr_format_default=0, diff --git a/navit/attr_type_def.h b/navit/attr_type_def.h deleted file mode 100644 index af0b6571f7..0000000000 --- a/navit/attr_type_def.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef NAVIT_ATTR_TYPE_DEFH -#define NAVIT_ATTR_TYPE_DEFH - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Attribute type values, created using macro magic. - */ -enum attr_type { -#define ATTR2(x,y) attr_##y=x, -#define ATTR(x) attr_##x, - - /* Special macro for unused attribute types. Creates a placeholder entry - * in the enum so the following values do not change. */ -#define ATTR_UNUSED ATTR_UNUSED_L(__LINE__) -#define ATTR_UNUSED_L(x) ATTR_UNUSED_WITH_LINE_NUMBER(x) -#define ATTR_UNUSED_WITH_LINE_NUMBER(x) ATTR_UNUSED_##x, - -#include "attr_def.h" - -#undef ATTR_UNUSED_WITH_LINE_NUMBER -#undef ATTR_UNUSED_L -#undef ATTR_UNUSED - -#undef ATTR2 -#undef ATTR -}; - -#ifdef __cplusplus -} -/* __cplusplus */ -#endif - -/* NAVIT_ATTR_TYPE_DEFH */ -#endif diff --git a/navit/coord.c b/navit/coord.c index 03dec06b9b..cefa995aca 100644 --- a/navit/coord.c +++ b/navit/coord.c @@ -132,11 +132,11 @@ void coord_rect_extend(struct coord_rect *r, struct coord *c) { * Parses \c char \a *coord_input and writes back the coordinates to \c coord \a *result, using \c projection \a output_projection. * \a *coord_input may specify its projection at the beginning. * The format for \a *coord_input can be: - * \li [Proj:][-]0xXX.... [-]0xXX... - Mercator coordinates, hex integers (XX), Proj can be "mg" or "garmin", defaults to mg - * \li [Proj:][D][D]Dmm.mm.. N/S [D][D]DMM.mm... E/W - lat/long (WGS 84), integer degrees (DD) and minutes as decimal fraction (MM), Proj must be "geo" or absent - * \li [Proj:][-][D]D.d[d]... [-][D][D]D.d[d]... - long/lat (WGS 84, note order!), degrees as decimal fraction, Proj does not matter - * \li utm[zoneinfo]:[-][D]D.d[d]... [-][D][D]D.d[d] - UTM coordinates, as decimal fraction, with optional zone information (?) - * \li [-][D]D.d[d]...,[-][D][D]D.d[d]... - comma-separated (but without space inside the string) lat/long degrees as decimal fraction, Proj does not matter + * \li [Proj:][-]0xXX.... [-]0xXX... - Mercator coordinates, hex integers (XX), Proj can be "mg" or "garmin", defaults to mg + * \li [Proj:][D][D]Dmm.mm.. N/S [D][D]DMM.mm... E/W - lat/long (WGS 84), integer degrees (DD) and minutes as decimal fraction (MM), Proj must be "geo" or absent + * \li [Proj:][-][D]D.d[d]... [-][D][D]D.d[d]... - long/lat (WGS 84, note order!), degrees as decimal fraction, Proj does not matter + * \li utm[zoneinfo]:[-][D]D.d[d]... [-][D][D]D.d[d] - UTM coordinates, as decimal fraction, with optional zone information (?) + * \li [-][D]D.d[d]...,[-][D][D]D.d[d]... - comma-separated (but without space inside the string) lat/long degrees as decimal fraction, Proj does not matter * Note that the spaces are relevant for parsing. * * @param *coord_input String to be parsed @@ -146,50 +146,60 @@ void coord_rect_extend(struct coord_rect *r, struct coord *c) { */ int coord_parse(const char *coord_input, enum projection output_projection, struct coord *result) { - char *proj=NULL,*s,*co; + char *proj=NULL,*s=NULL,*co; const char *str=coord_input; int args,ret = 0; struct coord_geo g; struct coord c,offset; enum projection str_pro=projection_none; int space_as_sep = 0; + c.x=0; + c.y=0; - dbg(lvl_debug,"enter('%s',%d,%p)", coord_input, output_projection, result); - s=strchr(str, ' '); - if (!s) { + dbg(lvl_debug,"enter('%s',%s,%p)\n", coord_input, projection_to_name(output_projection), result); + co=strchr(str,':'); + if(co) + s=strstr(str, ": "); + else { + while(*str==' ') { + str++; + } + s=strstr(str, " "); + while(s && *s==' ') { + s++; + } + } + + + if (s && !strstr(str, ",")) { space_as_sep = 1; - s=strchr(str, ','); } - co=strchr(str,':'); - if (co && co < s) { + if (co) { proj=g_malloc(co-str+1); g_strlcpy(proj, str, 1+co-str); - dbg(lvl_debug,"projection=%s", proj); + dbg(lvl_debug,"projection=%s\n", proj); str=co+1; - s=strchr(str,space_as_sep?' ':','); + if(space_as_sep) + str++; + s=(char*)str; if (!strcmp(proj, "geo")) str_pro = projection_none; else { str_pro = projection_from_name(proj,&offset); if (str_pro == projection_none) { - dbg(lvl_error, "Unknown projection: %s", proj); + dbg(lvl_error, "Unknown projection: %s\n", proj); goto out; } } + } else if (!space_as_sep || strstr(str, "0x")) { + s=(char*)str; } - if (! s) { - ret=0; - goto out; - } - while (*s == ' ') { - s++; - } - if (!space_as_sep && (!strncmp(s, "0x", 2) || !strncmp(s, "-0x", 3))) { + if ((!strncmp(s, "0x", 2) || !strncmp(s, "-0x", 3))) { args=sscanf(str, "%i %i%n",&c.x, &c.y, &ret); if (args < 2) goto out; - dbg(lvl_debug,"str='%s' x=0x%x y=0x%x c=%d", str, c.x, c.y, ret); - dbg(lvl_debug,"rest='%s'", str+ret); + dbg(lvl_debug,"str='%s' x=0x%x y=0x%x c=%d\n", str, c.x, c.y, ret); + dbg(lvl_debug,"rest='%s'\n", str+ret); if (str_pro == projection_none) str_pro=projection_mg; @@ -198,16 +208,17 @@ int coord_parse(const char *coord_input, enum projection output_projection, stru transform_from_geo(output_projection, &g, &c); } *result=c; - } else if (!space_as_sep && (*s == 'N' || *s == 'n' || *s == 'S' || *s == 's')) { + } else if ((*s == 'N' || *s == 'n' || *s == 'S' || *s == 's')) { double lng, lat; char ns, ew; - dbg(lvl_debug,"str='%s'", str); + dbg(lvl_debug,"str='%s'\n", str); args=sscanf(str, "%lf %c %lf %c%n", &lat, &ns, &lng, &ew, &ret); - dbg(lvl_debug,"args=%d", args); - dbg(lvl_debug,"lat=%f %c lon=%f %c", lat, ns, lng, ew); + dbg(lvl_debug,"args=%d\n", args); + dbg(lvl_debug,"lat=%f %c lon=%f %c\n", lat, ns, lng, ew); if (args < 4) goto out; - dbg(lvl_debug,"projection=%d str_pro=%d projection_none=%d", output_projection, str_pro, projection_none); + dbg(lvl_debug,"projection=%s str_pro=%d projection_none=%d\n", projection_to_name(output_projection), str_pro, + projection_none); if (str_pro == projection_none) { g.lat=floor(lat/100); lat-=g.lat*100; @@ -219,13 +230,13 @@ int coord_parse(const char *coord_input, enum projection output_projection, stru g.lat=-g.lat; if (ew == 'w' || ew == 'W') g.lng=-g.lng; - dbg(lvl_debug,"transform_from_geo(%f,%f)",g.lat,g.lng); + dbg(lvl_debug,"transform_from_geo(%f,%f)\n",g.lat,g.lng); transform_from_geo(output_projection, &g, result); - dbg(lvl_debug,"result 0x%x,0x%x", result->x,result->y); + dbg(lvl_debug,"result 0x%x,0x%x\n", result->x,result->y); } - dbg(lvl_debug,"str='%s' x=%f ns=%c y=%f ew=%c c=%d", str, lng, ns, lat, ew, ret); - dbg(lvl_debug,"rest='%s'", str+ret); - } else if (!space_as_sep && (str_pro == projection_utm)) { + dbg(lvl_debug,"str='%s' x=%f ns=%c y=%f ew=%c c=%d\n", str, lng, ns, lat, ew, ret); + dbg(lvl_debug,"rest='%s'\n", str+ret); + } else if (str_pro == projection_utm) { double x,y; args=sscanf(str, "%lf %lf%n", &x, &y, &ret); if (args < 2) @@ -237,31 +248,30 @@ int coord_parse(const char *coord_input, enum projection output_projection, stru transform_from_geo(output_projection, &g, &c); } *result=c; - } else if (space_as_sep) { - // When entering coords like google's format, we actually get strings like "52.5219,19.4127" + } else if (!space_as_sep) { + // When entering coords like google's format, we actually get strings like "52.5219, 19.4127" double lng, lat; - args=sscanf(str, "%lf,%lf%n", &lat, &lng, &ret); + args=sscanf(str, "%lf, %lf%n", &lat, &lng, &ret); if (args < 2) goto out; - dbg(lvl_debug,"str='%s' x=%f y=%f c=%d", str, lng, lat, ret); - dbg(lvl_debug,"rest='%s'", str+ret); + dbg(lvl_debug,"str='%s' x=%f y=%f c=%d\n", str, lng, lat, ret); + dbg(lvl_debug,"rest='%s'\n", str+ret); g.lng=lng; g.lat=lat; transform_from_geo(output_projection, &g, result); - } - else { + } else { double lng, lat; args=sscanf(str, "%lf %lf%n", &lng, &lat, &ret); if (args < 2) goto out; - dbg(lvl_debug,"str='%s' x=%f y=%f c=%d", str, lng, lat, ret); - dbg(lvl_debug,"rest='%s'", str+ret); + dbg(lvl_debug,"str='%s' x=%f y=%f c=%d\n", str, lng, lat, ret); + dbg(lvl_debug,"rest='%s'\n", str+ret); g.lng=lng; g.lat=lat; transform_from_geo(output_projection, &g, result); } ret+=str-coord_input; - dbg(lvl_info, "ret=%d delta=%d ret_str='%s'", ret, GPOINTER_TO_INT(str-coord_input), coord_input+ret); + dbg(lvl_debug, "ret=%d delta=%d ret_str='%s'\n", ret, GPOINTER_TO_INT(str-coord_input), coord_input+ret); out: g_free(proj); return ret; @@ -300,7 +310,7 @@ void coord_print(enum projection pro, struct coord *c, FILE *out) { } else { y = c->y; } - fprintf( out, "%s: %s0x%x %s0x%x\n", + fprintf( out, "%s:%s0x%x %s0x%x\n", projection_to_name( pro ), sign_x, x, sign_y, y ); diff --git a/navit/debug.c b/navit/debug.c index 9c615f8398..e46637cb21 100644 --- a/navit/debug.c +++ b/navit/debug.c @@ -472,9 +472,6 @@ void debug_dump_mallocs(void) { } } - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wframe-address" // We know what we are doing here, suppress warning void *debug_malloc(const char *where, int line, const char *func, int size) { struct malloc_head *head; struct malloc_tail *tail; @@ -511,7 +508,7 @@ void *debug_malloc(const char *where, int line, const char *func, int size) { tail->magic=0xdeadbef0; return head; } -#pragma GCC diagnostic pop + void *debug_malloc0(const char *where, int line, const char *func, int size) { void *ret=debug_malloc(where, line, func, size); diff --git a/navit/item.h b/navit/item.h index d1ee433b98..d3e222196b 100644 --- a/navit/item.h +++ b/navit/item.h @@ -25,7 +25,14 @@ extern "C" { #endif #include -#include "item_type_def.h" + +enum item_type { +#define ITEM2(x,y) type_##y=x, +#define ITEM(x) type_##x, +#include "item_def.h" +#undef ITEM2 +#undef ITEM +}; #define route_item_first type_street_0 #define route_item_last type_street_parking_lane diff --git a/navit/item_type_def.h b/navit/item_type_def.h deleted file mode 100644 index cecad21cb3..0000000000 --- a/navit/item_type_def.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef NAVIT_ITEM_TYPE_DEFH -#define NAVIT_ITEM_TYPE_DEFH - -#ifdef __cplusplus -extern "C" { -#endif - -enum item_type { -#define ITEM2(x,y) type_##y=x, -#define ITEM(x) type_##x, -#include "item_def.h" -#undef ITEM2 -#undef ITEM -}; - -#ifdef __cplusplus -} -/* __cplusplus */ -#endif - -/* NAVIT_ITEM_TYPE_DEFH */ -#endif diff --git a/navit/map/garmin/garmin.c b/navit/map/garmin/garmin.c index 79768bcc3d..2f4808b3bf 100644 --- a/navit/map/garmin/garmin.c +++ b/navit/map/garmin/garmin.c @@ -95,44 +95,44 @@ struct gscale { int bits; }; -//static struct gscale mapscales[] = { -// {"7000 km", 70000.0, 8} -// ,{"5000 km", 50000.0, 8} -// ,{"3000 km", 30000.0, 9} -// ,{"2000 km", 20000.0, 9} -// ,{"1500 km", 15000.0, 10} -// ,{"1000 km", 10000.0, 10} -// ,{"700 km", 7000.0, 11} -// ,{"500 km", 5000.0, 11} -// ,{"300 km", 3000.0, 13} -// ,{"200 km", 2000.0, 13} -// ,{"150 km", 1500.0, 13} -// ,{"100 km", 1000.0, 14} -// ,{"70 km", 700.0, 15} -// ,{"50 km", 500.0, 16} -// ,{"30 km", 300.0, 16} -// ,{"20 km", 200.0, 17} -// ,{"15 km", 150.0, 17} -// ,{"10 km", 100.0, 18} -// ,{"7 km", 70.0, 18} -// ,{"5 km", 50.0, 19} -// ,{"3 km", 30.0, 19} -// ,{"2 km", 20.0, 20} -// ,{"1.5 km", 15.0, 22} -// ,{"1 km", 10.0, 24} -// ,{"700 m", 7.0, 24} -// ,{"500 m", 5.0, 24} -// ,{"300 m", 3.0, 24} -// ,{"200 m", 2.0, 24} -// ,{"150 m", 1.5, 24} -// ,{"100 m", 1.0, 24} -// ,{"70 m", 0.7, 24} -// ,{"50 m", 0.5, 24} -// ,{"30 m", 0.3, 24} -// ,{"20 m", 0.2, 24} -// ,{"15 m", 0.1, 24} -// ,{"10 m", 0.15, 24} -//}; +static struct gscale mapscales[] = { + {"7000 km", 70000.0, 8} + ,{"5000 km", 50000.0, 8} + ,{"3000 km", 30000.0, 9} + ,{"2000 km", 20000.0, 9} + ,{"1500 km", 15000.0, 10} + ,{"1000 km", 10000.0, 10} + ,{"700 km", 7000.0, 11} + ,{"500 km", 5000.0, 11} + ,{"300 km", 3000.0, 13} + ,{"200 km", 2000.0, 13} + ,{"150 km", 1500.0, 13} + ,{"100 km", 1000.0, 14} + ,{"70 km", 700.0, 15} + ,{"50 km", 500.0, 16} + ,{"30 km", 300.0, 16} + ,{"20 km", 200.0, 17} + ,{"15 km", 150.0, 17} + ,{"10 km", 100.0, 18} + ,{"7 km", 70.0, 18} + ,{"5 km", 50.0, 19} + ,{"3 km", 30.0, 19} + ,{"2 km", 20.0, 20} + ,{"1.5 km", 15.0, 22} + ,{"1 km", 10.0, 24} + ,{"700 m", 7.0, 24} + ,{"500 m", 5.0, 24} + ,{"300 m", 3.0, 24} + ,{"200 m", 2.0, 24} + ,{"150 m", 1.5, 24} + ,{"100 m", 1.0, 24} + ,{"70 m", 0.7, 24} + ,{"50 m", 0.5, 24} + ,{"30 m", 0.3, 24} + ,{"20 m", 0.2, 24} + ,{"15 m", 0.1, 24} + ,{"10 m", 0.15, 24} +}; static int garmin_object_label(struct gobject *o, struct attr *attr) { @@ -342,8 +342,6 @@ static int point_attr_get(void *priv_data, enum attr_type attr_type, struct attr mr->last_oattr = g; mr->last_attr = 0; } -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wimplicit-fallthrough=" switch(mr->last_attr) { case 0: mr->last_attr++; @@ -378,7 +376,6 @@ static int point_attr_get(void *priv_data, enum attr_type attr_type, struct attr default: return 0; } -#pragma GCC diagnostic pop break; case attr_label: attr->type = attr_label; @@ -423,171 +420,168 @@ static struct item_methods methods_garmin_poly = { coord_is_node, }; -//static int search_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr) { -// struct gobject *g = priv_data; -// struct map_rect_priv *mr = g->priv_data; -// int rc; -// switch (attr_type) { -// case attr_any: -// if (g != mr->last_oattr) { -// mr->last_oattr = g; -// mr->last_attr = 0; -// } -//#pragma GCC diagnostic push -//#pragma GCC diagnostic ignored "-Wimplicit-fallthrough=" -// switch(mr->last_attr) { -// case 0: -// mr->last_attr++; -// attr->type = attr_label; -// rc = garmin_object_label(g, attr); -// if (rc) -// return rc; -// case 1: -// mr->last_attr++; -// attr->type = attr_debug; -// rc = garmin_object_debug(g, attr); -// if (rc) -// return rc; -// case 2: -// mr->last_attr++; -// if (g->type == GO_POLYLINE) { -// attr->type = attr_street_name; -// rc = garmin_object_label(g, attr); -// if (rc) -// return rc; -// } -// case 3: -// mr->last_attr++; -// attr->type = attr_flags; -// attr->u.num = 0; -// rc = gar_object_flags(g); -// if (rc & F_ONEWAY) -// attr->u.num |= AF_ONEWAY; -// if (rc & F_SEGMENTED) -// attr->u.num |= AF_SEGMENTED; -// return 1; -// default: -// return 0; -// } -//#pragma GCC diagnostic pop -// break; -// case attr_label: -// attr->type = attr_label; -// return garmin_object_label(g, attr); -// case attr_town_name: -// attr->type = attr_town_name; -// if (mr->label) -// free(mr->label); -// mr->label = gar_srch_get_city(g); -// attr->u.str = mr->label; -// if (attr->u.str) -// return 1; -// return 0; -// case attr_town_id: -// rc = gar_srch_get_cityid(g); -// if (rc) { -// attr->type = attr_town_id; -// attr->u.num = rc; -// return 1; -// } -// return 0; -// case attr_town_postal: -// attr->type = attr_town_postal; -// attr->u.str = gar_srch_get_zip(g); -// if (attr->u.str) -// return 1; -// return 0; -// case attr_street_name: -// attr->type = attr_street_name; -// if (mr->label) -// free(mr->label); -// mr->label = gar_srch_get_roadname(g); -// attr->u.str = mr->label; -// if (attr->u.str) -// return 1; -// return 0; -// case attr_street_id: -// attr->type = attr_street_id; -// attr->u.num = gar_srch_get_roadid(g); -// if (attr->u.num) -// return 1; -// return 0; -// case attr_flags: -// attr->type = attr_flags; -// attr->u.num = 0; -// rc = gar_object_flags(g); -// if (rc & F_ONEWAY) -// attr->u.num |= AF_ONEWAY; -// if (rc & F_SEGMENTED) -// attr->u.num |= AF_SEGMENTED; -// return 1; -// case attr_country_id: -// rc = gar_srch_get_countryid(g); -// if (rc) { -// attr->type = attr_country_id; -// attr->u.num = rc; -// return 1; -// } -// return 0; -// case attr_country_name: -// attr->type = attr_country_name; -// attr->u.str = gar_srch_get_country(g); -// if (attr->u.str) -// return 1; -// return 0; -// case attr_district_id: -// rc = gar_srch_get_regionid(g); -// if (rc) { -// attr->type = attr_district_id; -// attr->u.num = rc; -// return 1; -// } -// return 0; -// case attr_district_name: -// attr->type = attr_district_name; -// attr->u.str = gar_srch_get_region(g); -// if (attr->u.str) -// return 1; -// return 0; -// case attr_town_streets_item: -// return 0; -// default: -// dlog(1, "Don't know about attribute %d[%04X]=%s yet\n", -// attr_type,attr_type, attr_to_name(attr_type)); -// } -// -// return 0; -//} - -//static int search_coord_get(void *priv_data, struct coord *c, int count) { -// struct gobject *g = priv_data; -// struct map_rect_priv *mr = g->priv_data; -// struct gcoord gc; -// if (!count) -// return 0; -// if (g != mr->last_itterated) { -// mr->last_itterated = g; -// mr->last_coord = 0; -// } -// -// if (mr->last_coord > 0) -// return 0; -// -// if (gar_get_object_coord(mr->gmap, g, &gc)) { -// c->x = gc.x; -// c->y = gc.y; -// mr->last_coord++; -// return 1; -// } -// return 0; -//} - -//static struct item_methods methods_garmin_search = { -// coord_rewind, -// search_coord_get, -// attr_rewind, -// search_attr_get, -//}; +static int search_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr) { + struct gobject *g = priv_data; + struct map_rect_priv *mr = g->priv_data; + int rc; + switch (attr_type) { + case attr_any: + if (g != mr->last_oattr) { + mr->last_oattr = g; + mr->last_attr = 0; + } + switch(mr->last_attr) { + case 0: + mr->last_attr++; + attr->type = attr_label; + rc = garmin_object_label(g, attr); + if (rc) + return rc; + case 1: + mr->last_attr++; + attr->type = attr_debug; + rc = garmin_object_debug(g, attr); + if (rc) + return rc; + case 2: + mr->last_attr++; + if (g->type == GO_POLYLINE) { + attr->type = attr_street_name; + rc = garmin_object_label(g, attr); + if (rc) + return rc; + } + case 3: + mr->last_attr++; + attr->type = attr_flags; + attr->u.num = 0; + rc = gar_object_flags(g); + if (rc & F_ONEWAY) + attr->u.num |= AF_ONEWAY; + if (rc & F_SEGMENTED) + attr->u.num |= AF_SEGMENTED; + return 1; + default: + return 0; + } + break; + case attr_label: + attr->type = attr_label; + return garmin_object_label(g, attr); + case attr_town_name: + attr->type = attr_town_name; + if (mr->label) + free(mr->label); + mr->label = gar_srch_get_city(g); + attr->u.str = mr->label; + if (attr->u.str) + return 1; + return 0; + case attr_town_id: + rc = gar_srch_get_cityid(g); + if (rc) { + attr->type = attr_town_id; + attr->u.num = rc; + return 1; + } + return 0; + case attr_town_postal: + attr->type = attr_town_postal; + attr->u.str = gar_srch_get_zip(g); + if (attr->u.str) + return 1; + return 0; + case attr_street_name: + attr->type = attr_street_name; + if (mr->label) + free(mr->label); + mr->label = gar_srch_get_roadname(g); + attr->u.str = mr->label; + if (attr->u.str) + return 1; + return 0; + case attr_street_id: + attr->type = attr_street_id; + attr->u.num = gar_srch_get_roadid(g); + if (attr->u.num) + return 1; + return 0; + case attr_flags: + attr->type = attr_flags; + attr->u.num = 0; + rc = gar_object_flags(g); + if (rc & F_ONEWAY) + attr->u.num |= AF_ONEWAY; + if (rc & F_SEGMENTED) + attr->u.num |= AF_SEGMENTED; + return 1; + case attr_country_id: + rc = gar_srch_get_countryid(g); + if (rc) { + attr->type = attr_country_id; + attr->u.num = rc; + return 1; + } + return 0; + case attr_country_name: + attr->type = attr_country_name; + attr->u.str = gar_srch_get_country(g); + if (attr->u.str) + return 1; + return 0; + case attr_district_id: + rc = gar_srch_get_regionid(g); + if (rc) { + attr->type = attr_district_id; + attr->u.num = rc; + return 1; + } + return 0; + case attr_district_name: + attr->type = attr_district_name; + attr->u.str = gar_srch_get_region(g); + if (attr->u.str) + return 1; + return 0; + case attr_town_streets_item: + return 0; + default: + dlog(1, "Don't know about attribute %d[%04X]=%s yet\n", + attr_type,attr_type, attr_to_name(attr_type)); + } + + return 0; +} + +static int search_coord_get(void *priv_data, struct coord *c, int count) { + struct gobject *g = priv_data; + struct map_rect_priv *mr = g->priv_data; + struct gcoord gc; + if (!count) + return 0; + if (g != mr->last_itterated) { + mr->last_itterated = g; + mr->last_coord = 0; + } + + if (mr->last_coord > 0) + return 0; + + if (gar_get_object_coord(mr->gmap, g, &gc)) { + c->x = gc.x; + c->y = gc.y; + mr->last_coord++; + return 1; + } + return 0; +} + +static struct item_methods methods_garmin_search = { + coord_rewind, + search_coord_get, + attr_rewind, + search_attr_get, +}; static struct item *garmin_poi2item(struct map_rect_priv *mr, struct gobject *o, unsigned short otype) { @@ -617,11 +611,11 @@ static struct item *garmin_pg2item(struct map_rect_priv *mr, struct gobject *o, return &mr->item; } -//static struct item *garmin_srch2item(struct map_rect_priv *mr, struct gobject *o, unsigned short otype) { -// mr->item.type = type_country_label; -// mr->item.meth = &methods_garmin_search; -// return &mr->item; -//} +static struct item *garmin_srch2item(struct map_rect_priv *mr, struct gobject *o, unsigned short otype) { + mr->item.type = type_country_label; + mr->item.meth = &methods_garmin_search; + return &mr->item; +} static struct item *garmin_obj2item(struct map_rect_priv *mr, struct gobject *o) { unsigned short otype; diff --git a/navit/maptool/osm.c b/navit/maptool/osm.c index c9531144b7..f76120e3e4 100644 --- a/navit/maptool/osm.c +++ b/navit/maptool/osm.c @@ -2163,7 +2163,7 @@ static void osm_process_town_by_boundary_update_attrs(struct item_bin *town, str /* Administrative centres are not to be contained in their own districts. */ if(max_adm_level>0) for(a=max_possible_adm_level-1; a>max_adm_level && a>2; a--) - tc->attrs[a-2].type=attr_none; + tc->attrs[a-2].type=type_none; } /** diff --git a/navit/projection.c b/navit/projection.c index 512a4d8883..f00c44c8b3 100644 --- a/navit/projection.c +++ b/navit/projection.c @@ -37,6 +37,7 @@ struct projection_name projection_names[]= { }; static int utmref_letter(char l) { + l=tolower(l); if (l < 'a' || l == 'i' || l == 'o') return -1; if (l < 'i') @@ -65,12 +66,18 @@ enum projection projection_from_name(const char *name, struct coord *utm_offset) return projection_names[i].projection; } if (utm_offset) { - if (sscanf(name,"utm%d%c",&zone,&ns) == 2 && zone > 0 && zone <= 60 && (ns == 'n' || ns == 's')) { + int scanres = sscanf(name,"utm%d%c",&zone,&ns); + ns = tolower(ns); + if (scanres == 2 && zone > 0 && zone <= 60 && (ns == 'n' || ns == 's')) { utm_offset->x=zone*1000000; utm_offset->y=(ns == 's' ? -10000000:0); return projection_utm; } if (sscanf(name,"utmref%d%c%c%c",&zone,&zone_field,&square_x,&square_y)) { + zone=tolower(zone); + zone_field=tolower(zone_field); + square_x=tolower(square_x); + square_y=tolower(square_y); i=utmref_letter(zone_field); if (i < 2 || i > 21) { dbg(lvl_error,"invalid zone field '%c' in '%s'",zone_field,name); diff --git a/navit/projection.h b/navit/projection.h index d67952b1fb..26a3284f7b 100644 --- a/navit/projection.h +++ b/navit/projection.h @@ -21,11 +21,11 @@ #define NAVIT_PROJECTION_H enum projection { - projection_none, /*!< No projection or unknown projection */ - projection_mg, /*!< Mercator projection */ - projection_garmin, /*!< Garmin projection */ - projection_screen, /*!< Screen projection */ - projection_utm /*!< UTM projection */ + projection_none, /*!< No projection or unknown projection */ + projection_mg, /*!< Mercator projection */ + projection_garmin, /*!< Garmin projection */ + projection_screen, /*!< Screen projection */ + projection_utm /*!< UTM projection */ }; enum map_datum { diff --git a/navit/search_houseno_interpol.c b/navit/search_houseno_interpol.c index 4ba39b9932..b08bfacea6 100644 --- a/navit/search_houseno_interpol.c +++ b/navit/search_houseno_interpol.c @@ -64,8 +64,7 @@ void house_number_interpolation_clear_current(struct house_number_interpolation g_free(inter->last); g_free(inter->curr); inter->first=inter->last=inter->curr=NULL; - inter->increment=-1; - inter->include_end_nodes=end_nodes_undefined; + inter->increment=inter->include_end_nodes=-1; } void house_number_interpolation_clear_all(struct house_number_interpolation *inter) { @@ -112,8 +111,6 @@ static char *search_next_house_number_curr_interpol(struct house_number_interpol hn=search_next_house_number_curr_interpol_with_ends(inter); } while (hn!=NULL && house_number_is_end_number(hn, inter)); break; - case end_nodes_undefined: - break; } return hn; } diff --git a/navit/search_houseno_interpol.h b/navit/search_houseno_interpol.h index 417cb63ccd..460d236c7f 100644 --- a/navit/search_houseno_interpol.h +++ b/navit/search_houseno_interpol.h @@ -20,7 +20,6 @@ enum include_end_nodes { end_nodes_yes, end_nodes_no, - end_nodes_undefined=-1, }; /** Data for a house number interpolation. */ diff --git a/navit/speech.h b/navit/speech.h index a928c700c3..8e4d3d91c1 100644 --- a/navit/speech.h +++ b/navit/speech.h @@ -20,8 +20,6 @@ #ifndef NAVIT_SPEECH_H #define NAVIT_SPEECH_H -#include "attr_type_def.h" - struct speech_priv; struct attr_iter; diff --git a/navit/util.c b/navit/util.c index 3e26d14af4..0dfdab20ec 100644 --- a/navit/util.c +++ b/navit/util.c @@ -766,7 +766,7 @@ unsigned int iso8601_to_secs(char *iso8601) { a=val[0]/100; b=2-a+a/4; - if (val[1] < 3) { + if (val[1] < 2) { val[0]--; val[1]+=12; } diff --git a/po/nl.po.in b/po/nl.po.in index d5683d14c8..6b19361226 100644 --- a/po/nl.po.in +++ b/po/nl.po.in @@ -2369,7 +2369,7 @@ msgid "" "Sorry, we currently do not support maps above 3.8G on Android, please select " "a smaller one." msgstr "" -"Kaarten gorter dan 3,8GB zijn momenteel niet ondersteund op Android.\n" +"Kaarten gorter dan 3,8GB zijn momenteel niet ondersteund op Android.\r\n" "Kies a.u.b. een kleinere kaart." #. Android resource: @strings/map_no_fix diff --git a/po/sr.po.in b/po/sr.po.in index a3ad42c5ce..fe3ef64dc2 100644 --- a/po/sr.po.in +++ b/po/sr.po.in @@ -21,7 +21,7 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && " "n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" -"Language: sr\n" +"Language: \n" "X-Report-Errors: https://translations.launchpad.net/navit/trunk/+pots/navit\n" msgid "Running from source directory\n" diff --git a/po/zh_TW.po.in b/po/zh_TW.po.in index 6d152d63a1..426155840b 100644 --- a/po/zh_TW.po.in +++ b/po/zh_TW.po.in @@ -15,7 +15,6 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" -"Language: zh_TW\n" msgid "Running from source directory\n" msgstr "自源目錄執行\n"