On Fri, 2008-04-25 at 14:46 -0700, Alan Millar wrote:
> Unfortunately, it is in perl because that's what I know; I've never done
> anything in Java yet.  I've been wondering if this may be just the time to
> learn it.  I'm not sure if a JOSM plugin is a good place to start learning
> Java or if that is biting off too much to start.
> 
> Any advice?  Thanks

Thankfully, the validator tests don't require *too* much java.  You can
basically cut 'n paste from an existing one with very little trouble.

I hadn't touched Java in about 10 years before I started looking at
JOSM.  I do a lot of C on a daily basis, but no Java.  It wasn't hard to
pick back up.

Here's an example validator test:

http://svn.openstreetmap.org/applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/DuplicateNode.java

You basically examine all the Osm Primitives in a couple of visit
functions like this:

        @Override
        public void visit(Node n) 
        {
                nodes.add(n.coor, n);
        }

Usually, you just collect them into a structure like that 'nodes' list.
Then, in the endTest() function you go an examine all of them.  I've
been keeping custom versions of JOSM around that have some really nice
helpers for writing JOSM plugins. 

        http://dev.openstreetmap.org/~daveh/josm/018/

Like this:

        for (Way wtmp : Main.ds.rl.waysUsingNode(n)) {

That iterates over a list of all the ways using Node 'n'.  You probably
recognize this operation.  I think you do it a bit in your perl script.

-- Dave


_______________________________________________
Talk-us mailing list
Talk-us@openstreetmap.org
http://lists.openstreetmap.org/cgi-bin/mailman/listinfo/talk-us

Reply via email to