🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: be.test
Article #305

josm

#305
From: marc
Date: Fri, 24 Feb 2012 22:23
63 lines
3092 bytes
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: <ji92kt$es$1@dont-email.me>
Path: arc1-ca.pugleaf.net!h9ni5251pbe.0!nntp.google.com!news2.google.com!goblin2!goblin.stu.neva.ru!newsfeed1.swip.net!85.214.198.2.MISMATCH!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: fd345,9ba6e3ebd26d8076,start
X-Google-NewGroupId: yes
X-Google-Attributes: gide120ccb152,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Received: by 10.68.221.4 with SMTP id qa4mr3702467pbc.7.1330122205765;
        Fri, 24 Feb 2012 14:23:25 -0800 (PST)
Path: arc1-ca.pugleaf.net!h9ni5251pbe.0!nntp.google.com!news2.google.com!goblin2!goblin.stu.neva.ru!newsfeed1.swip.net!85.214.198.2.MISMATCH!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail
From: marc <nomail@be.com>
Newsgroups: be.test
Subject: josm
Followup-To: be.test
Date: Fri, 24 Feb 2012 23:23:24 +0100
Organization: A noiseless patient Spider
Lines: 63
Message-ID: <ji92kt$es$1@dont-email.me>
Mime-Version: 1.0
Injection-Date: Fri, 24 Feb 2012 22:23:25 +0000 (UTC)
Injection-Info: mx04.eternal-september.org; posting-host="nNHDRJuXK6XXzxOBUz0mVQ";
 logging-data="476"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/R6Lr0tFnqmyF3vgTe+i5Z"
User-Agent: KNode/4.4.9
Cancel-Lock: sha1:QcXPmvp05/OyS6eeQuHzDpJ75Po=
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 7Bit