Changeset 28044 in osm for applications/editors/josm
- Timestamp:
- 2012-03-11T17:50:51+01:00 (13 years ago)
- Location:
- applications/editors/josm/plugins/opendata
- Files:
-
- 7 added
- 51 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/opendata/build.xml
r28021 r28044 28 28 <property name="commit.message" value="Commit message"/> 29 29 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 30 <property name="plugin.main.version" value="50 56"/>30 <property name="plugin.main.version" value="5068"/> 31 31 <!-- should not be necessary to change the following properties --> 32 32 <property name="josm" location="../../core/dist/josm-custom.jar"/> -
applications/editors/josm/plugins/opendata/modules/fr.paris/src/org/openstreetmap/josm/plugins/opendata/modules/fr/paris/ParisConstants.java
r28000 r28044 28 28 * Portal 29 29 */ 30 public static final String PORTAL = "http://opendata.paris.fr/opendata/ jsp/site/Portal.jsp?";30 public static final String PORTAL = "http://opendata.paris.fr/opendata/"; 31 31 32 32 /** -
applications/editors/josm/plugins/opendata/modules/fr.paris/src/org/openstreetmap/josm/plugins/opendata/modules/fr/paris/datasets/ParisDataSetHandler.java
r28000 r28044 26 26 27 27 private int documentId; 28 private int portletId;28 private static final int portletId = 106; // FIXME 29 29 30 public ParisDataSetHandler(int documentId , int portletId) {31 init(documentId , portletId);30 public ParisDataSetHandler(int documentId) { 31 init(documentId); 32 32 } 33 33 34 public ParisDataSetHandler(int documentId, int portletId,String relevantTag) {34 public ParisDataSetHandler(int documentId, String relevantTag) { 35 35 super(relevantTag); 36 init(documentId , portletId);36 init(documentId); 37 37 } 38 38 39 public ParisDataSetHandler(int documentId, int portletId,boolean relevantUnion, String ... relevantTags) {39 public ParisDataSetHandler(int documentId, boolean relevantUnion, String ... relevantTags) { 40 40 super(relevantUnion, relevantTags); 41 init(documentId , portletId);41 init(documentId); 42 42 } 43 43 44 public ParisDataSetHandler(int documentId, int portletId,String ... relevantTags) {45 this(documentId, portletId,false, relevantTags);44 public ParisDataSetHandler(int documentId, String ... relevantTags) { 45 this(documentId, false, relevantTags); 46 46 } 47 47 48 public ParisDataSetHandler(int documentId, int portletId,boolean relevantUnion, Tag ... relevantTags) {48 public ParisDataSetHandler(int documentId, boolean relevantUnion, Tag ... relevantTags) { 49 49 super(relevantUnion, relevantTags); 50 init(documentId , portletId);50 init(documentId); 51 51 } 52 52 53 private final void init(int documentId , int portletId) {53 private final void init(int documentId) { 54 54 this.documentId = documentId; 55 this.portletId = portletId;56 55 } 57 56 … … 75 74 try { 76 75 if (documentId > 0) { 77 return new URL(PORTAL + "document_id="+documentId + "&portlet_id="+portletId); 76 return new URL(PORTAL + "jsp/site/Portal.jsp?document_id="+documentId + "&portlet_id="+portletId); 77 } 78 } catch (MalformedURLException e) { 79 e.printStackTrace(); 80 } 81 return null; 82 } 83 84 protected abstract String getDirectLink(); 85 86 /* (non-Javadoc) 87 * @see org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler#getDataURL() 88 */ 89 @Override 90 public URL getDataURL() { 91 try { 92 if (documentId > 0) { 93 return new URL(PORTAL + "rating/download/?id_resource="+documentId + "&type_resource=document&url="+getDirectLink()); 78 94 } 79 95 } catch (MalformedURLException e) { -
applications/editors/josm/plugins/opendata/modules/fr.paris/src/org/openstreetmap/josm/plugins/opendata/modules/fr/paris/datasets/urbanisme/SanisettesHandler.java
r28000 r28044 16 16 package org.openstreetmap.josm.plugins.opendata.modules.fr.paris.datasets.urbanisme; 17 17 18 import java.util.ArrayList; 19 import java.util.Iterator; 20 import java.util.List; 21 22 import org.openstreetmap.josm.corrector.UserCancelException; 18 23 import org.openstreetmap.josm.data.osm.DataSet; 24 import org.openstreetmap.josm.data.osm.Node; 25 import org.openstreetmap.josm.data.osm.Way; 26 import org.openstreetmap.josm.plugins.opendata.core.datasets.WayCombiner; 19 27 import org.openstreetmap.josm.plugins.opendata.modules.fr.paris.datasets.ParisDataSetHandler; 20 28 … … 22 30 23 31 public SanisettesHandler() { 24 super(93, 106); 32 super(93); 33 setName("Sanisettes"); 25 34 } 26 35 27 36 @Override 28 37 public boolean acceptsFilename(String filename) { 29 return acceptsShpFilename(filename, "sanisettes"); 38 return acceptsShpFilename(filename, "sanisettes") || acceptsZipFilename(filename, "sanisettes"); 39 } 40 41 private boolean wayBelongsTo(Way a, List<Way> ways) { 42 for (Way b : ways) { 43 if (a.getNode(0).equals(b.getNode(0)) || a.getNode(0).equals(b.getNode(b.getNodesCount()-1)) 44 || a.getNode(a.getNodesCount()-1).equals(b.getNode(0)) || a.getNode(a.getNodesCount()-1).equals(b.getNode(b.getNodesCount()-1))) { 45 return true; 46 } 47 } 48 return false; 49 } 50 51 private boolean wayProcessed(Way a, List<List<Way>> waysToCombine) { 52 for (List<Way> ways : waysToCombine) { 53 for (Way b : ways) { 54 if (a.equals(b)) { 55 return true; 56 } 57 } 58 } 59 return false; 60 } 61 62 @Override 63 public void updateDataSet(DataSet ds) { 64 65 List<Way> sourceWays = new ArrayList<Way>(ds.getWays()); 66 List<List<Way>> waysToCombine = new ArrayList<List<Way>>(); 67 68 for (Iterator<Way> it = sourceWays.iterator(); it.hasNext();) { 69 Way w = it.next(); 70 it.remove(); 71 if (!wayProcessed(w, waysToCombine)) { 72 List<Way> list = new ArrayList<Way>(); 73 list.add(w); 74 boolean finished = false; 75 List<Way> sourceWays2 = new ArrayList<Way>(sourceWays); 76 while (!finished) { 77 int before = list.size(); 78 for (Iterator<Way> it2 = sourceWays2.iterator(); it2.hasNext();) { 79 Way w2 = it2.next(); 80 if (wayBelongsTo(w2, list)) { 81 list.add(w2); 82 it2.remove(); 83 } 84 } 85 int after = list.size(); 86 finished = (after == before); 87 } 88 if (list.size() > 1) { 89 waysToCombine.add(list); 90 } 91 } 92 } 93 94 for (List<Way> ways : waysToCombine) { 95 try { 96 WayCombiner.combineWays(ways); 97 } catch (UserCancelException e) { 98 return; 99 } 100 } 101 102 for (Way w : ds.getWays()) { 103 if (w.getNodesCount() <= 3) { 104 ds.removePrimitive(w); 105 for (Node n : w.getNodes()) { 106 ds.removePrimitive(n); 107 } 108 } else { 109 w.put("amenity", "toilets"); 110 } 111 } 30 112 } 31 113 32 114 @Override 33 public void updateDataSet(DataSet ds) { 115 protected String getDirectLink() { 116 return PORTAL+"hn/sanisettes.zip"; 117 } 118 119 /* (non-Javadoc) 120 * @see org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler#checkShpNodeProximity() 121 */ 122 @Override 123 public boolean checkShpNodeProximity() { 124 return true; 34 125 } 35 126 } -
applications/editors/josm/plugins/opendata/modules/fr.sncf/src/org/openstreetmap/josm/plugins/opendata/modules/fr/sncf/datasets/EquipementsHandler.java
r28000 r28044 15 15 @Override 16 16 public boolean acceptsFilename(String filename) { 17 return accepts XlsFilename(filename, "gare_20......");17 return acceptsCsvXlsFilename(filename, "gare_20......"); 18 18 } 19 19 … … 31 31 @Override 32 32 public LatLon getSpreadSheetCoor(EastNorth en, String[] fields) { 33 // Lambert II coordinates offset by 2000000 (see http://fr.wikipedia.org/wiki/Projection_conique_conforme_de_Lambert#Projections_officielles_en_France_m .C3.A9tropolitaine)33 // Lambert II coordinates offset by 2000000 (see http://fr.wikipedia.org/wiki/Projection_conique_conforme_de_Lambert#Projections_officielles_en_France_métropolitaine) 34 34 return super.getSpreadSheetCoor(new EastNorth(en.getX(), en.getY()-2000000), fields); 35 35 } -
applications/editors/josm/plugins/opendata/modules/fr.sncf/src/org/openstreetmap/josm/plugins/opendata/modules/fr/sncf/datasets/SncfDataSetHandler.java
r28000 r28044 82 82 return null; 83 83 } 84 85 /* (non-Javadoc) 86 * @see org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler#getLicenseURL() 87 */ 88 @Override 89 public URL getLicenseURL() { 90 try { 91 return new URL("http://test.data-sncf.com/licence"); 92 } catch (MalformedURLException e) { 93 e.printStackTrace(); 94 } 95 return null; 96 } 84 97 } -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/ToulouseConstants.java
r28022 r28044 16 16 package org.openstreetmap.josm.plugins.opendata.modules.fr.toulouse; 17 17 18 import org.openstreetmap.josm.plugins.opendata.core.datasets.DataSetCategory; 18 19 import org.openstreetmap.josm.plugins.opendata.core.datasets.fr.FrenchConstants; 19 20 … … 46 47 */ 47 48 public static final String TOULOUSE_NEPTUNE_XSD = "/neptune_toulouse/neptune.xsd"; 49 50 /** 51 * Categories: TODO: icons 52 */ 53 public static final DataSetCategory CAT_ASSOCIATIONS = new DataSetCategory("Associations", ""); 54 public static final DataSetCategory CAT_CITOYENNETE = new DataSetCategory("Citoyenneté", ""); 55 public static final DataSetCategory CAT_CULTURE = new DataSetCategory("Culture", ""); 56 public static final DataSetCategory CAT_ENFANCE = new DataSetCategory("Enfance", ""); 57 public static final DataSetCategory CAT_ENVIRONNEMENT = new DataSetCategory("Environnement", ""); 58 public static final DataSetCategory CAT_PATRIMOINE = new DataSetCategory("Patrimoine", ""); 59 public static final DataSetCategory CAT_SPORT = new DataSetCategory("Sport", ""); 60 public static final DataSetCategory CAT_TOPOGRAPHIE = new DataSetCategory("Topographie", ""); 61 public static final DataSetCategory CAT_TRANSPORT = new DataSetCategory("Transport", ""); 62 public static final DataSetCategory CAT_URBANISME = new DataSetCategory("Urbanisme", ""); 48 63 } -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/ToulouseDataSetHandler.java
r28022 r28044 98 98 99 99 /* (non-Javadoc) 100 * @see org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler#getDataURL() 101 */ 102 @Override 103 public URL getDataURL() { 104 try { 105 return new URL(getLocalPortalURL().toString()+"/resource/document"); 106 } catch (MalformedURLException e) { 107 e.printStackTrace(); 108 } 109 return null; 110 } 111 112 /* (non-Javadoc) 100 113 * @see org.openstreetmap.josm.plugins.fr.opendata.datasets.AbstractDataSetHandler#getWikiURL() 101 114 */ … … 113 126 114 127 protected final void setWikiPage(String wikiPage) { 115 this.wikiPage = wikiPage; 128 this.wikiPage = wikiPage.replace(" ", "_"); 129 setName(wikiPage.replace("_", " ")); 116 130 } 117 131 } -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/associations/Club3eAgeHandler.java
r28000 r28044 25 25 super(12587, "leisure=club", "club=elderly"); 26 26 setWikiPage("Clubs du 3ème âge"); 27 setCategory(CAT_ASSOCIATIONS); 27 28 } 28 29 -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/citoyennete/BureauxVoteHandler.java
r28000 r28044 25 25 super(12550, "polling_station"); 26 26 setWikiPage("Bureaux de vote 2012"); 27 setCategory(CAT_CITOYENNETE); 27 28 } 28 29 -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/citoyennete/MairieAnnexeHandler.java
r28000 r28044 24 24 public MairieAnnexeHandler() { 25 25 super(12560, "Mairies annexes"); 26 setCategory(CAT_CITOYENNETE); 26 27 } 27 28 -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/citoyennete/MairieHandler.java
r28000 r28044 24 24 public MairieHandler() { 25 25 this(12554, "Mairies"); 26 setCategory(CAT_CITOYENNETE); 26 27 } 27 28 -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/citoyennete/PolesTerritoriauxHandler.java
r28000 r28044 24 24 public PolesTerritoriauxHandler() { 25 25 super(12568); 26 setName("Pôles territoriaux "); 27 setCategory(CAT_CITOYENNETE); 26 28 } 27 29 -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/citoyennete/QuartiersHandler.java
r28000 r28044 25 25 super(12574, "admin_level=11"); 26 26 setWikiPage("Quartiers de proximité"); 27 setCategory(CAT_CITOYENNETE); 27 28 } 28 29 -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/citoyennete/SecteursHandler.java
r28000 r28044 25 25 super(12580, "admin_level=10"); 26 26 setWikiPage("Secteurs de proximité"); 27 setCategory(CAT_CITOYENNETE); 27 28 } 28 29 -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/culture/BibliothequesHandler.java
r28000 r28044 25 25 super(12402, "amenity=library"); 26 26 setWikiPage("Médiathèques, bibliothèques et bibliobus"); 27 setCategory(CAT_CULTURE); 27 28 } 28 29 -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/culture/EquipementCulturelBalmaHandler.java
r28000 r28044 25 25 super(13997); 26 26 setWikiPage("Équipements Culturels"); 27 setCategory(CAT_CULTURE); 27 28 } 28 29 -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/culture/LudothequeHandler.java
r28000 r28044 25 25 super(12420, "amenity=toy_library"); 26 26 setWikiPage("Ludothèques"); 27 setCategory(CAT_CULTURE); 27 28 } 28 29 -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/culture/MuseeHandler.java
r28000 r28044 26 26 super(12426, "tourism=museum"); 27 27 setWikiPage("Musées"); 28 setCategory(CAT_CULTURE); 28 29 } 29 30 -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/culture/TheatreHandler.java
r28000 r28044 25 25 super(12448, "amenity=theatre"); 26 26 setWikiPage("Théâtres"); 27 setCategory(CAT_CULTURE); 27 28 } 28 29 -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/enfance/CrechesHandler.java
r28000 r28044 25 25 super(12462, "amenity=kindergarten"); 26 26 setWikiPage("Crèches"); 27 setCategory(CAT_ENFANCE); 27 28 } 28 29 -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/enfance/EcoleBalmaHandler.java
r28000 r28044 25 25 super(13993, "amenity=school"); 26 26 setWikiPage("Écoles"); 27 setCategory(CAT_ENFANCE); 27 28 } 28 29 -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/enfance/EcoleElementaireHandler.java
r28000 r28044 25 25 super(12474, "amenity=school"); 26 26 setWikiPage("Écoles élémentaires publiques"); 27 setCategory(CAT_ENFANCE); 27 28 for (String forbidden : new String[]{"maternelle","primaire","collège","lycée","secondaire"}) { 28 29 addForbiddenTag("school:FR="+forbidden); -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/enfance/EcoleMaternelleHandler.java
r28000 r28044 25 25 super(12490, "amenity=school"); 26 26 setWikiPage("Écoles maternelles publiques"); 27 setCategory(CAT_ENFANCE); 27 28 for (String forbidden : new String[]{"élémentaire","primaire","collège","lycée","secondaire"}) { 28 29 addForbiddenTag("school:FR="+forbidden); -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/enfance/PetiteEnfanceEtJeunesseBalmaHandler.java
r28000 r28044 25 25 super(14001); 26 26 setWikiPage("Petite enfance et jeunesse"); 27 setCategory(CAT_ENFANCE); 27 28 } 28 29 -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/environnement/RecupEmballageHandler.java
r28000 r28044 25 25 super(12494, "amenity=recycling"); 26 26 setWikiPage("Récup' Emballage"); 27 setCategory(CAT_ENVIRONNEMENT); 27 28 } 28 29 -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/environnement/RecupVerreHandler.java
r28000 r28044 25 25 super(12496, "amenity=recycling"); 26 26 setWikiPage("Récup' Verre"); 27 setCategory(CAT_ENVIRONNEMENT); 27 28 } 28 29 -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/environnement/StationEpurationHandler.java
r28000 r28044 25 25 super(12500, "man_made=wastewater_plant"); 26 26 setWikiPage("Stations d'épuration"); 27 setCategory(CAT_ENVIRONNEMENT); 27 28 } 28 29 -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/patrimoine/Parcelles1680Handler.java
r28000 r28044 24 24 public Parcelles1680Handler() { 25 25 super(12514); 26 setName("Parcellaire de 1680"); 27 setCategory(CAT_PATRIMOINE); 26 28 } 27 29 -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/patrimoine/Parcelles1830Handler.java
r28000 r28044 24 24 public Parcelles1830Handler() { 25 25 super(12534); 26 setName("Parcellaire de 1830"); 27 setCategory(CAT_PATRIMOINE); 26 28 } 27 29 -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/sport/InstallationSportiveBalmaHandler.java
r28000 r28044 25 25 super(14010); 26 26 setWikiPage("Installations sportives"); 27 setCategory(CAT_SPORT); 27 28 } 28 29 -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/topographie/AltimetrieVoieHandler.java
r28000 r28044 24 24 public AltimetrieVoieHandler() { 25 25 super(12660, "ele"); 26 setName("Altimétrie des voies"); 27 setCategory(CAT_TOPOGRAPHIE); 26 28 } 27 29 -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/transport/HorodateurHandler.java
r28000 r28044 29 29 super(12540, "vending=parking_tickets"); 30 30 setWikiPage("Horodateurs"); 31 setCategory(CAT_TRANSPORT); 31 32 } 32 33 -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/transport/MetroStationHandler.java
r28000 r28044 24 24 public MetroStationHandler() { 25 25 super(12542, "subway=yes"); 26 setName("Stations de métro"); 27 setCategory(CAT_TRANSPORT); 26 28 } 27 29 -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/transport/PMRHandler.java
r28000 r28044 25 25 super(12538, "amenity=parking_space"); 26 26 setWikiPage("PMR"); 27 setCategory(CAT_TRANSPORT); 27 28 } 28 29 -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/transport/PistesCyclablesHandler.java
r28000 r28044 41 41 public PistesCyclablesHandler() { 42 42 this("Nom_voie"); 43 setCategory(CAT_TRANSPORT); 43 44 } 44 45 -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/transport/ReseauTisseoHandler.java
r28031 r28044 17 17 18 18 import java.io.File; 19 import java.net.MalformedURLException; 19 20 import java.net.URL; 20 21 … … 31 32 super(14022, "network=fr_tisseo"); 32 33 NeptuneReader.registerSchema(neptuneSchemaUrl); 34 setName("Réseau Tisséo (Métro, Bus, Tram)"); 35 setCategory(CAT_TRANSPORT); 33 36 } 34 37 … … 54 57 } 55 58 59 /* (non-Javadoc) 60 * @see org.openstreetmap.josm.plugins.opendata.modules.fr.toulouse.datasets.ToulouseDataSetHandler#getWikiURL() 61 */ 62 @Override 63 public URL getWikiURL() { 64 try { 65 return new URL("http://wiki.openstreetmap.org/wiki/Toulouse/Transports_en_commun#Réseau_Tisséo"); 66 } catch (MalformedURLException e) { 67 e.printStackTrace(); 68 } 69 return null; 70 } 71 56 72 @Override 57 73 public void updateDataSet(DataSet ds) { -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/transport/TramwayStationHandler.java
r28000 r28044 24 24 public TramwayStationHandler() { 25 25 super(12611, "tram=yes"); 26 setName("Stations de tramway"); 27 setCategory(CAT_TRANSPORT); 26 28 } 27 29 -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/transport/VeloToulouseHandler.java
r28000 r28044 26 26 super(12546, "amenity=bicycle_rental"); 27 27 setWikiPage("Vélô Toulouse"); 28 setCategory(CAT_TRANSPORT); 28 29 } 29 30 -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/transport/Zone30Handler.java
r28000 r28044 25 25 super(12548, "Street", "maxspeed=30"); 26 26 setWikiPage("Zones 30"); 27 setCategory(CAT_TRANSPORT); 27 28 } 28 29 -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/urbanisme/CommuneHandler.java
r28000 r28044 24 24 public CommuneHandler() { 25 25 super(12582, "admin_level=8"); 26 setName("Communes"); 27 setCategory(CAT_URBANISME); 26 28 } 27 29 -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/urbanisme/NumerosRueHandler.java
r28000 r28044 31 31 super(12673, "addr:housenumber"); 32 32 setWikiPage("Numéros de rue"); 33 setCategory(CAT_URBANISME); 33 34 } 34 35 -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/urbanisme/SanisetteHandler.java
r28000 r28044 25 25 super(12584, "amenity=toilets"); 26 26 setWikiPage("Sanisettes"); 27 setCategory(CAT_URBANISME); 27 28 } 28 29 -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/urbanisme/VoirieHandler.java
r28000 r28044 37 37 public VoirieHandler() { 38 38 this(12693, "lib_off", "highway"); 39 setName("Filaire de voirie"); 40 setCategory(CAT_URBANISME); 39 41 } 40 42 -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/OdPlugin.java
r28031 r28044 16 16 package org.openstreetmap.josm.plugins.opendata; 17 17 18 import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 19 import static org.openstreetmap.josm.tools.I18n.marktr; 20 21 import java.awt.event.KeyEvent; 18 22 import java.io.File; 19 23 import java.util.Arrays; 24 import java.util.HashMap; 20 25 import java.util.List; 26 import java.util.Map; 27 28 import javax.swing.JMenu; 21 29 22 30 import org.openstreetmap.josm.Main; 23 31 import org.openstreetmap.josm.actions.ExtensionFileFilter; 32 import org.openstreetmap.josm.gui.MainMenu; 24 33 import org.openstreetmap.josm.gui.MapFrame; 25 34 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; … … 27 36 import org.openstreetmap.josm.plugins.PluginInformation; 28 37 import org.openstreetmap.josm.plugins.opendata.core.OdConstants; 38 import org.openstreetmap.josm.plugins.opendata.core.actions.DownloadDataAction; 39 import org.openstreetmap.josm.plugins.opendata.core.actions.DownloadDataTask; 40 import org.openstreetmap.josm.plugins.opendata.core.actions.OpenPreferencesActions; 41 import org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler; 42 import org.openstreetmap.josm.plugins.opendata.core.datasets.DataSetCategory; 29 43 import org.openstreetmap.josm.plugins.opendata.core.gui.OdDialog; 30 44 import org.openstreetmap.josm.plugins.opendata.core.gui.OdPreferenceSetting; … … 38 52 import org.openstreetmap.josm.plugins.opendata.core.io.tabular.OdsImporter; 39 53 import org.openstreetmap.josm.plugins.opendata.core.io.tabular.XlsImporter; 54 import org.openstreetmap.josm.plugins.opendata.core.modules.Module; 40 55 import org.openstreetmap.josm.plugins.opendata.core.modules.ModuleHandler; 41 56 import org.openstreetmap.josm.plugins.opendata.core.modules.ModuleInformation; … … 46 61 47 62 public final XmlImporter xmlImporter; 63 64 private final JMenu menu; 48 65 49 66 public OdPlugin(PluginInformation info) { // NO_UCD … … 65 82 // Load modules 66 83 loadModules(); 84 // Add menu 85 menu = Main.main.menu.addMenu(marktr("Open Data"), KeyEvent.VK_O, Main.main.menu.defaultMenuPos, ht("/Plugin/OpenData")); 86 buildMenu(); 87 // Add download task 88 Main.main.menu.openLocation.addDownloadTaskClass(DownloadDataTask.class); 67 89 } 68 90 69 91 public static final OdPlugin getInstance() { 70 92 return instance; 93 } 94 95 private void buildMenu() { 96 for (Module module : ModuleHandler.moduleList) { 97 Map<DataSetCategory, JMenu> catMenus = new HashMap<DataSetCategory, JMenu>(); 98 JMenu moduleMenu = null; 99 for (AbstractDataSetHandler handler: module.getHandlers()) { 100 if (handler.getDataURL() != null) { 101 if (moduleMenu == null) { 102 String moduleName = module.getDisplayedName(); 103 if (moduleName == null || moduleName.isEmpty()) { 104 moduleName = module.getModuleInformation().getName(); 105 } 106 moduleMenu = new JMenu(moduleName); 107 moduleMenu.setIcon(module.getModuleInformation().getScaledIcon()); 108 } 109 DataSetCategory cat = handler.getCategory(); 110 JMenu endMenu = null; 111 if (cat != null) { 112 if ((endMenu = catMenus.get(cat)) == null) { 113 catMenus.put(cat, endMenu = new JMenu(cat.getName())); 114 moduleMenu.add(endMenu); 115 } 116 } 117 if (endMenu == null) { 118 endMenu = moduleMenu; 119 } 120 endMenu.add(new DownloadDataAction(handler)); 121 } 122 } 123 if (moduleMenu != null) { 124 menu.add(moduleMenu); 125 } 126 } 127 menu.addSeparator(); 128 MainMenu.add(menu, new OpenPreferencesActions()); 71 129 } 72 130 -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/AbstractDataSetHandler.java
r28022 r28044 53 53 import org.openstreetmap.josm.data.projection.proj.LambertConformalConic.Parameters2SP; 54 54 import org.openstreetmap.josm.gui.preferences.SourceEditor.ExtendedSourceEntry; 55 import org.openstreetmap.josm.io.AbstractReader; 55 56 import org.openstreetmap.josm.plugins.opendata.core.OdConstants; 56 57 import org.openstreetmap.josm.plugins.opendata.core.util.NamesFrUtils; … … 92 93 } 93 94 95 private String name; 96 private DataSetCategory category; 94 97 private String sourceDate; 95 98 private File associatedFile; … … 170 173 public URL getWikiURL() {return null;} 171 174 172 public abstract URL getLocalPortalURL(); 173 public abstract URL getNationalPortalURL(); 175 public URL getLocalPortalURL() {return null;} 176 177 public URL getNationalPortalURL() {return null;} 174 178 175 179 public URL getLicenseURL() {return null;} 180 181 public URL getDataURL() {return null;} 182 183 public AbstractReader getReaderForUrl(String url) {return null;} 184 185 public final DataSetCategory getCategory() { 186 return category; 187 } 188 189 public final void setCategory(DataSetCategory category) { 190 this.category = category; 191 } 176 192 177 193 public final Collection<String> getOsmXapiRequests(Bounds bounds) { … … 340 356 } 341 357 342 /**343 * @return the source344 */345 358 public String getSource() { 346 359 return null; 347 360 } 348 361 349 /**350 * @return the sourceDate351 */352 362 public final String getSourceDate() { 353 363 return sourceDate; 354 364 } 355 365 356 /**357 * @param sourceDate the sourceDate to set358 */359 366 public final void setSourceDate(String sourceDate) { 360 367 this.sourceDate = sourceDate; 361 368 } 362 369 370 public final String getName() { 371 return name; 372 } 373 374 public final void setName(String name) { 375 this.name = name; 376 } 377 363 378 public String getLocalPortalIconName() { 364 379 return ICON_CORE_24; … … 503 518 return null; 504 519 } 520 521 public boolean checkShpNodeProximity() { 522 return false; 523 } 505 524 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/AbstractImporter.java
r28018 r28044 18 18 import java.io.File; 19 19 import java.io.IOException; 20 import java.text.SimpleDateFormat;21 import java.util.Date;22 20 23 import org.openstreetmap.josm.Main;24 21 import org.openstreetmap.josm.actions.ExtensionFileFilter; 25 22 import org.openstreetmap.josm.data.osm.DataSet; … … 30 27 import org.openstreetmap.josm.plugins.opendata.core.OdConstants; 31 28 import org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler; 29 import org.openstreetmap.josm.plugins.opendata.core.datasets.DataSetUpdater; 32 30 import org.openstreetmap.josm.plugins.opendata.core.layers.OdDataLayer; 33 31 import org.openstreetmap.josm.plugins.opendata.core.modules.Module; … … 73 71 @Override 74 72 protected OsmDataLayer createLayer(DataSet dataSet, File associatedFile, String layerName) { 75 if (handler != null) { 76 handler.setAssociatedFile(associatedFile); 77 handler.setSourceDate(new SimpleDateFormat("yyyy-MM-dd").format(new Date(associatedFile.lastModified()))); 78 if (!Main.pref.getBoolean(PREF_RAWDATA)) { 79 handler.updateDataSet(dataSet); 80 } 81 handler.checkDataSetSource(dataSet); 82 handler.checkNames(dataSet); 83 } 73 DataSetUpdater.updateDataSet(dataSet, handler, associatedFile); 84 74 return new OdDataLayer(dataSet, layerName, associatedFile, handler); 85 75 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/archive/ZipReader.java
r28031 r28044 50 50 private final ZipInputStream zis; 51 51 private final AbstractDataSetHandler handler; 52 53 private File file; 52 54 53 public ZipReader( ZipInputStream zis, AbstractDataSetHandler handler) {54 this.zis = zis;55 public ZipReader(InputStream in, AbstractDataSetHandler handler) { 56 this.zis = in instanceof ZipInputStream ? (ZipInputStream) in : new ZipInputStream(in); 55 57 this.handler = handler; 56 58 } 57 59 58 60 public static DataSet parseDataSet(InputStream in, AbstractDataSetHandler handler, ProgressMonitor instance) throws IOException, XMLStreamException, FactoryConfigurationError, JAXBException { 59 return new ZipReader(new ZipInputStream(in), handler).parseDoc(instance); 61 return new ZipReader(in, handler).parseDoc(instance); 62 } 63 64 public final File getReadFile() { 65 return file; 60 66 } 61 67 … … 81 87 } 82 88 83 p rivateDataSet parseDoc(ProgressMonitor instance) throws IOException, XMLStreamException, FactoryConfigurationError, JAXBException {89 public DataSet parseDoc(ProgressMonitor instance) throws IOException, XMLStreamException, FactoryConfigurationError, JAXBException { 84 90 85 91 final File temp = createTempDir(); … … 91 97 File file = new File(temp + File.separator + entry.getName()); 92 98 if (file.exists() && !file.delete()) { 93 throw new IOException("Could not delete temp file : " + file.getAbsolutePath());99 throw new IOException("Could not delete temp file/dir: " + file.getAbsolutePath()); 94 100 } 95 if (!file.createNewFile()) { 96 throw new IOException("Could not create temp file: " + file.getAbsolutePath()); 97 } 98 FileOutputStream fos = new FileOutputStream(file); 99 byte[] buffer = new byte[8192]; 100 int count = 0; 101 while ((count = zis.read(buffer, 0, buffer.length)) > 0) { 102 fos.write(buffer, 0, count); 103 } 104 fos.close(); 105 for (String ext : new String[] { 106 CSV_EXT, KML_EXT, KMZ_EXT, XLS_EXT, ODS_EXT, SHP_EXT, MIF_EXT, TAB_EXT, XML_EXT 107 }) { 108 if (entry.getName().toLowerCase().endsWith("."+ext)) { 109 candidates.add(file); 110 System.out.println(entry.getName()); 111 break; 101 if (!entry.isDirectory()) { 102 if (!file.createNewFile()) { 103 throw new IOException("Could not create temp file: " + file.getAbsolutePath()); 104 } 105 FileOutputStream fos = new FileOutputStream(file); 106 byte[] buffer = new byte[8192]; 107 int count = 0; 108 while ((count = zis.read(buffer, 0, buffer.length)) > 0) { 109 fos.write(buffer, 0, count); 112 110 } 111 fos.close(); 112 long time = entry.getTime(); 113 if (time > -1) { 114 file.setLastModified(time); 115 } 116 for (String ext : new String[] { 117 CSV_EXT, KML_EXT, KMZ_EXT, XLS_EXT, ODS_EXT, SHP_EXT, MIF_EXT, TAB_EXT, XML_EXT 118 }) { 119 if (entry.getName().toLowerCase().endsWith("."+ext)) { 120 candidates.add(file); 121 System.out.println(entry.getName()); 122 break; 123 } 124 } 125 } else if (!file.mkdir()) { 126 throw new IOException("Could not create temp dir: " + file.getAbsolutePath()); 113 127 } 114 128 } 115 129 116 Filefile = null;130 file = null; 117 131 118 132 if (candidates.size() > 1) { … … 159 173 } 160 174 } 161 175 } catch (IllegalArgumentException e) { 176 System.err.println(e.getMessage()); 162 177 } finally { 163 178 deleteDir(temp); -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/ShpReader.java
r28000 r28044 371 371 } 372 372 373 private Node getNode(Point p, String key) { 374 Node n = nodes.get(key); 375 if (n == null && handler != null && handler.checkShpNodeProximity()) { 376 LatLon ll = new LatLon(p.getY(), p.getX()); 377 for (Node node : nodes.values()) { 378 if (node.getCoor().equalsEpsilon(ll)) { 379 return node; 380 } 381 } 382 } 383 return n; 384 } 385 373 386 private Node createOrGetNode(Point p) throws MismatchedDimensionException, TransformException { 374 387 if (transform != null) { 375 388 Point p2 = (Point) JTS.transform(p, transform); 376 389 String key = p2.getX()+"/"+p2.getY(); 377 Node n = nodes.get(key); 390 //String key = LatLon.roundToOsmPrecisionStrict(p2.getX())+"/"+LatLon.roundToOsmPrecisionStrict(p2.getY()); 391 Node n = getNode(p2, key); 378 392 if (n == null) { 379 393 nodes.put(key, n = new Node(new LatLon(p2.getY(), p2.getX()))); -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/modules/AbstractModule.java
r28000 r28044 55 55 public List<AbstractDataSetHandler> getHandlers() { 56 56 return handlers; 57 } 58 59 /* (non-Javadoc) 60 * @see org.openstreetmap.josm.plugins.opendata.core.modules.Module#getDisplayedName() 61 */ 62 @Override 63 public String getDisplayedName() { 64 return info.name; 57 65 } 58 66 -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/modules/Module.java
r28000 r28044 23 23 public interface Module { 24 24 25 public String getDisplayedName(); 26 25 27 public List<AbstractDataSetHandler> getHandlers(); 26 28
Note:
See TracChangeset
for help on using the changeset viewer.