Changeset 30563 in osm for applications/editors/josm/plugins/opendata/src
- Timestamp:
- 2014-08-05T13:53:46+02:00 (10 years ago)
- Location:
- applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata
- Files:
-
- 66 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/OdPlugin.java
r30529 r30563 22 22 import org.openstreetmap.josm.plugins.Plugin; 23 23 import org.openstreetmap.josm.plugins.PluginInformation; 24 import org.openstreetmap.josm.plugins.opendata.core.OdConstants;25 24 import org.openstreetmap.josm.plugins.opendata.core.actions.DownloadDataAction; 26 25 import org.openstreetmap.josm.plugins.opendata.core.actions.DownloadDataTask; … … 47 46 import org.openstreetmap.josm.tools.Pair; 48 47 49 public final class OdPlugin extends Plugin implements OdConstants{48 public final class OdPlugin extends Plugin { 50 49 51 50 private static OdPlugin instance; … … 102 101 private void buildMenu() { 103 102 for (Module module : ModuleHandler.moduleList) { 104 Map<DataSetCategory, JMenu> catMenus = new HashMap< DataSetCategory, JMenu>();103 Map<DataSetCategory, JMenu> catMenus = new HashMap<>(); 105 104 JMenu moduleMenu = null; 106 105 for (AbstractDataSetHandler handler: module.getNewlyInstanciatedHandlers()) { -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/OdConstants.java
r30340 r30563 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.opendata.core; 3 4 import static org.openstreetmap.josm.tools.I18n.tr;5 3 6 4 import java.util.ArrayList; 7 5 import java.util.Collection; 8 6 9 import org.openstreetmap.josm.actions.ExtensionFileFilter;10 7 import org.openstreetmap.josm.data.projection.Projections; 11 8 import org.openstreetmap.josm.plugins.opendata.core.io.LambertCC9ZonesProjectionPatterns; 12 9 import org.openstreetmap.josm.plugins.opendata.core.io.ProjectionPatterns; 13 10 14 public interfaceOdConstants {11 public abstract class OdConstants { 15 12 16 13 /** … … 20 17 public static final String ISO8859_15 = "ISO-8859-15"; 21 18 public static final String CP850 = "Cp850"; 19 public static final String CP1251 = "Cp1251"; 22 20 public static final String CP1252 = "Cp1252"; 23 21 public static final String MAC_ROMAN = "MacRoman"; … … 100 98 101 99 /** 102 * File filter used in import/export dialogs.103 */104 public static final ExtensionFileFilter CSV_FILE_FILTER = new ExtensionFileFilter(CSV_EXT, CSV_EXT, tr("CSV files") + " (*."+CSV_EXT+")");105 public static final ExtensionFileFilter XLS_FILE_FILTER = new ExtensionFileFilter(XLS_EXT, XLS_EXT, tr("XLS files") + " (*."+XLS_EXT+")");106 public static final ExtensionFileFilter ODS_FILE_FILTER = new ExtensionFileFilter(ODS_EXT, ODS_EXT, tr("ODS files") + " (*."+ODS_EXT+")");107 public static final ExtensionFileFilter SHP_FILE_FILTER = new ExtensionFileFilter(SHP_EXT, SHP_EXT, tr("Shapefiles") + " (*."+SHP_EXT+")");108 public static final ExtensionFileFilter MIF_TAB_FILE_FILTER = new ExtensionFileFilter(MIF_EXT+","+TAB_EXT, MIF_EXT, tr("MapInfo files") + " (*."+MIF_EXT+",*."+TAB_EXT+")");109 public static final ExtensionFileFilter KML_KMZ_FILE_FILTER = new ExtensionFileFilter(KML_EXT+","+KMZ_EXT, KMZ_EXT, tr("KML/KMZ files") + " (*."+KML_EXT+",*."+KMZ_EXT+")");110 public static final ExtensionFileFilter GML_FILE_FILTER = new ExtensionFileFilter(GML_EXT, GML_EXT, tr("GML files") + " (*."+GML_EXT+")");111 public static final ExtensionFileFilter ZIP_FILE_FILTER = new ExtensionFileFilter(ZIP_EXT, ZIP_EXT, tr("Zip Files") + " (*."+ZIP_EXT+")");112 public static final ExtensionFileFilter SEVENZIP_FILE_FILTER = new ExtensionFileFilter(SEVENZIP_EXT, SEVENZIP_EXT, tr("7Zip Files") + " (*."+SEVENZIP_EXT+")");113 public static final ExtensionFileFilter XML_FILE_FILTER = new ExtensionFileFilter(XML_EXT, XML_EXT, tr("OpenData XML files") + " (*."+XML_EXT+")");114 115 /**116 100 * Coordinates fields 117 101 */ … … 120 104 121 105 // The list of all ProjectionPatterns (filled at each constructor call) 122 public static final Collection<ProjectionPatterns> PROJECTIONS = new ArrayList< ProjectionPatterns>();106 public static final Collection<ProjectionPatterns> PROJECTIONS = new ArrayList<>(); 123 107 124 108 public static final ProjectionPatterns PRJ_WGS84 = new ProjectionPatterns("GPS|WGS84|°décimaux", Projections.getProjectionByCode("EPSG:4326")); -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/actions/DownloadDataTask.java
r30340 r30563 16 16 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 17 17 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 18 import org.openstreetmap.josm.plugins.opendata.core.OdConstants;19 18 import org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler; 20 19 import org.openstreetmap.josm.plugins.opendata.core.datasets.DataSetUpdater; … … 26 25 import org.openstreetmap.josm.plugins.opendata.core.modules.ModuleHandler; 27 26 28 public class DownloadDataTask extends DownloadOsmTask implements OdConstants{27 public class DownloadDataTask extends DownloadOsmTask { 29 28 30 29 private AbstractDataSetHandler handler; -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/actions/OpenLinkAction.java
r30340 r30563 16 16 17 17 @SuppressWarnings("serial") 18 public class OpenLinkAction extends JosmAction implements OdConstants{18 public class OpenLinkAction extends JosmAction { 19 19 20 20 private URL url; … … 37 37 if (index > -1) { 38 38 String s = url.toString().substring(index, index+1); 39 s = url.toString().replace(s, URLEncoder.encode(s, UTF8)); 39 s = url.toString().replace(s, URLEncoder.encode(s, OdConstants.UTF8)); 40 40 URI uri = new URI(s); 41 41 System.out.println("Opening "+uri); -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/actions/OpenPreferencesActions.java
r30340 r30563 13 13 import org.openstreetmap.josm.tools.ImageProvider; 14 14 15 public class OpenPreferencesActions extends JosmAction implements OdConstants{15 public class OpenPreferencesActions extends JosmAction { 16 16 17 17 public OpenPreferencesActions() { 18 18 super(false); 19 19 putValue(NAME, tr("OpenData preferences")); 20 putValue(SMALL_ICON, ImageProvider.get("dialogs", ICON_CORE_24)); 20 putValue(SMALL_ICON, ImageProvider.get("dialogs", OdConstants.ICON_CORE_24)); 21 21 putValue("toolbar", "opendata_open_preferences"); 22 22 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/actions/ViewLicenseAction.java
r30340 r30563 14 14 import org.openstreetmap.josm.tools.CheckParameterUtil; 15 15 16 public class ViewLicenseAction extends JosmAction implements OdConstants{16 public class ViewLicenseAction extends JosmAction { 17 17 18 18 private final License license; … … 22 22 CheckParameterUtil.ensureParameterNotNull(license, "license"); 23 23 this.license = license; 24 putValue(Action.SMALL_ICON, OdUtils.getImageIcon(ICON_AGREEMENT_24)); 24 putValue(Action.SMALL_ICON, OdUtils.getImageIcon(OdConstants.ICON_AGREEMENT_24)); 25 25 } 26 26 -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/AbstractDataSetHandler.java
r30340 r30563 35 35 import org.openstreetmap.josm.tools.Pair; 36 36 37 public abstract class AbstractDataSetHandler implements OdConstants{37 public abstract class AbstractDataSetHandler { 38 38 39 39 public abstract boolean acceptsFilename(String filename); … … 98 98 99 99 protected final boolean acceptsCsvFilename(String filename, String ... expected) { 100 return acceptsFilename(filename, expected, CSV_EXT); 100 return acceptsFilename(filename, expected, OdConstants.CSV_EXT); 101 101 } 102 102 103 103 protected final boolean acceptsXlsFilename(String filename, String ... expected) { 104 return acceptsFilename(filename, expected, XLS_EXT); 104 return acceptsFilename(filename, expected, OdConstants.XLS_EXT); 105 105 } 106 106 107 107 protected final boolean acceptsOdsFilename(String filename, String ... expected) { 108 return acceptsFilename(filename, expected, ODS_EXT); 108 return acceptsFilename(filename, expected, OdConstants.ODS_EXT); 109 109 } 110 110 111 111 protected final boolean acceptsShpFilename(String filename, String ... expected) { 112 return acceptsFilename(filename, expected, SHP_EXT); 112 return acceptsFilename(filename, expected, OdConstants.SHP_EXT); 113 113 } 114 114 115 115 protected final boolean acceptsMifFilename(String filename, String ... expected) { 116 return acceptsFilename(filename, expected, MIF_EXT); 116 return acceptsFilename(filename, expected, OdConstants.MIF_EXT); 117 117 } 118 118 119 119 protected final boolean acceptsMifTabFilename(String filename, String ... expected) { 120 return acceptsFilename(filename, expected, MIF_EXT, TAB_EXT); 120 return acceptsFilename(filename, expected, OdConstants.MIF_EXT, OdConstants.TAB_EXT); 121 121 } 122 122 123 123 protected final boolean acceptsShpMifFilename(String filename, String ... expected) { 124 return acceptsFilename(filename, expected, SHP_EXT, MIF_EXT); 124 return acceptsFilename(filename, expected, OdConstants.SHP_EXT, OdConstants.MIF_EXT); 125 125 } 126 126 127 127 protected final boolean acceptsKmlFilename(String filename, String ... expected) { 128 return acceptsFilename(filename, expected, KML_EXT); 128 return acceptsFilename(filename, expected, OdConstants.KML_EXT); 129 129 } 130 130 131 131 protected final boolean acceptsKmzFilename(String filename, String ... expected) { 132 return acceptsFilename(filename, expected, KMZ_EXT); 132 return acceptsFilename(filename, expected, OdConstants.KMZ_EXT); 133 133 } 134 134 135 135 protected final boolean acceptsKmzShpFilename(String filename, String ... expected) { 136 return acceptsFilename(filename, expected, KMZ_EXT, SHP_EXT); 136 return acceptsFilename(filename, expected, OdConstants.KMZ_EXT, OdConstants.SHP_EXT); 137 137 } 138 138 139 139 protected final boolean acceptsKmzTabFilename(String filename, String ... expected) { 140 return acceptsFilename(filename, expected, KMZ_EXT, TAB_EXT); 140 return acceptsFilename(filename, expected, OdConstants.KMZ_EXT, OdConstants.TAB_EXT); 141 141 } 142 142 143 143 protected final boolean acceptsZipFilename(String filename, String ... expected) { 144 return acceptsFilename(filename, expected, ZIP_EXT); 144 return acceptsFilename(filename, expected, OdConstants.ZIP_EXT); 145 145 } 146 146 147 147 protected final boolean accepts7ZipFilename(String filename, String ... expected) { 148 return acceptsFilename(filename, expected, SEVENZIP_EXT); 148 return acceptsFilename(filename, expected, OdConstants.SEVENZIP_EXT); 149 149 } 150 150 151 151 protected final boolean acceptsCsvKmzFilename(String filename, String ... expected) { 152 return acceptsFilename(filename, expected, CSV_EXT, KMZ_EXT); 152 return acceptsFilename(filename, expected, OdConstants.CSV_EXT, OdConstants.KMZ_EXT); 153 153 } 154 154 155 155 protected final boolean acceptsCsvKmzTabFilename(String filename, String ... expected) { 156 return acceptsFilename(filename, expected, CSV_EXT, KMZ_EXT, TAB_EXT); 156 return acceptsFilename(filename, expected, OdConstants.CSV_EXT, OdConstants.KMZ_EXT, OdConstants.TAB_EXT); 157 157 } 158 158 159 159 protected final boolean acceptsCsvXlsFilename(String filename, String ... expected) { 160 return acceptsFilename(filename, expected, CSV_EXT, XLS_EXT); 160 return acceptsFilename(filename, expected, OdConstants.CSV_EXT, OdConstants.XLS_EXT); 161 161 } 162 162 … … 276 276 277 277 public final Collection<IPrimitive> extractRelevantPrimitives(DataSet ds) { 278 ArrayList<IPrimitive> result = new ArrayList< IPrimitive>();278 ArrayList<IPrimitive> result = new ArrayList<>(); 279 279 for (IPrimitive p : ds.allPrimitives()) { 280 280 if (isRelevant(p)) { … … 363 363 364 364 public String getLocalPortalIconName() { 365 return ICON_CORE_24; 365 return OdConstants.ICON_CORE_24; 366 366 } 367 367 368 368 public String getNationalPortalIconName() { 369 return ICON_CORE_24; 369 return OdConstants.ICON_CORE_24; 370 370 } 371 371 372 372 public String getDataLayerIconName() { 373 return ICON_CORE_16; 373 return OdConstants.ICON_CORE_16; 374 374 } 375 375 … … 387 387 388 388 protected final ExtendedSourceEntry getMapPaintStyle(String displayName, String fileNameWithoutExtension) { 389 return new ExtendedSourceEntry(displayName, PROTO_RSRC+//"/"+ 389 return new ExtendedSourceEntry(displayName, OdConstants.PROTO_RSRC+//"/"+ 390 390 this.getClass().getPackage().getName().replace(".", "/")+"/"+ 391 fileNameWithoutExtension+"."+MAPCSS_EXT); 391 fileNameWithoutExtension+"."+OdConstants.MAPCSS_EXT); 392 392 } 393 393 … … 490 490 // Tools 491 491 492 private final Collection<JosmAction> tools = new ArrayList< JosmAction>();492 private final Collection<JosmAction> tools = new ArrayList<>(); 493 493 494 494 public final Collection<JosmAction> getTools() { -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/DataSetUpdater.java
r30340 r30563 14 14 import org.openstreetmap.josm.plugins.opendata.core.OdConstants; 15 15 16 public abstract class DataSetUpdater implements OdConstants{16 public abstract class DataSetUpdater { 17 17 18 18 public static final void updateDataSet(DataSet dataSet, AbstractDataSetHandler handler, File associatedFile) { … … 25 25 } 26 26 } 27 if (!Main.pref.getBoolean(PREF_RAWDATA)) { 27 if (!Main.pref.getBoolean(OdConstants.PREF_RAWDATA)) { 28 28 handler.updateDataSet(dataSet); 29 29 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/SimpleDataSetHandler.java
r30340 r30563 19 19 import org.openstreetmap.josm.data.projection.Projection; 20 20 import org.openstreetmap.josm.gui.mappaint.MapPaintStyles; 21 import org.openstreetmap.josm.plugins.opendata.core.OdConstants; 21 22 import org.openstreetmap.josm.plugins.opendata.core.io.OverpassApi; 22 23 23 24 public abstract class SimpleDataSetHandler extends AbstractDataSetHandler { 24 25 25 protected static final Projection wgs84 = PRJ_WGS84.getProjection(); 26 27 private final List<Tag> relevantTags = new ArrayList< Tag>();28 private final List<Tag> forbiddenTags = new ArrayList< Tag>();26 protected static final Projection wgs84 = OdConstants.PRJ_WGS84.getProjection(); 27 28 private final List<Tag> relevantTags = new ArrayList<>(); 29 private final List<Tag> forbiddenTags = new ArrayList<>(); 29 30 30 31 private final boolean relevantUnion; … … 152 153 153 154 protected final String[] getOverpassApiConditions() { 154 List<String> conditions = new ArrayList< String>();155 List<String> conditions = new ArrayList<>(); 155 156 for (Tag tag : this.relevantTags) { 156 157 conditions.add(OverpassApi.hasKey(tag.getKey(), tag.getValue())); -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/at/AustrianConstants.java
r30340 r30563 2 2 package org.openstreetmap.josm.plugins.opendata.core.datasets.at; 3 3 4 import org.openstreetmap.josm.plugins.opendata.core.OdConstants;5 4 6 public interface AustrianConstants extends OdConstants{5 public interface AustrianConstants { 7 6 8 7 /** -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/au/AustralianConstants.java
r30340 r30563 2 2 package org.openstreetmap.josm.plugins.opendata.core.datasets.au; 3 3 4 import org.openstreetmap.josm.plugins.opendata.core.OdConstants;5 4 6 public interface AustralianConstants extends OdConstants{5 public interface AustralianConstants { 7 6 8 7 /** -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/be/BelgianConstants.java
r30340 r30563 4 4 import org.openstreetmap.josm.plugins.opendata.core.OdConstants; 5 5 6 public interface BelgianConstants extends OdConstants{6 public interface BelgianConstants { 7 7 8 8 /** 9 9 * Portal 10 10 */ 11 public static final String BELGIAN_PORTAL = "http://data.gov.be/"+PATTERN_LANG+"/dataset/"; 11 public static final String BELGIAN_PORTAL = "http://data.gov.be/"+OdConstants.PATTERN_LANG+"/dataset/"; 12 12 13 13 /** -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/be/BelgianDataSetHandler.java
r30340 r30563 11 11 import org.openstreetmap.josm.data.osm.Tag; 12 12 import org.openstreetmap.josm.data.projection.Projection; 13 import org.openstreetmap.josm.plugins.opendata.core.OdConstants; 13 14 import org.openstreetmap.josm.plugins.opendata.core.datasets.SimpleDataSetHandler; 14 15 import org.openstreetmap.josm.plugins.opendata.core.io.tabular.DefaultCsvHandler; … … 23 24 private String nationalPortalPathNl; 24 25 25 protected static final Projection lambert1972 = PRJ_LAMBERT_1972.getProjection(); 26 protected static final Projection lambert2008 = PRJ_LAMBERT_2008.getProjection(); 26 protected static final Projection lambert1972 = OdConstants.PRJ_LAMBERT_1972.getProjection(); 27 protected static final Projection lambert2008 = OdConstants.PRJ_LAMBERT_2008.getProjection(); 27 28 28 29 protected static final Projection[] projections = new Projection[]{ … … 104 105 nationalPortalPath = nationalPortalPathEn; 105 106 } 106 return new URL(BELGIAN_PORTAL.replace(PATTERN_LANG, lang.substring(0, 2))+nationalPortalPath);//FIXME 107 return new URL(BELGIAN_PORTAL.replace(OdConstants.PATTERN_LANG, lang.substring(0, 2))+nationalPortalPath);//FIXME 107 108 } catch (MalformedURLException e) { 108 109 e.printStackTrace(); -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/ca/CanadianConstants.java
r30340 r30563 2 2 package org.openstreetmap.josm.plugins.opendata.core.datasets.ca; 3 3 4 import org.openstreetmap.josm.plugins.opendata.core.OdConstants;5 4 6 public interface CanadianConstants extends OdConstants{5 public interface CanadianConstants { 7 6 8 7 /** -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/cl/ChileanConstants.java
r30340 r30563 2 2 package org.openstreetmap.josm.plugins.opendata.core.datasets.cl; 3 3 4 import org.openstreetmap.josm.plugins.opendata.core.OdConstants;5 4 6 public interface ChileanConstants extends OdConstants{5 public interface ChileanConstants { 7 6 8 7 /** -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/es/SpanishConstants.java
r30340 r30563 2 2 package org.openstreetmap.josm.plugins.opendata.core.datasets.es; 3 3 4 import org.openstreetmap.josm.plugins.opendata.core.OdConstants;5 4 6 public interface SpanishConstants extends OdConstants{5 public interface SpanishConstants { 7 6 8 7 /** -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/fr/FrenchConstants.java
r30340 r30563 2 2 package org.openstreetmap.josm.plugins.opendata.core.datasets.fr; 3 3 4 import org.openstreetmap.josm.plugins.opendata.core.OdConstants;5 4 6 public interface FrenchConstants extends OdConstants{5 public interface FrenchConstants { 7 6 8 7 /** -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/fr/FrenchDataSetHandler.java
r30340 r30563 15 15 import org.openstreetmap.josm.data.projection.Projection; 16 16 import org.openstreetmap.josm.data.projection.Projections; 17 import org.openstreetmap.josm.plugins.opendata.core.OdConstants; 17 18 import org.openstreetmap.josm.plugins.opendata.core.datasets.SimpleDataSetHandler; 18 19 import org.openstreetmap.josm.plugins.opendata.core.io.tabular.DefaultCsvHandler; … … 24 25 private String nationalPortalPath; 25 26 26 protected static final Projection lambert93 = PRJ_LAMBERT_93.getProjection(); // France metropolitaine 27 protected static final Projection lambert93 = OdConstants.PRJ_LAMBERT_93.getProjection(); // France metropolitaine 27 28 protected static final Projection utm20 = Projections.getProjectionByCode("EPSG:32620"); // UTM 20 N - Guadeloupe, Martinique 28 29 protected static final Projection utm22 = Projections.getProjectionByCode("EPSG:32622"); // UTM 22 N - Guyane -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/it/ItalianConstants.java
r30340 r30563 2 2 package org.openstreetmap.josm.plugins.opendata.core.datasets.it; 3 3 4 import org.openstreetmap.josm.plugins.opendata.core.OdConstants;5 4 6 public interface ItalianConstants extends OdConstants{5 public interface ItalianConstants { 7 6 8 7 /** -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/ke/KenyanConstants.java
r30340 r30563 2 2 package org.openstreetmap.josm.plugins.opendata.core.datasets.ke; 3 3 4 import org.openstreetmap.josm.plugins.opendata.core.OdConstants;5 4 6 public interface KenyanConstants extends OdConstants{5 public interface KenyanConstants { 7 6 8 7 /** -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/nl/DutchConstants.java
r30340 r30563 2 2 package org.openstreetmap.josm.plugins.opendata.core.datasets.nl; 3 3 4 import org.openstreetmap.josm.plugins.opendata.core.OdConstants;5 4 6 public interface DutchConstants extends OdConstants{5 public interface DutchConstants { 7 6 8 7 /** -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/no/NorwegianConstants.java
r30340 r30563 2 2 package org.openstreetmap.josm.plugins.opendata.core.datasets.no; 3 3 4 import org.openstreetmap.josm.plugins.opendata.core.OdConstants;5 4 6 public interface NorwegianConstants extends OdConstants{5 public interface NorwegianConstants { 7 6 8 7 /** -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/nz/NewZealanderConstants.java
r30340 r30563 2 2 package org.openstreetmap.josm.plugins.opendata.core.datasets.nz; 3 3 4 import org.openstreetmap.josm.plugins.opendata.core.OdConstants;5 4 6 public interface NewZealanderConstants extends OdConstants{5 public interface NewZealanderConstants { 7 6 8 7 /** -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/pt/PortugueseConstants.java
r30340 r30563 2 2 package org.openstreetmap.josm.plugins.opendata.core.datasets.pt; 3 3 4 import org.openstreetmap.josm.plugins.opendata.core.OdConstants;5 4 6 public interface PortugueseConstants extends OdConstants{5 public interface PortugueseConstants { 7 6 8 7 /** -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/uk/BritishConstants.java
r30340 r30563 2 2 package org.openstreetmap.josm.plugins.opendata.core.datasets.uk; 3 3 4 import org.openstreetmap.josm.plugins.opendata.core.OdConstants;5 4 6 public interface BritishConstants extends OdConstants{5 public interface BritishConstants { 7 6 8 7 /** -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/us/AmericanConstants.java
r30340 r30563 2 2 package org.openstreetmap.josm.plugins.opendata.core.datasets.us; 3 3 4 import org.openstreetmap.josm.plugins.opendata.core.OdConstants;5 4 6 public interface AmericanConstants extends OdConstants{5 public interface AmericanConstants { 7 6 8 7 /** -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/gui/DialogPrompter.java
r30340 r30563 37 37 } 38 38 39 public final DialogPrompter promptInEdt() { 39 public final DialogPrompter<T> promptInEdt() { 40 40 if (SwingUtilities.isEventDispatchThread()) { 41 41 run(); -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/gui/ModulePreference.java
r30532 r30563 56 56 import org.openstreetmap.josm.tools.ImageProvider; 57 57 58 public class ModulePreference implements SubPreferenceSetting , OdConstants{58 public class ModulePreference implements SubPreferenceSetting { 59 59 /*public static class Factory implements PreferenceSettingFactory { 60 60 public PreferenceSetting createPreferenceSetting() { … … 221 221 LinkedList<String> l = new LinkedList<>(model.getSelectedModuleNames()); 222 222 Collections.sort(l); 223 Main.pref.putCollection(PREF_MODULES, l); 223 Main.pref.putCollection(OdConstants.PREF_MODULES, l); 224 224 return true; 225 225 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/gui/ModulePreferencesModel.java
r30532 r30563 20 20 import org.openstreetmap.josm.plugins.opendata.core.modules.ModuleInformation; 21 21 22 public class ModulePreferencesModel extends Observable implements OdConstants{22 public class ModulePreferencesModel extends Observable { 23 23 private final ArrayList<ModuleInformation> availableModules = new ArrayList<>(); 24 24 private final ArrayList<ModuleInformation> displayedModules = new ArrayList<>(); … … 29 29 30 30 protected Collection<String> getModules(Collection<String> def) { 31 return Main.pref.getCollection(PREF_MODULES, def); 31 return Main.pref.getCollection(OdConstants.PREF_MODULES, def); 32 32 } 33 33 -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/gui/OdDialog.java
r30340 r30563 32 32 33 33 @SuppressWarnings("serial") 34 public class OdDialog extends ToggleDialog implements OdConstants,LayerChangeListener, EditLayerChangeListener {34 public class OdDialog extends ToggleDialog implements LayerChangeListener, EditLayerChangeListener { 35 35 36 private final SideButton selectButton; 36 //private final SideButton selectButton; 37 37 private final SideButton downloadButton; 38 38 private final SideButton diffButton; … … 91 91 92 92 public OdDialog() { 93 super("OpenData", ICON_CORE_24, tr("Open the OpenData window."), 93 super("OpenData", OdConstants.ICON_CORE_24, tr("Open the OpenData window."), 94 94 Shortcut.registerShortcut("subwindow:opendata", tr("Toggle: {0}", "OpenData"), 95 95 KeyEvent.VK_A, Shortcut.ALT_CTRL_SHIFT), 150, false, OdPreferenceSetting.class); 96 96 97 97 this.buttons = Arrays.asList(new SideButton[] { 98 selectButton = new SideButton(new SelectAction()), 98 /*selectButton =*/ new SideButton(new SelectAction()), 99 99 downloadButton = new SideButton(new DownloadAction()), 100 100 diffButton = new SideButton(new DiffAction()), -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/gui/OdPreferenceSetting.java
r30340 r30563 30 30 import org.openstreetmap.josm.tools.GBC; 31 31 32 public class OdPreferenceSetting extends DefaultTabPreferenceSetting implements OdConstants{32 public class OdPreferenceSetting extends DefaultTabPreferenceSetting { 33 33 34 34 //private final JRadioButton rbCC43 = new JRadioButton(tr("CC43")); … … 46 46 47 47 public OdPreferenceSetting() { 48 super(ICON_CORE_48, tr("OpenData Preferences"), 48 super(OdConstants.ICON_CORE_48, tr("OpenData Preferences"), 49 49 tr("A special handler for various Open Data portals<br/><br/>"+ 50 50 "Please read the Terms and Conditions of Use of each portal<br/>"+ … … 58 58 */ 59 59 public static final Collection<String> getModuleSites() { 60 return Main.pref.getCollection(PREF_MODULES_SITES, Arrays.asList(DEFAULT_MODULE_SITES)); 60 return Main.pref.getCollection(OdConstants.PREF_MODULES_SITES, Arrays.asList(OdConstants.DEFAULT_MODULE_SITES)); 61 61 } 62 62 … … 67 67 */ 68 68 public static void setModuleSites(List<String> sites) { 69 Main.pref.putCollection(PREF_MODULES_SITES, sites); 69 Main.pref.putCollection(OdConstants.PREF_MODULES_SITES, sites); 70 70 } 71 71 … … 87 87 88 88 // option to enable raw data 89 rawData.setSelected(Main.pref.getBoolean(PREF_RAWDATA, DEFAULT_RAWDATA)); 89 rawData.setSelected(Main.pref.getBoolean(OdConstants.PREF_RAWDATA, OdConstants.DEFAULT_RAWDATA)); 90 90 rawData.setToolTipText(tr("Import only raw data (i.e. do not add/delete tags or replace them by standard OSM tags)")); 91 91 general.add(rawData, GBC.eop().insets(0, 0, 0, 0)); … … 112 112 // option to set the Overpass API server 113 113 JLabel jLabelOapi = new JLabel(tr("Overpass API server:")); 114 oapi.setText(Main.pref.get(PREF_OAPI, DEFAULT_OAPI)); 114 oapi.setText(Main.pref.get(OdConstants.PREF_OAPI, OdConstants.DEFAULT_OAPI)); 115 115 oapi.setToolTipText(tr("Overpass API server used to download OSM data")); 116 116 general.add(jLabelOapi, GBC.std().insets(0, 5, 10, 0)); … … 119 119 // option to set the XAPI server 120 120 JLabel jLabelXapi = new JLabel(tr("XAPI server:")); 121 xapi.setText(Main.pref.get(PREF_XAPI, DEFAULT_XAPI)); 121 xapi.setText(Main.pref.get(OdConstants.PREF_XAPI, OdConstants.DEFAULT_XAPI)); 122 122 xapi.setToolTipText(tr("XAPI server used to download OSM data when Overpass API is not available")); 123 123 general.add(jLabelXapi, GBC.std().insets(0, 5, 10, 0)); … … 134 134 boolean result = modulePref.ok(); 135 135 //Main.pref.put(PREF_COORDINATES, rbWGS84.isSelected() ? VALUE_WGS84 : VALUE_CC9ZONES); 136 Main.pref.put(PREF_OAPI, oapi.getText()); 137 Main.pref.put(PREF_XAPI, xapi.getText()); 138 Main.pref.put(PREF_RAWDATA, rawData.isSelected()); 136 Main.pref.put(OdConstants.PREF_OAPI, oapi.getText()); 137 Main.pref.put(OdConstants.PREF_XAPI, xapi.getText()); 138 Main.pref.put(OdConstants.PREF_RAWDATA, rawData.isSelected()); 139 139 140 140 // create a task for downloading modules if the user has activated, yet not downloaded, -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/AbstractImporter.java
r30340 r30563 11 11 import org.openstreetmap.josm.io.IllegalDataException; 12 12 import org.openstreetmap.josm.io.OsmImporter; 13 import org.openstreetmap.josm.plugins.opendata.core.OdConstants;14 13 import org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler; 15 14 import org.openstreetmap.josm.plugins.opendata.core.datasets.DataSetUpdater; … … 18 17 import org.openstreetmap.josm.plugins.opendata.core.modules.ModuleHandler; 19 18 20 public abstract class AbstractImporter extends OsmImporter implements OdConstants{19 public abstract class AbstractImporter extends OsmImporter { 21 20 22 21 protected AbstractDataSetHandler handler; -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/NetworkReader.java
r30532 r30563 32 32 import org.openstreetmap.josm.tools.CheckParameterUtil; 33 33 34 public class NetworkReader extends OsmServerReader implements OdConstants{34 public class NetworkReader extends OsmServerReader { 35 35 36 36 private final String url; … … 47 47 public static final Map<String, Class<? extends AbstractReader>> FILE_READERS = new HashMap<>(); 48 48 static { 49 FILE_READERS.put(CSV_EXT, CsvReader.class); 50 FILE_READERS.put(KML_EXT, KmlReader.class); 51 FILE_READERS.put(KMZ_EXT, KmzReader.class); 52 FILE_READERS.put(GML_EXT, GmlReader.class); 53 FILE_READERS.put(XLS_EXT, XlsReader.class); 54 FILE_READERS.put(ODS_EXT, OdsReader.class); 55 FILE_READERS.put(SHP_EXT, ShpReader.class); 56 FILE_READERS.put(MIF_EXT, MifReader.class); 57 FILE_READERS.put(TAB_EXT, TabReader.class); 49 FILE_READERS.put(OdConstants.CSV_EXT, CsvReader.class); 50 FILE_READERS.put(OdConstants.KML_EXT, KmlReader.class); 51 FILE_READERS.put(OdConstants.KMZ_EXT, KmzReader.class); 52 FILE_READERS.put(OdConstants.GML_EXT, GmlReader.class); 53 FILE_READERS.put(OdConstants.XLS_EXT, XlsReader.class); 54 FILE_READERS.put(OdConstants.ODS_EXT, OdsReader.class); 55 FILE_READERS.put(OdConstants.SHP_EXT, ShpReader.class); 56 FILE_READERS.put(OdConstants.MIF_EXT, MifReader.class); 57 FILE_READERS.put(OdConstants.TAB_EXT, TabReader.class); 58 58 } 59 59 60 60 public static final Map<String, Class<? extends AbstractReader>> FILE_AND_ARCHIVE_READERS = new HashMap<>(FILE_READERS); 61 61 static { 62 FILE_AND_ARCHIVE_READERS.put(ZIP_EXT, ZipReader.class); 63 FILE_AND_ARCHIVE_READERS.put(SEVENZIP_EXT, SevenZipReader.class); 62 FILE_AND_ARCHIVE_READERS.put(OdConstants.ZIP_EXT, ZipReader.class); 63 FILE_AND_ARCHIVE_READERS.put(OdConstants.SEVENZIP_EXT, SevenZipReader.class); 64 64 } 65 65 -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/OsmDownloader.java
r30340 r30563 9 9 import org.openstreetmap.josm.plugins.opendata.core.OdConstants; 10 10 11 public class OsmDownloader implements OdConstants{11 public class OsmDownloader { 12 12 13 13 public static final void downloadOapi(String oapiReq) { 14 14 if (oapiReq != null) { 15 15 try { 16 String oapiServer = Main.pref.get(PREF_OAPI, DEFAULT_OAPI); 16 String oapiServer = Main.pref.get(OdConstants.PREF_OAPI, OdConstants.DEFAULT_OAPI); 17 17 System.out.println(oapiReq); 18 String oapiReqEnc = URLEncoder.encode(oapiReq, UTF8); 18 String oapiReqEnc = URLEncoder.encode(oapiReq, OdConstants.UTF8); 19 19 Main.main.menu.openLocation.openUrl(false, oapiServer+"data="+oapiReqEnc); 20 20 } catch (UnsupportedEncodingException e) { … … 26 26 public static final void downloadXapi(Collection<String> xapiReqs) { 27 27 if (xapiReqs != null) { 28 String xapiServer = Main.pref.get(PREF_XAPI, DEFAULT_XAPI); 28 String xapiServer = Main.pref.get(OdConstants.PREF_XAPI, OdConstants.DEFAULT_XAPI); 29 29 for (String xapiReq : xapiReqs) { 30 30 Main.main.menu.openLocation.openUrl(false, xapiServer+xapiReq); -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/ProjectionPatterns.java
r30340 r30563 7 7 import org.openstreetmap.josm.plugins.opendata.core.OdConstants; 8 8 9 public class ProjectionPatterns implements OdConstants{9 public class ProjectionPatterns { 10 10 11 11 private final Pattern xPattern; … … 17 17 this.yPattern = yPattern; 18 18 this.projection = projection; 19 PROJECTIONS.add(this); 19 OdConstants.PROJECTIONS.add(this); 20 20 } 21 21 … … 25 25 26 26 public ProjectionPatterns(String proj, Projection projection) { 27 this(getCoordinatePattern(X_STRING, proj), getCoordinatePattern(Y_STRING, proj), projection); 27 this(getCoordinatePattern(OdConstants.X_STRING, proj), getCoordinatePattern(OdConstants.Y_STRING, proj), projection); 28 28 } 29 29 30 30 public ProjectionPatterns(String proj) { 31 this(getCoordinatePattern(X_STRING, proj), getCoordinatePattern(Y_STRING, proj), null); 31 this(getCoordinatePattern(OdConstants.X_STRING, proj), getCoordinatePattern(OdConstants.Y_STRING, proj), null); 32 32 } 33 33 -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/XmlImporter.java
r30340 r30563 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.opendata.core.io; 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 3 5 4 6 import java.io.File; … … 8 10 import javax.xml.bind.JAXBException; 9 11 12 import org.openstreetmap.josm.actions.ExtensionFileFilter; 10 13 import org.openstreetmap.josm.data.osm.DataSet; 11 14 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 12 15 import org.openstreetmap.josm.io.IllegalDataException; 16 import org.openstreetmap.josm.plugins.opendata.core.OdConstants; 13 17 14 18 public class XmlImporter extends AbstractImporter { 19 20 public static final ExtensionFileFilter XML_FILE_FILTER = new ExtensionFileFilter( 21 OdConstants.XML_EXT, OdConstants.XML_EXT, tr("OpenData XML files") + " (*."+OdConstants.XML_EXT+")"); 15 22 16 23 public XmlImporter() { -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/archive/ArchiveReader.java
r30532 r30563 23 23 import org.openstreetmap.josm.plugins.opendata.core.io.NeptuneReader; 24 24 import org.openstreetmap.josm.plugins.opendata.core.io.NetworkReader; 25 import org.openstreetmap.josm.plugins.opendata.core.io.XmlImporter; 25 26 import org.openstreetmap.josm.plugins.opendata.core.io.geographic.GmlReader; 26 27 import org.openstreetmap.josm.plugins.opendata.core.io.geographic.KmlReader; … … 34 35 import org.openstreetmap.josm.plugins.opendata.core.util.OdUtils; 35 36 36 public abstract class ArchiveReader extends AbstractReader implements OdConstants{37 public abstract class ArchiveReader extends AbstractReader { 37 38 38 39 protected final AbstractDataSetHandler handler; … … 113 114 instance = progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false); 114 115 } 115 if (file.getName().toLowerCase().endsWith(CSV_EXT)) { 116 if (file.getName().toLowerCase().endsWith(OdConstants.CSV_EXT)) { 116 117 from = CsvReader.parseDataSet(in, handler, instance); 117 } else if (file.getName().toLowerCase().endsWith(KML_EXT)) { 118 } else if (file.getName().toLowerCase().endsWith(OdConstants.KML_EXT)) { 118 119 from = KmlReader.parseDataSet(in, instance); 119 } else if (file.getName().toLowerCase().endsWith(KMZ_EXT)) { 120 } else if (file.getName().toLowerCase().endsWith(OdConstants.KMZ_EXT)) { 120 121 from = KmzReader.parseDataSet(in, instance); 121 } else if (file.getName().toLowerCase().endsWith(XLS_EXT)) { 122 } else if (file.getName().toLowerCase().endsWith(OdConstants.XLS_EXT)) { 122 123 from = XlsReader.parseDataSet(in, handler, instance); 123 } else if (file.getName().toLowerCase().endsWith(ODS_EXT)) { 124 } else if (file.getName().toLowerCase().endsWith(OdConstants.ODS_EXT)) { 124 125 from = OdsReader.parseDataSet(in, handler, instance); 125 } else if (file.getName().toLowerCase().endsWith(SHP_EXT)) { 126 } else if (file.getName().toLowerCase().endsWith(OdConstants.SHP_EXT)) { 126 127 from = ShpReader.parseDataSet(in, file, handler, instance); 127 } else if (file.getName().toLowerCase().endsWith(MIF_EXT)) { 128 } else if (file.getName().toLowerCase().endsWith(OdConstants.MIF_EXT)) { 128 129 from = MifReader.parseDataSet(in, file, handler, instance); 129 } else if (file.getName().toLowerCase().endsWith(TAB_EXT)) { 130 } else if (file.getName().toLowerCase().endsWith(OdConstants.TAB_EXT)) { 130 131 from = TabReader.parseDataSet(in, file, handler, instance); 131 } else if (file.getName().toLowerCase().endsWith(GML_EXT)) { 132 } else if (file.getName().toLowerCase().endsWith(OdConstants.GML_EXT)) { 132 133 from = GmlReader.parseDataSet(in, handler, instance); 133 } else if (file.getName().toLowerCase().endsWith(XML_EXT)) { 134 } else if (file.getName().toLowerCase().endsWith(OdConstants.XML_EXT)) { 134 135 if (OdPlugin.getInstance().xmlImporter.acceptFile(file)) { 135 136 from = NeptuneReader.parseDataSet(in, handler, instance); … … 155 156 } 156 157 // Special treatment for XML files (check supported XSD), unless handler explicitely skip it 157 if (XML_FILE_FILTER.accept(file) && ((archiveHandler != null && archiveHandler.skipXsdValidation()) 158 if (XmlImporter.XML_FILE_FILTER.accept(file) && ((archiveHandler != null && archiveHandler.skipXsdValidation()) 158 159 || OdPlugin.getInstance().xmlImporter.acceptFile(file))) { 159 160 candidates.add(file); -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/archive/SevenZipImporter.java
r30340 r30563 2 2 package org.openstreetmap.josm.plugins.opendata.core.io.archive; 3 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 4 6 import java.io.InputStream; 5 7 8 import org.openstreetmap.josm.actions.ExtensionFileFilter; 6 9 import org.openstreetmap.josm.data.osm.DataSet; 7 10 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 8 11 import org.openstreetmap.josm.io.IllegalDataException; 12 import org.openstreetmap.josm.plugins.opendata.core.OdConstants; 9 13 import org.openstreetmap.josm.plugins.opendata.core.io.AbstractImporter; 10 14 11 15 public class SevenZipImporter extends AbstractImporter { 16 17 public static final ExtensionFileFilter SEVENZIP_FILE_FILTER = new ExtensionFileFilter( 18 OdConstants.SEVENZIP_EXT, OdConstants.SEVENZIP_EXT, tr("7Zip Files") + " (*."+OdConstants.SEVENZIP_EXT+")"); 12 19 13 20 public SevenZipImporter() { -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/archive/ZipImporter.java
r30340 r30563 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.opendata.core.io.archive; 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 3 5 4 6 import java.io.File; 5 7 import java.io.InputStream; 6 8 9 import org.openstreetmap.josm.actions.ExtensionFileFilter; 7 10 import org.openstreetmap.josm.data.osm.DataSet; 8 11 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 9 12 import org.openstreetmap.josm.io.IllegalDataException; 13 import org.openstreetmap.josm.plugins.opendata.core.OdConstants; 10 14 import org.openstreetmap.josm.plugins.opendata.core.io.AbstractImporter; 11 15 12 16 public class ZipImporter extends AbstractImporter { 17 18 public static final ExtensionFileFilter ZIP_FILE_FILTER = new ExtensionFileFilter( 19 OdConstants.ZIP_EXT, OdConstants.ZIP_EXT, tr("Zip Files") + " (*."+OdConstants.ZIP_EXT+")"); 13 20 14 21 public ZipImporter() { -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/AbstractMapInfoReader.java
r30532 r30563 15 15 import org.openstreetmap.josm.plugins.opendata.core.OdConstants; 16 16 17 public abstract class AbstractMapInfoReader extends AbstractReader implements OdConstants{17 public abstract class AbstractMapInfoReader extends AbstractReader { 18 18 19 19 protected static final String VERSION_1 = "1"; … … 22 22 protected static final String VERSION_450 = "450"; 23 23 24 protected static final String CHARSET_WINDOWS = "WindowsLatin1"; 24 protected static final String CHARSET_WINDOWS_LATIN = "WindowsLatin1"; 25 protected static final String CHARSET_WINDOWS_CYRILLIC = "WindowsCyrillic"; 25 26 protected static final String CHARSET_NEUTRAL = "Neutral"; 26 27 protected static final String CHARSET_MAC = "MacRoman"; … … 46 47 } 47 48 48 @SuppressWarnings("resource") 49 protected final BufferedReader getDataReader(File headerFile, String extension, Charset charset) throws FileNotFoundException { 49 protected final BufferedReader getDataReader(File headerFile, String extension, Charset charset) throws FileNotFoundException { 50 50 File dataFile = getDataFile(headerFile, extension); 51 51 return dataFile.exists() ? new BufferedReader(new InputStreamReader(new FileInputStream(dataFile), charset)) : null; … … 58 58 protected Charset parseCharset(String[] words, int index) { 59 59 words[index] = words[index].replace("\"", ""); 60 if (words[index].equalsIgnoreCase(CHARSET_WINDOWS)) { 61 return Charset.forName(CP1252); 60 if (words[index].equalsIgnoreCase(CHARSET_WINDOWS_LATIN)) { 61 return Charset.forName(OdConstants.CP1252); 62 } else if (words[index].equalsIgnoreCase(CHARSET_WINDOWS_CYRILLIC)) { 63 return Charset.forName(OdConstants.CP1251); 62 64 } else if (words[index].equalsIgnoreCase(CHARSET_NEUTRAL)) { 63 return Charset.forName(ISO8859_15); 65 return Charset.forName(OdConstants.ISO8859_15); 64 66 } else if (words[index].equalsIgnoreCase(CHARSET_MAC)) { 65 return Charset.forName(MAC_ROMAN); 67 return Charset.forName(OdConstants.MAC_ROMAN); 66 68 } else { 67 69 System.err.println("Line "+lineNum+". Unknown charset detected: "+line); -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/DefaultShpHandler.java
r30532 r30563 35 35 import org.openstreetmap.josm.tools.Pair; 36 36 37 public class DefaultShpHandler extends DefaultGeographicHandler implements ShpHandler , OdConstants{37 public class DefaultShpHandler extends DefaultGeographicHandler implements ShpHandler { 38 38 39 39 private static final List<Pair<org.opengis.referencing.datum.Ellipsoid, Ellipsoid>> … … 49 49 50 50 private static final boolean equals(Double a, Double b) { 51 boolean res = Math.abs(a - b) <= Main.pref.getDouble(PREF_CRS_COMPARISON_TOLERANCE, DEFAULT_CRS_COMPARISON_TOLERANCE); 52 if (Main.pref.getBoolean(PREF_CRS_COMPARISON_DEBUG, false)) { 51 boolean res = Math.abs(a - b) <= Main.pref.getDouble(OdConstants.PREF_CRS_COMPARISON_TOLERANCE, OdConstants.DEFAULT_CRS_COMPARISON_TOLERANCE); 52 if (Main.pref.getBoolean(OdConstants.PREF_CRS_COMPARISON_DEBUG, false)) { 53 53 System.out.println("Comparing "+a+" and "+b+" -> "+res); 54 54 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/GeographicReader.java
r30532 r30563 50 50 import com.vividsolutions.jts.geom.Point; 51 51 52 public abstract class GeographicReader extends AbstractReader implements OdConstants{52 public abstract class GeographicReader extends AbstractReader { 53 53 54 54 protected static CoordinateReferenceSystem wgs84; … … 172 172 */ 173 173 protected static final boolean warnLenientMethod(final Component parent, final CoordinateReferenceSystem crs) { 174 return new DialogPrompter() { 174 return new DialogPrompter<ExtendedDialog>() { 175 175 @Override 176 176 protected ExtendedDialog buildDialog() { … … 265 265 266 266 Hints.putSystemDefault(Hints.COMPARISON_TOLERANCE, 267 Main.pref.getDouble(PREF_CRS_COMPARISON_TOLERANCE, DEFAULT_CRS_COMPARISON_TOLERANCE)); 267 Main.pref.getDouble(OdConstants.PREF_CRS_COMPARISON_TOLERANCE, OdConstants.DEFAULT_CRS_COMPARISON_TOLERANCE)); 268 268 if (((AbstractCRS)candidate).equals((AbstractIdentifiedObject)crs, false)) { 269 269 System.out.println("Found a potential CRS: "+candidate.getName()); 270 270 candidates.add(candidate); 271 } else if (Main.pref.getBoolean(PREF_CRS_COMPARISON_DEBUG, false)) { 271 } else if (Main.pref.getBoolean(OdConstants.PREF_CRS_COMPARISON_DEBUG, false)) { 272 272 compareDebug(crs, candidate); 273 273 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/GmlImporter.java
r30340 r30563 2 2 package org.openstreetmap.josm.plugins.opendata.core.io.geographic; 3 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 4 6 import java.io.InputStream; 5 7 8 import org.openstreetmap.josm.actions.ExtensionFileFilter; 6 9 import org.openstreetmap.josm.data.osm.DataSet; 7 10 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 8 11 import org.openstreetmap.josm.io.IllegalDataException; 12 import org.openstreetmap.josm.plugins.opendata.core.OdConstants; 9 13 import org.openstreetmap.josm.plugins.opendata.core.io.AbstractImporter; 10 14 11 15 public class GmlImporter extends AbstractImporter { 12 16 17 public static final ExtensionFileFilter GML_FILE_FILTER = new ExtensionFileFilter( 18 OdConstants.GML_EXT, OdConstants.GML_EXT, tr("GML files") + " (*."+OdConstants.GML_EXT+")"); 19 13 20 public GmlImporter() { 14 21 super(GML_FILE_FILTER); -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/GmlReader.java
r30532 r30563 30 30 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 31 31 import org.openstreetmap.josm.io.UTFInputStreamReader; 32 import org.openstreetmap.josm.plugins.opendata.core.OdConstants; 32 33 import org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler; 33 34 import org.openstreetmap.josm.plugins.opendata.core.datasets.NationalHandlers; … … 66 67 } 67 68 68 private final Map<String, CrsData> crsDataMap = new HashMap< String, GmlReader.CrsData>();69 private final Map<String, CrsData> crsDataMap = new HashMap<>(); 69 70 70 71 public GmlReader(XMLStreamReader parser, GmlHandler handler) { … … 75 76 76 77 public static DataSet parseDataSet(InputStream in, AbstractDataSetHandler handler, ProgressMonitor instance) throws IOException, XMLStreamException { 77 InputStreamReader ir = UTFInputStreamReader.create(in, UTF8); 78 InputStreamReader ir = UTFInputStreamReader.create(in, OdConstants.UTF8); 78 79 XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(ir); 79 80 try { -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/KmlKmzImporter.java
r30340 r30563 2 2 package org.openstreetmap.josm.plugins.opendata.core.io.geographic; 3 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 4 6 import java.io.InputStream; 5 7 8 import org.openstreetmap.josm.actions.ExtensionFileFilter; 6 9 import org.openstreetmap.josm.data.osm.DataSet; 7 10 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 8 11 import org.openstreetmap.josm.io.IllegalDataException; 12 import org.openstreetmap.josm.plugins.opendata.core.OdConstants; 9 13 import org.openstreetmap.josm.plugins.opendata.core.io.AbstractImporter; 10 14 11 15 public class KmlKmzImporter extends AbstractImporter { 12 16 17 public static final ExtensionFileFilter KML_KMZ_FILE_FILTER = new ExtensionFileFilter( 18 OdConstants.KML_EXT+","+OdConstants.KMZ_EXT, OdConstants.KMZ_EXT, tr("KML/KMZ files") + " (*."+OdConstants.KML_EXT+",*."+OdConstants.KMZ_EXT+")"); 19 13 20 public KmlKmzImporter() { 14 21 super(KML_KMZ_FILE_FILTER); … … 19 26 throws IllegalDataException { 20 27 try { 21 if (file.getName().toLowerCase().endsWith(KML_EXT)) { 28 if (file.getName().toLowerCase().endsWith(OdConstants.KML_EXT)) { 22 29 return KmlReader.parseDataSet(in, instance); 23 30 } else { -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/KmlReader.java
r30532 r30563 29 29 import org.openstreetmap.josm.plugins.opendata.core.io.ProjectionPatterns; 30 30 31 public class KmlReader extends AbstractReader implements OdConstants{31 public class KmlReader extends AbstractReader { 32 32 33 33 public static final String KML_PLACEMARK = "Placemark"; … … 52 52 53 53 public static DataSet parseDataSet(InputStream in, ProgressMonitor instance) throws IOException, XMLStreamException, FactoryConfigurationError { 54 InputStreamReader ir = UTFInputStreamReader.create(in , UTF8);54 InputStreamReader ir = UTFInputStreamReader.create(in); 55 55 XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(ir); 56 //XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(in, UTF8); 56 57 return new KmlReader(parser).parseDoc(); 57 58 } … … 71 72 72 73 private static boolean keyIsIgnored(String key) { 73 for (ProjectionPatterns pp : PROJECTIONS) { 74 for (ProjectionPatterns pp : OdConstants.PROJECTIONS) { 74 75 if (pp.getXPattern().matcher(key).matches() || pp.getYPattern().matcher(key).matches()) { 75 76 return true; … … 80 81 81 82 private void parsePlaceMark(DataSet ds) throws XMLStreamException { 82 List<OsmPrimitive> list = new ArrayList< OsmPrimitive>();83 List<OsmPrimitive> list = new ArrayList<>(); 83 84 Way way = null; 84 85 Node node = null; 85 86 Relation relation = null; 86 87 String role = ""; 87 Map<String, String> tags = new HashMap< String, String>();88 Map<String, String> tags = new HashMap<>(); 88 89 while (parser.hasNext()) { 89 90 int event = parser.next(); -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/KmzReader.java
r30340 r30563 16 16 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 17 17 import org.openstreetmap.josm.io.AbstractReader; 18 import org.openstreetmap.josm.plugins.opendata.core.OdConstants;19 18 20 public class KmzReader extends AbstractReader implements OdConstants{19 public class KmzReader extends AbstractReader { 21 20 22 21 private ZipInputStream zis; -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/MifReader.java
r30340 r30563 14 14 import java.io.UnsupportedEncodingException; 15 15 import java.nio.charset.Charset; 16 16 import java.util.Arrays; 17 18 import org.openstreetmap.josm.Main; 17 19 import org.openstreetmap.josm.data.coor.EastNorth; 18 20 import org.openstreetmap.josm.data.osm.DataSet; … … 25 27 import org.openstreetmap.josm.data.projection.Projections; 26 28 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 29 import org.openstreetmap.josm.plugins.opendata.core.OdConstants; 27 30 import org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler; 28 31 import org.openstreetmap.josm.plugins.opendata.core.util.OdUtils; 29 32 30 33 /** 31 * MapInfo Interchange File (MIF) reader, based on this specification: 32 * http://www.gissky.com/Download/Download/DataFormat/Mapinfo_Mif.pdf 33 * 34 * MapInfo Interchange File (MIF) reader, based on these specifications:<ul> 35 * <li><a href="http://www.gissky.com/Download/Download/DataFormat/Mapinfo_Mif.pdf">Mapinfo_Mif.pdf (dead link)</a></li> 36 * <li><a href="http://resource.mapinfo.com/static/files/document/1074660800077/interchange_file.pdf">interchange_file.pdf</a></li> 37 * </ul> 34 38 */ 35 39 public class MifReader extends AbstractMapInfoReader { 36 40 37 private enum State { 38 UNKNOWN, 39 READING_COLUMNS, 40 START_POLYGON, 41 READING_POINTS, 42 END_POLYGON, 43 START_POLYLINE, 44 END_POLYLINE 45 } 46 47 protected BufferedReader midReader; 48 49 private Character delimiter = '\t'; 50 51 private State state = State.UNKNOWN; 52 53 private Projection josmProj; 54 private DataSet ds; 55 private Relation region; 56 private Way polygon; 57 private Node node; 58 private Way polyline; 59 60 // CoordSys clause 61 private MifProjection proj; 62 private MifDatum datum; 63 private String units; 64 private Double originLon; 65 private Double originLat; 66 private Double stdP1; 67 private Double stdP2; 68 private Double azimuth; 69 private Double scaleFactor; 70 private Double falseEasting; 71 private Double falseNorthing; 72 private Double range; 73 74 // Region clause 75 private int numpolygons = -1; 76 private int numpts = -1; 77 78 public static DataSet parseDataSet(InputStream in, File file, 79 AbstractDataSetHandler handler, ProgressMonitor instance) throws IOException { 80 return new MifReader().parse(in, file, instance, Charset.forName(ISO8859_15)); 81 } 82 83 private void parseDelimiter(String[] words) { 84 delimiter = words[1].charAt(1); 85 } 86 87 private void parseUnique(String[] words) { 88 // TODO 89 System.err.println("TODO: "+line); 90 } 91 92 private void parseIndex(String[] words) { 93 // TODO 94 System.err.println("TODO: "+line); 95 } 96 97 private void parseCoordSys(String[] words) { 98 for (int i = 0; i<words.length; i++) { 99 words[i] = words[i].replace(",", ""); 100 } 101 if (words[1].equalsIgnoreCase("Earth")) { 102 proj = MifProjection.forCode(Integer.parseInt(words[3])); 103 datum = MifDatum.forCode(Integer.parseInt(words[4])); 104 105 // Custom datum: TODO: use custom decalage values 106 int offset = datum == Custom ? 4 : 0; 107 108 if (proj == Longitude_Latitude) { 109 josmProj = Projections.getProjectionByCode("EPSG:4326"); // WGS 84 110 return; 111 } 112 113 // Units 114 units = words[5+offset]; 115 116 // Origin, longitude 117 originLon = Double.parseDouble(words[6+offset]); 118 119 // Origin, latitude 120 switch(proj) { 121 case Albers_Equal_Area_Conic: 122 case Azimuthal_Equidistant_polar_aspect_only: 123 case Equidistant_Conic_also_known_as_Simple_Conic: 124 case Hotine_Oblique_Mercator: 125 case Lambert_Azimuthal_Equal_Area_polar_aspect_only: 126 case Lambert_Conformal_Conic: 127 case Lambert_Conformal_Conic_modified_for_Belgium_1972: 128 case New_Zealand_Map_Grid: 129 case Stereographic: 130 case Swiss_Oblique_Mercator: 131 case Transverse_Mercator_also_known_as_Gauss_Kruger: 132 case Transverse_Mercator_modified_for_Danish_System_34_Jylland_Fyn: 133 case Transverse_Mercator_modified_for_Danish_System_45_Bornholm: 134 case Transverse_Mercator_modified_for_Finnish_KKJ: 135 case Transverse_Mercator_modified_for_Sjaelland: 136 case Polyconic: 137 originLat = Double.parseDouble(words[7+offset]); 138 break; 139 } 140 141 // Standard Parallel 1 142 switch (proj) { 143 case Cylindrical_Equal_Area: 144 case Regional_Mercator: 145 stdP1 = Double.parseDouble(words[7+offset]); 146 break; 147 case Albers_Equal_Area_Conic: 148 case Equidistant_Conic_also_known_as_Simple_Conic: 149 case Lambert_Conformal_Conic: 150 case Lambert_Conformal_Conic_modified_for_Belgium_1972: 151 stdP1 = Double.parseDouble(words[8+offset]); 152 break; 153 } 154 155 // Standard Parallel 2 156 switch (proj) { 157 case Albers_Equal_Area_Conic: 158 case Equidistant_Conic_also_known_as_Simple_Conic: 159 case Lambert_Conformal_Conic: 160 case Lambert_Conformal_Conic_modified_for_Belgium_1972: 161 stdP2 = Double.parseDouble(words[9+offset]); 162 break; 163 } 164 165 // Azimuth 166 if (proj == Hotine_Oblique_Mercator) { 167 azimuth = Double.parseDouble(words[8+offset]); 168 } 169 170 // Scale Factor 171 switch (proj) { 172 case Hotine_Oblique_Mercator: 173 scaleFactor = Double.parseDouble(words[9+offset]); 174 break; 175 case Stereographic: 176 case Transverse_Mercator_also_known_as_Gauss_Kruger: 177 case Transverse_Mercator_modified_for_Danish_System_34_Jylland_Fyn: 178 case Transverse_Mercator_modified_for_Danish_System_45_Bornholm: 179 case Transverse_Mercator_modified_for_Finnish_KKJ: 180 case Transverse_Mercator_modified_for_Sjaelland: 181 scaleFactor = Double.parseDouble(words[8+offset]); 182 break; 183 } 184 185 // False Easting/Northing 186 switch (proj) { 187 case Albers_Equal_Area_Conic: 188 case Equidistant_Conic_also_known_as_Simple_Conic: 189 case Hotine_Oblique_Mercator: 190 case Lambert_Conformal_Conic: 191 case Lambert_Conformal_Conic_modified_for_Belgium_1972: 192 falseEasting = Double.parseDouble(words[10+offset]); 193 falseNorthing = Double.parseDouble(words[11+offset]); 194 break; 195 case Stereographic: 196 case Transverse_Mercator_also_known_as_Gauss_Kruger: 197 case Transverse_Mercator_modified_for_Danish_System_34_Jylland_Fyn: 198 case Transverse_Mercator_modified_for_Danish_System_45_Bornholm: 199 case Transverse_Mercator_modified_for_Finnish_KKJ: 200 case Transverse_Mercator_modified_for_Sjaelland: 201 falseEasting = Double.parseDouble(words[9+offset]); 202 falseNorthing = Double.parseDouble(words[10+offset]); 203 break; 204 case New_Zealand_Map_Grid: 205 case Swiss_Oblique_Mercator: 206 case Polyconic: 207 falseEasting = Double.parseDouble(words[8+offset]); 208 falseNorthing = Double.parseDouble(words[9+offset]); 209 break; 210 } 211 212 // Range 213 switch (proj) { 214 case Azimuthal_Equidistant_polar_aspect_only: 215 case Lambert_Azimuthal_Equal_Area_polar_aspect_only: 216 range = Double.parseDouble(words[8+offset]); 217 } 218 219 switch (proj) { 220 case Lambert_Conformal_Conic: 221 if ((datum == Geodetic_Reference_System_1980_GRS_80 || datum == Custom) && equals(originLon, 3.0)) { 222 // This sounds good for Lambert 93 or Lambert CC 9 223 if (equals(originLat, 46.5) && equals(stdP1, 44.0) && equals(stdP2, 49.0) && equals(falseEasting, 700000.0) && equals(falseNorthing, 6600000.0)) { 224 josmProj = Projections.getProjectionByCode("EPSG:2154"); // Lambert 93 225 } else if (equals(falseEasting, 1700000.0)) { 226 for (int i=0; josmProj == null && i<9; i++) { 227 if (equals(originLat, 42.0+i) && equals(stdP1, 41.25+i) && equals(stdP2, 42.75+i) && equals(falseNorthing, (i+1)*1000000.0 + 200000.0)) { 228 josmProj = Projections.getProjectionByCode("EPSG:"+Integer.toString(3942 + i)); // LambertCC9Zones 229 } 230 } 231 } 232 } 233 break; 234 default: 235 // TODO 236 System.err.println("TODO: "+line); 237 } 238 239 } else if (words[1].equalsIgnoreCase("Nonearth")) { 240 // TODO 241 System.err.println("TODO: "+line); 242 } else if (words[1].equalsIgnoreCase("Layout")) { 243 // TODO 244 System.err.println("TODO: "+line); 245 } else if (words[1].equalsIgnoreCase("Table")) { 246 // TODO 247 System.err.println("TODO: "+line); 248 } else if (words[1].equalsIgnoreCase("Window")) { 249 // TODO 250 System.err.println("TODO: "+line); 251 } else { 252 System.err.println("Line "+lineNum+". Invalid CoordSys clause: "+line); 253 } 254 } 255 256 private void parseTransform(String[] words) { 257 // TODO 258 System.err.println("TODO: "+line); 259 } 260 261 @Override 262 protected void parseColumns(String[] words) { 263 super.parseColumns(words); 264 state = State.READING_COLUMNS; 265 } 266 267 private void parseData(String[] words) { 268 if (ds == null) { 269 ds = new DataSet(); 270 } 271 } 272 273 private void parsePoint(String[] words) throws IOException { 274 readAttributes(createNode(words[1], words[2])); 275 } 276 277 private void parseLine(String[] words) { 278 // TODO 279 System.err.println("TODO: "+line); 280 } 281 282 private void parsePLine(String[] words) throws IOException { 283 if (words.length > 2) { 284 // TODO: pline with multiple sections 285 polyline = new Way(); 286 ds.addPrimitive(polyline); 287 readAttributes(polyline); 288 numpts = Integer.parseInt(words[1]); // Not described in PDF but found in real files: PLINE XX, with XX = numpoints 289 state = State.READING_POINTS; 290 } else { 291 numpts = -1; 292 state = State.START_POLYLINE; 293 } 294 } 295 296 private void parseRegion(String[] words) throws IOException { 297 region = new Relation(); 298 region.put("type", "multipolygon"); 299 ds.addPrimitive(region); 300 readAttributes(region); 301 numpolygons = Integer.parseInt(words[1]); 302 state = State.START_POLYGON; 303 } 304 305 private void parseArc(String[] words) { 306 // TODO 307 System.err.println("TODO: "+line); 308 } 309 310 private void parseText(String[] words) { 311 // TODO 312 System.err.println("TODO: "+line); 313 } 314 315 private void parseRect(String[] words) { 316 // TODO 317 System.err.println("TODO: "+line); 318 } 319 320 private void parseRoundRect(String[] words) { 321 // TODO 322 System.err.println("TODO: "+line); 323 } 324 325 private void parseEllipse(String[] words) { 326 // TODO 327 System.err.println("TODO: "+line); 328 } 329 330 private DataSet parse(InputStream in, File file, ProgressMonitor instance, Charset charset) throws IOException { 331 try { 332 headerReader = new BufferedReader(new InputStreamReader(in, charset)); 333 midReader = getDataReader(file, ".mid", charset); 334 parseHeader(); 335 if (midReader != null) { 336 midReader.close(); 337 } 338 return ds; 339 } catch (UnsupportedEncodingException e) { 340 throw new IOException(e); 341 } 342 } 343 344 @Override 345 protected void parseHeaderLine(String[] words) throws IOException { 346 if (words[0].equalsIgnoreCase("Version")) { 347 parseVersion(words); 348 } else if (words[0].equalsIgnoreCase("Charset")) { 349 parseCharset(words); 350 } else if (words[0].equalsIgnoreCase("Delimiter")) { 351 parseDelimiter(words); 352 } else if (words[0].equalsIgnoreCase("Unique")) { 353 parseUnique(words); 354 } else if (words[0].equalsIgnoreCase("Index")) { 355 parseIndex(words); 356 } else if (words[0].equalsIgnoreCase("CoordSys")) { 357 parseCoordSys(words); 358 } else if (words[0].equalsIgnoreCase("Transform")) { 359 parseTransform(words); 360 } else if (words[0].equalsIgnoreCase("Columns")) { 361 parseColumns(words); 362 } else if (words[0].equalsIgnoreCase("Data")) { 363 parseData(words); 364 } else if (ds != null) { 365 if (state == State.START_POLYGON) { 366 numpts = Integer.parseInt(words[0]); 367 polygon = new Way(); 368 ds.addPrimitive(polygon); 369 region.addMember(new RelationMember("outer", polygon)); 370 state = State.READING_POINTS; 371 372 } else if (state == State.START_POLYLINE) { 373 numpts = Integer.parseInt(words[0]); 374 polyline = new Way(); 375 ds.addPrimitive(polyline); 376 readAttributes(polyline); 377 state = State.READING_POINTS; 378 379 } else if (state == State.READING_POINTS && numpts > 0) { 380 if (josmProj != null) { 381 node = createNode(words[0], words[1]); 382 if (polygon != null) { 383 polygon.addNode(node); 384 } else if (polyline != null) { 385 polyline.addNode(node); 386 } 387 } 388 if (--numpts == 0) { 389 if (numpolygons > -1) { 390 if (--numpolygons > 0) { 391 state = State.START_POLYGON; 392 } else { 393 state = State.END_POLYGON; 394 polygon = null; 395 } 396 } else if (polyline != null) { 397 state = State.UNKNOWN; 398 polyline = null; 399 } 400 } 401 } else if (words[0].equalsIgnoreCase("Point")) { 402 parsePoint(words); 403 } else if (words[0].equalsIgnoreCase("Line")) { 404 parseLine(words); 405 } else if (words[0].equalsIgnoreCase("PLine")) { 406 parsePLine(words); 407 } else if (words[0].equalsIgnoreCase("Region")) { 408 parseRegion(words); 409 } else if (words[0].equalsIgnoreCase("Arc")) { 410 parseArc(words); 411 } else if (words[0].equalsIgnoreCase("Text")) { 412 parseText(words); 413 } else if (words[0].equalsIgnoreCase("Rect")) { 414 parseRect(words); 415 } else if (words[0].equalsIgnoreCase("RoundRect")) { 416 parseRoundRect(words); 417 } else if (words[0].equalsIgnoreCase("Ellipse")) { 418 parseEllipse(words); 419 } else if (words[0].equalsIgnoreCase("Pen")) { 420 // Do nothing 421 } else if (words[0].equalsIgnoreCase("Brush")) { 422 // Do nothing 423 } else if (words[0].equalsIgnoreCase("Center")) { 424 // Do nothing 425 } else if (words[0].equalsIgnoreCase("Symbol")) { 426 // Do nothing 427 } else if (words[0].equalsIgnoreCase("Font")) { 428 // Do nothing 429 } else if (!words[0].isEmpty()) { 430 System.err.println("Line "+lineNum+". Unknown clause in data section: "+line); 431 } 432 } else if (state == State.READING_COLUMNS && numcolumns > 0) { 433 columns.add(words[0]); 434 if (--numcolumns == 0) { 435 state = State.UNKNOWN; 436 } 437 } else if (!line.isEmpty()) { 438 System.err.println("Line "+lineNum+". Unknown clause in header: "+line); 439 } 440 } 441 442 protected void readAttributes(OsmPrimitive p) throws IOException { 443 if (midReader != null) { 444 String midLine = midReader.readLine(); 445 if (midLine != null) { 446 String[] fields = OdUtils.stripQuotesAndExtraChars(midLine.split(delimiter.toString()), delimiter.toString()); 447 if (columns.size() != fields.length) { 448 System.err.println("Error: Incoherence between MID and MIF files ("+columns.size()+" columns vs "+fields.length+" fields)"); 449 } 450 for (int i=0; i<Math.min(columns.size(), fields.length); i++) { 451 String field = fields[i].trim(); 452 /*if (field.startsWith("\"") && field.endsWith("\"")) { 453 field = fields[i].substring(fields[i].indexOf('"')+1, fields[i].lastIndexOf('"')); 454 }*/ 455 if (!field.isEmpty()) { 456 p.put(columns.get(i), field); 457 } 458 } 459 } 460 } 461 } 462 463 protected final Node createNode(String x, String y) { 464 Node node = new Node(josmProj.eastNorth2latlon(new EastNorth(Double.parseDouble(x), Double.parseDouble(y)))); 465 ds.addPrimitive(node); 466 return node; 467 } 468 469 /** Compare two doubles within a default epsilon */ 470 public static boolean equals(Double a, Double b) { 471 if (a==b) return true; 472 // If the difference is less than epsilon, treat as equal. 473 return Math.abs(a - b) < 0.0000001; 474 } 41 private enum State { 42 UNKNOWN, 43 READING_COLUMNS, 44 START_POLYGON, 45 READING_POINTS, 46 END_POLYGON, 47 START_POLYLINE, 48 END_POLYLINE 49 } 50 51 protected BufferedReader midReader; 52 53 private Character delimiter = '\t'; 54 55 private State state = State.UNKNOWN; 56 57 private Projection josmProj; 58 private DataSet ds; 59 private Relation region; 60 private Way polygon; 61 private Node node; 62 private Way polyline; 63 64 // CoordSys clause 65 private MifProjection proj; 66 private MifDatum datum; 67 private String units; 68 private Double originLon; 69 private Double originLat; 70 private Double stdP1; 71 private Double stdP2; 72 private Double azimuth; 73 private Double scaleFactor; 74 private Double falseEasting; 75 private Double falseNorthing; 76 private Double range; 77 private Double minx; 78 private Double miny; 79 private Double maxx; 80 private Double maxy; 81 82 // Region clause 83 private int numpolygons = -1; 84 private int numpts = -1; 85 86 public static DataSet parseDataSet(InputStream in, File file, 87 AbstractDataSetHandler handler, ProgressMonitor instance) throws IOException { 88 return new MifReader().parse(in, file, instance, Charset.forName(OdConstants.ISO8859_15)); 89 } 90 91 private void parseDelimiter(String[] words) { 92 delimiter = words[1].charAt(1); 93 } 94 95 private void parseUnique(String[] words) { 96 // TODO 97 Main.warn("TODO Unique: "+line); 98 } 99 100 private void parseIndex(String[] words) { 101 // TODO 102 Main.warn("TODO Index: "+line); 103 } 104 105 private void parseCoordSysSyntax1(String[] words) { 106 proj = MifProjection.forCode(Integer.parseInt(words[3])); 107 datum = MifDatum.forCode(Integer.parseInt(words[4])); 108 109 // Custom datum: TODO: use custom decalage values 110 int offset = datum == Custom ? 4 : 0; 111 112 if (proj == Longitude_Latitude) { 113 josmProj = Projections.getProjectionByCode("EPSG:4326"); // WGS 84 114 return; 115 } 116 117 // Units 118 units = words[5+offset]; 119 120 // Origin, longitude 121 originLon = Double.parseDouble(words[6+offset]); 122 123 // Origin, latitude 124 switch(proj) { 125 case Albers_Equal_Area_Conic: 126 case Azimuthal_Equidistant_polar_aspect_only: 127 case Equidistant_Conic_also_known_as_Simple_Conic: 128 case Hotine_Oblique_Mercator: 129 case Lambert_Azimuthal_Equal_Area_polar_aspect_only: 130 case Lambert_Conformal_Conic: 131 case Lambert_Conformal_Conic_modified_for_Belgium_1972: 132 case New_Zealand_Map_Grid: 133 case Stereographic: 134 case Swiss_Oblique_Mercator: 135 case Transverse_Mercator_also_known_as_Gauss_Kruger: 136 case Transverse_Mercator_modified_for_Danish_System_34_Jylland_Fyn: 137 case Transverse_Mercator_modified_for_Danish_System_45_Bornholm: 138 case Transverse_Mercator_modified_for_Finnish_KKJ: 139 case Transverse_Mercator_modified_for_Sjaelland: 140 case Polyconic: 141 originLat = Double.parseDouble(words[7+offset]); 142 break; 143 } 144 145 // Standard Parallel 1 146 switch (proj) { 147 case Cylindrical_Equal_Area: 148 case Regional_Mercator: 149 stdP1 = Double.parseDouble(words[7+offset]); 150 break; 151 case Albers_Equal_Area_Conic: 152 case Equidistant_Conic_also_known_as_Simple_Conic: 153 case Lambert_Conformal_Conic: 154 case Lambert_Conformal_Conic_modified_for_Belgium_1972: 155 stdP1 = Double.parseDouble(words[8+offset]); 156 break; 157 } 158 159 // Standard Parallel 2 160 switch (proj) { 161 case Albers_Equal_Area_Conic: 162 case Equidistant_Conic_also_known_as_Simple_Conic: 163 case Lambert_Conformal_Conic: 164 case Lambert_Conformal_Conic_modified_for_Belgium_1972: 165 stdP2 = Double.parseDouble(words[9+offset]); 166 break; 167 } 168 169 // Azimuth 170 if (proj == Hotine_Oblique_Mercator) { 171 azimuth = Double.parseDouble(words[8+offset]); 172 } 173 174 // Scale Factor 175 switch (proj) { 176 case Hotine_Oblique_Mercator: 177 scaleFactor = Double.parseDouble(words[9+offset]); 178 break; 179 case Stereographic: 180 case Transverse_Mercator_also_known_as_Gauss_Kruger: 181 case Transverse_Mercator_modified_for_Danish_System_34_Jylland_Fyn: 182 case Transverse_Mercator_modified_for_Danish_System_45_Bornholm: 183 case Transverse_Mercator_modified_for_Finnish_KKJ: 184 case Transverse_Mercator_modified_for_Sjaelland: 185 scaleFactor = Double.parseDouble(words[8+offset]); 186 break; 187 } 188 189 // False Easting/Northing 190 switch (proj) { 191 case Albers_Equal_Area_Conic: 192 case Equidistant_Conic_also_known_as_Simple_Conic: 193 case Hotine_Oblique_Mercator: 194 case Lambert_Conformal_Conic: 195 case Lambert_Conformal_Conic_modified_for_Belgium_1972: 196 falseEasting = Double.parseDouble(words[10+offset]); 197 falseNorthing = Double.parseDouble(words[11+offset]); 198 break; 199 case Stereographic: 200 case Transverse_Mercator_also_known_as_Gauss_Kruger: 201 case Transverse_Mercator_modified_for_Danish_System_34_Jylland_Fyn: 202 case Transverse_Mercator_modified_for_Danish_System_45_Bornholm: 203 case Transverse_Mercator_modified_for_Finnish_KKJ: 204 case Transverse_Mercator_modified_for_Sjaelland: 205 falseEasting = Double.parseDouble(words[9+offset]); 206 falseNorthing = Double.parseDouble(words[10+offset]); 207 break; 208 case New_Zealand_Map_Grid: 209 case Swiss_Oblique_Mercator: 210 case Polyconic: 211 falseEasting = Double.parseDouble(words[8+offset]); 212 falseNorthing = Double.parseDouble(words[9+offset]); 213 break; 214 } 215 216 // Range 217 switch (proj) { 218 case Azimuthal_Equidistant_polar_aspect_only: 219 case Lambert_Azimuthal_Equal_Area_polar_aspect_only: 220 range = Double.parseDouble(words[8+offset]); 221 } 222 223 switch (proj) { 224 case Lambert_Conformal_Conic: 225 if ((datum == Geodetic_Reference_System_1980_GRS_80 || datum == Custom) && equals(originLon, 3.0)) { 226 // This sounds good for Lambert 93 or Lambert CC 9 227 if (equals(originLat, 46.5) && equals(stdP1, 44.0) && equals(stdP2, 49.0) && equals(falseEasting, 700000.0) && equals(falseNorthing, 6600000.0)) { 228 josmProj = Projections.getProjectionByCode("EPSG:2154"); // Lambert 93 229 } else if (equals(falseEasting, 1700000.0)) { 230 for (int i=0; josmProj == null && i<9; i++) { 231 if (equals(originLat, 42.0+i) && equals(stdP1, 41.25+i) && equals(stdP2, 42.75+i) && equals(falseNorthing, (i+1)*1000000.0 + 200000.0)) { 232 josmProj = Projections.getProjectionByCode("EPSG:"+Integer.toString(3942 + i)); // LambertCC9Zones 233 } 234 } 235 } 236 } 237 break; 238 default: 239 // TODO 240 Main.warn("TODO proj: "+line); 241 } 242 243 // TODO: handle cases with Affine declaration 244 int index = parseAffineUnits(words); 245 246 // handle cases with Bounds declaration 247 parseBounds(words, index); 248 } 249 250 private void parseCoordSysSyntax2(String[] words) { 251 // handle cases with Affine declaration 252 int index = parseAffineUnits(words); 253 254 // FIXME: no idea what projection has to be used for real with "non-earth" mode... 255 josmProj = Projections.getProjectionByCode("EPSG:4326"); // WGS 84 256 257 units = words[index+1]; 258 259 parseBounds(words, index+2); 260 } 261 262 private int parseAffineUnits(String[] words) { 263 // TODO: handle affine units 264 return 2+0; 265 } 266 267 private void parseBounds(String[] words, int index) { 268 if (index < words.length && "Bounds".equals(words[index])) { 269 // Useless parenthesis... "(minx, miny) (maxx, maxy)" 270 minx = Double.parseDouble(words[index+1].substring(1)); 271 miny = Double.parseDouble(words[index+2].substring(0, words[index+2].length()-1)); 272 maxx = Double.parseDouble(words[index+3].substring(1)); 273 maxy = Double.parseDouble(words[index+4].substring(0, words[index+4].length()-1)); 274 if (Main.isTraceEnabled()) { 275 Main.trace(Arrays.toString(words) + " -> "+minx+","+miny+","+maxx+","+maxy); 276 } 277 } 278 } 279 280 private void parseCoordSys(String[] words) { 281 for (int i = 0; i<words.length; i++) { 282 words[i] = words[i].replace(",", ""); 283 } 284 switch (words[1].toLowerCase()) { 285 case "earth": 286 parseCoordSysSyntax1(words); 287 break; 288 case "nonearth": 289 parseCoordSysSyntax2(words); 290 break; 291 case "layout": 292 case "table": 293 case "window": 294 // TODO: support Layout, Table, Window clauses 295 Main.warn("TODO: "+line); 296 break; 297 default: 298 Main.warn("Line "+lineNum+". Invalid CoordSys clause: "+line); 299 } 300 } 301 302 private void parseTransform(String[] words) { 303 // TODO 304 Main.warn("TODO Transform: "+line); 305 } 306 307 @Override 308 protected void parseColumns(String[] words) { 309 super.parseColumns(words); 310 state = State.READING_COLUMNS; 311 } 312 313 private void parseData(String[] words) { 314 if (ds == null) { 315 ds = new DataSet(); 316 } 317 } 318 319 private void parsePoint(String[] words) throws IOException { 320 readAttributes(createNode(words[1], words[2])); 321 } 322 323 private void parseLine(String[] words) throws IOException { 324 Way line = new Way(); 325 ds.addPrimitive(line); 326 readAttributes(line); 327 line.addNode(createNode(words[1], words[2])); 328 line.addNode(createNode(words[3], words[4])); 329 } 330 331 private void parsePLine(String[] words) throws IOException { 332 if (words.length > 2) { 333 // TODO: pline with multiple sections 334 polyline = new Way(); 335 ds.addPrimitive(polyline); 336 readAttributes(polyline); 337 numpts = Integer.parseInt(words[1]); // Not described in PDF but found in real files: PLINE XX, with XX = numpoints 338 state = State.READING_POINTS; 339 } else { 340 numpts = -1; 341 state = State.START_POLYLINE; 342 } 343 } 344 345 private void parseRegion(String[] words) throws IOException { 346 region = new Relation(); 347 region.put("type", "multipolygon"); 348 ds.addPrimitive(region); 349 readAttributes(region); 350 numpolygons = Integer.parseInt(words[1]); 351 state = State.START_POLYGON; 352 } 353 354 private void parseArc(String[] words) { 355 // TODO 356 Main.warn("TODO Arc: "+line); 357 } 358 359 private void parseText(String[] words) { 360 // TODO 361 Main.warn("TODO Text: "+line); 362 } 363 364 private void parseRect(String[] words) { 365 // TODO 366 Main.warn("TODO Rect: "+line); 367 } 368 369 private void parseRoundRect(String[] words) { 370 // TODO 371 Main.warn("TODO RoundRect: "+line); 372 } 373 374 private void parseEllipse(String[] words) { 375 // TODO 376 Main.warn("TODO Ellipse: "+line); 377 } 378 379 private DataSet parse(InputStream in, File file, ProgressMonitor instance, Charset charset) throws IOException { 380 try { 381 headerReader = new BufferedReader(new InputStreamReader(in, charset)); 382 midReader = getDataReader(file, ".mid", charset); 383 parseHeader(); 384 if (midReader != null) { 385 midReader.close(); 386 } 387 return ds; 388 } catch (UnsupportedEncodingException e) { 389 throw new IOException(e); 390 } 391 } 392 393 @Override 394 protected void parseHeaderLine(String[] words) throws IOException { 395 if (words[0].equalsIgnoreCase("Version")) { 396 parseVersion(words); 397 } else if (words[0].equalsIgnoreCase("Charset")) { 398 parseCharset(words); 399 } else if (words[0].equalsIgnoreCase("Delimiter")) { 400 parseDelimiter(words); 401 } else if (words[0].equalsIgnoreCase("Unique")) { 402 parseUnique(words); 403 } else if (words[0].equalsIgnoreCase("Index")) { 404 parseIndex(words); 405 } else if (words[0].equalsIgnoreCase("CoordSys")) { 406 parseCoordSys(words); 407 } else if (words[0].equalsIgnoreCase("Transform")) { 408 parseTransform(words); 409 } else if (words[0].equalsIgnoreCase("Columns")) { 410 parseColumns(words); 411 } else if (words[0].equalsIgnoreCase("Data")) { 412 parseData(words); 413 } else if (ds != null) { 414 if (state == State.START_POLYGON) { 415 numpts = Integer.parseInt(words[0]); 416 polygon = new Way(); 417 ds.addPrimitive(polygon); 418 region.addMember(new RelationMember("outer", polygon)); 419 state = State.READING_POINTS; 420 421 } else if (state == State.START_POLYLINE) { 422 numpts = Integer.parseInt(words[0]); 423 polyline = new Way(); 424 ds.addPrimitive(polyline); 425 readAttributes(polyline); 426 state = State.READING_POINTS; 427 428 } else if (state == State.READING_POINTS && numpts > 0) { 429 if (josmProj != null) { 430 node = createNode(words[0], words[1]); 431 if (polygon != null) { 432 polygon.addNode(node); 433 } else if (polyline != null) { 434 polyline.addNode(node); 435 } 436 } 437 if (--numpts == 0) { 438 if (numpolygons > -1) { 439 if (--numpolygons > 0) { 440 state = State.START_POLYGON; 441 } else { 442 state = State.END_POLYGON; 443 polygon = null; 444 } 445 } else if (polyline != null) { 446 state = State.UNKNOWN; 447 polyline = null; 448 } 449 } 450 } else if (words[0].equalsIgnoreCase("Point")) { 451 parsePoint(words); 452 } else if (words[0].equalsIgnoreCase("Line")) { 453 parseLine(words); 454 } else if (words[0].equalsIgnoreCase("PLine")) { 455 parsePLine(words); 456 } else if (words[0].equalsIgnoreCase("Region")) { 457 parseRegion(words); 458 } else if (words[0].equalsIgnoreCase("Arc")) { 459 parseArc(words); 460 } else if (words[0].equalsIgnoreCase("Text")) { 461 parseText(words); 462 } else if (words[0].equalsIgnoreCase("Rect")) { 463 parseRect(words); 464 } else if (words[0].equalsIgnoreCase("RoundRect")) { 465 parseRoundRect(words); 466 } else if (words[0].equalsIgnoreCase("Ellipse")) { 467 parseEllipse(words); 468 } else if (words[0].equalsIgnoreCase("Pen")) { 469 // Do nothing 470 } else if (words[0].equalsIgnoreCase("Brush")) { 471 // Do nothing 472 } else if (words[0].equalsIgnoreCase("Center")) { 473 // Do nothing 474 } else if (words[0].equalsIgnoreCase("Symbol")) { 475 // Do nothing 476 } else if (words[0].equalsIgnoreCase("Font")) { 477 // Do nothing 478 } else if (!words[0].isEmpty()) { 479 Main.warn("Line "+lineNum+". Unknown clause in data section: "+line); 480 } 481 } else if (state == State.READING_COLUMNS && numcolumns > 0) { 482 columns.add(words[0]); 483 if (--numcolumns == 0) { 484 state = State.UNKNOWN; 485 } 486 } else if (!line.isEmpty()) { 487 Main.warn("Line "+lineNum+". Unknown clause in header: "+line); 488 } 489 } 490 491 protected void readAttributes(OsmPrimitive p) throws IOException { 492 if (midReader != null) { 493 String midLine = midReader.readLine(); 494 if (midLine != null) { 495 String[] fields = OdUtils.stripQuotesAndExtraChars(midLine.split(delimiter.toString()), delimiter.toString()); 496 if (columns.size() != fields.length) { 497 Main.error("Incoherence between MID and MIF files ("+columns.size()+" columns vs "+fields.length+" fields)"); 498 } 499 for (int i=0; i<Math.min(columns.size(), fields.length); i++) { 500 String field = fields[i].trim(); 501 /*if (field.startsWith("\"") && field.endsWith("\"")) { 502 field = fields[i].substring(fields[i].indexOf('"')+1, fields[i].lastIndexOf('"')); 503 }*/ 504 if (!field.isEmpty()) { 505 p.put(columns.get(i), field); 506 } 507 } 508 } 509 } 510 } 511 512 protected final Node createNode(String x, String y) { 513 Node node = new Node(josmProj.eastNorth2latlon(new EastNorth(Double.parseDouble(x), Double.parseDouble(y)))); 514 ds.addPrimitive(node); 515 return node; 516 } 517 518 /** Compare two doubles within a default epsilon */ 519 public static boolean equals(Double a, Double b) { 520 if (a==b) return true; 521 // If the difference is less than epsilon, treat as equal. 522 return Math.abs(a - b) < 0.0000001; 523 } 475 524 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/MifTabImporter.java
r30340 r30563 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.opendata.core.io.geographic; 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 3 5 4 6 import java.io.IOException; 5 7 import java.io.InputStream; 6 8 9 import org.openstreetmap.josm.actions.ExtensionFileFilter; 7 10 import org.openstreetmap.josm.data.osm.DataSet; 8 11 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 9 12 import org.openstreetmap.josm.io.IllegalDataException; 13 import org.openstreetmap.josm.plugins.opendata.core.OdConstants; 10 14 import org.openstreetmap.josm.plugins.opendata.core.io.AbstractImporter; 11 15 12 16 public class MifTabImporter extends AbstractImporter { 13 17 18 public static final ExtensionFileFilter MIF_TAB_FILE_FILTER = new ExtensionFileFilter( 19 OdConstants.MIF_EXT+","+OdConstants.TAB_EXT, OdConstants.MIF_EXT, tr("MapInfo files") + " (*."+OdConstants.MIF_EXT+",*."+OdConstants.TAB_EXT+")"); 20 14 21 public MifTabImporter() { 15 22 super(MIF_TAB_FILE_FILTER); … … 20 27 throws IllegalDataException { 21 28 try { 22 if (file.getName().toLowerCase().endsWith(MIF_EXT)) { 29 if (file.getName().toLowerCase().endsWith(OdConstants.MIF_EXT)) { 23 30 return MifReader.parseDataSet(in, file, handler, instance); 24 31 } else { -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/ShpImporter.java
r30340 r30563 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.opendata.core.io.geographic; 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 3 5 4 6 import java.io.IOException; 5 7 import java.io.InputStream; 6 8 9 import org.openstreetmap.josm.actions.ExtensionFileFilter; 7 10 import org.openstreetmap.josm.data.osm.DataSet; 8 11 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 9 12 import org.openstreetmap.josm.io.IllegalDataException; 13 import org.openstreetmap.josm.plugins.opendata.core.OdConstants; 10 14 import org.openstreetmap.josm.plugins.opendata.core.io.AbstractImporter; 11 15 12 16 public class ShpImporter extends AbstractImporter { 13 17 18 public static final ExtensionFileFilter SHP_FILE_FILTER = new ExtensionFileFilter( 19 OdConstants.SHP_EXT, OdConstants.SHP_EXT, tr("Shapefiles") + " (*."+OdConstants.SHP_EXT+")"); 20 14 21 public ShpImporter() { 15 22 super(SHP_FILE_FILTER); -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/TabReader.java
r30340 r30563 16 16 import org.openstreetmap.josm.data.osm.DataSet; 17 17 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 18 import org.openstreetmap.josm.plugins.opendata.core.OdConstants; 18 19 import org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler; 19 20 import org.openstreetmap.josm.plugins.opendata.core.io.tabular.SpreadSheetHandler; … … 35 36 public static DataSet parseDataSet(InputStream in, File file, 36 37 AbstractDataSetHandler handler, ProgressMonitor instance) throws IOException { 37 return new TabReader(handler).parse(in, file, instance, Charset.forName(ISO8859_15)); 38 return new TabReader(handler).parse(in, file, instance, Charset.forName(OdConstants.ISO8859_15)); 38 39 } 39 40 … … 57 58 return null; 58 59 } 59 List<String> result = new ArrayList< String>();60 List<String> result = new ArrayList<>(); 60 61 Row row = dbfReader.readRow(); 61 62 for (int i=0; i<columns.size(); i++) { -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/tabular/CsvImporter.java
r30340 r30563 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.opendata.core.io.tabular; 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 3 5 4 6 import java.io.BufferedReader; … … 8 10 import java.io.InputStream; 9 11 12 import org.openstreetmap.josm.actions.ExtensionFileFilter; 10 13 import org.openstreetmap.josm.data.osm.DataSet; 11 14 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 12 15 import org.openstreetmap.josm.io.IllegalDataException; 16 import org.openstreetmap.josm.plugins.opendata.core.OdConstants; 13 17 import org.openstreetmap.josm.plugins.opendata.core.io.AbstractImporter; 14 18 15 19 public class CsvImporter extends AbstractImporter { 20 21 public static final ExtensionFileFilter CSV_FILE_FILTER = new ExtensionFileFilter( 22 OdConstants.CSV_EXT, OdConstants.CSV_EXT, tr("CSV files") + " (*."+OdConstants.CSV_EXT+")"); 16 23 17 24 public static final String COLOMBUS_HEADER = "INDEX,TAG,DATE,TIME,LATITUDE N/S,LONGITUDE E/W,HEIGHT,SPEED,HEADING,FIX MODE,VALID,PDOP,HDOP,VDOP,VOX"; -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/tabular/CsvReader.java
r30340 r30563 10 10 import org.openstreetmap.josm.data.osm.DataSet; 11 11 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 12 import org.openstreetmap.josm.plugins.opendata.core.OdConstants; 12 13 import org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler; 13 14 import org.openstreetmap.josm.plugins.opendata.core.util.OdUtils; … … 27 28 public CsvReader(CsvHandler handler, String defaultSep) { 28 29 super(handler); 29 this.charset = handler != null && handler.getCharset() != null ? handler.getCharset() : Charset.forName(UTF8); 30 this.charset = handler != null && handler.getCharset() != null ? handler.getCharset() : Charset.forName(OdConstants.UTF8); 30 31 this.sep = handler != null && handler.getSeparator() != null ? handler.getSeparator() : defaultSep; 31 32 } … … 40 41 return csvReader.parse(in, instance); 41 42 } catch (IllegalArgumentException e) { 42 if (csvHandler == null || (csvHandler.getSeparator()!= null&&csvHandler.getSeparator().equals(";"))) {43 if (csvHandler == null || csvHandler.getSeparator() == null || ";".equals(csvHandler.getSeparator())) { 43 44 // If default sep has been used, try comma 44 45 System.out.println(e.getMessage()); -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/tabular/OdsDocument.java
r30340 r30563 11 11 import org.jopendocument.io.SaxContentUnmarshaller; 12 12 import org.jopendocument.model.OpenDocument; 13 import org.openstreetmap.josm.plugins.opendata.core.OdConstants;14 13 import org.xml.sax.InputSource; 15 14 import org.xml.sax.XMLReader; 16 15 import org.xml.sax.helpers.XMLReaderFactory; 17 16 18 public class OdsDocument extends OpenDocument implements OdConstants{17 public class OdsDocument extends OpenDocument { 19 18 20 19 public OdsDocument(InputStream in) { -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/tabular/OdsImporter.java
r30340 r30563 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.opendata.core.io.tabular; 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 3 5 4 6 import java.io.IOException; 5 7 import java.io.InputStream; 6 8 9 import org.openstreetmap.josm.actions.ExtensionFileFilter; 7 10 import org.openstreetmap.josm.data.osm.DataSet; 8 11 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 9 12 import org.openstreetmap.josm.io.IllegalDataException; 13 import org.openstreetmap.josm.plugins.opendata.core.OdConstants; 10 14 import org.openstreetmap.josm.plugins.opendata.core.io.AbstractImporter; 11 15 12 16 public class OdsImporter extends AbstractImporter { 13 17 18 public static final ExtensionFileFilter ODS_FILE_FILTER = new ExtensionFileFilter( 19 OdConstants.ODS_EXT, OdConstants.ODS_EXT, tr("ODS files") + " (*."+OdConstants.ODS_EXT+")"); 20 14 21 public OdsImporter() { 15 22 super(ODS_FILE_FILTER); -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/tabular/SpreadSheetReader.java
r30532 r30563 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.Component; 7 import java.awt.GraphicsEnvironment; 6 8 import java.io.IOException; 7 9 import java.io.InputStream; … … 27 29 import org.openstreetmap.josm.plugins.opendata.core.io.ProjectionPatterns; 28 30 29 public abstract class SpreadSheetReader extends AbstractReader implements OdConstants{31 public abstract class SpreadSheetReader extends AbstractReader { 30 32 31 33 private static final NumberFormat formatFrance = NumberFormat.getInstance(Locale.FRANCE); … … 65 67 return xCol > -1 && yCol > -1; 66 68 } 67 @Override public String toString() { 69 @Override 70 public String toString() { 68 71 return "CoordinateColumns [proj=" + proj + ", xCol=" + xCol + ", yCol=" + yCol + "]"; 69 72 } … … 86 89 } 87 90 88 @Override public void run() { 89 ProjectionChooser dialog = (ProjectionChooser) new ProjectionChooser(progressMonitor.getWindowParent()).showDialog(); 91 @Override 92 public void run() { 93 Component parent = progressMonitor == null ? Main.parent : progressMonitor.getWindowParent(); 94 ProjectionChooser dialog = (ProjectionChooser) new ProjectionChooser(parent).showDialog(); 90 95 if (dialog.getValue() == 1) { 91 96 proj = dialog.getProjection(); … … 100 105 101 106 for (int i = 0; i<header.length; i++) { 102 for (ProjectionPatterns pp : PROJECTIONS) { 107 for (ProjectionPatterns pp : OdConstants.PROJECTIONS) { 103 108 List<CoordinateColumns> columns = projColumns.get(pp); 104 109 if (columns == null) { … … 144 149 } else if (!columns.isEmpty()) { 145 150 if (!handlerOK) { 151 if (GraphicsEnvironment.isHeadless()) { 152 throw new IllegalArgumentException("No valid coordinates have been found and cannot prompt user in headless mode."); 153 } 146 154 // TODO: filter proposed projections with min/max values ? 147 155 ChooserLauncher launcher = new ChooserLauncher(progressMonitor); … … 233 241 firstNode = n; 234 242 } 235 if (n == firstNode || n.getCoor().greatCircleDistance(firstNode.getCoor()) > Main.pref.getDouble(PREF_TOLERANCE, DEFAULT_TOLERANCE)) { 243 if (n == firstNode || n.getCoor().greatCircleDistance(firstNode.getCoor()) > Main.pref.getDouble(OdConstants.PREF_TOLERANCE, OdConstants.DEFAULT_TOLERANCE)) { 236 244 ds.addPrimitive(n); 237 245 } else { … … 240 248 } 241 249 } 242 if (handler != null && !Main.pref.getBoolean(PREF_RAWDATA)) { 250 if (handler != null && !Main.pref.getBoolean(OdConstants.PREF_RAWDATA)) { 243 251 handler.nodesAdded(ds, nodes, header, lineNumber); 244 252 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/tabular/XlsImporter.java
r30340 r30563 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.opendata.core.io.tabular; 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 3 5 4 6 import java.io.IOException; 5 7 import java.io.InputStream; 6 8 9 import org.openstreetmap.josm.actions.ExtensionFileFilter; 7 10 import org.openstreetmap.josm.data.osm.DataSet; 8 11 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 9 12 import org.openstreetmap.josm.io.IllegalDataException; 13 import org.openstreetmap.josm.plugins.opendata.core.OdConstants; 10 14 import org.openstreetmap.josm.plugins.opendata.core.io.AbstractImporter; 11 15 12 16 public class XlsImporter extends AbstractImporter { 13 17 18 public static final ExtensionFileFilter XLS_FILE_FILTER = new ExtensionFileFilter( 19 OdConstants.XLS_EXT, OdConstants.XLS_EXT, tr("XLS files") + " (*."+OdConstants.XLS_EXT+")"); 20 14 21 public XlsImporter() { 15 22 super(XLS_FILE_FILTER); -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/layers/OdDataLayer.java
r30532 r30563 28 28 import org.openstreetmap.josm.plugins.opendata.core.util.OdUtils; 29 29 30 public class OdDataLayer extends OsmDataLayer implements Od Constants, OdLayer, LayerChangeListener {30 public class OdDataLayer extends OsmDataLayer implements OdLayer, LayerChangeListener { 31 31 32 32 public OdDiffLayer diffLayer; … … 52 52 53 53 @Override public Icon getBaseIcon() { 54 return OdUtils.getImageIcon(handler != null ? handler.getDataLayerIconName() : ICON_CORE_16); 54 return OdUtils.getImageIcon(handler != null ? handler.getDataLayerIconName() : OdConstants.ICON_CORE_16); 55 55 } 56 56 … … 133 133 } 134 134 if (this.handler.getWikiURL() != null) { 135 result.add(new OpenLinkAction(this.handler.getWikiURL(), ICON_OSM_24, 135 result.add(new OpenLinkAction(this.handler.getWikiURL(), OdConstants.ICON_OSM_24, 136 136 tr("View OSM Wiki page"), tr("Launch browser to the OSM Wiki page of the selected data set"))); 137 137 } … … 147 147 License lic = this.handler.getLicense(); 148 148 if (lic.getURL() != null && lic.getURL().getProtocol().startsWith("http")) { 149 result.add(new OpenLinkAction(lic.getURL(), ICON_AGREEMENT_24, 149 result.add(new OpenLinkAction(lic.getURL(), OdConstants.ICON_AGREEMENT_24, 150 150 tr("View License"), tr("Launch browser to the license page of the selected data set"))); 151 151 } 152 152 if (lic.getSummaryURL() != null && lic.getSummaryURL().getProtocol().startsWith("http")) { 153 result.add(new OpenLinkAction(lic.getSummaryURL(), ICON_AGREEMENT_24, 153 result.add(new OpenLinkAction(lic.getSummaryURL(), OdConstants.ICON_AGREEMENT_24, 154 154 tr("View License (summary)"), tr("Launch browser to the summary license page of the selected data set"))); 155 155 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/layers/OdDiffLayer.java
r30532 r30563 20 20 import org.openstreetmap.josm.tools.Pair; 21 21 22 public class OdDiffLayer extends Layer implements OdLayer , OdConstants{22 public class OdDiffLayer extends Layer implements OdLayer { 23 23 24 24 private final OdDataLayer dataLayer; … … 62 62 63 63 private OsmPrimitive findPrimitiveAt(DataSet dataSet, OsmPrimitive source) { 64 double maxDistance = Main.pref.getDouble(PREF_MAXDISTANCE, DEFAULT_MAXDISTANCE); 64 double maxDistance = Main.pref.getDouble(OdConstants.PREF_MAXDISTANCE, OdConstants.DEFAULT_MAXDISTANCE); 65 65 //List<OsmPrimitive> samePrimitives = new ArrayList<OsmPrimitive>(); 66 66 OsmPrimitive nearestSamePrimitive = null; -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/licenses/LOOL.java
r30340 r30563 5 5 import org.openstreetmap.josm.plugins.opendata.core.util.OdUtils; 6 6 7 public class LOOL extends License implements OdConstants{7 public class LOOL extends License { 8 8 9 9 //public static final String URL_FR = "http://www.data.gouv.fr/Licence-Ouverte-Open-Licence"; 10 10 11 11 public LOOL() { 12 setIcon(OdUtils.getImageIcon(ICON_LOOL_48, true)); 13 setURL(LOOL.class.getResource(RESOURCE_PATH+"Licence-Ouverte-Open-Licence-ENG.rtf"), "en"); 14 setURL(LOOL.class.getResource(RESOURCE_PATH+"Licence-Ouverte-Open-Licence.rtf"), "fr"); 12 setIcon(OdUtils.getImageIcon(OdConstants.ICON_LOOL_48, true)); 13 setURL(LOOL.class.getResource(OdConstants.RESOURCE_PATH+"Licence-Ouverte-Open-Licence-ENG.rtf"), "en"); 14 setURL(LOOL.class.getResource(OdConstants.RESOURCE_PATH+"Licence-Ouverte-Open-Licence.rtf"), "fr"); 15 15 } 16 16 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/licenses/ODbL.java
r30340 r30563 4 4 import org.openstreetmap.josm.plugins.opendata.core.OdConstants; 5 5 6 public class ODbL extends License implements OdConstants{6 public class ODbL extends License { 7 7 8 8 //public static final String URL = "http://opendatacommons.org/licenses/odbl/1-0"; … … 14 14 for (String lang : new String[]{"", "fr"}) { 15 15 if (lang.isEmpty()) { 16 setURL(ODbL.class.getResource(RESOURCE_PATH+"odbl-1.0.htm")); 17 setSummaryURL(ODbL.class.getResource(RESOURCE_PATH+"odbl-summary-1.0.htm")); 16 setURL(ODbL.class.getResource(OdConstants.RESOURCE_PATH+"odbl-1.0.htm")); 17 setSummaryURL(ODbL.class.getResource(OdConstants.RESOURCE_PATH+"odbl-summary-1.0.htm")); 18 18 } else { 19 setURL(ODbL.class.getResource(RESOURCE_PATH+"odbl-1.0-"+lang+".htm"), lang); 20 setSummaryURL(ODbL.class.getResource(RESOURCE_PATH+"odbl-summary-1.0-"+lang+".htm"), lang); 19 setURL(ODbL.class.getResource(OdConstants.RESOURCE_PATH+"odbl-1.0-"+lang+".htm"), lang); 20 setSummaryURL(ODbL.class.getResource(OdConstants.RESOURCE_PATH+"odbl-summary-1.0-"+lang+".htm"), lang); 21 21 } 22 22 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/modules/AbstractModule.java
r30532 r30563 17 17 import org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler; 18 18 19 public abstract class AbstractModule implements Module , OdConstants{19 public abstract class AbstractModule implements Module { 20 20 21 21 protected final List<Class<? extends AbstractDataSetHandler>> handlers = new ArrayList<>(); … … 52 52 try { 53 53 // Copy style sheet to disk to allow JOSM to load it at startup (even making the plugin "early" does not allow it) 54 String path = OdPlugin.getInstance().getResourcesDirectory()+File.separator+src.url.replace(PROTO_RSRC, "").replace('/', File.separatorChar); 54 String path = OdPlugin.getInstance().getResourcesDirectory()+File.separator+src.url.replace(OdConstants.PROTO_RSRC, "").replace('/', File.separatorChar); 55 55 56 56 int n = 0; 57 57 byte[] buffer = new byte[4096]; 58 InputStream in = getClass().getResourceAsStream(src.url.substring(PROTO_RSRC.length()-1)); 58 InputStream in = getClass().getResourceAsStream(src.url.substring(OdConstants.PROTO_RSRC.length()-1)); 59 59 new File(path.substring(0, path.lastIndexOf(File.separatorChar))).mkdirs(); 60 60 FileOutputStream out = new FileOutputStream(path); … … 66 66 67 67 // Add source pointing to the local file 68 src.url = PROTO_FILE+path; 68 src.url = OdConstants.PROTO_FILE+path; 69 69 sources.add(src); 70 70 } catch (IOException e) { -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/modules/ModuleHandler.java
r30532 r30563 56 56 * 57 57 */ 58 public class ModuleHandler implements OdConstants{58 public class ModuleHandler { 59 59 60 60 /** … … 251 251 } 252 252 if (msg != null && confirmDisableModule(parent, msg, module.name)) { 253 Main.pref.removeFromCollection(PREF_MODULES, module.name); 253 Main.pref.removeFromCollection(OdConstants.PREF_MODULES, module.name); 254 254 } 255 255 } … … 359 359 public static List<ModuleInformation> buildListOfModulesToLoad(Component parent) { 360 360 Set<String> modules = new HashSet<>(); 361 modules.addAll(Main.pref.getCollection(PREF_MODULES, new LinkedList<String>())); 362 if (System.getProperty("josm."+PREF_MODULES) != null) { 363 modules.addAll(Arrays.asList(System.getProperty("josm."+PREF_MODULES).split(","))); 361 modules.addAll(Main.pref.getCollection(OdConstants.PREF_MODULES, new LinkedList<String>())); 362 if (System.getProperty("josm."+OdConstants.PREF_MODULES) != null) { 363 modules.addAll(Arrays.asList(System.getProperty("josm."+OdConstants.PREF_MODULES).split(","))); 364 364 } 365 365 Map<String, ModuleInformation> infos = loadLocallyAvailableModuleInformation(null); -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/modules/ModuleInformation.java
r30532 r30563 34 34 * without the need of loading any class from the module jar file. 35 35 */ 36 public class ModuleInformation implements OdConstants{36 public class ModuleInformation { 37 37 public File file = null; 38 38 public String name = null; … … 218 218 sb.append(" <a href=\"").append(link).append("\">").append(tr("More info...")).append("</a>"); 219 219 } 220 if (downloadlink != null && !downloadlink.startsWith(OSM_SITE+"dist/")) { 220 if (downloadlink != null && !downloadlink.startsWith(OdConstants.OSM_SITE+"dist/")) { 221 221 sb.append("<p> </p><p>"+tr("<b>Module provided by an external source:</b> {0}", downloadlink)+"</p>"); 222 222 } … … 347 347 public ImageIcon getScaledIcon() { 348 348 if (icon == null) 349 return OdUtils.getImageIcon(ICON_EMPTY_24); 349 return OdUtils.getImageIcon(OdConstants.ICON_EMPTY_24); 350 350 return new ImageIcon(icon.getImage().getScaledInstance(24, 24, Image.SCALE_SMOOTH)); 351 351 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/modules/ReadRemoteModuleInformationTask.java
r30532 r30563 31 31 import org.openstreetmap.josm.io.OsmTransferException; 32 32 import org.openstreetmap.josm.plugins.opendata.OdPlugin; 33 import org.openstreetmap.josm.plugins.opendata.core.OdConstants;34 33 import org.openstreetmap.josm.tools.ImageProvider; 35 34 import org.xml.sax.SAXException; … … 39 38 * 40 39 */ 41 public class ReadRemoteModuleInformationTask extends PleaseWaitRunnable implements OdConstants{40 public class ReadRemoteModuleInformationTask extends PleaseWaitRunnable { 42 41 43 42 private Collection<String> sites; -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/util/NamesFrUtils.java
r30532 r30563 15 15 import org.openstreetmap.josm.plugins.opendata.core.datasets.SimpleDataSetHandler; 16 16 17 public abstract class NamesFrUtils implements OdConstants{17 public abstract class NamesFrUtils { 18 18 19 19 private static Map<String, String> dictionary = initDictionary(); … … 34 34 try { 35 35 BufferedReader reader = new BufferedReader(new InputStreamReader( 36 SimpleDataSetHandler.class.getResourceAsStream(DICTIONARY_FR), UTF8)); 36 SimpleDataSetHandler.class.getResourceAsStream(OdConstants.DICTIONARY_FR), OdConstants.UTF8)); 37 37 String line = reader.readLine(); // Skip first line 38 38 while ((line = reader.readLine()) != null) {
Note:
See TracChangeset
for help on using the changeset viewer.