Changeset 35269 in osm for applications/editors/josm/plugins/opendata/modules/fr.toulouse
- Timestamp:
- 2020-01-11T16:18:11+01:00 (5 years ago)
- Location:
- applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/ToulouseModule.java
r33518 r35269 3 3 4 4 import java.util.Collection; 5 import java.util.Comparator;6 5 import java.util.TreeSet; 7 6 … … 59 58 import org.openstreetmap.josm.plugins.opendata.modules.fr.toulouse.datasets.urbanisme.SanisetteHandler; 60 59 import org.openstreetmap.josm.plugins.opendata.modules.fr.toulouse.datasets.urbanisme.VoirieHandler; 60 import org.openstreetmap.josm.tools.Logging; 61 61 62 /** 63 * Open data module for Toulouse portal. 64 */ 62 65 public class ToulouseModule extends AbstractModule { 63 66 … … 112 115 public static final DataSet data = new DataSet(); 113 116 114 private static final Collection<Relation> getBoundaries(int admin_level) { 115 Collection<Relation> result = new TreeSet<>(new Comparator<Relation>() { 116 @Override 117 public int compare(Relation o1, Relation o2) { 118 if (o1.hasKey("name") && o2.hasKey("name")) { 119 return o1.get("name").compareTo(o2.get("name")); 120 } else if (o1.hasKey("ref") && o2.hasKey("ref")) { 121 return o1.get("ref").compareTo(o2.get("ref")); 122 } else { 123 return o1.get("description").compareTo(o2.get("description")); 124 } 117 private static Collection<Relation> getBoundaries(int adminLevel) { 118 Collection<Relation> result = new TreeSet<>((o1, o2) -> { 119 if (o1.hasKey("name") && o2.hasKey("name")) { 120 return o1.get("name").compareTo(o2.get("name")); 121 } else if (o1.hasKey("ref") && o2.hasKey("ref")) { 122 return o1.get("ref").compareTo(o2.get("ref")); 123 } else { 124 return o1.get("description").compareTo(o2.get("description")); 125 125 } 126 126 }); 127 127 synchronized (data) { 128 128 for (Relation r : data.getRelations()) { 129 if (r.hasTag("admin_level", Integer.toString(admin _level)) &&129 if (r.hasTag("admin_level", Integer.toString(adminLevel)) && 130 130 (r.hasKey("name") || r.hasKey("ref") || r.hasKey("description"))) { 131 131 result.add(r); … … 141 141 for (final ToulouseDataSetHandler handler : new ToulouseDataSetHandler[]{ 142 142 new CommuneHandler(), new SecteursHandler(), new QuartiersHandler()}) { 143 MainApplication.worker.submit(new Runnable() { 144 @Override 145 public void run() { 146 try { 147 DataSet ds = new NetworkReader(handler.getDataURL().toString(), handler, false). 148 parseOsm(NullProgressMonitor.INSTANCE); 149 handler.updateDataSet(ds); 150 synchronized (data) { 151 data.mergeFrom(ds); 152 } 153 } catch (OsmTransferException e) { 154 e.printStackTrace(); 143 MainApplication.worker.submit(() -> { 144 try { 145 DataSet ds = new NetworkReader(handler.getDataURL().toString(), handler, false). 146 parseOsm(NullProgressMonitor.INSTANCE); 147 handler.updateDataSet(ds); 148 synchronized (data) { 149 data.mergeFrom(ds); 155 150 } 151 } catch (OsmTransferException e) { 152 Logging.error(e); 156 153 } 157 154 }); -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/ToulouseDataSetHandler.java
r33518 r35269 35 35 import org.openstreetmap.josm.plugins.opendata.modules.fr.toulouse.ToulouseModule; 36 36 import org.openstreetmap.josm.plugins.utilsplugin2.selection.NodeWayUtils; 37 import org.openstreetmap.josm.tools.Logging; 37 38 38 39 public abstract class ToulouseDataSetHandler extends FrenchDataSetHandler implements ToulouseConstants { … … 41 42 * Categories 42 43 */ 43 public static final DataSetCategory CAT_ASSOCIATIONS = new DataSetCategory("Associations", " styles/standard/people.png");44 public static final DataSetCategory CAT_CITOYENNETE = new DataSetCategory("Citoyenneté", "presets/townhall. png");45 public static final DataSetCategory CAT_CULTURE = new DataSetCategory("Culture", "presets/arts_centre. png");46 public static final DataSetCategory CAT_ENFANCE = new DataSetCategory("Enfance", "presets/kindergarten. png");44 public static final DataSetCategory CAT_ASSOCIATIONS = new DataSetCategory("Associations", "people.png"); 45 public static final DataSetCategory CAT_CITOYENNETE = new DataSetCategory("Citoyenneté", "presets/service/townhall.svg"); 46 public static final DataSetCategory CAT_CULTURE = new DataSetCategory("Culture", "presets/sightseeing/arts_centre.svg"); 47 public static final DataSetCategory CAT_ENFANCE = new DataSetCategory("Enfance", "presets/education/kindergarten.svg"); 47 48 public static final DataSetCategory CAT_ENVIRONNEMENT = new DataSetCategory("Environnement", 48 " styles/standard/service/recycling/recycling_container.svg");49 public static final DataSetCategory CAT_PATRIMOINE = new DataSetCategory("Patrimoine", "presets/ ruins.png");50 public static final DataSetCategory CAT_SERVICES = new DataSetCategory("Services", " styles/standard/vehicle/services.png");51 public static final DataSetCategory CAT_SPORT = new DataSetCategory("Sport", " styles/standard/sport/soccer.png");52 public static final DataSetCategory CAT_TOPOGRAPHIE = new DataSetCategory("Topographie", "presets/peak.svg"); 53 public static final DataSetCategory CAT_TRANSPORT = new DataSetCategory("Transport", "presets/ bus.png");54 public static final DataSetCategory CAT_URBANISME = new DataSetCategory("Urbanisme", " styles/standard/place/settlement/city.png");49 "presets/service/recycling/recycling_container.svg"); 50 public static final DataSetCategory CAT_PATRIMOINE = new DataSetCategory("Patrimoine", "presets/sightseeing/ruins.svg"); 51 public static final DataSetCategory CAT_SERVICES = new DataSetCategory("Services", "presets/vehicle/services.svg"); 52 public static final DataSetCategory CAT_SPORT = new DataSetCategory("Sport", "presets/sport/soccer.svg"); 53 public static final DataSetCategory CAT_TOPOGRAPHIE = new DataSetCategory("Topographie", "presets/landmark/peak.svg"); 54 public static final DataSetCategory CAT_TRANSPORT = new DataSetCategory("Transport", "presets/transport/bus.svg"); 55 public static final DataSetCategory CAT_URBANISME = new DataSetCategory("Urbanisme", "presets/place/city.svg"); 55 56 56 57 public ToulouseDataSetHandler(int portalId) { … … 63 64 } 64 65 65 public ToulouseDataSetHandler(int portalId, boolean relevantUnion, String 66 public ToulouseDataSetHandler(int portalId, boolean relevantUnion, String... relevantTags) { 66 67 super(relevantUnion, relevantTags); 67 68 init(portalId); 68 69 } 69 70 70 public ToulouseDataSetHandler(int portalId, String 71 public ToulouseDataSetHandler(int portalId, String... relevantTags) { 71 72 this(portalId, false, relevantTags); 72 73 } 73 74 74 /*public ToulouseDataSetHandler(int portalId, Tag relevantTag) { 75 super(relevantTag); 76 init(portalId); 77 }*/ 78 79 public ToulouseDataSetHandler(int portalId, boolean relevantUnion, Tag ... relevantTags) { 75 public ToulouseDataSetHandler(int portalId, boolean relevantUnion, Tag... relevantTags) { 80 76 super(relevantUnion, relevantTags); 81 77 init(portalId); 82 78 } 83 84 /*public ToulouseDataSetHandler(int portalId, Tag ... relevantTags) {85 this(portalId, false, relevantTags);86 }*/87 79 88 80 private void init(int portalId) { … … 92 84 String url = PORTAL + "/les-donnees/-/opendata/card/" + portalId + "--"; 93 85 setLocalPortalURL(url); 94 //setLicenseURL(url+"/license");95 86 setDataURL(url+"/resource/document"); 96 87 } … … 99 90 addTool(new SplitByNeighbourhood()); 100 91 } catch (MalformedURLException e) { 101 e.printStackTrace();92 Logging.error(e); 102 93 } 103 94 } … … 124 115 setWikiURL(WIKI + "/" + wikiPage.replace(" ", "_")); 125 116 } catch (MalformedURLException e) { 126 e.printStackTrace();117 Logging.error(e); 127 118 } 128 119 } -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/citoyennete/QuartiersHandler.java
r30340 r35269 12 12 setWikiPage("Quartiers de proximité"); 13 13 setCategory(CAT_CITOYENNETE); 14 setMenuIcon("presets/boundaries. png");14 setMenuIcon("presets/misc/boundaries.svg"); 15 15 } 16 16 -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/citoyennete/SecteursHandler.java
r30340 r35269 12 12 setWikiPage("Secteurs de proximité"); 13 13 setCategory(CAT_CITOYENNETE); 14 setMenuIcon("presets/boundaries. png");14 setMenuIcon("presets/misc/boundaries.svg"); 15 15 } 16 16 -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/transport/HorodateurHandler.java
r33518 r35269 16 16 setWikiPage("Horodateurs"); 17 17 setCategory(CAT_TRANSPORT); 18 setMenuIcon(" styles/standard/transport/ticket-machine.png");18 setMenuIcon("presets/transport/ticket-machine.svg"); 19 19 } 20 20 -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/transport/MetroStationHandler.java
r30340 r35269 12 12 setName("Stations de métro"); 13 13 setCategory(CAT_TRANSPORT); 14 setMenuIcon(" styles/standard/transport/railway_station.png");14 setMenuIcon("presets/transport/railway_station.svg"); 15 15 } 16 16 -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/transport/PMRHandler.java
r30340 r35269 12 12 setWikiPage("PMR"); 13 13 setCategory(CAT_TRANSPORT); 14 setMenuIcon(" styles/standard/vehicle/parking/handicapped.png");14 setMenuIcon("presets/vehicle/parking/handicapped.svg"); 15 15 } 16 16 -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/transport/TramwayStationHandler.java
r30340 r35269 12 12 setName("Stations de tramway"); 13 13 setCategory(CAT_TRANSPORT); 14 setMenuIcon(" styles/standard/transport/railway_station.png");14 setMenuIcon("presets/transport/railway_station.svg"); 15 15 } 16 16 -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/urbanisme/CommuneHandler.java
r30340 r35269 12 12 setName("Communes"); 13 13 setCategory(CAT_URBANISME); 14 setMenuIcon("presets/boundaries. png");14 setMenuIcon("presets/misc/boundaries.svg"); 15 15 } 16 16 -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/urbanisme/VoirieHandler.java
r31939 r35269 18 18 19 19 protected final Map<String, Collection<String>> map = new HashMap<>(); 20 20 21 21 private String streetField; 22 22 23 23 public VoirieHandler() { 24 24 this(12693, "lib_off", "highway"); 25 25 setName("Filaire de voirie"); 26 26 setCategory(CAT_URBANISME); 27 setMenuIcon(" styles/standard/transport/way/way_secondary.svg");27 setMenuIcon("presets/transport/way/way_secondary.svg"); 28 28 } 29 29 30 30 protected VoirieHandler(int portalId, String streetField, String relevantTag) { 31 31 super(portalId, relevantTag); … … 39 39 map.put("road", Arrays.asList(new String[] {"VA "})); 40 40 } 41 41 42 42 @Override 43 43 public boolean acceptsFilename(String filename) { … … 58 58 return null; 59 59 } 60 60 61 61 protected String getStreetId(Way w) { 62 62 return w.get("sti"); 63 63 } 64 64 65 65 @Override 66 66 public void updateDataSet(DataSet ds) { 67 67 Map<String, Relation> associatedStreets = new HashMap<>(); 68 68 69 69 for (Way w : ds.getWays()) { 70 70 String name = w.get(streetField); … … 75 75 w.remove("rivoli"); 76 76 w.remove("nrivoli"); 77 77 78 78 if (applyHighwayTag(name, w) == null) { 79 79 w.put("highway", "road"); 80 80 } 81 81 82 82 if (name.startsWith("RPT ") || name.startsWith("GIRATOIRE ")) { 83 83 // TODO: find correct highway … … 86 86 w.put("ref", name.split(" ")[1]); 87 87 } 88 88 89 89 w.put("name", name); 90 90 91 91 if (name.matches("D[0-9]+.*")) { 92 92 w.put("highway", "secondary"); … … 95 95 name = NamesFrUtils.checkStreetName(w, "name"); 96 96 } 97 97 98 98 if (!name.startsWith("VA ")) { // Unknown labels 99 99 Relation street = associatedStreets.get(getStreetId(w));
Note:
See TracChangeset
for help on using the changeset viewer.