Changeset 28113 in osm for applications
- Timestamp:
- 2012-03-19T00:23:49+01:00 (13 years ago)
- Location:
- applications/editors/josm/plugins/opendata
- Files:
-
- 25 added
- 39 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/opendata/modules/be.bruxelles/src/org/openstreetmap/josm/plugins/opendata/modules/be/bruxelles/datasets/BruxellesDataSetHandler.java
r28000 r28113 18 18 import java.net.MalformedURLException; 19 19 import java.net.URL; 20 import java.util.Locale;21 20 22 import org.openstreetmap.josm.Main;23 21 import org.openstreetmap.josm.data.projection.Projection; 24 22 import org.openstreetmap.josm.plugins.opendata.core.datasets.be.BelgianDataSetHandler; 23 import org.openstreetmap.josm.plugins.opendata.core.util.OdUtils; 25 24 import org.openstreetmap.josm.plugins.opendata.modules.be.bruxelles.BruxellesConstants; 26 25 … … 70 69 public URL getLocalPortalURL() { 71 70 String basePortal = null; 72 String lang = Main.pref.get("language"); 73 if (lang == null || lang.isEmpty()) { 74 lang = Locale.getDefault().toString(); 75 } 71 String lang = OdUtils.getJosmLanguage(); 76 72 77 73 if (lang.startsWith("fr")) { -
applications/editors/josm/plugins/opendata/modules/be.bruxelles/src/org/openstreetmap/josm/plugins/opendata/modules/be/bruxelles/datasets/culture/BDHandler.java
r28000 r28113 7 7 public class BDHandler extends BruxellesDataSetHandler { 8 8 9 public BDHandler() { 10 getCsvHandler().setSeparator(","); 11 } 12 9 13 @Override 10 14 public boolean acceptsFilename(String filename) { … … 19 23 } 20 24 } 21 22 /* (non-Javadoc)23 * @see org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler#getCsvSeparator()24 */25 @Override26 public String getCsvSeparator() {27 return ",";28 }29 25 } -
applications/editors/josm/plugins/opendata/modules/be.datagovbe/src/org/openstreetmap/josm/plugins/opendata/modules/be/datagovbe/datasets/DataGovDataSetHandler.java
r28000 r28113 15 15 // along with this program. If not, see <http://www.gnu.org/licenses/>. 16 16 package org.openstreetmap.josm.plugins.opendata.modules.be.datagovbe.datasets; 17 18 import java.net.URL;19 17 20 18 import org.openstreetmap.josm.data.projection.Projection; … … 58 56 return SOURCE_DATAGOVBE; 59 57 } 60 61 /* (non-Javadoc)62 * @see org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler#getLocalPortalURL()63 */64 @Override65 public URL getLocalPortalURL() {66 return null;67 }68 58 } -
applications/editors/josm/plugins/opendata/modules/fr.cg41/src/org/openstreetmap/josm/plugins/opendata/modules/fr/cg41/datasets/Cg41DataSetHandler.java
r28000 r28113 2 2 3 3 import java.net.MalformedURLException; 4 import java.net.URL;5 4 6 5 import org.openstreetmap.josm.data.osm.Tag; … … 9 8 10 9 public abstract class Cg41DataSetHandler extends FrenchDataSetHandler implements Cg41Constants { 11 12 private int portalId;13 10 14 11 public Cg41DataSetHandler(int portalId, String nationalPath) { … … 36 33 37 34 private final void init(int portalId, String nationalPath) { 38 this.portalId = portalId;39 35 setNationalPortalPath(nationalPath); 36 try { 37 if (portalId > 0) { 38 setLocalPortalURL(PORTAL_CG41 + portalId); 39 } 40 } catch (MalformedURLException e) { 41 e.printStackTrace(); 42 } 43 40 44 } 41 45 … … 63 67 return ICON_CG41_16; 64 68 } 65 66 public final URL getLocalPortalURL() {67 try {68 if (portalId > 0) {69 return new URL(PORTAL_CG41 + portalId);70 }71 } catch (MalformedURLException e) {72 e.printStackTrace();73 }74 return null;75 }76 69 } -
applications/editors/josm/plugins/opendata/modules/fr.datagouvfr/src/org/openstreetmap/josm/plugins/opendata/modules/fr/datagouvfr/datasets/DataGouvDataSetHandler.java
r28054 r28113 17 17 18 18 import java.net.MalformedURLException; 19 import java.net.URL;20 19 21 20 import org.openstreetmap.josm.data.projection.Projection; 22 21 import org.openstreetmap.josm.plugins.opendata.core.datasets.fr.FrenchDataSetHandler; 22 import org.openstreetmap.josm.plugins.opendata.core.licenses.License; 23 23 import org.openstreetmap.josm.plugins.opendata.modules.fr.datagouvfr.DataGouvFrConstants; 24 24 … … 50 50 setNationalPortalPath(portalPath); 51 51 setSingleProjection(singleProjection); 52 setLicense(License.LOOL); 52 53 } 53 54 … … 58 59 public String getSource() { 59 60 return SOURCE_DATAGOUVFR; 60 }61 62 /* (non-Javadoc)63 * @see org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler#getLocalPortalURL()64 */65 @Override66 public URL getLocalPortalURL() {67 return null;68 }69 70 /* (non-Javadoc)71 * @see org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler#getLicenseURL()72 */73 @Override74 public URL getLicenseURL() {75 try {76 return new URL(FRENCH_PORTAL+"Licence-Ouverte-Open-Licence");77 } catch (MalformedURLException e) {78 e.printStackTrace();79 }80 return null;81 61 } 82 62 -
applications/editors/josm/plugins/opendata/modules/fr.datagouvfr/src/org/openstreetmap/josm/plugins/opendata/modules/fr/datagouvfr/datasets/administration/GeoFlaHandler.java
r28050 r28113 37 37 super(); 38 38 setName("GEOFLA®"); 39 } 40 41 /* (non-Javadoc) 42 * @see org.openstreetmap.josm.plugins.opendata.portals.fr.datagouvfr.datasets.DataGouvDataSetHandler#getLocalPortalURL() 43 */ 44 @Override 45 public URL getLocalPortalURL() { 39 getShpHandler().setPreferMultipolygonToSimpleWay(true); 46 40 try { 47 return newURL("http://professionnels.ign.fr/ficheProduitCMS.do?idDoc=6185461");41 setLocalPortalURL("http://professionnels.ign.fr/ficheProduitCMS.do?idDoc=6185461"); 48 42 } catch (MalformedURLException e) { 49 System.err.println(e.getMessage()); 50 return null; 43 e.printStackTrace(); 51 44 } 52 45 } … … 79 72 protected boolean isArrondissementFile(String filename) { 80 73 return acceptsShpFilename(filename, "ARRONDISSEMENT") || acceptsShpFilename(filename, "LIMITE_ARRONDISSEMENT"); 81 }82 83 @Override84 public boolean preferMultipolygonToSimpleWay() {85 return true;86 74 } 87 75 -
applications/editors/josm/plugins/opendata/modules/fr.datagouvfr/src/org/openstreetmap/josm/plugins/opendata/modules/fr/datagouvfr/datasets/culture/BibliothequesHandler.java
r28054 r28113 16 16 package org.openstreetmap.josm.plugins.opendata.modules.fr.datagouvfr.datasets.culture; 17 17 18 import java.nio.charset.Charset;19 20 18 import org.openstreetmap.josm.data.osm.DataSet; 21 19 import org.openstreetmap.josm.data.osm.Node; … … 28 26 setName("Bibliothèques municipales"); 29 27 setDownloadFileName("lieux de lecture_geoloc.txt"); 28 getCsvHandler().setCharset(ISO8859_15); 30 29 } 31 30 … … 41 40 } 42 41 } 43 44 /* (non-Javadoc)45 * @see org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler#getCsvCharset()46 */47 @Override48 public Charset getCsvCharset() {49 return Charset.forName(ISO8859_15);50 }51 42 } -
applications/editors/josm/plugins/opendata/modules/fr.datagouvfr/src/org/openstreetmap/josm/plugins/opendata/modules/fr/datagouvfr/datasets/diplomatie/EtabAEFEHandler.java
r28054 r28113 26 26 setName("Établissements du réseau d'enseignement de l'AEFE"); 27 27 setDownloadFileName("ETALAB_MAEE_Extraction_LDAP_geoloc_AEFE_2011-10-13.csv"); 28 getCsvHandler().setSeparator(","); 28 29 } 29 30 … … 44 45 } 45 46 } 46 47 /* (non-Javadoc)48 * @see org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler#getCsvSeparator()49 */50 @Override51 public String getCsvSeparator() {52 return ",";53 }54 47 } -
applications/editors/josm/plugins/opendata/modules/fr.datagouvfr/src/org/openstreetmap/josm/plugins/opendata/modules/fr/datagouvfr/datasets/ecologie/AssainissementHandler.java
r28050 r28113 30 30 super("assainissement-collectif-30381843"); 31 31 setName("Assainissement collectif"); 32 getSpreadSheetHandler().setSheetNumber(1); 32 33 } 33 34 … … 40 41 public void updateDataSet(DataSet ds) { 41 42 // TODO Auto-generated method stub 42 }43 44 /* (non-Javadoc)45 * @see org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler#getSheetNumber()46 */47 @Override48 public int getSheetNumber() {49 return 1;50 43 } 51 44 -
applications/editors/josm/plugins/opendata/modules/fr.datagouvfr/src/org/openstreetmap/josm/plugins/opendata/modules/fr/datagouvfr/datasets/education/Etab1er2ndDegreHandler.java
r28054 r28113 16 16 package org.openstreetmap.josm.plugins.opendata.modules.fr.datagouvfr.datasets.education; 17 17 18 import java.nio.charset.Charset;19 20 18 import org.openstreetmap.josm.data.coor.EastNorth; 21 19 import org.openstreetmap.josm.data.coor.LatLon; 22 20 import org.openstreetmap.josm.data.osm.DataSet; 23 21 import org.openstreetmap.josm.data.osm.Node; 22 import org.openstreetmap.josm.plugins.opendata.core.io.tabular.DefaultCsvHandler; 24 23 import org.openstreetmap.josm.plugins.opendata.modules.fr.datagouvfr.datasets.DataGouvDataSetHandler; 25 24 26 25 public class Etab1er2ndDegreHandler extends DataGouvDataSetHandler { 27 26 27 private class EtabCsvHandler extends DefaultCsvHandler { 28 29 public EtabCsvHandler() { 30 setCharset(ISO8859_15); 31 setHandlesProjection(true); 32 } 33 34 @Override 35 public LatLon getCoor(EastNorth en, String[] fields) { 36 return getLatLonByDptCode(en, fields[0].substring(0, 3), false); 37 } 38 } 39 28 40 public Etab1er2ndDegreHandler() { 29 41 super("Géolocalisation-des-établissements-d'enseignement-du-premier-degré-et-du-second-degré-du-ministère-d-30378093"); 30 42 setName("Établissements d'enseignement du premier degré et du second degré"); 31 43 setDownloadFileName("MENJVA_etab_geoloc.csv"); 44 setCsvHandler(new EtabCsvHandler()); 32 45 } 33 46 … … 53 66 } 54 67 } 55 56 /* (non-Javadoc)57 * @see org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler#handlesCsvProjection()58 */59 @Override60 public boolean handlesSpreadSheetProjection() {61 return true;62 }63 64 /* (non-Javadoc)65 * @see org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler#getCsvCoor(org.openstreetmap.josm.data.coor.EastNorth, java.lang.String[])66 */67 @Override68 public LatLon getSpreadSheetCoor(EastNorth en, String[] fields) {69 return getLatLonByDptCode(en, fields[0].substring(0, 3), false);70 }71 72 /* (non-Javadoc)73 * @see org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler#getCsvCharset()74 */75 @Override76 public Charset getCsvCharset() {77 return Charset.forName(ISO8859_15);78 }79 68 } -
applications/editors/josm/plugins/opendata/modules/fr.datagouvfr/src/org/openstreetmap/josm/plugins/opendata/modules/fr/datagouvfr/datasets/education/EtabSupHandler.java
r28054 r28113 24 24 public class EtabSupHandler extends DataGouvDataSetHandler { 25 25 26 private class EtabSupCsvHandler extends InternalCsvHandler { 27 @Override 28 public LatLon getCoor(EastNorth en, String[] fields) { 29 // X/Y sont inversees dans le fichier 30 return wgs84.eastNorth2latlon(new EastNorth(en.north(), en.east())); 31 } 32 } 33 26 34 public EtabSupHandler() { 27 35 super("Etablissements-d'enseignement-supérieur-30382046", wgs84); 28 36 setName("Établissements d'enseignement supérieur"); 29 37 setDownloadFileName("livraison ETALAB 28 11 2011.xls"); 38 setCsvHandler(new EtabSupCsvHandler()); 30 39 } 31 40 … … 42 51 } 43 52 } 44 45 /* (non-Javadoc)46 * @see org.openstreetmap.josm.plugins.opendata.portals.fr.datagouvfr.datasets.DataGouvDataSetHandler#getSpreadSheetCoor(org.openstreetmap.josm.data.coor.EastNorth, java.lang.String[])47 */48 @Override49 public LatLon getSpreadSheetCoor(EastNorth en, String[] fields) {50 // X/Y sont inversees dans le fichier51 return wgs84.eastNorth2latlon(new EastNorth(en.north(), en.east()));52 }53 53 } -
applications/editors/josm/plugins/opendata/modules/fr.datagouvfr/src/org/openstreetmap/josm/plugins/opendata/modules/fr/datagouvfr/datasets/hydrologie/EauxDeSurfaceHandler.java
r28055 r28113 29 29 30 30 import org.openstreetmap.josm.data.osm.DataSet; 31 import org.openstreetmap.josm.plugins.opendata.core.io.archive.DefaultZipHandler; 31 32 import org.openstreetmap.josm.plugins.opendata.modules.fr.datagouvfr.datasets.DataGouvDataSetHandler; 32 33 import org.openstreetmap.josm.tools.Pair; … … 65 66 public EauxDeSurfaceHandler() { 66 67 setName("Eaux de surface"); 68 setZipHandler(new InternalZipHandler()); 67 69 } 68 70 … … 123 125 return new Pair<String, URL>(a.name, new URL("http://www.rapportage.eaufrance.fr/sites/default/files/SIG/FR"+a.code+"_SW.zip")); 124 126 } 125 126 /* (non-Javadoc) 127 * @see org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler#notifyTempFileWritten(java.io.File) 128 */ 129 @Override 130 public void notifyTempFileWritten(File file) { 131 if (file.getName().matches(SHP_PATTERN.replace("(.*)", "F")+"\\.prj")) { // Adour-Garonne .prj files cannot be parsed because they do not contain quotes... 132 try { 133 BufferedReader reader = new BufferedReader(new FileReader(file)); 134 String line = reader.readLine(); 135 reader.close(); 136 if (!line.contains("\"")) { 137 for (String term : new String[]{"GCS_ETRS_1989", "D_ETRS_1989", "GRS_1980", "Greenwich", "Degree"}) { 138 line = line.replace(term, "\""+term+"\""); 127 128 private class InternalZipHandler extends DefaultZipHandler { 129 @Override 130 public void notifyTempFileWritten(File file) { 131 if (file.getName().matches(SHP_PATTERN.replace("(.*)", "F")+"\\.prj")) { // Adour-Garonne .prj files cannot be parsed because they do not contain quotes... 132 try { 133 BufferedReader reader = new BufferedReader(new FileReader(file)); 134 String line = reader.readLine(); 135 reader.close(); 136 if (!line.contains("\"")) { 137 for (String term : new String[]{"GCS_ETRS_1989", "D_ETRS_1989", "GRS_1980", "Greenwich", "Degree"}) { 138 line = line.replace(term, "\""+term+"\""); 139 } 140 BufferedWriter writer = new BufferedWriter(new FileWriter(file)); 141 writer.write(line); 142 writer.close(); 139 143 } 140 BufferedWriter writer = new BufferedWriter(new FileWriter(file)); 141 writer.write(line); 142 writer.close(); 144 } catch (Exception e) { 145 e.printStackTrace(); 143 146 } 144 } catch (Exception e) {145 e.printStackTrace();146 147 } 147 148 } -
applications/editors/josm/plugins/opendata/modules/fr.datagouvfr/src/org/openstreetmap/josm/plugins/opendata/modules/fr/datagouvfr/datasets/transport/PassageNiveauHandler.java
r28054 r28113 16 16 package org.openstreetmap.josm.plugins.opendata.modules.fr.datagouvfr.datasets.transport; 17 17 18 import java.nio.charset.Charset;19 20 18 import org.openstreetmap.josm.data.osm.DataSet; 21 19 import org.openstreetmap.josm.data.osm.Node; … … 28 26 setName("Passages à niveau"); 29 27 setDownloadFileName("passage_a_niveau.csv"); 28 getCsvHandler().setCharset(ISO8859_15); 30 29 } 31 30 … … 41 40 } 42 41 } 43 44 /* (non-Javadoc)45 * @see org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler#getCsvCharset()46 */47 @Override48 public Charset getCsvCharset() {49 return Charset.forName(ISO8859_15);50 }51 42 } -
applications/editors/josm/plugins/opendata/modules/fr.lemans/src/org/openstreetmap/josm/plugins/opendata/modules/fr/lemans/datasets/LeMansDataSetHandler.java
r28091 r28113 23 23 import org.openstreetmap.josm.data.osm.Tag; 24 24 import org.openstreetmap.josm.plugins.opendata.core.datasets.fr.FrenchDataSetHandler; 25 import org.openstreetmap.josm.plugins.opendata.core.licenses.License; 25 26 import org.openstreetmap.josm.plugins.opendata.modules.fr.lemans.LeMansConstants; 26 27 import org.openstreetmap.josm.tools.Pair; 27 28 28 29 public abstract class LeMansDataSetHandler extends FrenchDataSetHandler implements LeMansConstants { 29 30 private String uuid;31 30 32 31 private String kmzUuid; … … 58 57 59 58 private final void init(String uuid) { 60 this.uuid = uuid; 59 try { 60 setLicense(License.ODbL); 61 if (uuid != null && !uuid.isEmpty()) { 62 setLocalPortalURL(PORTAL + "page.do?t=2&uuid=" + uuid); 63 } 64 } catch (MalformedURLException e) { 65 e.printStackTrace(); 66 } 61 67 } 62 68 … … 73 79 return SOURCE_LE_MANS; 74 80 } 75 76 public final URL getLocalPortalURL() {77 try {78 if (uuid != null && !uuid.isEmpty()) {79 return new URL(PORTAL + "page.do?t=2&uuid=" + uuid);80 }81 } catch (MalformedURLException e) {82 e.printStackTrace();83 }84 return null;85 }86 81 87 82 /* (non-Javadoc) 88 83 * @see org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler#getLicenseURL() 89 84 */ 90 @Override 85 /*@Override 91 86 public URL getLicenseURL() { 92 87 try { … … 96 91 } 97 92 return null; 98 } 99 93 }*/ 94 100 95 /* (non-Javadoc) 101 96 * @see org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler#getDataURLs() -
applications/editors/josm/plugins/opendata/modules/fr.paris/src/org/openstreetmap/josm/plugins/opendata/modules/fr/paris/datasets/ParisDataSetHandler.java
r28044 r28113 22 22 import org.openstreetmap.josm.plugins.opendata.core.datasets.fr.FrenchDataSetHandler; 23 23 import org.openstreetmap.josm.plugins.opendata.modules.fr.paris.ParisConstants; 24 import org.openstreetmap.josm.plugins.opendata.modules.fr.paris.ParisLicense; 24 25 25 26 public abstract class ParisDataSetHandler extends FrenchDataSetHandler implements ParisConstants { … … 53 54 private final void init(int documentId) { 54 55 this.documentId = documentId; 56 setLicense(new ParisLicense()); 57 try { 58 if (documentId > 0) { 59 setLocalPortalURL(PORTAL + "jsp/site/Portal.jsp?document_id="+documentId + "&portlet_id="+portletId); 60 } 61 } catch (MalformedURLException e) { 62 e.printStackTrace(); 63 } 55 64 } 56 65 … … 69 78 public String getLocalPortalIconName() { 70 79 return ICON_PARIS_24; 71 }72 73 public final URL getLocalPortalURL() {74 try {75 if (documentId > 0) {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 80 } 83 81 -
applications/editors/josm/plugins/opendata/modules/fr.paris/src/org/openstreetmap/josm/plugins/opendata/modules/fr/paris/datasets/urbanisme/SanisettesHandler.java
r28044 r28113 32 32 super(93); 33 33 setName("Sanisettes"); 34 getShpHandler().setCheckNodeProximity(true); 34 35 } 35 36 … … 116 117 return PORTAL+"hn/sanisettes.zip"; 117 118 } 118 119 /* (non-Javadoc)120 * @see org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler#checkShpNodeProximity()121 */122 @Override123 public boolean checkShpNodeProximity() {124 return true;125 }126 119 } -
applications/editors/josm/plugins/opendata/modules/fr.sncf/src/org/openstreetmap/josm/plugins/opendata/modules/fr/sncf/datasets/EquipementsHandler.java
r28044 r28113 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.sncf.datasets; 2 17 … … 8 23 public class EquipementsHandler extends SncfDataSetHandler { 9 24 25 private class LambertIICsvHandler extends InternalCsvHandler { 26 @Override 27 public LatLon getCoor(EastNorth en, String[] fields) { 28 // Lambert II coordinates offset by 2000000 (see http://fr.wikipedia.org/wiki/Projection_conique_conforme_de_Lambert#Projections_officielles_en_France_métropolitaine) 29 return super.getCoor(new EastNorth(en.getX(), en.getY()-2000000), fields); 30 } 31 } 32 10 33 public EquipementsHandler() { 11 34 super("equipementsgares"); 35 setCsvHandler(new LambertIICsvHandler()); 12 36 setSingleProjection(lambert4Zones[1]); // Lambert II 13 37 } … … 25 49 } 26 50 } 27 28 /* (non-Javadoc)29 * @see org.openstreetmap.josm.plugins.opendata.core.datasets.fr.FrenchDataSetHandler#getSpreadSheetCoor(org.openstreetmap.josm.data.coor.EastNorth, java.lang.String[])30 */31 @Override32 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étropolitaine)34 return super.getSpreadSheetCoor(new EastNorth(en.getX(), en.getY()-2000000), fields);35 }36 51 } -
applications/editors/josm/plugins/opendata/modules/fr.sncf/src/org/openstreetmap/josm/plugins/opendata/modules/fr/sncf/datasets/SncfDataSetHandler.java
r28044 r28113 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.sncf.datasets; 2 17 3 18 import java.net.MalformedURLException; 4 import java.net.URL;5 19 6 20 import org.openstreetmap.josm.data.osm.Tag; 7 21 import org.openstreetmap.josm.plugins.opendata.core.datasets.fr.FrenchDataSetHandler; 8 22 import org.openstreetmap.josm.plugins.opendata.modules.fr.sncf.SncfConstants; 23 import org.openstreetmap.josm.plugins.opendata.modules.fr.sncf.SncfLicense; 9 24 10 25 public abstract class SncfDataSetHandler extends FrenchDataSetHandler implements SncfConstants { 11 12 private String portalId;13 26 14 27 public SncfDataSetHandler(String portalId) { … … 45 58 46 59 private final void init(String portalId) { 47 this.portalId = portalId; 60 setLicense(new SncfLicense()); 61 if (portalId != null && !portalId.isEmpty()) { 62 try { 63 setLocalPortalURL(PORTAL + portalId); 64 } catch (MalformedURLException e) { 65 e.printStackTrace(); 66 } 67 } 48 68 } 49 69 … … 71 91 return ICON_16; 72 92 } 73 74 public final URL getLocalPortalURL() {75 try {76 if (portalId != null) {77 return new URL(PORTAL + portalId);78 }79 } catch (MalformedURLException e) {80 e.printStackTrace();81 }82 return null;83 }84 85 /* (non-Javadoc)86 * @see org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler#getLicenseURL()87 */88 @Override89 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 }97 93 } -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/ToulouseConstants.java
r28044 r28113 35 35 * Portal 36 36 */ 37 public static final String PORTAL = "http://data.grandtoulouse.fr /les-donnees/-/opendata/card/";37 public static final String PORTAL = "http://data.grandtoulouse.fr"; 38 38 39 39 /** -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/ToulouseDataSetHandler.java
r28044 r28113 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.toulouse.datasets; 2 17 3 18 import java.net.MalformedURLException; 4 import java.net.URL;5 19 6 20 import org.openstreetmap.josm.data.osm.Tag; 7 21 import org.openstreetmap.josm.plugins.opendata.core.datasets.fr.FrenchDataSetHandler; 8 22 import org.openstreetmap.josm.plugins.opendata.modules.fr.toulouse.ToulouseConstants; 23 import org.openstreetmap.josm.plugins.opendata.modules.fr.toulouse.ToulouseLicense; 9 24 10 25 public abstract class ToulouseDataSetHandler extends FrenchDataSetHandler implements ToulouseConstants { 11 12 private int portalId;13 private String wikiPage;14 26 15 27 public ToulouseDataSetHandler(int portalId) { … … 46 58 47 59 private final void init(int portalId) { 48 this.portalId = portalId; 60 try { 61 setLicense(new ToulouseLicense()); 62 if (portalId > 0) { 63 String url = PORTAL + "/les-donnees/-/opendata/card/" + portalId + "--"; 64 setLocalPortalURL(url); 65 //setLicenseURL(url+"/license"); 66 setDataURL(url+"/resource/document"); 67 } 68 } catch (MalformedURLException e) { 69 e.printStackTrace(); 70 } 49 71 } 50 72 … … 72 94 return ICON_CROIX_16; 73 95 } 74 75 public final URL getLocalPortalURL() {76 try {77 if (portalId > 0) {78 return new URL(PORTAL + portalId + "--");79 }80 } catch (MalformedURLException e) {81 e.printStackTrace();82 }83 return null;84 }85 86 /* (non-Javadoc)87 * @see org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler#getLicenseURL()88 */89 @Override90 public URL getLicenseURL() {91 try {92 return new URL(getLocalPortalURL().toString()+"/license");93 } catch (MalformedURLException e) {94 e.printStackTrace();95 }96 return null;97 }98 99 /* (non-Javadoc)100 * @see org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler#getDataURL()101 */102 @Override103 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)113 * @see org.openstreetmap.josm.plugins.fr.opendata.datasets.AbstractDataSetHandler#getWikiURL()114 */115 @Override116 public URL getWikiURL() {117 try {118 if (wikiPage != null && !wikiPage.isEmpty()) {119 return new URL(WIKI + "/" + wikiPage);120 }121 } catch (MalformedURLException e) {122 e.printStackTrace();123 }124 return null;125 }126 96 127 97 protected final void setWikiPage(String wikiPage) { 128 this.wikiPage = wikiPage.replace(" ", "_"); 129 setName(wikiPage.replace("_", " ")); 98 if (wikiPage != null && !wikiPage.isEmpty()) { 99 setName(wikiPage.replace("_", " ")); 100 try { 101 setWikiURL(WIKI + "/" + wikiPage.replace(" ", "_")); 102 } catch (MalformedURLException e) { 103 e.printStackTrace(); 104 } 105 } 130 106 } 131 107 } -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/transport/ChantiersPonctuelsHandler.java
r28096 r28113 16 16 package org.openstreetmap.josm.plugins.opendata.modules.fr.toulouse.datasets.transport; 17 17 18 import java.nio.charset.Charset;19 18 20 19 public class ChantiersPonctuelsHandler extends ChantiersHandler { … … 22 21 public ChantiersPonctuelsHandler() { 23 22 super(14071, "Chantiers en cours (ponctuel)"); 23 getCsvHandler().setCharset(ISO8859_15); 24 24 } 25 25 … … 28 28 return acceptsCsvKmzTabFilename(filename, "Chantiers_Ponctuels"); 29 29 } 30 31 /* (non-Javadoc)32 * @see org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler#getCsvCharset()33 */34 @Override35 public Charset getCsvCharset() {36 return Charset.forName(ISO8859_15);37 }38 30 } -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/transport/PistesCyclablesHandler.java
r28044 r28113 16 16 package org.openstreetmap.josm.plugins.opendata.modules.fr.toulouse.datasets.transport; 17 17 18 import static org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler.OaQueryType.NODE;19 import static org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler.OaQueryType.WAY;20 import static org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler.OaRecurseType.NODE_RELATION;21 import static org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler.OaRecurseType.RELATION_WAY;22 import static org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler.OaRecurseType.WAY_NODE;23 import static org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler.OaRecurseType.WAY_RELATION;24 25 18 import java.util.Arrays; 26 19 import java.util.Collection; … … 31 24 import org.openstreetmap.josm.data.osm.IPrimitive; 32 25 import org.openstreetmap.josm.data.osm.Way; 26 import org.openstreetmap.josm.plugins.opendata.core.io.OverpassApi; 33 27 import org.openstreetmap.josm.plugins.opendata.modules.fr.toulouse.datasets.ToulouseDataSetHandler; 28 29 import static org.openstreetmap.josm.plugins.opendata.core.io.OverpassApi.OaQueryType.*; 30 import static org.openstreetmap.josm.plugins.opendata.core.io.OverpassApi.OaRecurseType.*; 34 31 35 32 public class PistesCyclablesHandler extends ToulouseDataSetHandler { … … 65 62 @Override 66 63 protected String getOverpassApiQueries(String bbox, String... conditions) { 67 return oaQuery(bbox, NODE, conditions) + "\n" +68 oaRecurse(NODE_RELATION, RELATION_WAY, WAY_NODE) + "\n" +69 oaQuery(bbox, WAY, conditions) + "\n" +70 oaRecurse(WAY_NODE, "nodes") + "\n" +71 oaRecurse(WAY_RELATION);64 return OverpassApi.query(bbox, NODE, conditions) + "\n" + 65 OverpassApi.recurse(NODE_RELATION, RELATION_WAY, WAY_NODE) + "\n" + 66 OverpassApi.query(bbox, WAY, conditions) + "\n" + 67 OverpassApi.recurse(WAY_NODE, "nodes") + "\n" + 68 OverpassApi.recurse(WAY_RELATION); 72 69 } 73 70 -
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/transport/ReseauTisseoHandler.java
r28054 r28113 34 34 setName("Réseau Tisséo (Métro, Bus, Tram)"); 35 35 setCategory(CAT_TRANSPORT); 36 setSkipXsdValidation InZipReading(true);36 getZipHandler().setSkipXsdValidation(true); 37 37 } 38 38 -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/OdConstants.java
r28091 r28113 87 87 public static final String ICON_EMPTY_24 = "empty24.png"; 88 88 89 public static final String ICON_LOOL_48 = "lool48.png"; 90 89 91 /** 90 92 * File extensions. … … 156 158 * Resources 157 159 */ 158 public static final String DICTIONARY_FR = "/org/openstreetmap/josm/plugins/opendata/core/resources/dictionary.fr.csv"; 160 public static final String RESOURCE_PATH = "/org/openstreetmap/josm/plugins/opendata/core/resources/"; 161 public static final String DICTIONARY_FR = RESOURCE_PATH+"dictionary.fr.csv"; 159 162 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/actions/DownloadDataTask.java
r28054 r28113 16 16 package org.openstreetmap.josm.plugins.opendata.core.actions; 17 17 18 import static org.openstreetmap.josm.tools.I18n.tr; 19 18 20 import java.io.File; 21 import java.io.IOException; 19 22 import java.util.concurrent.Future; 20 23 import java.util.regex.Pattern; 24 25 import javax.swing.JOptionPane; 21 26 22 27 import org.openstreetmap.josm.Main; … … 25 30 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 26 31 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 27 import org.openstreetmap.josm.io.AbstractReader;28 32 import org.openstreetmap.josm.plugins.opendata.core.OdConstants; 29 33 import org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler; 30 34 import org.openstreetmap.josm.plugins.opendata.core.datasets.DataSetUpdater; 35 import org.openstreetmap.josm.plugins.opendata.core.gui.AskLicenseAgreementDialog; 31 36 import org.openstreetmap.josm.plugins.opendata.core.io.NetworkReader; 32 37 import org.openstreetmap.josm.plugins.opendata.core.layers.OdDataLayer; 38 import org.openstreetmap.josm.plugins.opendata.core.licenses.License; 33 39 import org.openstreetmap.josm.plugins.opendata.core.modules.Module; 34 40 import org.openstreetmap.josm.plugins.opendata.core.modules.ModuleHandler; … … 37 43 38 44 private AbstractDataSetHandler handler; 45 46 //private static final PdfEditorKit pdfEditorKit = new PdfEditorKit(); 39 47 40 48 @Override … … 45 53 @Override 46 54 public Future<?> loadUrl(boolean newLayer, String url, ProgressMonitor progressMonitor) { 47 Class<? extends AbstractReader> readerClass = null; // TODO 48 downloadTask = new InternDownloadTasK(newLayer, new NetworkReader(url, handler, readerClass), progressMonitor); 55 downloadTask = new InternalDownloadTasK(newLayer, new NetworkReader(url, handler), progressMonitor); 49 56 currentBounds = null; 50 // Extract .osm filename from URL to set the new layer name 51 //Matcher matcher = Pattern.compile("http://.*/(.*\\.osm)").matcher(url); 52 //newLayerName = matcher.matches() ? matcher.group(1) : null; 53 return Main.worker.submit(downloadTask); 57 if (handler == null || !handler.hasLicenseToBeAccepted() || askLicenseAgreement(handler.getLicense())) { 58 return Main.worker.submit(downloadTask); 59 } else { 60 return null; 61 } 54 62 } 55 63 … … 73 81 } 74 82 75 protected class InternDownloadTasK extends DownloadTask { 83 protected class InternalDownloadTasK extends DownloadTask { 76 84 77 public InternDownloadTasK(boolean newLayer, NetworkReader reader, ProgressMonitor progressMonitor) { 85 public InternalDownloadTasK(boolean newLayer, NetworkReader reader, ProgressMonitor progressMonitor) { 78 86 super(newLayer, reader, progressMonitor); 79 87 } … … 99 107 } 100 108 } 109 110 /** 111 * returns true if the user accepts the license, false if they refuse 112 */ 113 protected final boolean askLicenseAgreement(License license) { 114 if (license == null || (license.getURL() == null && license.getSummaryURL() == null)) { 115 return true; 116 } 117 try { 118 return new AskLicenseAgreementDialog(license).showDialog().getValue() == 1; 119 120 } catch (IOException e) { 121 JOptionPane.showMessageDialog(Main.parent, tr("License URL not available: {0}", license.toString())); 122 return false; 123 } 124 } 101 125 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/AbstractDataSetHandler.java
r28091 r28113 19 19 import java.net.MalformedURLException; 20 20 import java.net.URL; 21 import java.nio.charset.Charset;22 21 import java.util.ArrayList; 23 22 import java.util.Collection; … … 25 24 import java.util.regex.Pattern; 26 25 27 import org.geotools.referencing.CRS;28 import org.geotools.referencing.crs.AbstractDerivedCRS;29 import org.geotools.referencing.datum.DefaultEllipsoid;30 import org.geotools.referencing.operation.projection.LambertConformal;31 import org.geotools.referencing.operation.projection.LambertConformal1SP;32 import org.geotools.referencing.operation.projection.LambertConformal2SP;33 import org.geotools.referencing.operation.projection.MapProjection.AbstractProvider;34 import org.opengis.parameter.ParameterDescriptor;35 import org.opengis.parameter.ParameterValueGroup;36 import org.opengis.referencing.FactoryException;37 import org.opengis.referencing.crs.CoordinateReferenceSystem;38 import org.opengis.referencing.crs.GeographicCRS;39 import org.opengis.referencing.datum.GeodeticDatum;40 import org.opengis.referencing.operation.MathTransform;41 import org.openstreetmap.josm.Main;42 26 import org.openstreetmap.josm.data.Bounds; 43 import org.openstreetmap.josm.data.coor.EastNorth;44 27 import org.openstreetmap.josm.data.coor.LatLon; 45 28 import org.openstreetmap.josm.data.osm.DataSet; 46 29 import org.openstreetmap.josm.data.osm.IPrimitive; 47 30 import org.openstreetmap.josm.data.osm.OsmPrimitive; 48 import org.openstreetmap.josm.data.projection.AbstractProjection;49 import org.openstreetmap.josm.data.projection.Ellipsoid;50 import org.openstreetmap.josm.data.projection.Projection;51 import org.openstreetmap.josm.data.projection.Projections;52 import org.openstreetmap.josm.data.projection.proj.LambertConformalConic;53 import org.openstreetmap.josm.data.projection.proj.LambertConformalConic.Parameters;54 import org.openstreetmap.josm.data.projection.proj.LambertConformalConic.Parameters1SP;55 import org.openstreetmap.josm.data.projection.proj.LambertConformalConic.Parameters2SP;56 31 import org.openstreetmap.josm.gui.preferences.SourceEditor.ExtendedSourceEntry; 57 32 import org.openstreetmap.josm.io.AbstractReader; 58 33 import org.openstreetmap.josm.plugins.opendata.core.OdConstants; 34 import org.openstreetmap.josm.plugins.opendata.core.io.archive.DefaultZipHandler; 35 import org.openstreetmap.josm.plugins.opendata.core.io.archive.ZipHandler; 36 import org.openstreetmap.josm.plugins.opendata.core.io.geographic.DefaultShpHandler; 37 import org.openstreetmap.josm.plugins.opendata.core.io.geographic.ShpHandler; 38 import org.openstreetmap.josm.plugins.opendata.core.io.tabular.CsvHandler; 39 import org.openstreetmap.josm.plugins.opendata.core.io.tabular.DefaultCsvHandler; 40 import org.openstreetmap.josm.plugins.opendata.core.io.tabular.SpreadSheetHandler; 41 import org.openstreetmap.josm.plugins.opendata.core.licenses.License; 59 42 import org.openstreetmap.josm.plugins.opendata.core.util.NamesFrUtils; 60 43 import org.openstreetmap.josm.tools.Pair; … … 99 82 private String sourceDate; 100 83 private File associatedFile; 101 private URL dataURL;102 84 103 85 public AbstractDataSetHandler() { 86 setShpHandler(new DefaultShpHandler()); 87 setZipHandler(new DefaultZipHandler()); 88 setCsvHandler(new DefaultCsvHandler()); 104 89 } 105 90 … … 178 163 } 179 164 180 public URL getWikiURL() {return null;} 181 182 public URL getLocalPortalURL() {return null;} 183 184 public URL getNationalPortalURL() {return null;} 185 186 public URL getLicenseURL() {return null;} 187 188 public URL getDataURL() {return dataURL;} 189 190 public final void setDataURL(String url) throws MalformedURLException { 191 this.dataURL = new URL(url); 192 } 193 194 public final void setDataURL(URL url) { 195 this.dataURL = url; 165 // -------------------- License -------------------- 166 167 private License license; 168 169 public License getLicense() { 170 return license; 171 } 172 173 public final void setLicense(License license) { 174 this.license = license; 175 } 176 177 // --------------------- URLs --------------------- 178 179 private URL dataURL; 180 private URL wikiURL; 181 private URL localPortalURL; 182 private URL nationalPortalURL; 183 184 public URL getDataURL() { 185 return dataURL; 186 } 187 188 public final void setDataURL(URL dataURL) { 189 this.dataURL = dataURL; 190 } 191 192 public final void setDataURL(String dataURL) throws MalformedURLException { 193 setDataURL(new URL(dataURL)); 194 } 195 196 public URL getWikiURL() { 197 return wikiURL; 198 } 199 200 public final void setWikiURL(URL wikiURL) { 201 this.wikiURL = wikiURL; 202 } 203 204 public final void setWikiURL(String wikiURL) throws MalformedURLException { 205 setWikiURL(new URL(wikiURL)); 206 } 207 208 public URL getLocalPortalURL() { 209 return localPortalURL; 210 } 211 212 public final void setLocalPortalURL(URL localPortalURL) { 213 this.localPortalURL = localPortalURL; 214 } 215 216 public final void setLocalPortalURL(String localPortalURL) throws MalformedURLException { 217 setLocalPortalURL(new URL(localPortalURL)); 218 } 219 220 public URL getNationalPortalURL() { 221 return nationalPortalURL; 222 } 223 224 public final void setNationalPortalURL(URL nationalPortalURL) { 225 this.nationalPortalURL = nationalPortalURL; 226 } 227 228 public final void setNationalPortalURL(String nationalPortalURL) throws MalformedURLException { 229 setNationalPortalURL(new URL(nationalPortalURL)); 196 230 } 197 231 … … 199 233 200 234 public AbstractReader getReaderForUrl(String url) {return null;} 235 236 private boolean hasLicenseToBeAccepted = true; 237 238 public final boolean hasLicenseToBeAccepted() { 239 return hasLicenseToBeAccepted; 240 } 241 242 public final void setHasLicenseToBeAccepted(boolean hasLicenseToBeAccepted) { 243 this.hasLicenseToBeAccepted = hasLicenseToBeAccepted; 244 } 201 245 202 246 public final DataSetCategory getCategory() { … … 226 270 } 227 271 228 public enum OaQueryType {229 NODE ("node"),230 WAY ("way"),231 RELATION ("relation");232 @Override233 public String toString() { return this.value; }234 private OaQueryType(final String value) { this.value = value; }235 private final String value;236 }237 238 public enum OaRecurseType {239 RELATION_RELATION ("relation-relation"),240 RELATION_BACKWARDS ("relation-backwards"),241 RELATION_WAY ("relation-way"),242 RELATION_NODE ("relation-node"),243 WAY_NODE ("way-node"),244 WAY_RELATION ("way-relation"),245 NODE_RELATION ("node-relation"),246 NODE_WAY ("node-way");247 @Override248 public String toString() { return this.value; }249 private OaRecurseType(final String value) { this.value = value; }250 private final String value;251 }252 272 253 273 protected String getOverpassApiRequest(String bbox) {return null;} 254 255 protected final String oaUnion(String ... queries) {256 String result = "<union>\n";257 for (String query : queries) {258 if (query != null) {259 result += query + "\n";260 }261 }262 result += "</union>";263 return result;264 }265 266 protected final String oaQuery(String bbox, OaQueryType type, String ... conditions) {267 String result = "<query type=\""+type+"\" >\n";268 if (bbox != null) {269 result += "<bbox-query "+bbox+"/>\n";270 }271 for (String condition : conditions) {272 if (condition != null) {273 result += condition + "\n";274 }275 }276 result += "</query>";277 return result;278 }279 280 protected final String oaRecurse(OaRecurseType type, String into) {281 return "<recurse type=\""+type+"\" into=\""+into+"\"/>\n";282 }283 284 protected final String oaRecurse(OaRecurseType ... types) {285 String result = "";286 for (OaRecurseType type : types) {287 result += "<recurse type=\""+type+"\"/>\n";288 }289 return result;290 }291 292 protected final String oaPrint() {293 return "<print mode=\"meta\"/>";294 }295 296 protected final String oaHasKey(String key) {297 return oaHasKey(key, null);298 }299 300 protected final String oaHasKey(String key, String value) {301 return "<has-kv k=\""+key+"\" "+(value != null && !value.isEmpty() ? "v=\""+value+"\"" : "")+" />";302 }303 274 304 275 public boolean equals(IPrimitive p1, IPrimitive p2) {return false;} … … 405 376 } 406 377 407 public boolean handlesSpreadSheetProjection() {408 return false;409 }410 411 public List<Projection> getSpreadSheetProjections() {412 return null;413 }414 415 public LatLon getSpreadSheetCoor(EastNorth en, String[] fields) {416 return null;417 }418 419 public Charset getCsvCharset() {420 return null;421 }422 423 public String getCsvSeparator() {424 return null;425 }426 427 public int getSheetNumber() {428 return -1;429 }430 431 378 public ExtendedSourceEntry getMapPaintStyle() { 432 379 return null; … … 446 393 fileNameWithoutExtension+"."+MAPCSS_EXT); 447 394 } 448 449 public boolean preferMultipolygonToSimpleWay() { 450 return false; 451 } 452 395 453 396 public final void setAssociatedFile(File associatedFile) { 454 397 this.associatedFile = associatedFile; … … 457 400 public final File getAssociatedFile() { 458 401 return this.associatedFile; 459 }460 461 private static final List<Pair<org.opengis.referencing.datum.Ellipsoid, Ellipsoid>>462 ellipsoids = new ArrayList<Pair<org.opengis.referencing.datum.Ellipsoid, Ellipsoid>>();463 static {464 ellipsoids.add(new Pair<org.opengis.referencing.datum.Ellipsoid, Ellipsoid>(DefaultEllipsoid.GRS80, Ellipsoid.GRS80));465 ellipsoids.add(new Pair<org.opengis.referencing.datum.Ellipsoid, Ellipsoid>(DefaultEllipsoid.WGS84, Ellipsoid.WGS84));466 }467 468 private static final Double get(ParameterValueGroup values, ParameterDescriptor desc) {469 return (Double) values.parameter(desc.getName().getCode()).getValue();470 }471 472 private static final boolean equals(Double a, Double b) {473 boolean res = Math.abs(a - b) <= Main.pref.getDouble(PREF_CRS_COMPARISON_TOLERANCE, DEFAULT_CRS_COMPARISON_TOLERANCE);474 if (Main.pref.getBoolean(PREF_CRS_COMPARISON_DEBUG, false)) {475 System.out.println("Comparing "+a+" and "+b+" -> "+res);476 }477 return res;478 }479 480 public MathTransform findMathTransform(CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS, boolean lenient) throws FactoryException {481 if (sourceCRS instanceof GeographicCRS && sourceCRS.getName().getCode().equalsIgnoreCase("GCS_ETRS_1989")) {482 return CRS.findMathTransform(CRS.decode("EPSG:4258"), targetCRS, lenient);483 } else if (sourceCRS instanceof AbstractDerivedCRS && sourceCRS.getName().getCode().equalsIgnoreCase("Lambert_Conformal_Conic")) {484 List<MathTransform> result = new ArrayList<MathTransform>();485 AbstractDerivedCRS crs = (AbstractDerivedCRS) sourceCRS;486 MathTransform transform = crs.getConversionFromBase().getMathTransform();487 if (transform instanceof LambertConformal && crs.getDatum() instanceof GeodeticDatum) {488 LambertConformal lambert = (LambertConformal) transform;489 GeodeticDatum geo = (GeodeticDatum) crs.getDatum();490 for (Projection p : Projections.getProjections()) {491 if (p instanceof AbstractProjection) {492 AbstractProjection ap = (AbstractProjection) p;493 if (ap.getProj() instanceof LambertConformalConic) {494 for (Pair<org.opengis.referencing.datum.Ellipsoid, Ellipsoid> pair : ellipsoids) {495 if (pair.a.equals(geo.getEllipsoid()) && pair.b.equals(ap.getEllipsoid())) {496 boolean ok = true;497 ParameterValueGroup values = lambert.getParameterValues();498 Parameters params = ((LambertConformalConic) ap.getProj()).getParameters();499 500 ok = ok ? equals(get(values, AbstractProvider.LATITUDE_OF_ORIGIN), params.latitudeOrigin) : ok;501 ok = ok ? equals(get(values, AbstractProvider.CENTRAL_MERIDIAN), ap.getCentralMeridian()) : ok;502 ok = ok ? equals(get(values, AbstractProvider.SCALE_FACTOR), ap.getScaleFactor()) : ok;503 ok = ok ? equals(get(values, AbstractProvider.FALSE_EASTING), ap.getFalseEasting()) : ok;504 ok = ok ? equals(get(values, AbstractProvider.FALSE_NORTHING), ap.getFalseNorthing()) : ok;505 506 if (lambert instanceof LambertConformal2SP && params instanceof Parameters2SP) {507 Parameters2SP param = (Parameters2SP) params;508 ok = ok ? equals(Math.min(get(values, AbstractProvider.STANDARD_PARALLEL_1),get(values, AbstractProvider.STANDARD_PARALLEL_2)),509 Math.min(param.standardParallel1, param.standardParallel2)) : ok;510 ok = ok ? equals(Math.max(get(values, AbstractProvider.STANDARD_PARALLEL_1), get(values, AbstractProvider.STANDARD_PARALLEL_2)),511 Math.max(param.standardParallel1, param.standardParallel2)) : ok;512 513 } else if (!(lambert instanceof LambertConformal1SP && params instanceof Parameters1SP)) {514 ok = false;515 }516 517 if (ok) {518 try {519 result.add(CRS.findMathTransform(CRS.decode(p.toCode()), targetCRS, lenient));520 } catch (FactoryException e) {521 System.err.println(e.getMessage());522 }523 }524 }525 }526 }527 }528 }529 }530 if (!result.isEmpty()) {531 if (result.size() > 1) {532 System.err.println("Found multiple projections !"); // TODO: something533 }534 return result.get(0);535 }536 }537 return null;538 }539 540 public boolean checkShpNodeProximity() {541 return false;542 402 } 543 403 … … 555 415 return false; 556 416 } 557 558 private boolean setSkipXsdValidationInZipReading = false; 559 560 public final void setSkipXsdValidationInZipReading(boolean skip) { 561 setSkipXsdValidationInZipReading = skip; 562 } 563 564 public boolean skipXsdValidationInZipReading() { 565 return setSkipXsdValidationInZipReading; 566 } 567 568 public void notifyTempFileWritten(File file) { 569 // Do nothing, let handler overload this method if they need it 417 418 // --------- Shapefile handling --------- 419 420 private ShpHandler shpHandler; 421 422 public final void setShpHandler(ShpHandler handler) { 423 shpHandler = handler; 424 } 425 426 public final ShpHandler getShpHandler() { 427 return shpHandler; 428 } 429 430 // ------------ Zip handling ------------ 431 432 private ZipHandler zipHandler; 433 434 public final void setZipHandler(ZipHandler handler) { 435 zipHandler = handler; 436 } 437 438 public ZipHandler getZipHandler() { 439 return zipHandler; 440 } 441 442 // ------ Spreadsheet handling ---------- 443 444 private SpreadSheetHandler ssHandler; 445 446 public final void setSpreadSheetHandler(SpreadSheetHandler handler) { 447 ssHandler = handler; 448 } 449 450 public final SpreadSheetHandler getSpreadSheetHandler() { 451 return ssHandler; 452 } 453 454 public final void setCsvHandler(CsvHandler handler) { 455 setSpreadSheetHandler(handler); 456 } 457 458 public final CsvHandler getCsvHandler() { 459 if (ssHandler instanceof CsvHandler) { 460 return (CsvHandler) ssHandler; 461 } else { 462 return null; 463 } 570 464 } 571 465 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/SimpleDataSetHandler.java
r28000 r28113 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.core.datasets; 2 3 import static org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler.OaQueryType.NODE;4 import static org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler.OaQueryType.WAY;5 import static org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler.OaQueryType.RELATION;6 import static org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler.OaRecurseType.NODE_RELATION;7 import static org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler.OaRecurseType.RELATION_WAY;8 import static org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler.OaRecurseType.WAY_NODE;9 import static org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler.OaRecurseType.WAY_RELATION;10 17 11 18 import java.util.ArrayList; … … 17 24 import org.openstreetmap.josm.data.osm.Tag; 18 25 import org.openstreetmap.josm.data.projection.Projection; 26 import org.openstreetmap.josm.plugins.opendata.core.io.OverpassApi; 27 28 import static org.openstreetmap.josm.plugins.opendata.core.io.OverpassApi.OaQueryType.*; 29 import static org.openstreetmap.josm.plugins.opendata.core.io.OverpassApi.OaRecurseType.*; 19 30 20 31 public abstract class SimpleDataSetHandler extends AbstractDataSetHandler { … … 155 166 List<String> conditions = new ArrayList<String>(); 156 167 for (Tag tag : this.relevantTags) { 157 conditions.add( oaHasKey(tag.getKey(), tag.getValue()));168 conditions.add(OverpassApi.hasKey(tag.getKey(), tag.getValue())); 158 169 } 159 170 return conditions.toArray(new String[0]); … … 162 173 protected String getOverpassApiQueries(String bbox, String ... conditions) { 163 174 String[] mpconditions = new String[conditions.length+1]; 164 mpconditions[0] = oaHasKey("type", "multipolygon");175 mpconditions[0] = OverpassApi.hasKey("type", "multipolygon"); 165 176 for (int i=0; i<conditions.length; i++) { 166 177 mpconditions[i+1] = conditions[i]; 167 178 } 168 return oaQuery(bbox, NODE, conditions) + "\n" + // Nodes169 oaRecurse(NODE_RELATION, RELATION_WAY, WAY_NODE) + "\n" +170 oaQuery(bbox, WAY, conditions) + "\n" + // Full ways and their full relations171 oaRecurse(WAY_NODE, "nodes") + "\n" +172 oaRecurse(WAY_RELATION, RELATION_WAY, WAY_NODE) + "\n" +173 oaQuery(bbox, RELATION, mpconditions) + "\n" + // Full multipolygons174 oaRecurse(RELATION_WAY, WAY_NODE);179 return OverpassApi.query(bbox, NODE, conditions) + "\n" + // Nodes 180 OverpassApi.recurse(NODE_RELATION, RELATION_WAY, WAY_NODE) + "\n" + 181 OverpassApi.query(bbox, WAY, conditions) + "\n" + // Full ways and their full relations 182 OverpassApi.recurse(WAY_NODE, "nodes") + "\n" + 183 OverpassApi.recurse(WAY_RELATION, RELATION_WAY, WAY_NODE) + "\n" + 184 OverpassApi.query(bbox, RELATION, mpconditions) + "\n" + // Full multipolygons 185 OverpassApi.recurse(RELATION_WAY, WAY_NODE); 175 186 } 176 187 … … 183 194 if (this.relevantUnion) { 184 195 for (Tag tag : this.relevantTags) { 185 result += getOverpassApiQueries(bbox, oaHasKey(tag.getKey(), tag.getValue()));186 } 187 result = oaUnion(result);196 result += getOverpassApiQueries(bbox, OverpassApi.hasKey(tag.getKey(), tag.getValue())); 197 } 198 result = OverpassApi.union(result); 188 199 } else { 189 result = oaUnion(getOverpassApiQueries(bbox, getOverpassApiConditions()));190 } 191 return result + oaPrint();200 result = OverpassApi.union(getOverpassApiQueries(bbox, getOverpassApiConditions())); 201 } 202 return result + OverpassApi.print(); 192 203 } 193 204 -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/be/BelgianDataSetHandler.java
r28000 r28113 18 18 import java.net.MalformedURLException; 19 19 import java.net.URL; 20 import java.util.Arrays;21 import java.util.List;22 20 import java.util.Locale; 23 21 … … 28 26 import org.openstreetmap.josm.data.projection.Projection; 29 27 import org.openstreetmap.josm.plugins.opendata.core.datasets.SimpleDataSetHandler; 28 import org.openstreetmap.josm.plugins.opendata.core.io.tabular.DefaultCsvHandler; 30 29 31 30 public abstract class BelgianDataSetHandler extends SimpleDataSetHandler implements BelgianConstants { … … 45 44 lambert2008 46 45 }; 46 47 protected class InternalCsvHandler extends DefaultCsvHandler { 48 /*@Override 49 public List<Projection> getSpreadSheetProjections() { 50 if (singleProjection != null) { 51 return Arrays.asList(new Projection[]{singleProjection}); 52 } else { 53 return Arrays.asList(projections); 54 } 55 }*/ 56 57 @Override 58 public LatLon getCoor(EastNorth en, String[] fields) { 59 if (singleProjection != null) { 60 return singleProjection.eastNorth2latlon(en); 61 } else { 62 return super.getCoor(en, fields); 63 } 64 } 65 } 47 66 48 67 public BelgianDataSetHandler() { 49 68 init(); 50 69 } 51 70 52 71 public BelgianDataSetHandler(String relevantTag) { 53 72 super(relevantTag); 73 init(); 54 74 } 55 75 56 76 public BelgianDataSetHandler(boolean relevantUnion, String[] relevantTags) { 57 77 super(relevantUnion, relevantTags); 78 init(); 58 79 } 59 80 60 81 public BelgianDataSetHandler(boolean relevantUnion, Tag[] relevantTags) { 61 82 super(relevantUnion, relevantTags); 83 init(); 62 84 } 63 85 86 private void init() { 87 setCsvHandler(new InternalCsvHandler()); 88 } 89 64 90 protected final void setNationalPortalPath(String nationalPortalPathDe, String nationalPortalPathEn, String nationalPortalPathFr, String nationalPortalPathNl) { 65 91 this.nationalPortalPathDe = nationalPortalPathDe; … … 71 97 protected final void setSingleProjection(Projection singleProjection) { 72 98 this.singleProjection = singleProjection; 99 getCsvHandler().setHandlesProjection(singleProjection != null); 73 100 } 74 101 … … 116 143 return ICON_BE_24; 117 144 } 118 119 /* (non-Javadoc)120 * @see org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler#handlesCsvProjection()121 */122 @Override123 public boolean handlesSpreadSheetProjection() {124 return singleProjection != null ? true : super.handlesSpreadSheetProjection();125 }126 127 /* (non-Javadoc)128 * @see org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler#getCsvProjections()129 */130 @Override131 public List<Projection> getSpreadSheetProjections() {132 if (singleProjection != null) {133 return Arrays.asList(new Projection[]{singleProjection});134 } else {135 return Arrays.asList(projections);136 }137 }138 139 /* (non-Javadoc)140 * @see org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler#getCsvCoor(org.openstreetmap.josm.data.coor.EastNorth, java.lang.String[])141 */142 @Override143 public LatLon getSpreadSheetCoor(EastNorth en, String[] fields) {144 if (singleProjection != null) {145 return singleProjection.eastNorth2latlon(en);146 } else {147 return super.getSpreadSheetCoor(en, fields);148 }149 }150 145 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/fr/FrenchDataSetHandler.java
r28050 r28113 21 21 import java.net.URL; 22 22 import java.util.Arrays; 23 import java.util.List;24 23 import java.util.regex.Matcher; 25 24 import java.util.regex.Pattern; 26 25 27 import org.geotools.referencing.CRS;28 import org.opengis.referencing.FactoryException;29 import org.opengis.referencing.crs.CoordinateReferenceSystem;30 import org.opengis.referencing.operation.MathTransform;31 26 import org.openstreetmap.josm.data.coor.EastNorth; 32 27 import org.openstreetmap.josm.data.coor.LatLon; … … 38 33 import org.openstreetmap.josm.data.projection.UTM.Hemisphere; 39 34 import org.openstreetmap.josm.plugins.opendata.core.datasets.SimpleDataSetHandler; 35 import org.openstreetmap.josm.plugins.opendata.core.io.tabular.DefaultCsvHandler; 40 36 41 37 public abstract class FrenchDataSetHandler extends SimpleDataSetHandler implements FrenchConstants { … … 66 62 utm40, // Reunion 67 63 }; 64 65 protected class InternalCsvHandler extends DefaultCsvHandler { 66 /*@Override 67 public List<Projection> getSpreadSheetProjections() { 68 if (singleProjection != null) { 69 return Arrays.asList(new Projection[]{singleProjection}); 70 } else { 71 return Arrays.asList(projections); 72 } 73 }*/ 74 75 @Override 76 public LatLon getCoor(EastNorth en, String[] fields) { 77 if (singleProjection != null) { 78 return singleProjection.eastNorth2latlon(en); 79 } else { 80 return super.getCoor(en, fields); 81 } 82 } 83 84 @Override 85 public boolean handlesProjection() { 86 return singleProjection != null; 87 } 88 } 68 89 69 90 public FrenchDataSetHandler() { 70 91 init(); 71 92 } 72 93 73 94 public FrenchDataSetHandler(String relevantTag) { 74 95 super(relevantTag); 96 init(); 75 97 } 76 98 77 99 public FrenchDataSetHandler(boolean relevantUnion, String[] relevantTags) { 78 100 super(relevantUnion, relevantTags); 101 init(); 79 102 } 80 103 81 104 public FrenchDataSetHandler(boolean relevantUnion, Tag[] relevantTags) { 82 105 super(relevantUnion, relevantTags); 83 } 84 106 init(); 107 } 108 109 private void init() { 110 setShpHandler(new FrenchShpHandler()); 111 setCsvHandler(new InternalCsvHandler()); 112 } 113 85 114 protected final void setNationalPortalPath(String nationalPortalPath) { 86 115 this.nationalPortalPath = nationalPortalPath; … … 120 149 public String getNationalPortalIconName() { 121 150 return ICON_FR_24; 122 }123 124 /* (non-Javadoc)125 * @see org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler#handlesCsvProjection()126 */127 @Override128 public boolean handlesSpreadSheetProjection() {129 return singleProjection != null ? true : super.handlesSpreadSheetProjection();130 }131 132 /* (non-Javadoc)133 * @see org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler#getCsvProjections()134 */135 @Override136 public List<Projection> getSpreadSheetProjections() {137 if (singleProjection != null) {138 return Arrays.asList(new Projection[]{singleProjection});139 } else {140 return Arrays.asList(projections);141 }142 }143 144 /* (non-Javadoc)145 * @see org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler#getCsvCoor(org.openstreetmap.josm.data.coor.EastNorth, java.lang.String[])146 */147 @Override148 public LatLon getSpreadSheetCoor(EastNorth en, String[] fields) {149 if (singleProjection != null) {150 return singleProjection.eastNorth2latlon(en);151 } else {152 return super.getSpreadSheetCoor(en, fields);153 }154 151 } 155 152 … … 258 255 return ""; 259 256 } 260 261 /* (non-Javadoc)262 * @see org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler#findMathTransform(org.opengis.referencing.crs.CoordinateReferenceSystem, org.opengis.referencing.crs.CoordinateReferenceSystem, boolean)263 */264 @Override265 public MathTransform findMathTransform(CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS, boolean lenient)266 throws FactoryException {267 if (sourceCRS.getName().getCode().equalsIgnoreCase("RGM04")) {268 return CRS.findMathTransform(CRS.decode("EPSG:4471"), targetCRS, lenient);269 } else if (sourceCRS.getName().getCode().equalsIgnoreCase("RGFG95_UTM_Zone_22N")) {270 return CRS.findMathTransform(CRS.decode("EPSG:2972"), targetCRS, lenient);271 } else {272 return super.findMathTransform(sourceCRS, targetCRS, lenient);273 }274 }275 257 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/NetworkReader.java
r28088 r28113 50 50 private String filename; 51 51 52 public NetworkReader(String url, AbstractDataSetHandler handler , Class<? extends AbstractReader> readerClass) {52 public NetworkReader(String url, AbstractDataSetHandler handler) { 53 53 CheckParameterUtil.ensureParameterNotNull(url, "url"); 54 //CheckParameterUtil.ensureParameterNotNull(readerClass, "readerClass");55 54 this.url = url; 56 this.readerClass = readerClass;57 55 this.handler = handler; 56 this.readerClass = null; 58 57 } 59 58 -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/archive/ZipReader.java
r28055 r28113 50 50 private final ZipInputStream zis; 51 51 private final AbstractDataSetHandler handler; 52 private final ZipHandler zipHandler; 52 53 53 54 private File file; … … 56 57 this.zis = in instanceof ZipInputStream ? (ZipInputStream) in : new ZipInputStream(in); 57 58 this.handler = handler; 59 this.zipHandler = handler != null ? handler.getZipHandler() : null; 58 60 } 59 61 … … 116 118 fos.close(); 117 119 // Allow handler to perform specific treatments (for example, fix invalid .prj files) 118 if ( handler != null) {119 handler.notifyTempFileWritten(file);120 if (zipHandler != null) { 121 zipHandler.notifyTempFileWritten(file); 120 122 } 121 123 // Set last modification date … … 135 137 } 136 138 // Special treatment for XML files (check supported XSD), unless handler explicitely skip it 137 if (XML_FILE_FILTER.accept(file) && (( handler != null &&handler.skipXsdValidationInZipReading())139 if (XML_FILE_FILTER.accept(file) && ((zipHandler != null && zipHandler.skipXsdValidation()) 138 140 || OdPlugin.getInstance().xmlImporter.acceptFile(file))) { 139 141 candidates.add(file); -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/ShpReader.java
r28044 r28113 84 84 public class ShpReader extends AbstractReader implements OdConstants { 85 85 86 private final AbstractDataSetHandler handler;86 private final ShpHandler handler; 87 87 88 88 private final CoordinateReferenceSystem wgs84; … … 93 93 private MathTransform transform; 94 94 95 public ShpReader( AbstractDataSetHandler handler) throws NoSuchAuthorityCodeException, FactoryException {95 public ShpReader(ShpHandler handler) throws NoSuchAuthorityCodeException, FactoryException { 96 96 this.handler = handler; 97 97 this.wgs84 = CRS.decode("EPSG:4326"); … … 105 105 } 106 106 try { 107 return new ShpReader(handler).parse(file, instance); 107 return new ShpReader(handler != null ? handler.getShpHandler() : null).parse(file, instance); 108 108 } catch (IOException e) { 109 109 throw e; … … 373 373 private Node getNode(Point p, String key) { 374 374 Node n = nodes.get(key); 375 if (n == null && handler != null && handler.check ShpNodeProximity()) {375 if (n == null && handler != null && handler.checkNodeProximity()) { 376 376 LatLon ll = new LatLon(p.getY(), p.getX()); 377 377 for (Node node : nodes.values()) { -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/TabReader.java
r28000 r28113 34 34 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 35 35 import org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler; 36 import org.openstreetmap.josm.plugins.opendata.core.io.tabular.SpreadSheetHandler; 36 37 import org.openstreetmap.josm.plugins.opendata.core.io.tabular.SpreadSheetReader; 37 38 … … 76 77 77 78 private final DbaseFileReader dbfReader; 78 public TabOsmReader( AbstractDataSetHandler handler, TabFiles tabFiles) throws IOException {79 public TabOsmReader(SpreadSheetHandler handler, TabFiles tabFiles) throws IOException { 79 80 super(handler); 80 81 this.dbfReader = new DbaseFileReader(tabFiles, false, datCharset, null); … … 111 112 try { 112 113 File dataFile = getDataFile(file, ".dat"); 113 ds.mergeFrom(new TabOsmReader(handler, new TabFiles(file, dataFile)). 114 ds.mergeFrom(new TabOsmReader(handler != null ? handler.getSpreadSheetHandler() : null, new TabFiles(file, dataFile)). 114 115 doParse(columns.toArray(new String[0]), instance)); 115 116 } catch (IOException e) { -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/tabular/CsvReader.java
r28033 r28113 35 35 private String line; 36 36 37 public CsvReader( AbstractDataSetHandler handler) {37 public CsvReader(CsvHandler handler) { 38 38 this(handler, ";"); 39 39 } 40 40 41 public CsvReader( AbstractDataSetHandler handler, String defaultSep) {41 public CsvReader(CsvHandler handler, String defaultSep) { 42 42 super(handler); 43 this.charset = handler != null && handler.getC svCharset() != null ? handler.getCsvCharset() : Charset.forName(UTF8);44 this.sep = handler != null && handler.get CsvSeparator() != null ? handler.getCsvSeparator() : defaultSep;43 this.charset = handler != null && handler.getCharset() != null ? handler.getCharset() : Charset.forName(UTF8); 44 this.sep = handler != null && handler.getSeparator() != null ? handler.getSeparator() : defaultSep; 45 45 } 46 46 47 47 public static DataSet parseDataSet(InputStream in, AbstractDataSetHandler handler, ProgressMonitor instance) throws IOException { 48 CsvReader csvReader = new CsvReader(handler); 48 CsvHandler csvHandler = null; 49 if (handler.getSpreadSheetHandler() instanceof CsvHandler) { 50 csvHandler = (CsvHandler) handler.getSpreadSheetHandler(); 51 } 52 CsvReader csvReader = new CsvReader(csvHandler); 49 53 try { 50 54 return csvReader.parse(in, instance); 51 55 } catch (IllegalArgumentException e) { 52 if ( handler == null) {56 if (csvHandler == null || (csvHandler.getSeparator() != null && csvHandler.getSeparator().equals(";"))) { 53 57 // If default sep has been used, try comma 54 58 System.out.println(e.getMessage()); 55 CsvReader newReader = new CsvReader( handler, ",");59 CsvReader newReader = new CsvReader(csvHandler, ","); 56 60 newReader.initResources(in, instance); 57 61 newReader.line = csvReader.line; -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/tabular/OdsReader.java
r28000 r28113 38 38 private static final String SEP = "TextP:\\["; 39 39 40 public OdsReader( AbstractDataSetHandler handler) {40 public OdsReader(SpreadSheetHandler handler) { 41 41 super(handler); 42 42 } … … 44 44 public static DataSet parseDataSet(InputStream in, 45 45 AbstractDataSetHandler handler, ProgressMonitor instance) throws IOException { 46 return new OdsReader(handler).parse(in, instance); 46 return new OdsReader(handler != null ? handler.getSpreadSheetHandler() : null).parse(in, instance); 47 47 } 48 48 -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/tabular/SpreadSheetReader.java
r28000 r28113 37 37 import org.openstreetmap.josm.io.AbstractReader; 38 38 import org.openstreetmap.josm.plugins.opendata.core.OdConstants; 39 import org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler;40 39 import org.openstreetmap.josm.plugins.opendata.core.io.ProjectionChooser; 41 40 import org.openstreetmap.josm.plugins.opendata.core.io.ProjectionPatterns; … … 53 52 } 54 53 55 protected final AbstractDataSetHandler handler;56 57 public SpreadSheetReader( AbstractDataSetHandler handler) {54 protected final SpreadSheetHandler handler; 55 56 public SpreadSheetReader(SpreadSheetHandler handler) { 58 57 this.handler = handler; 59 58 } … … 122 121 } 123 122 124 final boolean handlerOK = handler != null && handler.handles SpreadSheetProjection();123 final boolean handlerOK = handler != null && handler.handlesProjection(); 125 124 126 125 if (proj != null) { … … 168 167 } 169 168 if (en.isValid()) { 170 n.setCoor(proj != null && !handlerOK ? proj.eastNorth2latlon(en) : handler.get SpreadSheetCoor(en, fields));169 n.setCoor(proj != null && !handlerOK ? proj.eastNorth2latlon(en) : handler.getCoor(en, fields)); 171 170 } else { 172 171 System.err.println("Warning: Skipping line "+lineNumber+" because no valid coordinates have been found."); -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/tabular/XlsReader.java
r28000 r28113 38 38 private int rowIndex; 39 39 40 public XlsReader( AbstractDataSetHandler handler) {40 public XlsReader(SpreadSheetHandler handler) { 41 41 super(handler); 42 42 } … … 44 44 public static DataSet parseDataSet(InputStream in, 45 45 AbstractDataSetHandler handler, ProgressMonitor instance) throws IOException { 46 return new XlsReader(handler).parse(in, instance); 46 return new XlsReader(handler != null ? handler.getSpreadSheetHandler() : null).parse(in, instance); 47 47 } 48 48 -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/layers/OdDataLayer.java
r28022 r28113 38 38 import org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler; 39 39 import org.openstreetmap.josm.plugins.opendata.core.io.OsmDownloader; 40 import org.openstreetmap.josm.plugins.opendata.core.licenses.License; 40 41 import org.openstreetmap.josm.plugins.opendata.core.util.OdUtils; 41 42 … … 155 156 tr("View National Portal page"), tr("Launch browser to the national portal page of the selected data set"))); 156 157 } 157 if (this.handler.getLicenseURL() != null) { 158 if (this.handler.getLicenseURL().getProtocol().startsWith("http")) { 159 result.add(new OpenLinkAction(this.handler.getLicenseURL(), ICON_AGREEMENT_24, 158 if (this.handler.getLicense() != null) { 159 License lic = this.handler.getLicense(); 160 if (lic.getURL() != null && lic.getURL().getProtocol().startsWith("http")) { 161 result.add(new OpenLinkAction(lic.getURL(), ICON_AGREEMENT_24, 160 162 tr("View License"), tr("Launch browser to the license page of the selected data set"))); 163 } else { 164 // TODO: view embedded licenses 165 } 166 if (lic.getSummaryURL() != null && lic.getSummaryURL().getProtocol().startsWith("http")) { 167 result.add(new OpenLinkAction(lic.getSummaryURL(), ICON_AGREEMENT_24, 168 tr("View License (summary)"), tr("Launch browser to the summary license page of the selected data set"))); 161 169 } else { 162 170 // TODO: view embedded licenses -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/util/OdUtils.java
r28022 r28113 18 18 import java.util.ArrayList; 19 19 import java.util.List; 20 import java.util.Locale; 20 21 21 22 import javax.swing.ImageIcon; 22 23 23 24 import org.apache.commons.lang3.StringUtils; 25 import org.openstreetmap.josm.Main; 24 26 import org.openstreetmap.josm.data.osm.OsmPrimitive; 25 27 import org.openstreetmap.josm.data.osm.Relation; … … 56 58 57 59 public static final ImageIcon getImageIcon(String iconName) { 58 return new ImageProvider(iconName).setAdditionalClassLoaders(ModuleHandler.getResourceClassLoaders()).get(); 60 return getImageIcon(iconName, false); 61 } 62 63 public static final ImageIcon getImageIcon(String iconName, boolean optional) { 64 return new ImageProvider(iconName).setOptional(optional).setAdditionalClassLoaders(ModuleHandler.getResourceClassLoaders()).get(); 65 } 66 67 public static final String getJosmLanguage() { 68 String lang = Main.pref.get("language"); 69 if (lang == null || lang.isEmpty()) { 70 lang = Locale.getDefault().toString(); 71 } 72 return lang; 59 73 } 60 74 }
Note:
See TracChangeset
for help on using the changeset viewer.