navit  0.5.1-trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Groups
Coordinate handling functions


struct coordcoord_get (unsigned char **p)
struct coordcoord_new (int x, int y)
struct coordcoord_new_from_attrs (struct attr *parent, struct attr **attrs)
void coord_destroy (struct coord *c)
struct coord_rectcoord_rect_new (struct coord *lu, struct coord *rl)
void coord_rect_destroy (struct coord_rect *r)
int coord_rect_overlap (struct coord_rect *r1, struct coord_rect *r2)
int coord_rect_contains (struct coord_rect *r, struct coord *c)
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)
int pcoord_parse (const char *c_str, enum projection pro, struct pcoord *pc_ret)
void coord_print (enum projection pro, struct coord *c, FILE *out)
void coord_format (float lat, float lng, enum coord_format fmt, char *buffer, int size)
 Converts a lat/lon into a text formatted text string. More...
unsigned int coord_hash (const void *key)
int coord_equal (const void *a, const void *b)

Detailed Description

Navit, a modular navigation system. Copyright (C) 2005-2008 Navit Team

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Function Documentation

void coord_destroy ( struct coord c)

Referenced by coord_destroy_py().

int coord_equal ( const void *  a,
const void *  b 

References FALSE, TRUE, x, and y.

Referenced by coord_hash_new(), and destination_equal().

void coord_format ( float  lat,
float  lng,
enum coord_format  fmt,
char *  buffer,
int  size 

Converts a lat/lon into a text formatted text string.

latThe latitude (if lat is 360 or greater, the latitude will be omitted)
lngThe longitude (if lng is 360 or greater, the longitude will be omitted)
fmtThe format to use.
  • DEGREES_DECIMAL=>Degrees with decimal places, i.e. 20.5000°N 110.5000°E
  • DEGREES_MINUTES=>Degrees and minutes, i.e. 20°30.00'N 110°30.00'E
  • DEGREES_MINUTES_SECONDS=>Degrees, minutes and seconds, i.e. 20°30'30.00"N 110°30'30"E
bufferA buffer large enough to hold the output + a terminating NULL (up to 31 bytes)
sizeThe size of the buffer


struct coord * coord_get ( unsigned char **  p)

Get a coordinate

pPointer to the coordinate
the coordinate

Referenced by street_name_number_get(), and street_name_numbers_get().

unsigned int coord_hash ( const void *  key)

References c, key, x, and y.

Referenced by coord_hash_new().

struct coord * coord_new ( int  x,
int  y 

References c, x, and y.

Referenced by coord_new_from_attrs(), and coord_new_py().

struct coord * coord_new_from_attrs ( struct attr parent,
struct attr **  attrs 

References attr_search(), coord_new(), attr::num, and attr::u.

Referenced by osd_marker_init().

int coord_parse ( const char *  coord_input,
enum projection  output_projection,
struct coord result 

Parses char *coord_input and writes back the coordinates to coord *result, using projection output_projection. *coord_input may specify its projection at the beginning. The format for *coord_input can be:

  • [Proj:][-]0xXX.... [-]0xXX... - Mercator coordinates, hex integers (XX), Proj can be "mg" or "garmin", defaults to mg
  • [Proj:][D][D] N/S [D][D] E/W - lat/long (WGS 84), integer degrees (DD) and minutes as decimal fraction (MM), Proj must be "geo" or absent
  • [Proj:][-][D]D.d[d]... [-][D][D]D.d[d] - long/lat (WGS 84, note order!), degrees as decimal fraction, Proj does not matter
  • utm[zoneinfo]:[-][D]D.d[d]... [-][D][D]D.d[d] - UTM coordinates, as decimal fraction, with optional zone information (?) Note that the spaces are relevant for parsing.
*coord_inputString to be parsed
output_projectionDesired projection of the result
*resultFor returning result
The lenght of the parsed string

References c, dbg, coord_geo::lat, lat, coord_geo::lng, lvl_debug, lvl_error, lvl_info, projection_from_name(), projection_mg, projection_none, projection_utm, transform_from_geo(), transform_to_geo(), x, and y.

Referenced by attr_new_from_text(), bookmarks_set_center_from_file(), navit_get_coord(), parse_line(), pcoord_parse(), and pcoord_py().

void coord_print ( enum projection  pro,
struct coord c,
FILE *  out 

References projection_to_name(), x, and y.

Referenced by bookmarks_write_center_to_file().

int coord_rect_contains ( struct coord_rect r,
struct coord c 
void coord_rect_destroy ( struct coord_rect r)

Referenced by coord_rect_destroy_py().

struct coord_rect * coord_rect_new ( struct coord lu,
struct coord rl 

References dbg_assert, coord_rect::lu, coord_rect::rl, x, and y.

Referenced by coord_rect_new_py().

int pcoord_parse ( const char *  c_str,
enum projection  pro,
struct pcoord pc_ret 

A wrapper for coord_parse that also returns the projection. For parameters see coord_parse.

References coord_parse(), pcoord::pro, x, pcoord::x, y, and pcoord::y.

Referenced by gui_internal_cmd_enter_coord_do(), and pcoord_get_from_message().