Add:Core: Added wrapper for coord_parse that "returns" a struct pcoord
authorsingesang <singesang@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Thu, 5 Mar 2009 13:37:29 +0000 (13:37 +0000)
committersingesang <singesang@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Thu, 5 Mar 2009 13:37:29 +0000 (13:37 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk/navit@2079 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/coord.c
navit/coord.h

index f74eb32..eac341c 100644 (file)
@@ -145,16 +145,19 @@ coord_rect_extend(struct coord_rect *r, struct coord *c)
                r->lu.y=c->y;
 }
 
-       /* [Proj:][Ð]DMM.ss[S][S]... N/S [D][D]DMM.ss[S][S]... E/W */
-       /* [Proj:][-][D]D.d[d]... [-][D][D]D.d[d]... */
-       /* [Proj:][-]0xX [-]0xX */
-/*
- * Currently supported:
- *     [Proj:]-0xX [-]0xX 
- *     - where Proj can be mg/garmin, defaults to mg
- *     [Proj:][D][D]Dmm.ss[S][S] N/S [D][D]DMM.ss[S][S]... E/W
- *     [Proj:][-][D]D.d[d]... [-][D][D]D.d[d]
- *     - where Proj can be geo
+/**
+ * Parses \c char \a *c_str and writes back the coordinates to \c coord \a *c_ret. Uses \c projection \a pro if no projection is given in \c char \a *c_str.
+ * The format for \a *c_str can be: 
+ *     \li [Proj:]-0xX [-]0xX 
+ *         - where Proj can be mg/garmin, defaults to mg
+ *     \li [Proj:][D][D]Dmm.ss[S][S] N/S [D][D]DMM.ss[S][S]... E/W
+ *     \li [Proj:][-][D]D.d[d]... [-][D][D]D.d[d]
+ *         - where Proj can be geo
+ *
+ * @param *c_str String to be parsed
+ * @param pro Projection of the string
+ * @param *pc_ret Where the \a pcoord should get stored
+ * @returns The lenght of the parsed string
  */
 
 int
@@ -254,6 +257,26 @@ out:
        return ret;
 }
 
+/**
+ * A wrapper for pcoord_parse that also return the projection
+ * @param *c_str String to be parsed
+ * @param pro Projection of the string
+ * @param *pc_ret Where the \a pcoord should get stored
+ * @returns The lenght of the parsed string
+ */
+
+int
+pcoord_parse(const char *c_str, enum projection pro, struct pcoord *pc_ret)
+{
+    struct coord c;
+    int ret;
+    ret = coord_parse(c_str, pro, &c);
+    pc_ret->x = c.x;
+    pc_ret->y = c.y;
+    pc_ret->pro = pro;
+    return ret;
+}
+
 void
 coord_print(enum projection pro, struct coord *c, FILE *out) {
        unsigned int x;
index d5546b1..615774f 100644 (file)
@@ -91,6 +91,7 @@ struct coord * coord_new(int x, int y);
 struct coord * coord_new_from_attrs(struct attr *parent, struct attr **attrs);
 void coord_destroy(struct coord *c);
 int coord_parse(const char *c_str, enum projection pro, struct coord *c_ret);
+int pcoord_parse(const char *c_str, enum projection pro, struct pcoord *c_ret);
 void coord_print(enum projection pro, struct coord *c, FILE *out);
 struct coord_rect * coord_rect_new(struct coord *lu, struct coord *rl);
 void coord_rect_destroy(struct coord_rect *r);