[josm-dev] [patch] be more verbose about available tracks in GPX layer

2009-09-16 Thread Gleb Smirnoff
  Dear JOSM developers,

  since introduction of "identifiable" tracks in API, I find it very useful
to see which track I am looking at in the editor. Therefore, written the
attached patch.

  Please consider including it into JOSM, if it doesn't have any problems.

-- 
Totus tuus, Glebius.
GLEB-RIPE
Index: gui/layer/GpxLayer.java
===
--- gui/layer/GpxLayer.java	(revision 2144)
+++ gui/layer/GpxLayer.java	(working copy)
@@ -329,10 +329,6 @@
 public String getToolTipText() {
 StringBuilder info = new StringBuilder().append("");
 
-info.append(trn("{0} track, ", "{0} tracks, ", data.tracks.size(), data.tracks.size())).append(
-trn("{0} route, ", "{0} routes, ", data.routes.size(), data.routes.size())).append(
-trn("{0} waypoint", "{0} waypoints", data.waypoints.size(), data.waypoints.size())).append("");
-
 if (data.attr.containsKey("name")) {
 info.append(tr("Name: {0}", data.attr.get(GpxData.META_NAME))).append("");
 }
@@ -342,15 +338,28 @@
 }
 
 if (data.tracks.size() > 0) {
-boolean first = true;
-WayPoint earliest = null, latest = null;
+	info.append(""
+		+ trn("{0} track", "{0} tracks", data.tracks.size(), data.tracks.size())
+		+ "" + tr("Name") + ""
+		+ tr("Description") + "" + tr("Timespan")
+		+ "" + tr("Length") + "" + tr("URL")
+		+ "");
 
 for (GpxTrack trk : data.tracks) {
+		WayPoint earliest = null, latest = null;
+
+		info.append("");
+		if (trk.attr.containsKey("name"))
+		info.append(trk.attr.get("name"));
+		info.append("");
+		if (trk.attr.containsKey("desc"))
+		info.append(" ").append(trk.attr.get("desc"));
+		info.append("");
+
 for (Collection seg : trk.trackSegs) {
 for (WayPoint pnt : seg) {
-if (first) {
+if (latest == null) {
 latest = earliest = pnt;
-first = false;
 } else {
 if (pnt.compareTo(earliest) < 0) {
 earliest = pnt;
@@ -360,19 +369,33 @@
 }
 }
 }
-}
-if (earliest != null && latest != null) {
-DateFormat df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT);
-info.append(tr("Timespan: ") + df.format(new Date((long) (earliest.time * 1000))) + " - "
+
+		if (earliest != null && latest != null) {
+		DateFormat df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT);
+		info.append(df.format(new Date((long) (earliest.time * 1000))) + " - "
 + df.format(new Date((long) (latest.time * 1000;
-int diff = (int) (latest.time - earliest.time);
-info.append(" (" + (diff / 3600) + ":" + ((diff % 3600) / 60) + ")");
-info.append("");
+		int diff = (int) (latest.time - earliest.time);
+		info.append(" (" + (diff / 3600) + ":" + ((diff % 3600) / 60) + ")");
+		}
+
+		info.append("");
+		info.append(new DecimalFormat("#0.00").format(trk.length() / 1000) + "km");
+		info.append("");
+		if (trk.attr.containsKey("url"))
+		info.append(trk.attr.get("url"));
+		info.append("");
 }
+
+	info.append("");
+
 }
+
 info.append(tr("Length: ") + new DecimalFormat("#0.00").format(data.length() / 1000) + "km");
 info.append("");
 
+	info.append(trn("{0} route, ", "{0} routes, ", data.routes.size(), data.routes.size())).append(
+trn("{0} waypoint", "{0} waypoints", data.waypoints.size(), data.waypoints.size())).append("");
+
 return info.append("").toString();
 }
 
Index: io/GpxReader.java
===
--- io/GpxReader.java	(revision 2144)
+++ io/GpxReader.java	(working copy)
@@ -285,7 +285,8 @@
 currentData.tracks.add(currentTrack);
 } else if (qName.equals("name") || qName.equals("cmt")
 || qName.equals("desc") || qName.equals("src")
-|| qName.equals("type") || qName.equals("number")) {
+|| qName.equals("type") || qName.equals("number")
+			|| qName.equals("url")) {
 currentTrack.attr.put(qName, accumulator.toString());
 }
 break;
Index: data/gpx/GpxTrack.java
===
--- data/gpx/GpxTrack.java	(revision 2144)
+++ data/gpx/GpxTrack.java	(working copy)
@@ -9,4 +9,25 @@
 public class GpxTrack extends WithAttributes {
 public Collection> trackSegs
 = new LinkedList>();
+
+/**
+ * calculates the length of the track
+ */
+public double length(){
+

Re: [OSM-dev] need help on bulk import of osmchange

2009-05-27 Thread Gleb Smirnoff
  Dave,

  thanks for help!

On Wed, May 27, 2009 at 01:42:35PM +0100, Dave Stubbs wrote:
D> Yes... lots of duplicates...
D> http://api.openstreetmap.org/browse/changeset/1326916
D> ...
D> http://api.openstreetmap.org/browse/changeset/1327131

I've got saved all changeset numbers. Is there a way to back them out?

After that, what script would you suggest to process correctly my
osmchange file?

-- 
Totus tuus, Glebius.
GLEB-RIPE

___
dev mailing list
dev@openstreetmap.org
http://lists.openstreetmap.org/listinfo/dev


[OSM-dev] need help on bulk import of osmchange

2009-05-27 Thread Gleb Smirnoff
  Hello,

  we are working on fixing things after one automated import that
covered a large part of Russia. The import created many nodes,
that describe villages and hamlets. It had two problems:

1) Many nodes where imported twice.
2) All names where incorrectly prefixed.

I have created a fixed version of database dump, and with help of
osmosis created and OsmChange file.

I have tried to upload it using python script:

http://svn.openstreetmap.org/applications/utils/import/bulk_upload_06/

The script reported about several commits (more than a dozen), and
returned no errors.

However, it appeared that only  sections of the OsmChange
file were processed. All  section were not.

Here is the OsmChange itself:

http://glebius.int.ru/tmp/delta.osc

Can anyone competent in this area review it and explain where is
the problem?

-- 
Totus tuus, Glebius.
GLEB-RIPE

___
dev mailing list
dev@openstreetmap.org
http://lists.openstreetmap.org/listinfo/dev


[OSM-dev] [bug] direction of GPS traces

2009-04-14 Thread Gleb Smirnoff
  Dear OSM developers,

  I have noticed that all my GPS traces uploaded to OSM base are displayed
in JOSM in opposite direction. First I though that this is bug in JOSM,
but it appeared that if I open the gpx file in JOSM, then the trace direction
is drawn correctly. And if I upload this exact file to OSM and then
download it into JOSM gpx layer, then the direction of trace is the opposite.

So I suspect bug either in the software that receives the trace and stores it
in the database, or in the software that serves requests for traces.

-- 
Totus tuus, Glebius.
GLEB-RIPE

___
dev mailing list
dev@openstreetmap.org
http://lists.openstreetmap.org/listinfo/dev