<div dir="ltr">Salut Tony,<br><br>Celui-ci est plus proche de ce que tu cherchais:<br><br>#!/bin/jython<br>'''<br>FindWaysBelongingToRoutesStartingFromStops.jy<br>- Given a list of stops, find all ways belonging to the route<br><br>This code is released under the GNU General<br>Public License v2 or later.<br><br>The GPL v3 is accessible here:<br><a href="http://www.gnu.org/licenses/gpl.html">http://www.gnu.org/licenses/gpl.html</a><br><br>The GPL v2 is accessible here:<br><a href="http://www.gnu.org/licenses/old-licenses/gpl-2.0.html">http://www.gnu.org/licenses/old-licenses/gpl-2.0.html</a><br><br>It comes with no warranty whatsoever.<br><br>'''<br>from javax.swing import JOptionPane<br>from org.openstreetmap.josm import Main<br>import org.openstreetmap.josm.command as Command<br>import org.openstreetmap.josm.data.osm.Node as Node<br>import org.openstreetmap.josm.data.osm.Way as Way<br>import org.openstreetmap.josm.data.osm.Relation as Relation<br>import org.openstreetmap.josm.data.Bounds as Bounds<br>import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor as BoundingXYVisitor<br>import org.openstreetmap.josm.data.osm.TagCollection as TagCollection<br>import org.openstreetmap.josm.data.osm.DataSet as DataSet<br>import org.openstreetmap.josm.data.osm.RelationMember as RelationMember<br>import org.openstreetmap.josm.actions.search.SearchAction as SearchAction<br><br>dummyRelation = Relation(); dummyWay = Way()<br><br>sideEffects = {<br>    'addWayToRoute': None,<br>    'createStopAreaRelations': None,<br>    }<br><br>logVerbosity = 50<br>'''<br>10: only report problems that require attention<br>20: report on collection<br>30: report on network nodes<br>40: report on which routes are being checked<br>50: report everything<br>'''<br><br>def getMapView():<br>    if Main.main and Main.main.map:<br>        return Main.main.map.mapView<br>    else:<br>        return None<br><br>dummy_way = Way()<br>dummy_relation = Relation()<br><br>print<br>print "****************************************"<br><br>cleanupTags=[['odbl',         ['CRAB:huisnrlabel', 'CRAB:hnrLabel', 'CRAB:hnrLabels']],<br>             ['tiger:source', ['CRAB:source', 'CRAB:herkomst']],<br>             ['yh:TYPE', ['addr:postcode']],<br>             ['yh:LINE_NAME', ['addr:city']],<br>             ['addr:flats',   ['CRAB:message']]<br>            ]<br>SearchAction.search('inview new "addr:housenumber" type:node', SearchAction.SearchMode.fromCode('R'))<br><br>mv = getMapView()<br>if mv and mv.editLayer and mv.editLayer.data:<br>    commandsList = []; i=0; names = {}; modified = False<br><br>    relationStillNeedsToBeCreated = True<br><br>    for node in mv.editLayer.data.getSelectedNodes():<br>        for key in node.getKeys():<br>            if ('addr:street' in node.getKeys()):<br>                if relationStillNeedsToBeCreated:<br>                    notFound = True<br>                    for relation in node.getReferrers():<br>                        if relation.get('type') == 'associatedStreet':<br>                            notFound = False<br>                            break<br>                    if notFound:<br>                        recycled=False<br>                        newRelation = Relation(dummyRelation)<br>                        relationStillNeedsToBeCreated = False<br>                    else:<br>                        recycled=True<br>                        newRelation = Relation(relation)<br>                        newRelation.removeAll()<br>                        relationStillNeedsToBeCreated = False<br><br>                newMember = RelationMember('house',node)<br>                if not(newMember in newRelation.getMembers()):<br>                    newRelation.addMember(i, newMember)<br>                    i+=1<br>                    modified = True<br>            newNode=Node(node)<br>            nodeTags = node.getKeys()<br>            for replaceWith, replaceThese in cleanupTags:<br>                for replaceThis in replaceThese:<br>                    if replaceThis in nodeTags:<br>                        newNode.put(replaceWith, node.get(replaceThis))<br>                        newNode.remove(replaceThis)<br>            commandsList.append(Command.ChangeCommand(node, newNode))<br><br>    newRelation.put('type', 'associatedStreet')<br>    newRelation.put('name', node.get('addr:street'))<br>    newRelation.put('addr:country', 'BE')<br><br>    if ('addr:city' in nodeTags):<br>        newRelation.put('addr:city', node.get('addr:city'))<br>    elif ('yh:LINE_NAME' in nodeTags):<br>        newRelation.put('addr:city', node.get('yh:LINE_NAME'))<br>    else:<br>        newRelation.put('addr:city', 'GemeenteOnbekend')<br><br>    if ('addr:postcode' in nodeTags):<br>        newRelation.put('addr:postcode', node.get('addr:postcode'))<br>    elif ('yh:TYPE' in nodeTags):<br>        newRelation.put('addr:postcode', node.get('yh:TYPE'))<br>    else:<br>        newRelation.put('addr:postcode', 'PostnummerOnbekend')<br>    newRelation.put('addr:country', 'BE')<br><br>    SearchAction.search(node.get('addr:street') + ' type:way', SearchAction.SearchMode.fromCode('R'))<br><br>    for way in mv.editLayer.data.getSelectedWays():<br>        if way.get('building'):<br>            newMember = RelationMember('house',way)<br>        else:<br>            newMember = RelationMember('street',way)<br>        if not(newMember in newRelation.getMembers()):<br>            newRelation.addMember(i, newMember)<br>            i+=1<br>            modified = True<br>    <br>    #print dir(mv)<br> <br>    if modified:<br>        #print dir(Command)<br>        if recycled: commandsList.append(Command.ChangeCommand(relation, newRelation))<br>        else: commandsList.append(Command.AddCommand(newRelation))<br>        Main.main.undoRedo.add(Command.SequenceCommand("Creating associatedStreet relation for " + node.get('addr:street'), commandsList))<br>        commandsList = []<br>        <br>            <br></div><div class="gmail_extra"><br><div class="gmail_quote">2014-11-05 9:28 GMT+01:00 Tony Emery <span dir="ltr"><<a href="mailto:tony.emery@yahoo.fr" target="_blank">tony.emery@yahoo.fr</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Bonjour à tous,<br>
<br>
Je suis en train de réaliser un référentiel voirie sur notre<br>
intercommunalité. On a fait le tour des tronçons de rues et on voudrait,<br>
pour chaque voie de chaque commune, créer une relation associated street.<br>
<br>
Existe-t-il un script sous josm ou QGIS qui pourrait automatiser ce travail<br>
qui serait, en gros :<br>
- sélectionne les objets qui ont la même valeur pour le tag "name"<br>
- s'il n'y a pas de relation associated street, créé-la<br>
- en option, s'il y a des adresses rattachées au même nom de rue, mets-les<br>
dans la relation.<br>
<br>
Merci pour vos réponses.<br>
<br>
<br>
<br>
-----<br>
Tony EMERY<br>
Administrateur OpenStreetMap.fr<br>
Mandataire Grand Sud-Est<br>
Géomaticien & chef de projets<br>
--<br>
View this message in context: <a href="http://gis.19327.n5.nabble.com/Creation-automatique-de-relations-associated-street-tp5823180.html" target="_blank">http://gis.19327.n5.nabble.com/Creation-automatique-de-relations-associated-street-tp5823180.html</a><br>
Sent from the France mailing list archive at Nabble.com.<br>
<br>
_______________________________________________<br>
Talk-fr mailing list<br>
<a href="mailto:Talk-fr@openstreetmap.org">Talk-fr@openstreetmap.org</a><br>
<a href="https://lists.openstreetmap.org/listinfo/talk-fr" target="_blank">https://lists.openstreetmap.org/listinfo/talk-fr</a><br>
</blockquote></div><br></div>