Article View: be.test
Article #315Re: josm
From: Gradient
Date: Sun, 18 Mar 2012 02:50
Date: Sun, 18 Mar 2012 02:50
68 lines
3296 bytes
3296 bytes
?
"marc" <nomail@be.com> wrote in message news:ji92kt$es$1@dont-email.me...
> http://wiki.openstreetmap.org/wiki/JOSM/Plugins/Scripting
>
> #!/bin/jython
> '''
> NumberOfHousenumbers.py
> This code is released under the GNU General
> Public License v2 or later.
>
> The GPL v3 is accessible here:
> http://www.gnu.org/licenses/gpl.html
>
> The GPL v2 is accessible here:
> http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
>
> It comes with no warranty whatsoever.
>
> This code illustrates how to use Jython to:
> * work with selected items or how to process all the primitives of a
> certain
> kind (node, way, relation)
>
> '''
> from javax.swing import JOptionPane
> from org.openstreetmap.josm import Main
> import org.openstreetmap.josm.data.osm.Node as Node
> import org.openstreetmap.josm.data.osm.Way as Way
> import org.openstreetmap.josm.data.osm.Relation as Relation
> import org.openstreetmap.josm.data.osm.TagCollection as TagCollection
> import org.openstreetmap.josm.data.osm.DataSet as DataSet
> import org.openstreetmap.josm.data.osm.RelationMember as RelationMember
>
> def getMapView():
> if Main.main and Main.main.map:
> return Main.main.map.mapView
> else:
> return None
>
> mv = getMapView()
> if mv and mv.editLayer and mv.editLayer.data:
> selectedRelations = mv.editLayer.data.getSelectedRelations()
>
> if not(selectedRelations):
> JOptionPane.showMessageDialog(Main.parent, "Please select one or
> more associatedStreet relations")
> else:
> print
> dummy_way = Way()
> dummy_relation = Relation()
> number = 0
> for aS in selectedRelations:
> for member in aS.getMembers():
> if member.getRole()=='house':
> number += 1
> print aS.get('name') + ': ' + str(number)
>
>
>
>
> --
> --
> What's on Shortwave guide: choose an hour, go!
> http://shortwave.tk
> 700+ Radio Stations on SW http://swstations.tk
> 300+ languages on SW http://radiolanguages.tk
>
Technical Details
Message-ID:
<4f654d7d$1@news.x-privat.org>Path:
arc1-ca.pugleaf.net!h9ni42270pbe.0!nntp.google.com!news1.google.com!goblin1!goblin2!goblin.stu.neva.ru!newsfeed.x-privat.org!x-privat.org!not-for-mailReferences:
<ji92kt$es$1@dont-email.me>Show Full Headers
Complete Article Headers
X-Google-Thread: fd345,9ba6e3ebd26d8076
X-Google-NewGroupId: yes
X-Google-Attributes: gide120ccb152,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Received: by 10.68.235.4 with SMTP id ui4mr10134456pbc.3.1332039049809;
Sat, 17 Mar 2012 19:50:49 -0700 (PDT)
Reply-To: "Gradient" <slope@no.where.net.gr>
From: "Gradient" <slope@no.where.net.gr>
Newsgroups: be.test
References: <ji92kt$es$1@dont-email.me>
In-Reply-To: <ji92kt$es$1@dont-email.me>
Subject: Re: josm
Date: Sun, 18 Mar 2012 13:50:25 +1100
Lines: 1
Organization: Spiral AG
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
Importance: Normal
X-Newsreader: Microsoft Windows Live Mail 14.0.8117.416
X-MimeOLE: Produced By Microsoft MimeOLE V14.0.8117.416
NNTP-Posting-Host: $$5dpnjhdxie1w37t.news.x-privat.org
Message-ID: <4f654d7d$1@news.x-privat.org>
X-Authenticated-User: $$i053au1xx8m-rhyemw
X-Complaints-To: abuse@x-privat.org
Path: arc1-ca.pugleaf.net!h9ni42270pbe.0!nntp.google.com!news1.google.com!goblin1!goblin2!goblin.stu.neva.ru!newsfeed.x-privat.org!x-privat.org!not-for-mail
Content-Type: text/plain;
format=flowed;
charset="iso-8859-1";
reply-type=original
Content-Transfer-Encoding: 7bit