[josm-dev] Jumbo Patch

Gabriel Ebner ge at gabrielebner.at
Sun Dec 16 12:19:52 GMT 2007


On Sat, Dec 15, 2007 at 11:58:20AM -0800, Dave Hansen wrote:
> On Sat, 2007-12-15 at 10:56 +0100, Gabriel Ebner wrote:
> > 
> > As we're speeding up way-on-node lookups one way or another anyhow,
> > couldn't
> > we just filter out the unwanted errors?  I.e. something like this:
> > 
> >     @Override
> >     public void endTest()
> >     {   
> >         for(List<OsmPrimitive> duplicated : nodes.values() )
> >         {   
> >             if( duplicated.size() > 1)
> >             {
> >                 boolean wantedError = false;
> > 
> >                 Set<String> types = new HashSet<String>();
> >                 for (OsmPrimitive p : duplicated) {
> >                   Set<String> nodeTypes = new HashSet<String>();
> >                   for (Way w : waysForNode((Node) p)) {
> >                     String type = getType(w);
> >                     if (types.contains(type)) {
> >                       wantedError = true;
			  break;
> >                     }
> >                     nodeTypes.add(type);
> >                   }
> >                   types.addAll(nodeTypes);
		      if (wantedError) break;
> >                 }
> > 
> >                 if (!wantedError) continue;
> > 
> >                 TestError testError = new TestError(this, Severity.ERROR, tr("Duplicated nodes"), duplicated);
> >                 errors.add( testError );
> >             }
> >         }
> >         nodes = null;
> >     }
> 
> I was looking through this in more detail, and I can't figure out quite
> what you're trying to do.
> 
> Could you clarify it with a few commands, and clarify the types and
> nodeTypes variable names?  I swear nodeTypes should be wayTypes.  

If each node could only have one way, and hence only one way type, we'd just
need to keep a set of all types we've seen so far, and check whether our node
is in that set (-> intersection of ways with same type), or add it to that set
otherwise.

But a node can be in multiple ways and therefore have multiple types, if any
of them is already in the set we've got an intersection of ways with the same
type, otherwise we need to add all of them to the set.

`nodeSet' is just the name for the types of the ways.

  Gabriel.




More information about the josm-dev mailing list