]> git.itanic.dy.fi Git - maemo-mapper/commitdiff
Added support for 6 figure OS grid references.
authorcamel <rwilliams.uk@gmail.com>
Thu, 1 Jan 2009 17:53:45 +0000 (17:53 +0000)
committercamel <rwilliams.uk@gmail.com>
Thu, 1 Jan 2009 17:53:45 +0000 (17:53 +0000)
git-svn-id: svn+ssh://garage/var/lib/gforge/svnroot/maemo-mapper/trunk@234 6c538b50-5814-0410-93ad-8bdf4c0149d1

src/types.h
src/util.c

index 85bdb9b28517d10f50f6c51a0e2b2d51c9d47b19..05c0b99e166a328dae88afaa7f644b9ca7d34ff8 100644 (file)
@@ -269,9 +269,10 @@ typedef enum
     NSEW_DDPDDDDD,
     NSEW_DD_MMPMMM,
     NSEW_DD_MM_SSPS,
-    IARU_LOC,
     UK_OSGB,
-    UK_NGR,
+    UK_NGR, // 8 char grid ref
+    UK_NGR6,// 6 char grid ref
+    IARU_LOC,
     DEG_FORMAT_ENUM_COUNT
 } DegFormat;
 
index 95cdadb2159ae5a40276b32c71bca84a77a64131..4e91bd9f25648b6e7f79f0ce1e379dc21c9b5b1a 100644 (file)
@@ -44,6 +44,7 @@
 #include "gpx.h"
 #include "util.h"
 
+gboolean convert_iaru_loc_to_lat_lon(const gchar* txt_lon, gdouble* lat, gdouble* lon);
 
 /**
  * Pop up a modal dialog box with simple error information in it.
@@ -74,6 +75,7 @@ deg_format(gdouble coor, gchar *scoor, gchar neg_char, gchar pos_char)
            case IARU_LOC:
        case UK_OSGB:
        case UK_NGR:
+       case UK_NGR6:
                // These formats should not be formatted in the same way
                // - they need to be converted first, therefore if we reach 
                // this bit of code use the first available format - drop through.
@@ -522,6 +524,7 @@ gboolean coord_system_check_lat_lon (gdouble lat, gdouble lon, gint *fallback_de
        {
        case UK_OSGB:
        case UK_NGR:
+       case UK_NGR6:
                valid = os_grid_check_lat_lon(lat, lon);
                if(fallback_deg_format != NULL) *fallback_deg_format = DDPDDDDD; 
                break;
@@ -602,8 +605,8 @@ gboolean convert_os_grid_to_bng(gint easting, gint northing, gchar* bng)
        snprintf(eing, 12, "%u", easting);
        snprintf(ning, 12, "%u", northing);
        
-       snprintf(eing, 5, "%s", eing+1);
-       snprintf(ning, 5, "%s", ning+1);
+       snprintf(eing, (_degformat == UK_NGR ? 5 : 4), "%s", eing+1);
+       snprintf(ning, (_degformat == UK_NGR ? 5 : 4), "%s", ning+1);
                
        sprintf(bng, "%c%c%s%s", 
                        (char)(tmp + 65), 
@@ -758,7 +761,7 @@ gboolean parse_coords(const gchar* txt_lat, const gchar* txt_lon, gdouble* lat,
        gboolean valid = FALSE;
        
        // UK_NGR starts with two letters, and then all numbers - it may contain spaces - no lon will be entered
-       if( _degformat == UK_NGR)
+       if( _degformat == UK_NGR || _degformat == UK_NGR6 )
        {
                valid = convert_os_ngr_to_latlon(txt_lat, lat, lon);
 
@@ -932,6 +935,7 @@ void format_lat_lon(gdouble d_lat, gdouble d_lon, gchar* lat, gchar* lon)
                }
                break;
        case UK_NGR:
+       case UK_NGR6:
                
                if(convert_lat_lon_to_bng(d_lat, d_lon, lat))
                {