[OSM-dev] [PATCH] make JOSM validator plugin detect empty ways

Andy Robinson Andy_J_Robinson at blueyonder.co.uk
Wed Aug 8 12:19:21 BST 2007


Dave,

I've been running Hennepin County (Minneapolis) the last few days as a test
area (still currently on nodes, there are about 155,000 of them) as it had
no existing data conflicts already in the database and being a major
conurbation with some current news interest I thought it might be useful.

Concur on the ways with no segs as there are a large number in the file.
I'll wait for the node and seg upload to finish before I worry about any
upload failures as a result of bad ways being present. 

While it's been uploading I have been looking at the original OSM file. I
haven't seen any positive element ID's (noted by another user) or any other
issues. The data looked fine in JOSM so I was happy.

Anyway, I shall continue to upload over the next few days and will then be
able to look more closely at the data in OSM via smaller bbox calls, the
whole County is rather too big to work with in JOSM.

Cheers,

Andy

Andy Robinson
Andy_J_Robinson at blueyonder.co.uk 

>-----Original Message-----
>From: dev-bounces at openstreetmap.org [mailto:dev-bounces at openstreetmap.org]
>On Behalf Of Dave Hansen
>Sent: 08 August 2007 12:36 AM
>To: Francisco R. Santos
>Cc: osm-dev
>Subject: [OSM-dev] [PATCH] make JOSM validator plugin detect empty ways
>
>I've been working on some conversion scripts to make .osm files from
>TIGER data.  I screwed up in those scripts and ended up creating a bunch
>of ways that have no segments in them.  The web server correctly detects
>these and won't let me upload them.  You never have to worry about these
>with downloaded data, but a plain opened OSM file might have them.
>
>-- Dave
>
>Index: src/org/openstreetmap/josm/plugins/validator/tests/EmptyWays.java
>===================================================================
>--- src/org/openstreetmap/josm/plugins/validator/tests/EmptyWays.java
>	(revision 0)
>+++ src/org/openstreetmap/josm/plugins/validator/tests/EmptyWays.java
>	(revision 0)
>@@ -0,0 +1,65 @@
>+package org.openstreetmap.josm.plugins.validator.tests;
>+
>+import static org.openstreetmap.josm.tools.I18n.tr;
>+
>+import java.awt.geom.Point2D;
>+import java.util.*;
>+
>+import org.openstreetmap.josm.data.osm.*;
>+import org.openstreetmap.josm.plugins.validator.*;
>+import org.openstreetmap.josm.plugins.validator.util.Bag;
>+import org.openstreetmap.josm.command.*;
>+
>+/**
>+ * Checks for similar named ways, symptom of a possible typo. It uses the
>+ * Levenshtein distance to check for similarity
>+ *
>+ * @author frsantos
>+ */
>+public class EmptyWays extends Test
>+{
>+    /**
>+	 * Constructor
>+	 */
>+	public EmptyWays()
>+	{
>+		super(tr("Empty Ways."),
>+			  tr("This test checks for ways that have no
segments in
>them."));
>+	}
>+
>+    @Override
>+    public Command fixError(TestError testError)
>+    {
>+		Way w = (Way)testError.getPrimitives().get(0);
>+
>+        List<Command> cmds = new ArrayList<Command>();
>+        cmds.add(new DeleteCommand(testError.getPrimitives()));
>+       	return new SequenceCommand(tr("Delete Ways"), cmds);
>+    }
>+    @Override
>+    public boolean isFixable(TestError testError)
>+    {
>+		return (testError.getTester() instanceof EmptyWays);
>+    }
>+
>+    @Override
>+    public void startTest()
>+    {
>+    }
>+
>+    @Override
>+    public void endTest()
>+    {
>+    }
>+
>+	@Override
>+	public void visit(Way w)
>+	{
>+        if( w.deleted )
>+            return;
>+		if (w.segments.size() > 0)
>+			return;
>+        errors.add(new TestError(this, Severity.WARNING, tr("Empty ways"),
>w));
>+	}
>+
>+}
>Index: src/org/openstreetmap/josm/plugins/validator/OSMValidatorPlugin.java
>===================================================================
>--- src/org/openstreetmap/josm/plugins/validator/OSMValidatorPlugin.java
>	(revision 3894)
>+++ src/org/openstreetmap/josm/plugins/validator/OSMValidatorPlugin.java
>	(working copy)
>@@ -53,6 +53,7 @@
>         ReusedSegment.class,
>         CrossingSegments.class,
>         SimilarNamedWays.class,
>+        EmptyWays.class,
>     };
>
> 	/**
>
>
>
>_______________________________________________
>dev mailing list
>dev at openstreetmap.org
>http://lists.openstreetmap.org/cgi-bin/mailman/listinfo/dev






More information about the dev mailing list