Changeset 36072 in osm for applications
- Timestamp:
- 2023-04-19T16:29:43+02:00 (21 months ago)
- Location:
- applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/actions/ViewLicenseAction.java
r30723 r36072 13 13 import org.openstreetmap.josm.plugins.opendata.core.util.OdUtils; 14 14 import org.openstreetmap.josm.tools.CheckParameterUtil; 15 import org.openstreetmap.josm.tools.Logging; 15 16 16 17 public class ViewLicenseAction extends JosmAction { … … 30 31 new ViewLicenseDialog(license).showDialog(); 31 32 } catch (IOException ex) { 32 ex.printStackTrace();33 Logging.error(ex); 33 34 } 34 35 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/AbstractDataSetHandler.java
r36024 r36072 80 80 private ImageIcon menuIcon; 81 81 82 p ublicAbstractDataSetHandler() {82 protected AbstractDataSetHandler() { 83 83 setShpHandler(new DefaultShpHandler()); 84 84 setArchiveHandler(new DefaultArchiveHandler()); … … 90 90 private boolean acceptsFilename(String filename, String[] expected, String ... extensions) { 91 91 if (filename != null) { 92 for (String name : expected) {92 for (String expectedName : expected) { 93 93 for (String ext : extensions) { 94 if (Pattern.compile( name+"\\."+ext, Pattern.CASE_INSENSITIVE).matcher(filename).matches()) {95 //if (filename.equalsIgnoreCase( name+"."+ext)) {94 if (Pattern.compile(expectedName+"\\."+ext, Pattern.CASE_INSENSITIVE).matcher(filename).matches()) { 95 //if (filename.equalsIgnoreCase(expectedName+"."+ext)) { 96 96 return true; 97 97 } … … 102 102 } 103 103 104 protected final boolean acceptsCsvFilename(String filename, String 104 protected final boolean acceptsCsvFilename(String filename, String... expected) { 105 105 return acceptsFilename(filename, expected, OdConstants.CSV_EXT); 106 106 } 107 107 108 protected final boolean acceptsXlsFilename(String filename, String 108 protected final boolean acceptsXlsFilename(String filename, String... expected) { 109 109 return acceptsFilename(filename, expected, OdConstants.XLS_EXT); 110 110 } 111 111 112 protected final boolean acceptsOdsFilename(String filename, String 112 protected final boolean acceptsOdsFilename(String filename, String... expected) { 113 113 return acceptsFilename(filename, expected, OdConstants.ODS_EXT); 114 114 } 115 115 116 protected final boolean acceptsShpFilename(String filename, String 116 protected final boolean acceptsShpFilename(String filename, String... expected) { 117 117 return acceptsFilename(filename, expected, OdConstants.SHP_EXT); 118 118 } 119 119 120 protected final boolean acceptsMifFilename(String filename, String 120 protected final boolean acceptsMifFilename(String filename, String... expected) { 121 121 return acceptsFilename(filename, expected, OdConstants.MIF_EXT); 122 122 } 123 123 124 protected final boolean acceptsMifTabFilename(String filename, String 124 protected final boolean acceptsMifTabFilename(String filename, String... expected) { 125 125 return acceptsFilename(filename, expected, OdConstants.MIF_EXT, OdConstants.TAB_EXT); 126 126 } 127 127 128 protected final boolean acceptsShpMifFilename(String filename, String 128 protected final boolean acceptsShpMifFilename(String filename, String... expected) { 129 129 return acceptsFilename(filename, expected, OdConstants.SHP_EXT, OdConstants.MIF_EXT); 130 130 } 131 131 132 protected final boolean acceptsKmlFilename(String filename, String 132 protected final boolean acceptsKmlFilename(String filename, String... expected) { 133 133 return acceptsFilename(filename, expected, OdConstants.KML_EXT); 134 134 } 135 135 136 protected final boolean acceptsKmzFilename(String filename, String 136 protected final boolean acceptsKmzFilename(String filename, String... expected) { 137 137 return acceptsFilename(filename, expected, OdConstants.KMZ_EXT); 138 138 } 139 139 140 protected final boolean acceptsKmzShpFilename(String filename, String 140 protected final boolean acceptsKmzShpFilename(String filename, String... expected) { 141 141 return acceptsFilename(filename, expected, OdConstants.KMZ_EXT, OdConstants.SHP_EXT); 142 142 } 143 143 144 protected final boolean acceptsKmzTabFilename(String filename, String 144 protected final boolean acceptsKmzTabFilename(String filename, String... expected) { 145 145 return acceptsFilename(filename, expected, OdConstants.KMZ_EXT, OdConstants.TAB_EXT); 146 146 } 147 147 148 protected final boolean acceptsZipFilename(String filename, String 148 protected final boolean acceptsZipFilename(String filename, String... expected) { 149 149 return acceptsFilename(filename, expected, OdConstants.ZIP_EXT); 150 150 } 151 151 152 protected final boolean accepts7ZipFilename(String filename, String 152 protected final boolean accepts7ZipFilename(String filename, String... expected) { 153 153 return acceptsFilename(filename, expected, OdConstants.SEVENZIP_EXT); 154 154 } 155 155 156 protected final boolean acceptsCsvKmzFilename(String filename, String 156 protected final boolean acceptsCsvKmzFilename(String filename, String... expected) { 157 157 return acceptsFilename(filename, expected, OdConstants.CSV_EXT, OdConstants.KMZ_EXT); 158 158 } 159 159 160 protected final boolean acceptsCsvKmzTabFilename(String filename, String 160 protected final boolean acceptsCsvKmzTabFilename(String filename, String... expected) { 161 161 return acceptsFilename(filename, expected, OdConstants.CSV_EXT, OdConstants.KMZ_EXT, OdConstants.TAB_EXT); 162 162 } 163 163 164 protected final boolean acceptsCsvXlsFilename(String filename, String 164 protected final boolean acceptsCsvXlsFilename(String filename, String... expected) { 165 165 return acceptsFilename(filename, expected, OdConstants.CSV_EXT, OdConstants.XLS_EXT); 166 166 } … … 544 544 545 545 public final boolean addTool(JosmAction tool) { 546 return tool != null ? tools.add(tool) : false;546 return tool != null && tools.add(tool); 547 547 } 548 548 549 549 public final boolean removeTool(JosmAction tool) { 550 return tool != null ? tools.remove(tool) : false;550 return tool != null && tools.remove(tool); 551 551 } 552 552 -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/SimpleDataSetHandler.java
r35899 r36072 33 33 private final boolean relevantUnion; 34 34 35 p ublicSimpleDataSetHandler() {35 protected SimpleDataSetHandler() { 36 36 this.relevantUnion = false; 37 37 } 38 38 39 p ublicSimpleDataSetHandler(String relevantTag) {39 protected SimpleDataSetHandler(String relevantTag) { 40 40 addRelevantTag(relevantTag); 41 41 this.relevantUnion = false; … … 51 51 } 52 52 53 p ublicSimpleDataSetHandler(boolean relevantUnion, String... relevantTags) {53 protected SimpleDataSetHandler(boolean relevantUnion, String... relevantTags) { 54 54 addRelevantTag(relevantTags); 55 55 this.relevantUnion = relevantUnion; 56 56 } 57 57 58 p ublicSimpleDataSetHandler(String... relevantTags) {58 protected SimpleDataSetHandler(String... relevantTags) { 59 59 this(false, relevantTags); 60 60 } 61 61 62 p ublicSimpleDataSetHandler(Tag relevantTag) {62 protected SimpleDataSetHandler(Tag relevantTag) { 63 63 addRelevantTag(relevantTag); 64 64 this.relevantUnion = false; 65 65 } 66 66 67 p ublicSimpleDataSetHandler(boolean relevantUnion, Tag ... relevantTags) {67 protected SimpleDataSetHandler(boolean relevantUnion, Tag ... relevantTags) { 68 68 addRelevantTag(relevantTags); 69 69 this.relevantUnion = relevantUnion; 70 70 } 71 71 72 p ublic SimpleDataSetHandler(Tag... relevantTags) {72 protected SimpleDataSetHandler(Tag... relevantTags) { 73 73 this(false, relevantTags); 74 74 } 75 75 76 public void addRelevantTag(String 76 public void addRelevantTag(String... relevantTags) { 77 77 addTags(this.relevantTags, relevantTags); 78 78 } 79 79 80 public void addRelevantTag(Tag 80 public void addRelevantTag(Tag... relevantTags) { 81 81 addTags(this.relevantTags, relevantTags); 82 82 } 83 83 84 public void addForbiddenTag(String 84 public void addForbiddenTag(String... forbiddenTags) { 85 85 addTags(this.forbiddenTags, forbiddenTags); 86 86 } 87 87 88 public void addForbiddenTag(Tag 88 public void addForbiddenTag(Tag... forbiddenTags) { 89 89 addTags(this.forbiddenTags, forbiddenTags); 90 90 } 91 91 92 private void addTags(final List<Tag> list, String... tags) {92 private static void addTags(final List<Tag> list, String... tags) { 93 93 if (tags != null) { 94 94 for (String tag : tags) { … … 105 105 } 106 106 107 private void addTags(final List<Tag> list, Tag... tags) {107 private static void addTags(final List<Tag> list, Tag... tags) { 108 108 if (tags != null) { 109 109 for (Tag tag : tags) { … … 133 133 } 134 134 } 135 if (isForbidden(p)) { 136 return false; 137 } 138 return true; 135 return !isForbidden(p); 139 136 } 140 137 … … 166 163 String[] mpconditions = new String[conditions.length+1]; 167 164 mpconditions[0] = OverpassApi.hasKey("type", "multipolygon"); 168 for (int i = 0; i < conditions.length; i++) { 169 mpconditions[i+1] = conditions[i]; 170 } 165 System.arraycopy(conditions, 0, mpconditions, 1, conditions.length); 171 166 return OverpassApi.query(bbox, NODE, conditions) + "\n" + // Nodes 172 167 OverpassApi.recurse(NODE_RELATION, RELATION_WAY, WAY_NODE) + "\n" + … … 194 189 @Override 195 190 protected Collection<String> getOsmXapiRequests(String bbox) { 196 String relevantTags = "";197 for (Tag tag : this.relevantTags) { 198 relevantTags += "["+tag.getKey()+"="+(tag.getValue() == null ? "*" : tag.getValue())+"]";199 } 200 String forbiddenTags = "";191 StringBuilder relevantTagsSB = new StringBuilder(); 192 for (Tag tag : this.relevantTags) { 193 relevantTagsSB.append("[").append(tag.getKey()).append("=").append(tag.getValue() == null ? "*" : tag.getValue()).append("]"); 194 } 195 StringBuilder forbiddenTagsSB = new StringBuilder(); 201 196 for (Tag tag : this.forbiddenTags) { 202 forbiddenTags += "[not("+tag.getKey()+"="+(tag.getValue() == null ? "*" : tag.getValue())+")]";203 } 204 return Collections.singleton("*[bbox="+bbox+"]"+relevantTags +forbiddenTags+"[@meta]");197 forbiddenTagsSB.append("[not(").append(tag.getKey()).append("=").append(tag.getValue() == null ? "*" : tag.getValue()).append(")]"); 198 } 199 return Collections.singleton("*[bbox="+bbox+"]"+relevantTagsSB+forbiddenTagsSB+"[@meta]"); 205 200 } 206 201 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/WayCombiner.java
r34662 r36072 33 33 } 34 34 35 pr otectedstatic Way getTargetWay(Collection<Way> combinedWays) {35 private static Way getTargetWay(Collection<Way> combinedWays) { 36 36 // init with an arbitrary way 37 37 Way targetWay = combinedWays.iterator().next(); -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/be/BelgianDataSetHandler.java
r34452 r36072 12 12 import org.openstreetmap.josm.plugins.opendata.core.OdConstants; 13 13 import org.openstreetmap.josm.plugins.opendata.core.datasets.SimpleDataSetHandler; 14 import org.openstreetmap.josm.plugins.opendata.core.io.tabular.CsvHandler; 14 15 import org.openstreetmap.josm.plugins.opendata.core.io.tabular.DefaultCsvHandler; 15 16 import org.openstreetmap.josm.spi.preferences.Config; 17 import org.openstreetmap.josm.tools.Logging; 16 18 17 19 public abstract class BelgianDataSetHandler extends SimpleDataSetHandler implements BelgianConstants { … … 52 54 } 53 55 54 p ublicBelgianDataSetHandler() {56 protected BelgianDataSetHandler() { 55 57 init(); 56 58 } 57 59 58 p ublicBelgianDataSetHandler(String relevantTag) {60 protected BelgianDataSetHandler(String relevantTag) { 59 61 super(relevantTag); 60 62 init(); 61 63 } 62 64 63 p ublicBelgianDataSetHandler(boolean relevantUnion, String[] relevantTags) {65 protected BelgianDataSetHandler(boolean relevantUnion, String[] relevantTags) { 64 66 super(relevantUnion, relevantTags); 65 67 init(); 66 68 } 67 69 68 p ublicBelgianDataSetHandler(boolean relevantUnion, Tag[] relevantTags) {70 protected BelgianDataSetHandler(boolean relevantUnion, Tag[] relevantTags) { 69 71 super(relevantUnion, relevantTags); 70 72 init(); … … 85 87 protected final void setSingleProjection(Projection singleProjection) { 86 88 this.singleProjection = singleProjection; 87 getCsvHandler().setHandlesProjection(singleProjection != null); 89 final CsvHandler handler = getCsvHandler(); 90 if (handler != null) { 91 handler.setHandlesProjection(singleProjection != null); 92 } 88 93 } 89 94 … … 108 113 return new URL(BELGIAN_PORTAL.replace(OdConstants.PATTERN_LANG, lang.substring(0, 2))+nationalPortalPath); //FIXME 109 114 } catch (MalformedURLException e) { 110 e.printStackTrace();115 Logging.error(e); 111 116 } 112 117 return null; -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/fr/FrenchDataSetHandler.java
r32545 r36072 18 18 import org.openstreetmap.josm.plugins.opendata.core.datasets.SimpleDataSetHandler; 19 19 import org.openstreetmap.josm.plugins.opendata.core.io.tabular.DefaultCsvHandler; 20 import org.openstreetmap.josm.tools.Logging; 20 21 21 22 public abstract class FrenchDataSetHandler extends SimpleDataSetHandler implements FrenchConstants { … … 71 72 } 72 73 73 p ublicFrenchDataSetHandler() {74 init(); 75 } 76 77 p ublicFrenchDataSetHandler(String relevantTag) {74 protected FrenchDataSetHandler() { 75 init(); 76 } 77 78 protected FrenchDataSetHandler(String relevantTag) { 78 79 super(relevantTag); 79 80 init(); 80 81 } 81 82 82 p ublicFrenchDataSetHandler(boolean relevantUnion, String[] relevantTags) {83 protected FrenchDataSetHandler(boolean relevantUnion, String[] relevantTags) { 83 84 super(relevantUnion, relevantTags); 84 85 init(); 85 86 } 86 87 87 p ublicFrenchDataSetHandler(boolean relevantUnion, Tag[] relevantTags) {88 protected FrenchDataSetHandler(boolean relevantUnion, Tag[] relevantTags) { 88 89 super(relevantUnion, relevantTags); 89 90 init(); … … 110 111 } 111 112 } catch (MalformedURLException e) { 112 e.printStackTrace();113 Logging.error(e); 113 114 } 114 115 return null; … … 125 126 } 126 127 127 protected static finalLatLon getLatLonByDptCode(EastNorth en, String dpt, boolean useCC9) {128 protected static LatLon getLatLonByDptCode(EastNorth en, String dpt, boolean useCC9) { 128 129 // CHECKSTYLE.OFF: LineLength 129 130 if (dpt.equals("971") || dpt.equals("972") || dpt.equals("977") || dpt.equals("978")) { // Antilles … … 161 162 } 162 163 163 private void replaceFaxPhone(OsmPrimitive p, String dataKey, String osmKey) {164 private static void replaceFaxPhone(OsmPrimitive p, String dataKey, String osmKey) { 164 165 String phone = p.get(dataKey); 165 166 if (phone != null) { … … 204 205 Matcher m2 = Pattern.compile(dayGroup+"(?:"+sep+dayGroup+")+").matcher(range); 205 206 if (m2.matches()) { 206 String replacement = "";207 StringBuilder replacement = new StringBuilder(); 207 208 for (int i = 0; i < m2.groupCount(); i++) { 208 209 if (i > 0) { 209 replacement += sep;210 replacement.append(sep); 210 211 } 211 replacement += getEnDay(m2.group(i+1));212 replacement.append(getEnDay(m2.group(i + 1))); 212 213 } 213 hours = hours.replace(range, replacement );214 hours = hours.replace(range, replacement.toString()); 214 215 } 215 216 } else { … … 223 224 } 224 225 225 private String getEnDay(String frDay) {226 private static String getEnDay(String frDay) { 226 227 for (int i = 0; i < dayFrSplit.length; i++) { 227 228 if (dayFrSplit[i].equals(frDay)) { -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/gui/DialogPrompter.java
r32545 r36072 2 2 package org.openstreetmap.josm.plugins.opendata.core.gui; 3 3 4 import java.lang.reflect.InvocationTargetException;5 6 import javax.swing.SwingUtilities;7 8 4 import org.openstreetmap.josm.gui.ExtendedDialog; 5 import org.openstreetmap.josm.gui.util.GuiHelper; 9 6 10 7 public class DialogPrompter<T extends ExtendedDialog> implements Runnable { … … 41 38 42 39 public final DialogPrompter<T> promptInEdt() { 43 if (SwingUtilities.isEventDispatchThread()) { 44 run(); 45 } else { 46 try { 47 SwingUtilities.invokeAndWait(this); 48 } catch (InterruptedException e) { 49 e.printStackTrace(); 50 } catch (InvocationTargetException e) { 51 e.printStackTrace(); 52 } 53 } 40 GuiHelper.runInEDTAndWait(this); 54 41 return this; 55 42 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/gui/ModulePreference.java
r35513 r36072 17 17 import java.util.Collection; 18 18 import java.util.Collections; 19 import java.util.Iterator;20 19 import java.util.LinkedList; 21 20 import java.util.List; … … 101 100 * by the user 102 101 */ 103 private boolean modulePreferencesActivated = false;102 private boolean modulePreferencesActivated; 104 103 105 104 protected JPanel buildSearchFieldPanel() { … … 116 115 gc.gridx = 1; 117 116 gc.weightx = 1.0; 118 pnl.add(tfFilter = new JTextField(), gc); 117 this.tfFilter = new JTextField(); 118 pnl.add(this.tfFilter, gc); 119 119 tfFilter.setToolTipText(tr("Enter a search expression")); 120 120 SelectAllOnFocusGainedDecorator.decorate(tfFilter); … … 332 332 model.refreshLocalModuleVersion(moduleDownloadTask.getDownloadedModules()); 333 333 model.clearPendingModules(moduleDownloadTask.getDownloadedModules()); 334 GuiHelper.runInEDT( () -> pnlModulePreferences.refreshView());334 GuiHelper.runInEDT(pnlModulePreferences::refreshView); 335 335 }; 336 336 … … 343 343 // select modules which actually have to be updated 344 344 // 345 Iterator<ModuleInformation> it = toUpdate.iterator(); 346 while (it.hasNext()) { 347 ModuleInformation pi = it.next(); 348 if (!pi.isUpdateRequired()) { 349 it.remove(); 350 } 351 } 345 toUpdate.removeIf(pi -> !pi.isUpdateRequired()); 352 346 if (toUpdate.isEmpty()) { 353 347 alertNothingToUpdate(); … … 387 381 */ 388 382 class ModulePreferenceActivationListener implements ChangeListener { 389 private Component pane;383 private final Component pane; 390 384 ModulePreferenceActivationListener(Component preferencesPane) { 391 385 pane = preferencesPane; … … 409 403 public void filter() { 410 404 String expr = tfFilter.getText().trim(); 411 if ( expr.equals("")) {405 if ("".equals(expr)) { 412 406 expr = null; 413 407 } … … 514 508 ret.add(model.get(i)); 515 509 } 516 return ret;510 return Collections.unmodifiableList(ret); 517 511 } 518 512 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/gui/ModulePreferencesModel.java
r34452 r36072 160 160 return displayedModules; 161 161 } 162 163 162 164 163 /** -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/gui/OdDialog.java
r34116 r36072 57 57 } 58 58 59 private class SelectAction extends JosmAction {59 private static class SelectAction extends JosmAction { 60 60 SelectAction() { 61 61 super(marktr("Select"), "dialogs/select", … … 69 69 } 70 70 71 private class DiffAction extends JosmAction {71 private static class DiffAction extends JosmAction { 72 72 DiffAction() { 73 73 super(marktr("Diff"), "dialogs/diff", tr("Perform diff between current data set and existing OSM data."), null, false); … … 80 80 } 81 81 82 private class ToolsAction extends JosmAction {82 private static class ToolsAction extends JosmAction { 83 83 ToolsAction() { 84 84 super(marktr("Tools"), "dialogs/utils", tr("Open tools menu for this data."), null, false); … … 96 96 KeyEvent.VK_A, Shortcut.ALT_CTRL_SHIFT), 150, false, OdPreferenceSetting.class); 97 97 98 this. buttons = Arrays.asList(new SideButton[] {99 /*selectButton =*/ new SideButton(new SelectAction()),100 downloadButton = new SideButton(new DownloadAction()),101 diffButton = new SideButton(new DiffAction()),102 t oolsButton = new SideButton(new ToolsAction())103 }); 98 this.downloadButton = new SideButton(new DownloadAction()); 99 this.diffButton = new SideButton(new DiffAction()); 100 this.toolsButton = new SideButton(new ToolsAction()); 101 this.buttons = Arrays.asList(/*selectButton =*/ new SideButton(new SelectAction()), 102 this.downloadButton, this.diffButton, this.toolsButton); 103 104 104 105 105 this.toolsButton.addMouseListener(new MouseAdapter() { -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/gui/ViewLicenseDialog.java
r34452 r36072 9 9 import java.io.IOException; 10 10 11 import javax.swing.Icon;12 11 import javax.swing.JEditorPane; 13 12 import javax.swing.JOptionPane; … … 18 17 import org.openstreetmap.josm.plugins.opendata.core.licenses.License; 19 18 import org.openstreetmap.josm.tools.ImageProvider; 19 import org.openstreetmap.josm.tools.Logging; 20 20 21 21 public class ViewLicenseDialog extends ExtendedDialog { … … 45 45 scrollPane.setPreferredSize(new Dimension(800, 600)); 46 46 47 setButtonIcons(new Icon[] { 48 ImageProvider.get("ok"), 47 setButtonIcons(ImageProvider.get("ok"), 49 48 ImageProvider.get("agreement24"), 50 ImageProvider.get("cancel"), 51 }); 52 setToolTipTexts(new String[] { 53 null, 49 ImageProvider.get("cancel")); 50 setToolTipTexts(null, 54 51 tr("View the full text of this license"), 55 null });52 null); 56 53 if (license.getIcon() != null) { 57 54 setIcon(license.getIcon()); … … 76 73 } 77 74 } catch (IOException e) { 78 e.printStackTrace();75 Logging.error(e); 79 76 } 80 77 summary = !summary; -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/OsmDownloader.java
r34452 r36072 25 25 MainApplication.getMenu().openLocation.openUrl(false, oapiServer+"data="+oapiReqEnc); 26 26 } catch (UnsupportedEncodingException e) { 27 e.printStackTrace();27 Logging.error(e); 28 28 } 29 29 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/archive/ArchiveReader.java
r33518 r36072 48 48 private File file; 49 49 50 p ublicArchiveReader(AbstractDataSetHandler handler, ArchiveHandler archiveHandler, boolean promptUser) {50 protected ArchiveReader(AbstractDataSetHandler handler, ArchiveHandler archiveHandler, boolean promptUser) { 51 51 this.handler = handler; 52 52 this.archiveHandler = archiveHandler; … … 123 123 } 124 124 } catch (IllegalArgumentException e) { 125 Logging.error(e .getMessage());125 Logging.error(e); 126 126 } finally { 127 127 OdUtils.deleteDir(temp); … … 149 149 Logging.info("Parsing file "+f.getName()); 150 150 DataSet from = null; 151 FileInputStream in = new FileInputStream(f); 152 ProgressMonitor instance = null; 153 if (progressMonitor != null) { 154 instance = progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false); 155 } 156 if (f.getName().toLowerCase().endsWith(OdConstants.CSV_EXT)) { 157 from = CsvReader.parseDataSet(in, handler, instance); 158 } else if (f.getName().toLowerCase().endsWith(OdConstants.KML_EXT)) { 159 from = KmlReader.parseDataSet(in, instance); 160 } else if (f.getName().toLowerCase().endsWith(OdConstants.KMZ_EXT)) { 161 from = KmzReader.parseDataSet(in, instance); 162 } else if (f.getName().toLowerCase().endsWith(OdConstants.XLS_EXT)) { 163 from = XlsReader.parseDataSet(in, handler, instance); 164 } else if (f.getName().toLowerCase().endsWith(OdConstants.ODS_EXT)) { 165 from = OdsReader.parseDataSet(in, handler, instance); 166 } else if (f.getName().toLowerCase().endsWith(OdConstants.SHP_EXT)) { 167 from = ShpReader.parseDataSet(in, f, handler, instance); 168 } else if (f.getName().toLowerCase().endsWith(OdConstants.MIF_EXT)) { 169 from = MifReader.parseDataSet(in, f, handler, instance); 170 } else if (f.getName().toLowerCase().endsWith(OdConstants.TAB_EXT)) { 171 from = TabReader.parseDataSet(in, f, handler, instance); 172 } else if (f.getName().toLowerCase().endsWith(OdConstants.GML_EXT)) { 173 from = GmlReader.parseDataSet(in, handler, instance); 174 } else if (f.getName().toLowerCase().endsWith(OdConstants.XML_EXT)) { 175 if (OdPlugin.getInstance().xmlImporter.acceptFile(f)) { 176 from = NeptuneReader.parseDataSet(in, handler, instance); 151 try (FileInputStream in = new FileInputStream(f)) { 152 ProgressMonitor instance = null; 153 if (progressMonitor != null) { 154 instance = progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false); 155 } 156 final String lowerCaseName = f.getName().toLowerCase(); 157 if (lowerCaseName.endsWith(OdConstants.CSV_EXT)) { 158 from = CsvReader.parseDataSet(in, handler, instance); 159 } else if (lowerCaseName.endsWith(OdConstants.KML_EXT)) { 160 from = KmlReader.parseDataSet(in, instance); 161 } else if (lowerCaseName.endsWith(OdConstants.KMZ_EXT)) { 162 from = KmzReader.parseDataSet(in, instance); 163 } else if (lowerCaseName.endsWith(OdConstants.XLS_EXT)) { 164 from = XlsReader.parseDataSet(in, handler, instance); 165 } else if (lowerCaseName.endsWith(OdConstants.ODS_EXT)) { 166 from = OdsReader.parseDataSet(in, handler, instance); 167 } else if (lowerCaseName.endsWith(OdConstants.SHP_EXT)) { 168 from = ShpReader.parseDataSet(in, f, handler, instance); 169 } else if (lowerCaseName.endsWith(OdConstants.MIF_EXT)) { 170 from = MifReader.parseDataSet(in, f, handler, instance); 171 } else if (lowerCaseName.endsWith(OdConstants.TAB_EXT)) { 172 from = TabReader.parseDataSet(in, f, handler, instance); 173 } else if (lowerCaseName.endsWith(OdConstants.GML_EXT)) { 174 from = GmlReader.parseDataSet(in, handler, instance); 175 } else if (lowerCaseName.endsWith(OdConstants.XML_EXT)) { 176 if (OdPlugin.getInstance().xmlImporter.acceptFile(f)) { 177 from = NeptuneReader.parseDataSet(in, handler, instance); 178 } else { 179 Logging.warn("Unsupported XML file: " + f.getName()); 180 } 177 181 } else { 178 Logging.warn("Unsupported XML file: "+f.getName()); 179 } 180 } else { 181 Logging.warn("Unsupported file extension: "+f.getName()); 182 } 183 return from; 182 Logging.warn("Unsupported file extension: " + f.getName()); 183 } 184 return from; 185 } 184 186 } 185 187 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/archive/CandidateChooser.java
r32545 r36072 33 33 } 34 34 35 private class Renderer extends DefaultListCellRenderer {35 private static class Renderer extends DefaultListCellRenderer { 36 36 37 37 @Override -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/GeographicReader.java
r36024 r36072 22 22 import javax.json.JsonReader; 23 23 import javax.json.spi.JsonProvider; 24 import javax.swing.Icon;25 24 import javax.swing.JOptionPane; 26 25 … … 39 38 import org.opengis.referencing.FactoryException; 40 39 import org.opengis.referencing.IdentifiedObject; 41 import org.opengis.referencing.NoSuchAuthorityCodeException;42 40 import org.opengis.referencing.crs.CoordinateReferenceSystem; 43 41 import org.opengis.referencing.crs.ProjectedCRS; … … 80 78 try { 81 79 wgs84 = CRS.decode("EPSG:4326"); 82 } catch (NoSuchAuthorityCodeException e) {83 e.printStackTrace();84 80 } catch (FactoryException e) { 85 e.printStackTrace();81 Logging.error(e); 86 82 } 87 83 } … … 97 93 private static final Map<String, Integer> esriWkid = new TreeMap<>(); 98 94 99 p ublicGeographicReader(GeographicHandler handler, GeographicHandler[] defaultHandlers) {95 protected GeographicReader(GeographicHandler handler, GeographicHandler[] defaultHandlers) { 100 96 this.nodes = new HashMap<>(); 101 97 this.handler = handler; … … 225 221 } 226 222 227 protected finalvoid addWayToMp(Relation r, String role, Way w) {223 protected static void addWayToMp(Relation r, String role, Way w) { 228 224 r.addMember(new RelationMember(role, w)); 229 225 } … … 233 229 * want to continue 234 230 */ 235 protected static finalboolean warnLenientMethod(final Component parent, final CoordinateReferenceSystem crs) {231 protected static boolean warnLenientMethod(final Component parent, final CoordinateReferenceSystem crs) { 236 232 return new DialogPrompter<ExtendedDialog>() { 237 233 @Override … … 239 235 final ExtendedDialog dlg = new ExtendedDialog(parent, 240 236 tr("Cannot transform to WGS84"), 241 new String[] {tr("Cancel"), tr("Continue")});237 tr("Cancel"), tr("Continue")); 242 238 // CHECKSTYLE.OFF: LineLength 243 239 dlg.setContent("<html>" + … … 247 243 "</html>"); 248 244 // CHECKSTYLE.ON: LineLength 249 dlg.setButtonIcons(new Icon[] { 250 new ImageProvider("cancel").setMaxSize(ImageSizes.LARGEICON).get(), 245 dlg.setButtonIcons(new ImageProvider("cancel").setMaxSize(ImageSizes.LARGEICON).get(), 251 246 new ImageProvider("ok").setMaxSize(ImageSizes.LARGEICON).addOverlay( 252 new ImageOverlay(new ImageProvider("warning-small"), 0.5, 0.5, 1.0, 1.0)).get()}); 253 dlg.setToolTipTexts(new String[] { 254 tr("Cancel"), 255 tr("Try lenient method")}); 247 new ImageOverlay(new ImageProvider("warning-small"), 0.5, 0.5, 1.0, 1.0)).get()); 248 dlg.setToolTipTexts(tr("Cancel"), 249 tr("Try lenient method")); 256 250 dlg.setIcon(JOptionPane.WARNING_MESSAGE); 257 251 dlg.setCancelButton(1); -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/GmlReader.java
r35125 r36072 9 9 import java.util.Map; 10 10 11 import javax.xml.stream.XMLInputFactory;12 11 import javax.xml.stream.XMLStreamConstants; 13 12 import javax.xml.stream.XMLStreamException; … … 35 34 import org.openstreetmap.josm.tools.Logging; 36 35 import org.openstreetmap.josm.tools.UserCancelException; 36 import org.openstreetmap.josm.tools.XmlUtils; 37 37 38 38 /** … … 59 59 private int dim; 60 60 61 private final class CrsData {61 private static final class CrsData { 62 62 public CoordinateReferenceSystem crs; 63 63 public MathTransform transform; … … 81 81 throws IOException, XMLStreamException { 82 82 InputStreamReader ir = UTFInputStreamReader.create(in, OdConstants.UTF8); 83 XMLStreamReader parser = X MLInputFactory.newInstance().createXMLStreamReader(ir);83 XMLStreamReader parser = XmlUtils.newSafeXMLInputFactory().createXMLStreamReader(ir); 84 84 try { 85 85 return new GmlReader(parser, handler != null ? handler.getGmlHandler() : null).parseDoc(instance); … … 98 98 while (parser.hasNext()) { 99 99 int event = parser.next(); 100 if (event == XMLStreamConstants.START_ELEMENT) { 101 if (isElement(GML_FEATURE_MEMBER)) { 102 try { 103 parseFeatureMember(parent); 104 } catch (UserCancelException e) { 105 return ds; 106 } 100 if (event == XMLStreamConstants.START_ELEMENT && isElement(GML_FEATURE_MEMBER)) { 101 try { 102 parseFeatureMember(parent); 103 } catch (UserCancelException e) { 104 Logging.trace(e); 105 return ds; 107 106 } 108 107 } … … 132 131 try { 133 132 findCRS(srs); 134 } catch (NoSuchAuthorityCodeException e) {135 e.printStackTrace();136 133 } catch (FactoryException e) { 137 e.printStackTrace();134 Logging.error(e); 138 135 } 139 136 if (crs == null) { … … 172 169 String[] tab = parser.getElementText().split(" "); 173 170 for (int i = 0; i < tab.length; i += dim) { 174 Point p = geometryFactory.createPoint(new Coordinate(Double. valueOf(tab[i]), Double.valueOf(tab[i+1])));175 node = createOrGetNode(p, dim > 2 && ! tab[i+2].equals("0") ? tab[i+2] : null);171 Point p = geometryFactory.createPoint(new Coordinate(Double.parseDouble(tab[i]), Double.parseDouble(tab[i+1]))); 172 node = createOrGetNode(p, dim > 2 && !"0".equals(tab[i+2]) ? tab[i+2] : null); 176 173 if (way != null) { 177 174 way.addNode(node); … … 182 179 } else if (isElement(GML_COORDINATES)) { 183 180 String[] tab = parser.getElementText().trim().split(","); 184 Point p = geometryFactory.createPoint(new Coordinate(Double. valueOf(tab[0]), Double.valueOf(tab[1])));181 Point p = geometryFactory.createPoint(new Coordinate(Double.parseDouble(tab[0]), Double.parseDouble(tab[1]))); 185 182 node = createOrGetNode(p); 186 183 if (way == null) { … … 207 204 } 208 205 if (prim != null) { 209 for ( String k : tags.keySet()) {210 prim.put( k, tags.get(k).toString());206 for (Map.Entry<String, StringBuilder> entry : tags.entrySet()) { 207 prim.put(entry.getKey(), entry.getValue().toString()); 211 208 } 212 209 }
Note:
See TracChangeset
for help on using the changeset viewer.