Il giorno 27 settembre 2013 23:23, marco bra <marcobra.ubu...@gmail.com> ha scritto:
> Groppo, non ho usato il tuo script, ma l'ho provato ed e' potente, > sarebbero da discriminare alcune liste di parole... che non vanno > maiuscole... "di", "del" etc. > Sì, il mio era un esempio per far vedere cosa si può fare. Lo si può modificare/migliorare in base alle proprie esigenze. Ad esempio, con le modifiche qui sotto (vedi "### aggiunta"), tiene conto di alcune preposizioni ed alla fine stampa sul terminale la lista dei nomi e le loro conversioni. #codice script """ Capitalize words of "name=*" tags in JOSM """ import sys from javax.swing import JOptionPane from org.openstreetmap.josm import Main def getMapView(): if Main.main and Main.main.map: return Main.main.map.mapView else: JOptionPane.showMessageDialog(Main.parent, "Apri dei dati, prima di eseguire lo script.") sys.exit(1) #### aggiunta prepositions = [" di ", " del ", " della ", " delle "] mv = getMapView() if mv and mv.editLayer and mv.editLayer.data: dataset = mv.editLayer.data elements = [] elements.extend(dataset.nodes) elements.extend(dataset.ways) elements.extend(dataset.relations) #For each OSM object in the dataset for element in elements: tags = element.getKeys() if len(tags) != 0: if "name" in tags: #capitalize words of "name" value oldName = element.get("name") newName = oldName.title() #### aggiunta for prep in prepositions: newName = newName.replace(prep.title(), prep.lower()) tags["name"] = newName #Print names to terminal print "%s ---> %s" % (oldName, newName) #Update element tags element.setKeys(tags) JOptionPane.showMessageDialog(Main.parent, "Done.")
_______________________________________________ Talk-it mailing list Talk-it@openstreetmap.org https://lists.openstreetmap.org/listinfo/talk-it