Changeset 28054 in osm for applications/editors
- Timestamp:
- 2012-03-12T22:03:36+01:00 (13 years ago)
- Location:
- applications/editors/josm/plugins/opendata
- Files:
-
- 2 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/opendata/modules/fr.datagouvfr/src/org/openstreetmap/josm/plugins/opendata/modules/fr/datagouvfr/DataGouvFrModule.java
r28053 r28054 24 24 import org.openstreetmap.josm.plugins.opendata.modules.fr.datagouvfr.datasets.ecologie.AssainissementHandler; 25 25 import org.openstreetmap.josm.plugins.opendata.modules.fr.datagouvfr.datasets.ecologie.ForetsPubliquesHandler; 26 import org.openstreetmap.josm.plugins.opendata.modules.fr.datagouvfr.datasets.ecologie.ReservesBiologiquesHandler; 26 27 import org.openstreetmap.josm.plugins.opendata.modules.fr.datagouvfr.datasets.education.Etab1er2ndDegreHandler; 27 28 import org.openstreetmap.josm.plugins.opendata.modules.fr.datagouvfr.datasets.education.EtabSupHandler; 29 import org.openstreetmap.josm.plugins.opendata.modules.fr.datagouvfr.datasets.hydrologie.EauxDeSurfaceHandler; 28 30 import org.openstreetmap.josm.plugins.opendata.modules.fr.datagouvfr.datasets.hydrologie.ROEHandler; 29 31 import org.openstreetmap.josm.plugins.opendata.modules.fr.datagouvfr.datasets.transport.PassageNiveauHandler; … … 43 45 handlers.add(new ROEHandler()); 44 46 handlers.add(new ForetsPubliquesHandler()); 47 handlers.add(new ReservesBiologiquesHandler()); 48 handlers.add(new EauxDeSurfaceHandler()); 45 49 } 46 50 } -
applications/editors/josm/plugins/opendata/modules/fr.datagouvfr/src/org/openstreetmap/josm/plugins/opendata/modules/fr/datagouvfr/datasets/DataGouvDataSetHandler.java
r28050 r28054 81 81 } 82 82 83 protected final void setD ataGouvFrUrl(String suffix) {83 protected final void setDownloadFileName(String filename) { 84 84 try { 85 setDataURL(FRENCH_PORTAL+"var/download/"+ suffix);85 setDataURL(FRENCH_PORTAL+"var/download/"+filename); 86 86 } catch (MalformedURLException e) { 87 87 e.printStackTrace(); -
applications/editors/josm/plugins/opendata/modules/fr.datagouvfr/src/org/openstreetmap/josm/plugins/opendata/modules/fr/datagouvfr/datasets/culture/BibliothequesHandler.java
r28050 r28054 27 27 super("Adresses-des-bibliothèques-municipales-30382179", lambert93); 28 28 setName("Bibliothèques municipales"); 29 setD ataGouvFrUrl("lieux de lecture_geoloc.txt");29 setDownloadFileName("lieux de lecture_geoloc.txt"); 30 30 } 31 31 -
applications/editors/josm/plugins/opendata/modules/fr.datagouvfr/src/org/openstreetmap/josm/plugins/opendata/modules/fr/datagouvfr/datasets/diplomatie/EtabAEFEHandler.java
r28050 r28054 25 25 super("Géolocalisation-des-établissements-du-réseau-d'enseignement-de-l'AEFE-30382449", wgs84); 26 26 setName("Établissements du réseau d'enseignement de l'AEFE"); 27 setD ataGouvFrUrl("ETALAB_MAEE_Extraction_LDAP_geoloc_AEFE_2011-10-13.csv");27 setDownloadFileName("ETALAB_MAEE_Extraction_LDAP_geoloc_AEFE_2011-10-13.csv"); 28 28 } 29 29 -
applications/editors/josm/plugins/opendata/modules/fr.datagouvfr/src/org/openstreetmap/josm/plugins/opendata/modules/fr/datagouvfr/datasets/ecologie/ForetsPubliquesHandler.java
r28053 r28054 1 // JOSM opendata plugin. 2 // Copyright (C) 2011-2012 Don-vip 3 // 4 // This program is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // This program is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with this program. If not, see <http://www.gnu.org/licenses/>. 1 16 package org.openstreetmap.josm.plugins.opendata.modules.fr.datagouvfr.datasets.ecologie; 2 17 … … 5 20 import java.util.ArrayList; 6 21 import java.util.List; 22 import java.util.regex.Matcher; 23 import java.util.regex.Pattern; 7 24 8 25 import org.openstreetmap.josm.data.osm.DataSet; 9 import org.openstreetmap.josm.data.osm. Relation;26 import org.openstreetmap.josm.data.osm.OsmPrimitive; 10 27 import org.openstreetmap.josm.plugins.opendata.core.datasets.fr.FrenchAdministrativeUnit; 11 28 import org.openstreetmap.josm.plugins.opendata.modules.fr.datagouvfr.datasets.DataGouvDataSetHandler; … … 13 30 14 31 public class ForetsPubliquesHandler extends DataGouvDataSetHandler { 32 33 private static final String PATTERN = "for_publ_v20.._reg(..)"; 15 34 16 35 public ForetsPubliquesHandler() { … … 20 39 @Override 21 40 public boolean acceptsFilename(String filename) { 22 return acceptsZipFilename(filename, "for_publ_v20.._reg..") || acceptsShpFilename(filename, "for_publ_v20.._reg.."); 41 boolean result = acceptsZipFilename(filename, PATTERN) || acceptsShpFilename(filename, PATTERN); 42 if (result) { 43 setNationalPortalPath(findPortalSuffix(filename)); 44 } 45 return result; 46 } 47 48 @Override 49 public boolean acceptsUrl(String url) { 50 boolean result = super.acceptsUrl(url); 51 if (result) { 52 setNationalPortalPath(findPortalSuffix(url)); 53 } 54 return result; 55 } 56 57 private final String findPortalSuffix(CharSequence filename) { 58 Matcher m = Pattern.compile(".*"+PATTERN+"\\....").matcher(filename); 59 if (m.matches()) { 60 String regionCode = m.group(1); 61 if (regionCode.equals("42")) { 62 return "Forêts-publiques-d’Alsace-30378695"; 63 } else if (regionCode.equals("72")) { 64 return "Forêts-publiques-d'Aquitaine-30378994"; 65 } else if (regionCode.equals("83")) { 66 return "Forêts-publiques-d'Auvergne-30379302"; 67 } else if (regionCode.equals("26")) { 68 return "Forêts-publiques-de-Bourgogne-30379206"; 69 } else if (regionCode.equals("53")) { 70 return "Forêts-publiques-de-Bretagne-30378874"; 71 } else if (regionCode.equals("24")) { 72 return "Forêts-publiques-du-Centre-30379134"; 73 } else if (regionCode.equals("21")) { 74 return "Forêts-publiques-de-Champagne-Ardenne-30378853"; 75 } else if (regionCode.equals("94")) { 76 return "Forêts-publiques-de-Corse-30379118"; 77 } else if (regionCode.equals("43")) { 78 return "Forêts-publiques-de-Franche-Comté-30378652"; 79 } else if (regionCode.equals("11")) { 80 return "Forêts-publiques-d’Île-de-France-30378829"; 81 } else if (regionCode.equals("91")) { 82 return "Forêts-publiques-de-Languedoc-Roussillon-30379312"; 83 } else if (regionCode.equals("74")) { 84 return "Forêts-publiques-du-Limousin-30378844"; 85 } else if (regionCode.equals("41")) { 86 return "Forêts-publiques-de-Lorraine-30378675"; 87 } else if (regionCode.equals("73")) { 88 return "Forêts-publiques-de-Midi-Pyrénées-30378665"; 89 } else if (regionCode.equals("31")) { 90 return "Forêts-publiques-du-Nord-Pas-de-Calais-30379095"; 91 } else if (regionCode.equals("25")) { 92 return "Forêts-publiques-de-Basse-Normandie-30378962"; 93 } else if (regionCode.equals("23")) { 94 return "Forêts-publiques-de-Haute-Normandie-30379164"; 95 } else if (regionCode.equals("52")) { 96 return "Forêts-publiques-des-Pays-de-la-Loire-30378999"; 97 } else if (regionCode.equals("22")) { 98 return "Forêts-publiques-de-Picardie-30379389"; 99 } else if (regionCode.equals("54")) { 100 return "Forêts-publiques-de-Poitou-Charente-30378900"; 101 } else if (regionCode.equals("93")) { 102 return "Forêts-publiques-de-PACA-30379322"; 103 } else if (regionCode.equals("82")) { 104 return "Forêts-publiques-de-Rhône-Alpes-30378732"; 105 } else { 106 System.err.println("Unknown French region code: "+regionCode); 107 } 108 } 109 return null; 23 110 } 24 111 25 112 @Override 26 113 public void updateDataSet(DataSet ds) { 27 for (Relation r : ds.getRelations()) { 28 r.put("landuse", "forest"); 29 replace(r, "LLIB_FRT", "name"); 114 for (OsmPrimitive p : ds.allPrimitives()) { 115 // For all identified objects (both closed ways and multipolygons) 116 if (p.hasKey("IIDTN_FRT")) { 117 p.put("landuse", "forest"); 118 replace(p, "LLIB_FRT", "name"); 119 } 30 120 } 31 121 } … … 39 129 try { 40 130 for (FrenchAdministrativeUnit region : FrenchAdministrativeUnit.allRegions) { 41 result.add(getForetURL(region.getCode(), region.getName())); 131 if (!region.getCode().startsWith("0")) { // Skip DOM/TOM 132 result.add(getForetURL(region.getCode(), region.getName())); 133 } 42 134 } 43 135 } catch (MalformedURLException e) { -
applications/editors/josm/plugins/opendata/modules/fr.datagouvfr/src/org/openstreetmap/josm/plugins/opendata/modules/fr/datagouvfr/datasets/education/Etab1er2ndDegreHandler.java
r28050 r28054 29 29 super("Géolocalisation-des-établissements-d'enseignement-du-premier-degré-et-du-second-degré-du-ministère-d-30378093"); 30 30 setName("Établissements d'enseignement du premier degré et du second degré"); 31 setD ataGouvFrUrl("MENJVA_etab_geoloc.csv");31 setDownloadFileName("MENJVA_etab_geoloc.csv"); 32 32 } 33 33 -
applications/editors/josm/plugins/opendata/modules/fr.datagouvfr/src/org/openstreetmap/josm/plugins/opendata/modules/fr/datagouvfr/datasets/education/EtabSupHandler.java
r28050 r28054 27 27 super("Etablissements-d'enseignement-supérieur-30382046", wgs84); 28 28 setName("Établissements d'enseignement supérieur"); 29 setD ataGouvFrUrl("livraison ETALAB 28 11 2011.xls");29 setDownloadFileName("livraison ETALAB 28 11 2011.xls"); 30 30 } 31 31 -
applications/editors/josm/plugins/opendata/modules/fr.datagouvfr/src/org/openstreetmap/josm/plugins/opendata/modules/fr/datagouvfr/datasets/transport/PassageNiveauHandler.java
r28050 r28054 27 27 super("Passages-à-niveau-30383135"); 28 28 setName("Passages à niveau"); 29 setD ataGouvFrUrl("passage_a_niveau.csv");29 setDownloadFileName("passage_a_niveau.csv"); 30 30 } 31 31 -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/transport/ReseauTisseoHandler.java
r28044 r28054 34 34 setName("Réseau Tisséo (Métro, Bus, Tram)"); 35 35 setCategory(CAT_TRANSPORT); 36 setSkipXsdValidationInZipReading(true); 36 37 } 37 38 -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/actions/DownloadDataTask.java
r28050 r28054 18 18 import java.io.File; 19 19 import java.util.concurrent.Future; 20 import java.util.regex.Pattern; 20 21 21 22 import org.openstreetmap.josm.Main; … … 25 26 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 26 27 import org.openstreetmap.josm.io.AbstractReader; 28 import org.openstreetmap.josm.plugins.opendata.core.OdConstants; 27 29 import org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler; 28 30 import org.openstreetmap.josm.plugins.opendata.core.datasets.DataSetUpdater; … … 32 34 import org.openstreetmap.josm.plugins.opendata.core.modules.ModuleHandler; 33 35 34 public class DownloadDataTask extends DownloadOsmTask {36 public class DownloadDataTask extends DownloadOsmTask implements OdConstants { 35 37 36 38 private AbstractDataSetHandler handler; … … 54 56 @Override 55 57 public boolean acceptsUrl(String url) { 58 this.handler = null; 56 59 for (Module module : ModuleHandler.moduleList) { 57 60 for (AbstractDataSetHandler handler : module.getHandlers()) { … … 60 63 return true; 61 64 } 65 } 66 } 67 for (String ext : new String[]{ZIP_EXT, CSV_EXT, KML_EXT, KMZ_EXT, XLS_EXT, ODS_EXT, SHP_EXT, MIF_EXT, TAB_EXT}) { 68 if (Pattern.compile(".*\\."+ext, Pattern.CASE_INSENSITIVE).matcher(url).matches()) { 69 return true; 62 70 } 63 71 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/AbstractDataSetHandler.java
r28050 r28054 548 548 return false; 549 549 } 550 551 private boolean setSkipXsdValidationInZipReading = false; 552 553 public final void setSkipXsdValidationInZipReading(boolean skip) { 554 setSkipXsdValidationInZipReading = skip; 555 } 556 557 public boolean skipXsdValidationInZipReading() { 558 return setSkipXsdValidationInZipReading; 559 } 550 560 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/archive/ZipReader.java
r28050 r28054 119 119 } 120 120 for (String ext : new String[] { 121 CSV_EXT, KML_EXT, KMZ_EXT, XLS_EXT, ODS_EXT, SHP_EXT, MIF_EXT, TAB_EXT , XML_EXT121 CSV_EXT, KML_EXT, KMZ_EXT, XLS_EXT, ODS_EXT, SHP_EXT, MIF_EXT, TAB_EXT 122 122 }) { 123 123 if (entry.getName().toLowerCase().endsWith("."+ext)) { … … 126 126 break; 127 127 } 128 } 129 // Special treatment for XML files (check supported XSD), unless handler explicitely skip it 130 if (XML_FILE_FILTER.accept(file) && ((handler != null && handler.skipXsdValidationInZipReading()) 131 || OdPlugin.getInstance().xmlImporter.acceptFile(file))) { 132 candidates.add(file); 133 System.out.println(entry.getName()); 128 134 } 129 135 } else if (!file.mkdir()) {
Note:
See TracChangeset
for help on using the changeset viewer.