X-Git-Url: https://git.street.me.uk/andy/viking.git/blobdiff_plain/2162b266d56a50f969dd80895c152269e0f6b64d..1d0135d80e87993f8ad323c1e5a4e5d495309a3b:/src/degrees_converters.c diff --git a/src/degrees_converters.c b/src/degrees_converters.c index 3557e91a..2261d674 100644 --- a/src/degrees_converters.c +++ b/src/degrees_converters.c @@ -1,8 +1,65 @@ +/* + * viking -- GPS Data and Topo Analyzer, Explorer, and Manager + * + * Copyright (C) 2006-2007, Guilhem Bonnefille + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + #include #include #include #include +/** + * @param pos_c char for positive value + * @param neg_c char for negative value + */ +static gchar *convert_dec_to_ddd(gdouble dec, gchar pos_c, gchar neg_c) +{ + gchar sign_c = ' '; + gdouble val_d; + gchar *result = NULL; + + if ( dec > 0 ) + sign_c = pos_c; + else if ( dec < 0 ) + sign_c = neg_c; + else /* Nul value */ + sign_c = ' '; + + /* Degree */ + val_d = fabs(dec); + + /* Format */ + /* TODO : replace "°" as UTF-8 */ + result = g_strdup_printf ( "%c%f°", sign_c, val_d ); + return result; +} + +gchar *convert_lat_dec_to_ddd(gdouble lat) +{ + return convert_dec_to_ddd(lat, 'N', 'S'); +} + +gchar *convert_lon_dec_to_ddd(gdouble lon) +{ + return convert_dec_to_ddd(lon, 'E', 'W'); +} + /** * @param pos_c char for positive value * @param neg_c char for negative value