|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
OSM elevation patchHi.
I patched my gpsbabel 1.3.6 to handle altitude for OSM files: For writing OSM file: If you specify "-o osm,ele", altitudes are written to OSM as " <tag k='ele' v='%.1f'/>". When reading OSM, "<tag k='ele' v='%f'/>" is read as altitude, unconditonally. I think it will be useful to merge into the gpsbabel sourcetree. Best regards Egil Hjelmeland. --- osm.c.orig 2009-10-06 22:32:02.265000000 +0200 +++ osm.c 2009-10-13 00:48:38.804800000 +0200 @@ -25,12 +25,14 @@ #include "xmlgeneric.h" static char *opt_tag, *opt_tagnd, *created_by; +static char *opt_ele = NULL; static arglist_t osm_args[] = { { "tag", &opt_tag, "Write additional way tag key/value pairs", NULL, ARGTYPE_STRING, ARG_NOMINMAX }, { "tagnd", &opt_tagnd, "Write additional node tag key/value pairs", NULL, ARGTYPE_STRING, ARG_NOMINMAX }, { "created_by", &created_by, "Use this value as custom created_by value","GPSBabel", ARGTYPE_STRING, ARG_NOMINMAX }, + { "ele", &opt_ele, "Include elevation tag for OSM nodes", "0", ARGTYPE_BOOL, ARG_NOMINMAX }, ARG_TERMINATOR }; @@ -551,6 +553,10 @@ if (! wpt->shortname) wpt->shortname = xstrdup(str); } + if (strcmp(key, "ele") == 0) { + if ( wpt->altitude == unknown_alt) + wpt->altitude = atof(str); + } else if (strcmp(key, "name:en") == 0) { if (wpt->shortname) xfree(wpt->shortname); @@ -835,6 +841,12 @@ break; } + if ((*opt_ele != '0') &&(wpt->altitude != unknown_alt) ) { + char ele[100]; + sprintf(ele, "%.1f", wpt->altitude); + osm_write_tag("ele", ele); + } + if (strlen(created_by) !=0) { gbfprintf(fout, " <tag k='created_by' v='%s",created_by); if (gpsbabel_time != 0) ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Gpsbabel-code mailing list http://www.gpsbabel.org Gpsbabel-code@... https://lists.sourceforge.net/lists/listinfo/gpsbabel-code |
|
|
Re: OSM elevation patchOn Tue, Oct 13, 2009 at 4:41 PM, Egil Hjelmeland <privat@...> wrote: Hi. Is there really any reason for this to be optional? If we know the elevation, why not just always include it? Oh, and xasprintf/free are preferred over staticly buffers. Yes, in this specific case it's a bit dorky since you're not going to get 100 digits of fp.... RJL When reading OSM, "<tag k='ele' v='%f'/>" is read as altitude, ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Gpsbabel-code mailing list http://www.gpsbabel.org Gpsbabel-code@... https://lists.sourceforge.net/lists/listinfo/gpsbabel-code |
|
|
Re: OSM elevation patchOptional: Because the current practice in Openstreetmap is to not
include elevation in the mapdata. Actually, in the OSM data model, elevation is not a first class citizen. It is only just an other attribute tag along with tags like "highway=motorway". I my self think that GPS elevation data is better than no elevation data. So from now on I will map with elevation data. But I did not want to force inclusion of ele-tag for other users of -o osm. But perhaps a reversed no_ele suboption is even better. xasprintf/free is fine if that is preferred. Will you do the merge of this into CVS, according to preferred coding practice? I just made this trival fix a late evening to meet my need. I don't think I will do more work on gpsbabel. So I am not particulary interested in opening a CVS account my self. BTW: Here is the first road I put into OSM with the ele-tag, using gpsbabel and JOSM, to verify the concept: http://www.openstreetmap.org/browse/way/42465546 Egil Robert Lipe wrote: > > > On Tue, Oct 13, 2009 at 4:41 PM, Egil Hjelmeland > <privat@... <mailto:privat@...>> wrote: > > Hi. > > I patched my gpsbabel 1.3.6 to handle altitude for OSM files: > > For writing OSM file: If you specify "-o osm,ele", altitudes are > written > to OSM as " <tag k='ele' v='%.1f'/>". > > > Is there really any reason for this to be optional? If we know the > elevation, why not just always include it? > > Oh, and xasprintf/free are preferred over staticly buffers. Yes, in > this specific case it's a bit dorky since you're not going to get 100 > digits of fp.... > > RJL > > > > > When reading OSM, "<tag k='ele' v='%f'/>" is read as altitude, > unconditonally. > > I think it will be useful to merge into the gpsbabel sourcetree. > > Best regards > Egil Hjelmeland. > > > --- osm.c.orig 2009-10-06 22:32:02.265000000 +0200 > +++ osm.c 2009-10-13 00:48:38.804800000 +0200 > @@ -25,12 +25,14 @@ > #include "xmlgeneric.h" > > static char *opt_tag, *opt_tagnd, *created_by; > +static char *opt_ele = NULL; > > static arglist_t osm_args[] = > { > { "tag", &opt_tag, "Write additional way tag key/value pairs", > NULL, ARGTYPE_STRING, ARG_NOMINMAX }, > { "tagnd", &opt_tagnd, "Write additional node tag key/value > pairs", NULL, ARGTYPE_STRING, ARG_NOMINMAX }, > { "created_by", &created_by, "Use this value as custom created_by > value","GPSBabel", ARGTYPE_STRING, ARG_NOMINMAX }, > + { "ele", &opt_ele, "Include elevation tag for OSM nodes", "0", > ARGTYPE_BOOL, ARG_NOMINMAX }, > ARG_TERMINATOR > }; > > @@ -551,6 +553,10 @@ > if (! wpt->shortname) > wpt->shortname = xstrdup(str); > } > + if (strcmp(key, "ele") == 0) { > + if ( wpt->altitude == unknown_alt) > + wpt->altitude = atof(str); > + } > else if (strcmp(key, "name:en") == 0) { > if (wpt->shortname) > xfree(wpt->shortname); > @@ -835,6 +841,12 @@ > break; > } > > + if ((*opt_ele != '0') &&(wpt->altitude != unknown_alt) ) { > + char ele[100]; > + sprintf(ele, "%.1f", wpt->altitude); > + osm_write_tag("ele", ele); > + } > + > if (strlen(created_by) !=0) { > gbfprintf(fout, " <tag k='created_by' > v='%s",created_by); > if (gpsbabel_time != 0) > > > > > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry(R) Developer Conference in SF, CA > is the only developer event you need to attend this year. > Jumpstart your > developing skills, take BlackBerry mobile applications to market > and stay > ahead of the curve. Join us from November 9 - 12, 2009. Register now! > http://p.sf.net/sfu/devconference > _______________________________________________ > Gpsbabel-code mailing list http://www.gpsbabel.org > Gpsbabel-code@... > <mailto:Gpsbabel-code@...> > https://lists.sourceforge.net/lists/listinfo/gpsbabel-code > > ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Gpsbabel-code mailing list http://www.gpsbabel.org Gpsbabel-code@... https://lists.sourceforge.net/lists/listinfo/gpsbabel-code |
| Free embeddable forum powered by Nabble | Forum Help |