]> git.street.me.uk Git - andy/viking.git/blob - src/coords.h
Add kdtree C code version 0.5.6 from https://code.google.com/p/kdtree/
[andy/viking.git] / src / coords.h
1 /*
2 coords.h
3 borrowed from:
4 http://acme.com/software/coords/
5 I (Evan Battaglia <viking@greentorch.org> have only made some small changes such as
6 renaming functions and defining LatLon and UTM structs.
7 */
8 /* coords.h - include file for coords routines
9 **
10 ** Copyright © 2001 by Jef Poskanzer <jef@acme.com>.
11 ** All rights reserved.
12 **
13 ** Redistribution and use in source and binary forms, with or without
14 ** modification, are permitted provided that the following conditions
15 ** are met:
16 ** 1. Redistributions of source code must retain the above copyright
17 **    notice, this list of conditions and the following disclaimer.
18 ** 2. Redistributions in binary form must reproduce the above copyright
19 **    notice, this list of conditions and the following disclaimer in the
20 **    documentation and/or other materials provided with the distribution.
21 **
22 ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
23 ** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 ** ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
26 ** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 ** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 ** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 ** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 ** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 ** SUCH DAMAGE.
33 */
34
35 #ifndef _VIKING_COORDS_H
36 #define _VIKING_COORDS_H
37
38 #include <glib.h>
39
40 G_BEGIN_DECLS
41
42 struct UTM {
43   gdouble northing;
44   gdouble easting;
45   gchar zone;
46   gchar letter;
47 };
48
49 struct LatLon {
50   gdouble lat;
51   gdouble lon;
52 };
53
54 int a_coords_utm_equal( const struct UTM *utm1, const struct UTM *utm2 );
55 void a_coords_latlon_to_utm ( const struct LatLon *latlon, struct UTM *utm );
56 void a_coords_utm_to_latlon ( const struct UTM *utm, struct LatLon *latlon );
57 double a_coords_utm_diff( const struct UTM *utm1, const struct UTM *utm2 );
58 double a_coords_latlon_diff ( const struct LatLon *ll1, const struct LatLon *ll2 );
59
60 /**
61  * Convert a double to a string WITHOUT LOCALE.
62  *
63  * Following GPX specifications, decimal values are xsd:decimal
64  * So, they must use the period separator, not the localized one.
65  *
66  * The returned value must be freed by g_free.
67  */
68 char *a_coords_dtostr ( double d );
69
70 /**
71  * Convert a LatLon to strings.
72  *
73  * Use the prefered representation.
74  */
75 void a_coords_latlon_to_string ( const struct LatLon *latlon, gchar **lat, gchar **lon );
76
77 G_END_DECLS
78
79 #endif