Changeset 32545 in osm for applications/editors/josm/plugins
- Timestamp:
- 2016-07-03T22:13:58+02:00 (8 years ago)
- Location:
- applications/editors/josm/plugins/opendata
- Files:
-
- 1 added
- 85 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/opendata/.checkstyle
r31695 r32545 8 8 <file-match-pattern match-pattern="." include-pattern="true"/> 9 9 </fileset> 10 <filter name="DerivedFiles" enabled="true"/> 11 <filter name="FilesFromPackage" enabled="true"> 12 <filter-data value="src/org/geotools"/> 13 <filter-data value="data"/> 14 <filter-data value="images"/> 15 <filter-data value="includes"/> 16 <filter-data value="styles"/> 17 <filter-data value="resources"/> 18 <filter-data value="scripts"/> 19 </filter> 10 20 </fileset-config> -
applications/editors/josm/plugins/opendata/.project
r32286 r32545 26 26 </arguments> 27 27 </buildCommand> 28 <buildCommand> 29 <name>net.sf.eclipsecs.core.CheckstyleBuilder</name> 30 <arguments> 31 </arguments> 32 </buildCommand> 28 33 </buildSpec> 29 34 <natures> … … 31 36 <nature>org.eclipse.jdt.core.javanature</nature> 32 37 <nature>org.eclipse.wst.common.project.facet.core.nature</nature> 38 <nature>net.sf.eclipsecs.core.CheckstyleNature</nature> 33 39 </natures> 34 40 </projectDescription> -
applications/editors/josm/plugins/opendata/.settings/org.eclipse.jdt.ui.prefs
r28696 r32545 1 1 eclipse.preferences.version=1 2 editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true 2 3 formatter_profile=_JOSM 3 4 formatter_settings_version=12 5 sp_cleanup.add_default_serial_version_id=true 6 sp_cleanup.add_generated_serial_version_id=false 7 sp_cleanup.add_missing_annotations=true 8 sp_cleanup.add_missing_deprecated_annotations=true 9 sp_cleanup.add_missing_methods=false 10 sp_cleanup.add_missing_nls_tags=false 11 sp_cleanup.add_missing_override_annotations=true 12 sp_cleanup.add_missing_override_annotations_interface_methods=true 13 sp_cleanup.add_serial_version_id=false 14 sp_cleanup.always_use_blocks=true 15 sp_cleanup.always_use_parentheses_in_expressions=false 16 sp_cleanup.always_use_this_for_non_static_field_access=false 17 sp_cleanup.always_use_this_for_non_static_method_access=false 18 sp_cleanup.convert_functional_interfaces=false 19 sp_cleanup.convert_to_enhanced_for_loop=false 20 sp_cleanup.correct_indentation=false 21 sp_cleanup.format_source_code=false 22 sp_cleanup.format_source_code_changes_only=false 23 sp_cleanup.insert_inferred_type_arguments=false 24 sp_cleanup.make_local_variable_final=true 25 sp_cleanup.make_parameters_final=false 26 sp_cleanup.make_private_fields_final=true 27 sp_cleanup.make_type_abstract_if_missing_method=false 28 sp_cleanup.make_variable_declarations_final=false 29 sp_cleanup.never_use_blocks=false 30 sp_cleanup.never_use_parentheses_in_expressions=true 31 sp_cleanup.on_save_use_additional_actions=true 32 sp_cleanup.organize_imports=true 33 sp_cleanup.qualify_static_field_accesses_with_declaring_class=false 34 sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true 35 sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true 36 sp_cleanup.qualify_static_member_accesses_with_declaring_class=false 37 sp_cleanup.qualify_static_method_accesses_with_declaring_class=false 38 sp_cleanup.remove_private_constructors=true 39 sp_cleanup.remove_redundant_type_arguments=true 40 sp_cleanup.remove_trailing_whitespaces=true 41 sp_cleanup.remove_trailing_whitespaces_all=true 42 sp_cleanup.remove_trailing_whitespaces_ignore_empty=false 43 sp_cleanup.remove_unnecessary_casts=true 44 sp_cleanup.remove_unnecessary_nls_tags=false 45 sp_cleanup.remove_unused_imports=true 46 sp_cleanup.remove_unused_local_variables=false 47 sp_cleanup.remove_unused_private_fields=true 48 sp_cleanup.remove_unused_private_members=false 49 sp_cleanup.remove_unused_private_methods=true 50 sp_cleanup.remove_unused_private_types=true 51 sp_cleanup.sort_members=false 52 sp_cleanup.sort_members_all=false 53 sp_cleanup.use_anonymous_class_creation=false 54 sp_cleanup.use_blocks=false 55 sp_cleanup.use_blocks_only_for_return_and_throw=false 56 sp_cleanup.use_lambda=true 57 sp_cleanup.use_parentheses_in_expressions=false 58 sp_cleanup.use_this_for_non_static_field_access=false 59 sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true 60 sp_cleanup.use_this_for_non_static_method_access=false 61 sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true 62 sp_cleanup.use_type_arguments=false -
applications/editors/josm/plugins/opendata/build.xml
r32287 r32545 1 1 <?xml version="1.0" encoding="utf-8"?> 2 2 <project name="opendata" default="dist" basedir="."> 3 <property name="plugin.main.version" value="104 07"/>3 <property name="plugin.main.version" value="10420"/> 4 4 <property name="plugin.author" value="Don-vip"/> 5 5 <property name="plugin.class" value="org.openstreetmap.josm.plugins.opendata.OdPlugin"/> -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/OdPlugin.java
r32287 r32545 98 98 } 99 99 100 public static finalOdPlugin getInstance() {100 public static OdPlugin getInstance() { 101 101 return instance; 102 102 } … … 191 191 } 192 192 193 private finalvoid loadModules() {193 private void loadModules() { 194 194 List<ModuleInformation> modulesToLoad = ModuleHandler.buildListOfModulesToLoad(Main.parent); 195 195 if (!modulesToLoad.isEmpty() && ModuleHandler.checkAndConfirmModuleUpdate(Main.parent)) { … … 201 201 } 202 202 203 private finalFile getSubDirectory(String name) {203 private File getSubDirectory(String name) { 204 204 File dir = new File(getPluginDir()+File.separator+name); 205 205 if (!dir.exists()) { … … 209 209 } 210 210 211 public finalFile getModulesDirectory() {211 public File getModulesDirectory() { 212 212 return getSubDirectory("modules"); 213 213 } 214 214 215 public finalFile getResourcesDirectory() {215 public File getResourcesDirectory() { 216 216 return getSubDirectory("resources"); 217 217 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/OdConstants.java
r30723 r32545 10 10 11 11 public abstract class OdConstants { 12 12 13 13 /** 14 14 * Encodings … … 20 20 public static final String CP1252 = "Cp1252"; 21 21 public static final String MAC_ROMAN = "MacRoman"; 22 22 23 23 /** 24 24 * Patterns 25 25 */ 26 26 public static final String PATTERN_LANG = "{lang}"; 27 27 28 28 /** 29 29 * Preferences … … 35 35 public static final String PREF_OAPI = "opendata.oapi"; 36 36 public static final String DEFAULT_OAPI = "http://www.overpass-api.de/api/interpreter?"; 37 37 38 38 public static final String PREF_XAPI = "opendata.xapi"; 39 39 public static final String DEFAULT_XAPI = "http://www.overpass-api.de/api/xapi?"; … … 50 50 public static final String PREF_MODULES = "opendata.modules"; 51 51 public static final String PREF_MODULES_SITES = "opendata.modules.sites"; 52 public final staticString OSM_SITE = "http://svn.openstreetmap.org/applications/editors/josm/plugins/opendata/";53 public final staticString[] DEFAULT_MODULE_SITES = {OSM_SITE + "modules.txt%<?modules=>"};52 public static final String OSM_SITE = "http://svn.openstreetmap.org/applications/editors/josm/plugins/opendata/"; 53 public static final String[] DEFAULT_MODULE_SITES = {OSM_SITE + "modules.txt%<?modules=>"}; 54 54 55 55 public static final String PREF_CRS_COMPARISON_TOLERANCE = "opendata.crs.comparison_tolerance"; … … 64 64 public static final String ICON_CORE_24 = "o24.png"; 65 65 public static final String ICON_CORE_48 = "o48.png"; 66 66 67 67 public static final String ICON_OSM_16 = "osm16.png"; 68 68 public static final String ICON_OSM_24 = "osm24.png"; … … 90 90 public static final String JAR_EXT = "jar"; 91 91 public static final String XML_EXT = "xml"; 92 92 93 93 /** 94 94 * Protocols … … 96 96 public static final String PROTO_FILE = "file://"; 97 97 public static final String PROTO_RSRC = "resource://"; 98 98 99 99 /** 100 100 * Coordinates fields … … 102 102 public static final String X_STRING = "X|LON|LONGI|.*LONGITUDE.*|EASTING"; 103 103 public static final String Y_STRING = "Y|LAT|LATI|.*LATITUDE.*|NORTHING"; 104 104 105 105 // The list of all ProjectionPatterns (filled at each constructor call) 106 106 public static final Collection<ProjectionPatterns> PROJECTIONS = new ArrayList<>(); 107 107 108 // CHECKSTYLE.OFF: LineLength 108 109 public static final ProjectionPatterns PRJ_WGS84 = new ProjectionPatterns("GPS|WGS84|°décimaux", Projections.getProjectionByCode("EPSG:4326")); 109 110 public static final ProjectionPatterns PRJ_LAMBERT_93 = new ProjectionPatterns("LAMB93|L93", Projections.getProjectionByCode("EPSG:2154")); … … 112 113 public static final ProjectionPatterns PRJ_LAMBERT_1972 = new ProjectionPatterns("LAMB72|LAMB1972", Projections.getProjectionByCode("EPSG:31370")); 113 114 public static final ProjectionPatterns PRJ_LAMBERT_2008 = new ProjectionPatterns("LAMB08|LAMB2008", Projections.getProjectionByCode("EPSG:3812")); 115 // CHECKSTYLE.ON: LineLength 114 116 115 117 // Must always be declared last -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/actions/DownloadDataTask.java
r30723 r32545 28 28 29 29 private AbstractDataSetHandler handler; 30 30 31 31 @Override 32 32 public Future<?> download(boolean newLayer, Bounds downloadArea, ProgressMonitor progressMonitor) { … … 63 63 return false; 64 64 } 65 65 66 66 @Override 67 67 public String[] getPatterns() { … … 89 89 @Override 90 90 protected OsmDataLayer createNewLayer(String layerName) { 91 File associatedFile = ((NetworkReader) reader).getReadFile();92 String filename = ((NetworkReader) reader).getReadFileName();91 File associatedFile = ((NetworkReader) reader).getReadFile(); 92 String filename = ((NetworkReader) reader).getReadFileName(); 93 93 if (layerName == null || layerName.isEmpty()) { 94 94 if (associatedFile != null) { … … 104 104 } 105 105 } 106 106 107 107 /** 108 108 * returns true if the user accepts the license, false if they refuse … … 114 114 try { 115 115 return new AskLicenseAgreementDialog(license).showDialog().getValue() == 1; 116 116 117 117 } catch (IOException e) { 118 118 JOptionPane.showMessageDialog(Main.parent, tr("License URL not available: {0}", license.toString())); -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/AbstractDataSetHandler.java
r32125 r32545 21 21 import org.openstreetmap.josm.io.AbstractReader; 22 22 import org.openstreetmap.josm.plugins.opendata.core.OdConstants; 23 import org.openstreetmap.josm.plugins.opendata.core.io.archive.ArchiveHandler; 23 24 import org.openstreetmap.josm.plugins.opendata.core.io.archive.DefaultArchiveHandler; 24 import org.openstreetmap.josm.plugins.opendata.core.io.archive.ArchiveHandler;25 25 import org.openstreetmap.josm.plugins.opendata.core.io.geographic.DefaultGmlHandler; 26 26 import org.openstreetmap.josm.plugins.opendata.core.io.geographic.DefaultShpHandler; … … 37 37 38 38 public abstract class AbstractDataSetHandler { 39 39 40 40 public abstract boolean acceptsFilename(String filename); 41 41 42 42 public boolean acceptsFile(File file) { 43 43 return acceptsFilename(file.getName()); 44 44 } 45 45 46 46 public abstract void updateDataSet(DataSet ds); 47 47 … … 60 60 } 61 61 } 62 62 63 63 public void checkNames(DataSet ds) { 64 64 if (ds != null) { … … 83 83 setGmlHandler(new DefaultGmlHandler()); 84 84 } 85 86 private final boolean acceptsFilename(String filename, String[] expected, String ... extensions) {85 86 private boolean acceptsFilename(String filename, String[] expected, String ... extensions) { 87 87 if (filename != null) { 88 88 for (String name : expected) { 89 89 for (String ext : extensions) { 90 90 if (Pattern.compile(name+"\\."+ext, Pattern.CASE_INSENSITIVE).matcher(filename).matches()) { 91 //if (filename.equalsIgnoreCase(name+"."+ext)) {91 //if (filename.equalsIgnoreCase(name+"."+ext)) { 92 92 return true; 93 93 } … … 97 97 return false; 98 98 } 99 99 100 100 protected final boolean acceptsCsvFilename(String filename, String ... expected) { 101 101 return acceptsFilename(filename, expected, OdConstants.CSV_EXT); … … 157 157 return acceptsFilename(filename, expected, OdConstants.CSV_EXT, OdConstants.KMZ_EXT, OdConstants.TAB_EXT); 158 158 } 159 159 160 160 protected final boolean acceptsCsvXlsFilename(String filename, String ... expected) { 161 161 return acceptsFilename(filename, expected, OdConstants.CSV_EXT, OdConstants.XLS_EXT); 162 162 } 163 163 164 164 // -------------------- License -------------------- 165 165 166 166 private License license; 167 167 168 168 public License getLicense() { 169 169 return license; … … 175 175 176 176 // --------------------- URLs --------------------- 177 177 178 178 private URL dataURL; 179 179 private URL wikiURL; 180 180 private URL localPortalURL; 181 181 private URL nationalPortalURL; 182 182 183 183 public URL getDataURL() { 184 184 return dataURL; … … 229 229 } 230 230 231 public List<Pair<String,URL>> getDataURLs() {return null;} 232 233 public AbstractReader getReaderForUrl(String url) {return null;} 234 231 public List<Pair<String, URL>> getDataURLs() { 232 return null; 233 } 234 235 public AbstractReader getReaderForUrl(String url) { 236 return null; 237 } 238 235 239 private boolean hasLicenseToBeAccepted = true; 236 240 … … 252 256 253 257 public final Collection<String> getOsmXapiRequests(Bounds bounds) { 254 return getOsmXapiRequests( 255 LatLon.roundToOsmPrecision(bounds.getMin().lon())+","+ 256 LatLon.roundToOsmPrecision(bounds.getMin().lat())+","+ 257 LatLon.roundToOsmPrecision(bounds.getMax().lon())+","+ 258 LatLon.roundToOsmPrecision(bounds.getMax().lat())); 259 } 260 261 protected Collection<String> getOsmXapiRequests(String bbox) {return null;} 262 258 return getOsmXapiRequests(LatLon.roundToOsmPrecision(bounds.getMin().lon())+","+ 259 LatLon.roundToOsmPrecision(bounds.getMin().lat())+","+ 260 LatLon.roundToOsmPrecision(bounds.getMax().lon())+","+ 261 LatLon.roundToOsmPrecision(bounds.getMax().lat())); 262 } 263 264 protected Collection<String> getOsmXapiRequests(String bbox) { 265 return null; 266 } 267 263 268 public final String getOverpassApiRequest(Bounds bounds) { 264 return getOverpassApiRequest( 265 "w=\""+LatLon.roundToOsmPrecision(bounds.getMin().lon())+"\" "+ 266 "s=\""+LatLon.roundToOsmPrecision(bounds.getMin().lat())+"\" "+ 267 "e=\""+LatLon.roundToOsmPrecision(bounds.getMax().lon())+"\" "+ 268 "n=\""+LatLon.roundToOsmPrecision(bounds.getMax().lat())+"\""); 269 } 270 271 protected String getOverpassApiRequest(String bbox) {return null;} 272 273 public boolean equals(IPrimitive p1, IPrimitive p2) {return false;} 274 275 public boolean isRelevant(IPrimitive p) {return false;} 276 269 return getOverpassApiRequest("w=\""+LatLon.roundToOsmPrecision(bounds.getMin().lon())+"\" "+ 270 "s=\""+LatLon.roundToOsmPrecision(bounds.getMin().lat())+"\" "+ 271 "e=\""+LatLon.roundToOsmPrecision(bounds.getMax().lon())+"\" "+ 272 "n=\""+LatLon.roundToOsmPrecision(bounds.getMax().lat())+"\""); 273 } 274 275 protected String getOverpassApiRequest(String bbox) { 276 return null; 277 } 278 279 public boolean equals(IPrimitive p1, IPrimitive p2) { 280 return false; 281 } 282 283 public boolean isRelevant(IPrimitive p) { 284 return false; 285 } 286 277 287 public final Collection<IPrimitive> extractRelevantPrimitives(DataSet ds) { 278 288 ArrayList<IPrimitive> result = new ArrayList<>(); … … 284 294 return result; 285 295 } 286 287 public boolean isForbidden(IPrimitive p) {return false;} 288 289 public boolean hasForbiddenTags() {return false;} 290 296 297 public boolean isForbidden(IPrimitive p) { 298 return false; 299 } 300 301 public boolean hasForbiddenTags() { 302 return false; 303 } 304 291 305 public interface ValueReplacer { 292 publicString replace(String value);293 } 294 306 String replace(String value); 307 } 308 295 309 protected final void replace(IPrimitive p, String dataKey, String osmKey) { 296 310 addOrReplace(p, dataKey, osmKey, null, null, null, true); … … 304 318 addOrReplace(p, dataKey, osmKey, dataValues, osmValues, null, true); 305 319 } 306 320 307 321 protected final void add(IPrimitive p, String dataKey, String osmKey, ValueReplacer replacer) { 308 322 addOrReplace(p, dataKey, osmKey, null, null, replacer, false); … … 312 326 addOrReplace(p, dataKey, osmKey, dataValues, osmValues, null, false); 313 327 } 314 315 private final void addOrReplace(IPrimitive p, String dataKey, String osmKey, String[] dataValues, String[] osmValues, ValueReplacer replacer, boolean replace) { 328 329 private void addOrReplace(IPrimitive p, String dataKey, String osmKey, String[] dataValues, String[] osmValues, 330 ValueReplacer replacer, boolean replace) { 316 331 String value = p.get(dataKey); 317 332 if (value != null) { … … 334 349 } 335 350 } 336 337 private finalvoid doAddReplace(IPrimitive p, String dataKey, String osmKey, String osmValue, boolean replace) {351 352 private void doAddReplace(IPrimitive p, String dataKey, String osmKey, String osmValue, boolean replace) { 338 353 if (replace) { 339 354 p.remove(dataKey); … … 345 360 return null; 346 361 } 347 362 348 363 public final String getSourceDate() { 349 364 return sourceDate; 350 365 } 351 366 352 367 public final void setSourceDate(String sourceDate) { 353 368 this.sourceDate = sourceDate; … … 357 372 return name; 358 373 } 359 374 360 375 public final void setName(String name) { 361 376 this.name = name; … … 365 380 return OdConstants.ICON_CORE_24; 366 381 } 367 382 368 383 public String getNationalPortalIconName() { 369 384 return OdConstants.ICON_CORE_24; 370 385 } 371 386 372 387 public String getDataLayerIconName() { 373 388 return OdConstants.ICON_CORE_16; 374 389 } 375 390 376 391 public ExtendedSourceEntry getMapPaintStyle() { 377 392 return null; … … 387 402 388 403 protected final ExtendedSourceEntry getMapPaintStyle(String displayName, String fileNameWithoutExtension) { 389 return new ExtendedSourceEntry(displayName, 404 return new ExtendedSourceEntry(displayName, OdConstants.PROTO_RSRC+//"/"+ 390 405 this.getClass().getPackage().getName().replace(".", "/")+"/"+ 391 406 fileNameWithoutExtension+"."+OdConstants.MAPCSS_EXT); 392 407 } 393 408 394 409 public final ImageIcon getMenuIcon() { 395 410 return menuIcon; … … 411 426 return this.associatedFile; 412 427 } 413 428 414 429 public boolean acceptsUrl(String url) { 415 430 URL dataURL = getDataURL(); … … 427 442 return false; 428 443 } 429 444 430 445 // --------- Shapefile handling --------- 431 446 432 447 private ShpHandler shpHandler; 433 448 … … 435 450 shpHandler = handler; 436 451 } 437 452 438 453 public final ShpHandler getShpHandler() { 439 454 return shpHandler; … … 441 456 442 457 // --------- MIF handling --------- 443 458 444 459 private MifHandler mifHandler; 445 460 … … 447 462 mifHandler = handler; 448 463 } 449 464 450 465 public final MifHandler getMifHandler() { 451 466 return mifHandler; … … 453 468 454 469 // --------- GML handling --------- 455 470 456 471 private GmlHandler gmlHandler; 457 472 … … 459 474 gmlHandler = handler; 460 475 } 461 476 462 477 public final GmlHandler getGmlHandler() { 463 478 return gmlHandler; … … 465 480 466 481 // ------------ Archive handling ------------ 467 482 468 483 private ArchiveHandler archiveHandler; 469 484 … … 471 486 archiveHandler = handler; 472 487 } 473 488 474 489 public ArchiveHandler getArchiveHandler() { 475 490 return archiveHandler; 476 491 } 477 492 478 493 // ------ Spreadsheet handling ---------- 479 494 … … 483 498 ssHandler = handler; 484 499 } 485 500 486 501 public final SpreadSheetHandler getSpreadSheetHandler() { 487 502 return ssHandler; … … 491 506 setSpreadSheetHandler(handler); 492 507 } 493 508 494 509 public final CsvHandler getCsvHandler() { 495 510 if (ssHandler instanceof CsvHandler) { … … 499 514 } 500 515 } 501 516 502 517 // Tools 503 518 504 519 private final Collection<JosmAction> tools = new ArrayList<>(); 505 520 506 521 public final Collection<JosmAction> getTools() { 507 522 return tools; 508 523 } 509 524 510 525 public final boolean addTool(JosmAction tool) { 511 526 return tool != null ? tools.add(tool) : false; 512 527 } 513 528 514 529 public final boolean removeTool(JosmAction tool) { 515 530 return tool != null ? tools.remove(tool) : false; -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/SimpleDataSetHandler.java
r30723 r32545 28 28 private final List<Tag> relevantTags = new ArrayList<>(); 29 29 private final List<Tag> forbiddenTags = new ArrayList<>(); 30 30 31 31 private final boolean relevantUnion; 32 32 33 33 public SimpleDataSetHandler() { 34 34 this.relevantUnion = false; 35 35 } 36 36 37 37 public SimpleDataSetHandler(String relevantTag) { 38 38 addRelevantTag(relevantTag); … … 47 47 setMenuIcon(MapPaintStyles.getNodeIcon(tag)); 48 48 } 49 49 50 50 public SimpleDataSetHandler(boolean relevantUnion, String ... relevantTags) { 51 51 addRelevantTag(relevantTags); … … 61 61 this.relevantUnion = false; 62 62 } 63 63 64 64 public SimpleDataSetHandler(boolean relevantUnion, Tag ... relevantTags) { 65 65 addRelevantTag(relevantTags); … … 86 86 addTags(this.forbiddenTags, forbiddenTags); 87 87 } 88 89 private finalvoid addTags(final List<Tag> list, String ... tags) {88 89 private void addTags(final List<Tag> list, String ... tags) { 90 90 if (tags != null) { 91 91 for (String tag : tags) { … … 102 102 } 103 103 104 private finalvoid addTags(final List<Tag> list, Tag ... tags) {104 private void addTags(final List<Tag> list, Tag ... tags) { 105 105 if (tags != null) { 106 106 for (Tag tag : tags) { … … 111 111 } 112 112 } 113 113 114 114 @Override 115 115 public boolean equals(IPrimitive p1, IPrimitive p2) { … … 135 135 return true; 136 136 } 137 137 138 138 @Override 139 139 public boolean isForbidden(IPrimitive p) { … … 163 163 String[] mpconditions = new String[conditions.length+1]; 164 164 mpconditions[0] = OverpassApi.hasKey("type", "multipolygon"); 165 for (int i =0; i<conditions.length; i++) {165 for (int i = 0; i < conditions.length; i++) { 166 166 mpconditions[i+1] = conditions[i]; 167 167 } 168 return OverpassApi.query(bbox, NODE, conditions) + "\n" + // Nodes 169 170 OverpassApi.query(bbox, WAY, conditions) + "\n" + // Full ways and their full relations171 172 173 174 175 } 176 168 return OverpassApi.query(bbox, NODE, conditions) + "\n" + // Nodes 169 OverpassApi.recurse(NODE_RELATION, RELATION_WAY, WAY_NODE) + "\n" + 170 OverpassApi.query(bbox, WAY, conditions) + "\n" + // Full ways and their full relations 171 OverpassApi.recurse(WAY_NODE, "nodes") + "\n" + 172 OverpassApi.recurse(WAY_RELATION, RELATION_WAY, WAY_NODE) + "\n" + 173 OverpassApi.query(bbox, RELATION, mpconditions) + "\n" + // Full multipolygons 174 OverpassApi.recurse(RELATION_WAY, WAY_NODE); 175 } 176 177 177 @Override 178 178 protected String getOverpassApiRequest(String bbox) { … … 180 180 if (this.relevantUnion) { 181 181 for (Tag tag : this.relevantTags) { 182 result += getOverpassApiQueries(bbox, OverpassApi.hasKey(tag.getKey(), tag.getValue())); 182 result += getOverpassApiQueries(bbox, OverpassApi.hasKey(tag.getKey(), tag.getValue())); 183 183 } 184 184 result = OverpassApi.union(result); -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/WayCombiner.java
r31655 r32545 26 26 27 27 // FIXME: Try to refactor CombineWayAction instead of using this class 28 public class WayCombiner { 29 28 public final class WayCombiner { 29 30 private WayCombiner() { 31 // Hide default constructor for utilities classes 32 } 33 30 34 protected static Way getTargetWay(Collection<Way> combinedWays) { 31 35 // init with an arbitrary way … … 42 46 return targetWay; 43 47 } 44 45 /** 46 * @param ways 47 * @throws UserCancelException 48 */ 48 49 49 public static void combineWays(Collection<Way> ways) throws UserCancelException { 50 50 … … 103 103 ReverseWayTagCorrector reverseWayTagCorrector = new ReverseWayTagCorrector(); 104 104 List<Way> reversedTagWays = new ArrayList<>(); 105 Collection<Command> changePropertyCommands = 105 Collection<Command> changePropertyCommands = null; 106 106 for (Way w : reversedWays) { 107 107 Way wnew = new Way(w); … … 138 138 parentRelations, 139 139 ways 140 );140 ); 141 141 dialog.prepareDefaultDecisions(); 142 142 … … 146 146 dialog.setVisible(true); 147 147 //if (dialog.isCanceled()) // FIXME 148 148 throw new UserCancelException(); 149 149 } 150 150 -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/at/AustrianConstants.java
r30723 r32545 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.opendata.core.datasets.at; 3 4 3 5 4 public interface AustrianConstants { … … 8 7 * Icon 9 8 */ 10 public static finalString ICON_AT_24 = "at24.png";9 String ICON_AT_24 = "at24.png"; 11 10 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/at/AustrianGmlHandler.java
r30723 r32545 13 13 public CoordinateReferenceSystem getCrsFor(String crsName) 14 14 throws NoSuchAuthorityCodeException, FactoryException { 15 15 16 16 // See http://www.esri-austria.at/downloads/coords_at.html 17 17 18 18 if (crsName != null && crsName.startsWith("AUT")) { 19 // CHECKSTYLE.OFF: LineLength 19 20 if (crsName.equalsIgnoreCase("AUT-GK28")) { // Gauß-Krüger, Meridianstreifen M28 20 21 return CRS.decode("EPSG:31281"); 21 22 22 23 } else if (crsName.equalsIgnoreCase("AUT-GK31")) { // Gauß-Krüger, Meridianstreifen M31 23 24 return CRS.decode("EPSG:31282"); 24 25 25 26 } else if (crsName.equalsIgnoreCase("AUT-GK34")) { // Gauß-Krüger, Meridianstreifen M34 26 27 return CRS.decode("EPSG:31283"); 27 28 28 29 } else if (crsName.equalsIgnoreCase("AUT-GK28-5")) { // Gauß-Krüger, Meridianstreifen M28, ohne 5 Mio. im Hochwert 29 30 return CRS.decode("EPSG:31251"); 30 31 31 32 } else if (crsName.equalsIgnoreCase("AUT-GK31-5")) { // Gauß-Krüger, Meridianstreifen M31, ohne 5 Mio. im Hochwert 32 33 return CRS.decode("EPSG:31252"); 33 34 34 35 } else if (crsName.equalsIgnoreCase("AUT-GK34-5")) { // Gauß-Krüger, Meridianstreifen M34, ohne 5 Mio. im Hochwert 35 36 return CRS.decode("EPSG:31253"); 36 37 37 38 } else if (crsName.equalsIgnoreCase("AUT-BM28")) { // Bundesmeldenetz, Meridianstreifen M28 38 39 return CRS.decode("EPSG:31288"); 39 40 40 41 } else if (crsName.equalsIgnoreCase("AUT-BM31")) { // Bundesmeldenetz, Meridianstreifen M31 41 42 return CRS.decode("EPSG:31289"); 42 43 43 44 } else if (crsName.equalsIgnoreCase("AUT-BM34")) { // Bundesmeldenetz, Meridianstreifen M34 44 45 return CRS.decode("EPSG:31290"); 45 46 46 47 } else if (crsName.equalsIgnoreCase("AUT-LM")) { // Lambertsche Kegelprojektion (geogr. Breite des Koo.Ursprungs = 47°30') 47 48 return CRS.decode("EPSG:31287"); 48 49 49 50 } else if (crsName.equalsIgnoreCase("AUT-LL-BESSEL")) { // Geographische Koordinaten auf dem Bessel-Ellipsoid, Längenzählung nach Greenwich 50 51 // See http://josebatiz.com/granvision/Almap/Install/Data1/_B5694C166D6A4B5390B1E547C6A1FAF6 51 52 // FIXME 52 53 } 54 // CHECKSTYLE.ON: LineLength 53 55 } 54 56 return super.getCrsFor(crsName); -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/au/AustralianConstants.java
r30723 r32545 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.opendata.core.datasets.au; 3 4 3 5 4 public interface AustralianConstants { … … 8 7 * Portal 9 8 */ 10 public static finalString AUSTRALIAN_PORTAL = "http://data.gov.au/dataset/";11 9 String AUSTRALIAN_PORTAL = "http://data.gov.au/dataset/"; 10 12 11 /** 13 12 * Icon 14 13 */ 15 public static finalString ICON_AU_24 = "au24.png";14 String ICON_AU_24 = "au24.png"; 16 15 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/be/BelgianConstants.java
r30723 r32545 9 9 * Portal 10 10 */ 11 public static finalString BELGIAN_PORTAL = "http://data.gov.be/"+OdConstants.PATTERN_LANG+"/dataset/";12 11 String BELGIAN_PORTAL = "http://data.gov.be/"+OdConstants.PATTERN_LANG+"/dataset/"; 12 13 13 /** 14 14 * Icon 15 15 */ 16 public static finalString ICON_BE_24 = "be24.png";16 String ICON_BE_24 = "be24.png"; 17 17 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/be/BelgianDataSetHandler.java
r30723 r32545 26 26 protected static final Projection lambert1972 = OdConstants.PRJ_LAMBERT_1972.getProjection(); 27 27 protected static final Projection lambert2008 = OdConstants.PRJ_LAMBERT_2008.getProjection(); 28 28 29 29 protected static final Projection[] projections = new Projection[]{ 30 lambert1972,31 lambert200830 lambert1972, 31 lambert2008 32 32 }; 33 33 34 34 protected class InternalCsvHandler extends DefaultCsvHandler { 35 35 /*@Override … … 41 41 } 42 42 }*/ 43 43 44 44 @Override 45 45 public LatLon getCoor(EastNorth en, String[] fields) { … … 70 70 init(); 71 71 } 72 72 73 73 private void init() { 74 74 setCsvHandler(new InternalCsvHandler()); 75 75 } 76 76 77 protected final void setNationalPortalPath(String nationalPortalPathDe, String nationalPortalPathEn, String nationalPortalPathFr, String nationalPortalPathNl) { 77 protected final void setNationalPortalPath(String nationalPortalPathDe, String nationalPortalPathEn, 78 String nationalPortalPathFr, String nationalPortalPathNl) { 78 79 this.nationalPortalPathDe = nationalPortalPathDe; 79 80 this.nationalPortalPathEn = nationalPortalPathEn; … … 95 96 lang = Locale.getDefault().toString(); 96 97 } 97 98 98 99 if (lang.startsWith("de") && nationalPortalPathDe != null) { 99 100 nationalPortalPath = nationalPortalPathDe; … … 105 106 nationalPortalPath = nationalPortalPathEn; 106 107 } 107 return new URL(BELGIAN_PORTAL.replace(OdConstants.PATTERN_LANG, lang.substring(0, 2))+nationalPortalPath); //FIXME108 return new URL(BELGIAN_PORTAL.replace(OdConstants.PATTERN_LANG, lang.substring(0, 2))+nationalPortalPath); //FIXME 108 109 } catch (MalformedURLException e) { 109 110 e.printStackTrace(); -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/ca/CanadianConstants.java
r30723 r32545 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.opendata.core.datasets.ca; 3 4 3 5 4 public interface CanadianConstants { … … 8 7 * Portal 9 8 */ 10 public static finalString CANADIAN_PORTAL = "http://www.data.gc.ca/geo/";11 9 String CANADIAN_PORTAL = "http://www.data.gc.ca/geo/"; 10 12 11 /** 13 12 * Icon 14 13 */ 15 public static finalString ICON_CA_24 = "ca24.png";14 String ICON_CA_24 = "ca24.png"; 16 15 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/cl/ChileanConstants.java
r30723 r32545 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.opendata.core.datasets.cl; 3 4 3 5 4 public interface ChileanConstants { … … 8 7 * Portal 9 8 */ 10 public static finalString CHILEAN_PORTAL = "http://datos.gob.cl/datasets/";11 9 String CHILEAN_PORTAL = "http://datos.gob.cl/datasets/"; 10 12 11 /** 13 12 * Icon 14 13 */ 15 public static finalString ICON_CL_24 = "cl24.png";14 String ICON_CL_24 = "cl24.png"; 16 15 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/es/SpanishConstants.java
r30723 r32545 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.opendata.core.datasets.es; 3 4 3 5 4 public interface SpanishConstants { … … 8 7 * Portal 9 8 */ 10 public static finalString SPANISH_PORTAL = "http://datos.gob.es/datos/";11 9 String SPANISH_PORTAL = "http://datos.gob.es/datos/"; 10 12 11 /** 13 12 * Icon 14 13 */ 15 public static finalString ICON_ES_24 = "es24.png";14 String ICON_ES_24 = "es24.png"; 16 15 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/fr/FrenchConstants.java
r30723 r32545 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.opendata.core.datasets.fr; 3 4 3 5 4 public interface FrenchConstants { … … 8 7 * Portal 9 8 */ 10 public static finalString FRENCH_PORTAL = "http://www.data.gouv.fr/";11 9 String FRENCH_PORTAL = "http://www.data.gouv.fr/"; 10 12 11 /** 13 12 * Icon 14 13 */ 15 public static finalString ICON_FR_24 = "fr24.png";16 14 String ICON_FR_24 = "fr24.png"; 15 17 16 /** 18 17 * NEPTUNE XML Schema 19 18 */ 20 public static finalString NEPTUNE_XSD = "/resources/neptune/neptune.xsd";19 String NEPTUNE_XSD = "/resources/neptune/neptune.xsd"; 21 20 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/fr/FrenchDataSetHandler.java
r30723 r32545 30 30 protected static final Projection utm38 = Projections.getProjectionByCode("EPSG:32738"); // UTM 38 S - Mayotte 31 31 protected static final Projection utm40 = Projections.getProjectionByCode("EPSG:32740"); // UTM 40 S - Reunion 32 32 33 33 protected static final Projection[] lambert4Zones = new Projection[4]; 34 34 static { 35 for (int i =0; i<lambert4Zones.length; i++) {35 for (int i = 0; i < lambert4Zones.length; i++) { 36 36 lambert4Zones[i] = Projections.getProjectionByCode("EPSG:"+Integer.toString(27561+i)); 37 37 } … … 39 39 40 40 protected static final Projection[] projections = new Projection[]{ 41 lambert93, // France metropolitaine42 utm20, // Guadeloupe, Martinique43 utm22, // Guyane44 utm38, // Mayotte45 utm40, // Reunion41 lambert93, // France metropolitaine 42 utm20, // Guadeloupe, Martinique 43 utm22, // Guyane 44 utm38, // Mayotte 45 utm40, // Reunion 46 46 }; 47 47 48 48 protected class InternalCsvHandler extends DefaultCsvHandler { 49 49 /*@Override … … 55 55 } 56 56 }*/ 57 57 58 58 @Override 59 59 public LatLon getCoor(EastNorth en, String[] fields) { … … 89 89 init(); 90 90 } 91 91 92 92 private void init() { 93 93 setShpHandler(new FrenchShpHandler()); … … 124 124 return ICON_FR_24; 125 125 } 126 126 127 127 protected static final LatLon getLatLonByDptCode(EastNorth en, String dpt, boolean useCC9) { 128 // CHECKSTYLE.OFF: LineLength 128 129 if (dpt.equals("971") || dpt.equals("972") || dpt.equals("977") || dpt.equals("978")) { // Antilles 129 130 return utm20.eastNorth2latlon(en); … … 157 158 throw new IllegalArgumentException("Unsupported department code: "+dpt); 158 159 } 160 // CHECKSTYLE.ON: LineLength 159 161 } 160 162 … … 170 172 replaceFaxPhone(p, dataKey, "contact:fax"); 171 173 } 172 174 173 175 protected void replacePhone(OsmPrimitive p, String dataKey) { 174 176 replaceFaxPhone(p, dataKey, "contact:phone"); 175 177 } 176 178 177 179 private static final String dayFr = "L|Lu|M|Ma|Me|J|Je|V|Ve|S|Sa|D|Di"; 178 180 private static final String dayEn = "Mo|Mo|Tu|Tu|We|Th|Th|Fr|Fr|Sa|Sa|Su|Su"; 179 181 180 182 private static final String[] dayFrSplit = dayFr.split("\\|"); 181 183 private static final String[] dayEnSplit = dayEn.split("\\|"); 182 184 183 185 protected void replaceOpeningHours(OsmPrimitive p, String dataKey) { 184 186 String hours = p.get(dataKey); … … 194 196 String dayNcGroup = "(?:"+dayFr+")"; 195 197 // FIXME: this doesn't work yet 196 for (String sep : new String[]{"-", ","}) {198 for (String sep : new String[]{"-", ","}) { 197 199 boolean finished = false; 198 200 while (!finished) { … … 203 205 if (m2.matches()) { 204 206 String replacement = ""; 205 for (int i =0; i<m2.groupCount(); i++) {207 for (int i = 0; i < m2.groupCount(); i++) { 206 208 if (i > 0) { 207 209 replacement += sep; … … 220 222 } 221 223 } 222 224 223 225 private String getEnDay(String frDay) { 224 for (int i =0; i<dayFrSplit.length; i++) {226 for (int i = 0; i < dayFrSplit.length; i++) { 225 227 if (dayFrSplit[i].equals(frDay)) { 226 228 return dayEnSplit[i]; -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/fr/FrenchShpHandler.java
r30723 r32545 32 32 if (sourceCRS instanceof ProjectedCRS) { 33 33 GeodeticDatum datum = ((ProjectedCRS) sourceCRS).getDatum(); 34 if (datum.getPrimeMeridian().getGreenwichLongitude() > 0.0 && ((ProjectedCRS) sourceCRS).getConversionFromBase().getMathTransform() instanceof LambertConformal2SP) { 34 if (datum.getPrimeMeridian().getGreenwichLongitude() > 0.0 35 && ((ProjectedCRS) sourceCRS).getConversionFromBase().getMathTransform() instanceof LambertConformal2SP) { 35 36 LambertConformal2SP lambert = (LambertConformal2SP) ((ProjectedCRS) sourceCRS).getConversionFromBase().getMathTransform(); 36 37 Double falseNorthing = get(lambert.getParameterValues(), AbstractProvider.FALSE_NORTHING); -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/it/ItalianConstants.java
r30723 r32545 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.opendata.core.datasets.it; 3 4 3 5 4 public interface ItalianConstants { … … 8 7 * Portal 9 8 */ 10 public static finalString ITALIAN_PORTAL = "http://www.dati.gov.it/content/";11 9 String ITALIAN_PORTAL = "http://www.dati.gov.it/content/"; 10 12 11 /** 13 12 * Icon 14 13 */ 15 public static finalString ICON_IT_24 = "it24.png";14 String ICON_IT_24 = "it24.png"; 16 15 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/ke/KenyanConstants.java
r30723 r32545 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.opendata.core.datasets.ke; 3 4 3 5 4 public interface KenyanConstants { … … 8 7 * Portal 9 8 */ 10 public static finalString KENYAN_PORTAL = "https://opendata.go.ke/";11 9 String KENYAN_PORTAL = "https://opendata.go.ke/"; 10 12 11 /** 13 12 * Icon 14 13 */ 15 public static finalString ICON_KE_24 = "ke24.png";14 String ICON_KE_24 = "ke24.png"; 16 15 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/nl/DutchConstants.java
r30723 r32545 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.opendata.core.datasets.nl; 3 4 3 5 4 public interface DutchConstants { … … 8 7 * Portal 9 8 */ 10 public static finalString NORWEGIAN_PORTAL = "http://data.overheid.nl/package/";11 9 String NORWEGIAN_PORTAL = "http://data.overheid.nl/package/"; 10 12 11 /** 13 12 * Icon 14 13 */ 15 public static finalString ICON_NL_24 = "nl24.png";14 String ICON_NL_24 = "nl24.png"; 16 15 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/no/NorwegianConstants.java
r30723 r32545 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.opendata.core.datasets.no; 3 4 3 5 4 public interface NorwegianConstants { … … 8 7 * Portal 9 8 */ 10 public static finalString NORWEGIAN_PORTAL = "http://data.norge.no/data/";11 9 String NORWEGIAN_PORTAL = "http://data.norge.no/data/"; 10 12 11 /** 13 12 * Icon 14 13 */ 15 public static finalString ICON_NO_24 = "no24.png";14 String ICON_NO_24 = "no24.png"; 16 15 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/nz/NewZealanderConstants.java
r30723 r32545 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.opendata.core.datasets.nz; 3 4 3 5 4 public interface NewZealanderConstants { … … 8 7 * Portal 9 8 */ 10 public static finalString NEW_ZEALANDER_PORTAL = "http://data.govt.nz/dataset/";11 9 String NEW_ZEALANDER_PORTAL = "http://data.govt.nz/dataset/"; 10 12 11 /** 13 12 * Icon 14 13 */ 15 public static finalString ICON_NZ_24 = "nz24.png";14 String ICON_NZ_24 = "nz24.png"; 16 15 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/pt/PortugueseConstants.java
r30723 r32545 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.opendata.core.datasets.pt; 3 4 3 5 4 public interface PortugueseConstants { … … 8 7 * Portal 9 8 */ 10 public static finalString PORTUGUESE_PORTAL = "http://www.dados.gov.pt/PT/CatalogoDados/Dados.aspx?name=";11 9 String PORTUGUESE_PORTAL = "http://www.dados.gov.pt/PT/CatalogoDados/Dados.aspx?name="; 10 12 11 /** 13 12 * Icon 14 13 */ 15 public static finalString ICON_PT_24 = "pt24.png";14 String ICON_PT_24 = "pt24.png"; 16 15 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/uk/BritishConstants.java
r30723 r32545 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.opendata.core.datasets.uk; 3 4 3 5 4 public interface BritishConstants { … … 8 7 * Portal 9 8 */ 10 public static finalString BRITISH_PORTAL = "http://data.gov.uk/dataset/";11 9 String BRITISH_PORTAL = "http://data.gov.uk/dataset/"; 10 12 11 /** 13 12 * Icon 14 13 */ 15 public static finalString ICON_UK_24 = "uk24.png";14 String ICON_UK_24 = "uk24.png"; 16 15 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/us/AmericanConstants.java
r30723 r32545 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.opendata.core.datasets.us; 3 4 3 5 4 public interface AmericanConstants { … … 8 7 * Portal 9 8 */ 10 public static finalString AMERICAN_PORTAL = "http://explore.data.gov/";11 9 String AMERICAN_PORTAL = "http://explore.data.gov/"; 10 12 11 /** 13 12 * Icon 14 13 */ 15 public static finalString ICON_US_24 = "us24.png";14 String ICON_US_24 = "us24.png"; 16 15 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/gui/DialogPrompter.java
r30723 r32545 8 8 import org.openstreetmap.josm.gui.ExtendedDialog; 9 9 10 public class DialogPrompter 11 10 public class DialogPrompter<T extends ExtendedDialog> implements Runnable { 11 12 12 private T dialog; 13 13 private int value = -1; 14 14 15 protected T buildDialog() {return null;} // To be overriden if needed 16 15 protected T buildDialog() { 16 // To be overriden if needed 17 return null; 18 } 19 17 20 public DialogPrompter() { 18 21 this(null); 19 22 } 20 23 21 24 public DialogPrompter(T dialog) { 22 25 this.dialog = dialog; 23 26 } 24 27 25 28 public final T getDialog() { 26 29 return dialog; 27 30 } 28 31 29 32 @Override 30 33 public final void run() { … … 36 39 } 37 40 } 38 41 39 42 public final DialogPrompter<T> promptInEdt() { 40 43 if (SwingUtilities.isEventDispatchThread()) { -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/gui/ModuleListPanel.java
r30340 r32545 27 27 * 28 28 */ 29 public class ModuleListPanel extends VerticallyScrollablePanel {29 public class ModuleListPanel extends VerticallyScrollablePanel { 30 30 private ModulePreferencesModel model; 31 31 … … 70 70 gbc.anchor = GridBagConstraints.CENTER; 71 71 gbc.fill = GridBagConstraints.BOTH; 72 gbc.insets = new Insets(40, 0,40,0);72 gbc.insets = new Insets(40, 0, 40, 0); 73 73 gbc.weightx = 1.0; 74 74 gbc.weighty = 1.0; 75 75 76 76 HtmlPanel hint = new HtmlPanel(); 77 hint.setText( 78 "<html>" 77 hint.setText("<html>" 79 78 + tr("Please click on <strong>Download list</strong> to download and display a list of available modules.") 80 79 + "</html>" 81 );80 ); 82 81 add(hint, gbc); 83 82 } … … 107 106 cbModule.setSelected(selected); 108 107 cbModule.setToolTipText(formatCheckboxTooltipText(pi)); 109 cbModule.addActionListener(new ActionListener(){ 108 cbModule.addActionListener(new ActionListener() { 109 @Override 110 110 public void actionPerformed(ActionEvent e) { 111 111 model.setModuleSelected(pi.getName(), cbModule.isSelected()); … … 119 119 gbc.gridx = 0; 120 120 gbc.gridy = ++row; 121 gbc.insets = new Insets(5, 5,0,5);121 gbc.insets = new Insets(5, 5, 0, 5); 122 122 gbc.weighty = 0.0; 123 123 gbc.weightx = 0.0; … … 131 131 description.setText(pi.getDescriptionAsHtml()); 132 132 description.getEditorPane().addHyperlinkListener(new HyperlinkListener() { 133 @Override 133 134 public void hyperlinkUpdate(HyperlinkEvent e) { 134 if (e.getEventType() == EventType.ACTIVATED) {135 if (e.getEventType() == EventType.ACTIVATED) { 135 136 OpenBrowser.displayUrl(e.getURL().toString()); 136 137 } … … 140 141 gbc.gridx = 1; 141 142 gbc.gridy = ++row; 142 gbc.insets = new Insets(3, 25,5,5);143 gbc.insets = new Insets(3, 25, 5, 5); 143 144 gbc.weighty = 1.0; 144 145 add(description, gbc); -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/gui/ModulePreference.java
r31048 r32545 67 67 Collection<ModuleInformation> failed = task.getFailedModules(); 68 68 StringBuilder sb = new StringBuilder(); 69 if (! 69 if (!downloaded.isEmpty()) { 70 70 sb.append(trn( 71 71 "The following module has been downloaded <strong>successfully</strong>:", … … 73 73 downloaded.size(), 74 74 downloaded.size() 75 ));75 )); 76 76 sb.append("<ul>"); 77 for (ModuleInformation pi: downloaded) {77 for (ModuleInformation pi : downloaded) { 78 78 sb.append("<li>").append(pi.name).append(" (").append(pi.version).append(")").append("</li>"); 79 79 } 80 80 sb.append("</ul>"); 81 81 } 82 if (! 82 if (!failed.isEmpty()) { 83 83 sb.append(trn( 84 84 "Downloading the following module has <strong>failed</strong>:", … … 86 86 failed.size(), 87 87 failed.size() 88 ));88 )); 89 89 sb.append("<ul>"); 90 for (ModuleInformation pi: failed) {90 for (ModuleInformation pi : failed) { 91 91 sb.append("<li>").append(pi.name).append("</li>"); 92 92 } … … 108 108 109 109 protected JPanel buildSearchFieldPanel() { 110 JPanel pnl 111 pnl.setBorder(BorderFactory.createEmptyBorder(5, 5,5,5));110 JPanel pnl = new JPanel(new GridBagLayout()); 111 pnl.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); 112 112 GridBagConstraints gc = new GridBagConstraints(); 113 113 … … 115 115 gc.fill = GridBagConstraints.HORIZONTAL; 116 116 gc.weightx = 0.0; 117 gc.insets = new Insets(0, 0,0,3);117 gc.insets = new Insets(0, 0, 0, 3); 118 118 pnl.add(new JLabel(tr("Search:")), gc); 119 119 … … 128 128 129 129 protected JPanel buildActionPanel() { 130 JPanel pnl = new JPanel(new GridLayout(1, 3));130 JPanel pnl = new JPanel(new GridLayout(1, 3)); 131 131 132 132 pnl.add(new JButton(new DownloadAvailableModulesAction())); … … 139 139 JPanel pnl = new JPanel(new BorderLayout()); 140 140 pnl.add(buildSearchFieldPanel(), BorderLayout.NORTH); 141 model 141 model = new ModulePreferencesModel(); 142 142 spModulePreferences = new JScrollPane(pnlModulePreferences = new ModuleListPanel(model)); 143 143 spModulePreferences.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); 144 144 spModulePreferences.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); 145 145 spModulePreferences.getVerticalScrollBar().addComponentListener( 146 new ComponentAdapter() {146 new ComponentAdapter() { 147 147 @Override 148 148 public void componentShown(ComponentEvent e) { 149 149 spModulePreferences.setBorder(UIManager.getBorder("ScrollPane.border")); 150 150 } 151 151 152 @Override 152 153 public void componentHidden(ComponentEvent e) { … … 154 155 } 155 156 } 156 );157 ); 157 158 158 159 pnl.add(spModulePreferences, BorderLayout.CENTER); … … 181 182 tr("Accept the new module sites and close the dialog"), 182 183 null /* no special help topic */ 183 ),184 ), 184 185 new ButtonSpec( 185 186 tr("Cancel"), … … 187 188 tr("Close the dialog"), 188 189 null /* no special help topic */ 189 )190 ) 190 191 }; 191 192 ModuleConfigurationSitesPanel pnl = new ModuleConfigurationSitesPanel(); … … 200 201 options[0], 201 202 null /* no help topic */ 202 );203 ); 203 204 if (answer != 0 /* OK */) 204 205 return; … … 218 219 @Override 219 220 public boolean ok() { 220 if (! 221 if (!modulePreferencesActivated) 221 222 return false; 222 223 if (model.isActiveModulesChanged()) { … … 260 261 class DownloadAvailableModulesAction extends AbstractAction { 261 262 262 publicDownloadAvailableModulesAction() {263 putValue(NAME, tr("Download list"));263 DownloadAvailableModulesAction() { 264 putValue(NAME, tr("Download list")); 264 265 putValue(SHORT_DESCRIPTION, tr("Download the list of available modules")); 265 266 putValue(SMALL_ICON, ImageProvider.get("download")); … … 292 293 */ 293 294 class UpdateSelectedModulesAction extends AbstractAction { 294 publicUpdateSelectedModulesAction() {295 putValue(NAME, tr("Update modules"));295 UpdateSelectedModulesAction() { 296 putValue(NAME, tr("Update modules")); 296 297 putValue(SHORT_DESCRIPTION, tr("Update the selected modules")); 297 298 putValue(SMALL_ICON, ImageProvider.get("dialogs", "refresh")); … … 314 315 !failed.isEmpty() ? JOptionPane.WARNING_MESSAGE : JOptionPane.INFORMATION_MESSAGE, 315 316 HelpUtil.ht("/Preferences/Modules") 316 );317 ); 317 318 } 318 319 … … 327 328 JOptionPane.INFORMATION_MESSAGE, 328 329 null // FIXME: provide help context 329 );330 ); 330 331 } 331 332 }); … … 340 341 toUpdate, 341 342 tr("Update modules") 342 );343 ); 343 344 // the async task for downloading module information 344 final ReadRemoteModuleInformationTask moduleInfoDownloadTask = new ReadRemoteModuleInformationTask(OdPreferenceSetting.getModuleSites()); 345 final ReadRemoteModuleInformationTask moduleInfoDownloadTask = 346 new ReadRemoteModuleInformationTask(OdPreferenceSetting.getModuleSites()); 345 347 346 348 // to be run asynchronously after the module download … … 374 376 // 375 377 Iterator<ModuleInformation> it = toUpdate.iterator(); 376 while (it.hasNext()) {378 while (it.hasNext()) { 377 379 ModuleInformation pi = it.next(); 378 380 if (!pi.isUpdateRequired()) { … … 395 397 } 396 398 397 398 399 /** 399 400 * The action for configuring the module download sites … … 401 402 */ 402 403 class ConfigureSitesAction extends AbstractAction { 403 publicConfigureSitesAction() {404 putValue(NAME, tr("Configure sites..."));404 ConfigureSitesAction() { 405 putValue(NAME, tr("Configure sites...")); 405 406 putValue(SHORT_DESCRIPTION, tr("Configure the list of sites where modules are downloaded from")); 406 407 putValue(SMALL_ICON, ImageProvider.get("dialogs", "settings")); … … 420 421 class ModulePreferenceActivationListener implements ChangeListener { 421 422 private Component pane; 422 publicModulePreferenceActivationListener(Component preferencesPane) {423 ModulePreferenceActivationListener(Component preferencesPane) { 423 424 pane = preferencesPane; 424 425 } … … 426 427 @Override 427 428 public void stateChanged(ChangeEvent e) { 428 JTabbedPane tp = (JTabbedPane) e.getSource();429 JTabbedPane tp = (JTabbedPane) e.getSource(); 429 430 if (tp.getSelectedComponent() == pane) { 430 431 readLocalModuleInformation(); … … 464 465 } 465 466 466 static privateclass ModuleConfigurationSitesPanel extends JPanel {467 private static class ModuleConfigurationSitesPanel extends JPanel { 467 468 468 469 private DefaultListModel<String> model; … … 478 479 add(new JScrollPane(list), GBC.std().fill()); 479 480 JPanel buttons = new JPanel(new GridBagLayout()); 480 buttons.add(new JButton(new AbstractAction(tr("Add")) {481 buttons.add(new JButton(new AbstractAction(tr("Add")) { 481 482 @Override 482 483 public void actionPerformed(ActionEvent e) { … … 486 487 tr("Enter URL"), 487 488 JOptionPane.QUESTION_MESSAGE 488 );489 ); 489 490 if (s != null) { 490 491 model.addElement(s); … … 492 493 } 493 494 }), GBC.eol().fill(GBC.HORIZONTAL)); 494 buttons.add(new JButton(new AbstractAction(tr("Edit")) {495 buttons.add(new JButton(new AbstractAction(tr("Edit")) { 495 496 @Override 496 497 public void actionPerformed(ActionEvent e) { … … 501 502 tr("Warning"), 502 503 JOptionPane.WARNING_MESSAGE 503 );504 ); 504 505 return; 505 506 } 506 String s = (String) JOptionPane.showInputDialog(507 String s = (String) JOptionPane.showInputDialog( 507 508 Main.parent, 508 509 tr("Edit Open Data Module description URL."), … … 512 513 null, 513 514 list.getSelectedValue() 514 );515 ); 515 516 if (s != null) { 516 517 model.setElementAt(s, list.getSelectedIndex()); … … 518 519 } 519 520 }), GBC.eol().fill(GBC.HORIZONTAL)); 520 buttons.add(new JButton(new AbstractAction(tr("Delete")) {521 buttons.add(new JButton(new AbstractAction(tr("Delete")) { 521 522 @Override 522 523 public void actionPerformed(ActionEvent event) { … … 527 528 tr("Warning"), 528 529 JOptionPane.WARNING_MESSAGE 529 );530 ); 530 531 return; 531 532 } … … 536 537 } 537 538 538 publicModuleConfigurationSitesPanel() {539 ModuleConfigurationSitesPanel() { 539 540 build(); 540 541 } … … 543 544 if (model.getSize() == 0) return Collections.emptyList(); 544 545 List<String> ret = new ArrayList<>(model.getSize()); 545 for (int i =0; i< model.getSize();i++){546 for (int i = 0; i < model.getSize(); i++) { 546 547 ret.add(model.get(i)); 547 548 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/gui/ModulePreferencesModel.java
r30723 r32545 31 31 return Main.pref.getCollection(OdConstants.PREF_MODULES, def); 32 32 } 33 33 34 34 public ModulePreferencesModel() { 35 35 currentActiveModules = new HashSet<>(); … … 75 75 } 76 76 77 protected 77 protected void updateAvailableModule(ModuleInformation other) { 78 78 if (other == null) return; 79 79 ModuleInformation pi = getModuleInformation(other.name); … … 148 148 availableModules, 149 149 new Comparator<ModuleInformation>() { 150 @Override 150 151 public int compare(ModuleInformation o1, ModuleInformation o2) { 151 152 String n1 = o1.getName() == null ? "" : o1.getName().toLowerCase(); … … 154 155 } 155 156 } 156 );157 ); 157 158 } 158 159 … … 193 194 ModuleInformation pi = getModuleInformation(name); 194 195 if (pi != null) { 195 selectedModulesMap.put(pi, selected);196 selectedModulesMap.put(pi, selected); 196 197 if (pi.isUpdateRequired()) { 197 198 pendingDownloads.add(pi.name); … … 209 210 * @param modules the list of modules to clear for a pending download 210 211 */ 211 public void clearPendingModules(Collection<ModuleInformation> modules) {212 public void clearPendingModules(Collection<ModuleInformation> modules) { 212 213 if (modules == null || modules.isEmpty()) return; 213 for (ModuleInformation pi: modules) {214 for (ModuleInformation pi : modules) { 214 215 pendingDownloads.remove(pi.name); 215 216 } … … 324 325 public boolean isActiveModulesChanged() { 325 326 Set<String> newActiveModules = getSelectedModuleNames(); 326 return ! 327 return !newActiveModules.equals(currentActiveModules); 327 328 } 328 329 … … 355 356 } 356 357 oldinfo.localversion = newinfo.version; 357 } catch (ModuleException e) {358 } catch (ModuleException e) { 358 359 e.printStackTrace(); 359 360 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/gui/OdDialog.java
r32525 r32545 36 36 private final SideButton diffButton; 37 37 private final SideButton toolsButton; 38 38 39 39 private final List<SideButton> buttons; 40 40 41 41 private final TreeModel treeModel; 42 42 43 43 private OdDataLayer dataLayer; 44 44 45 45 private class DownloadAction extends JosmAction { 46 publicDownloadAction() {46 DownloadAction() { 47 47 super(marktr("Download"), "download", tr("Download OSM data corresponding to the current data set."), null, false); 48 48 } 49 49 50 @Override 50 51 public void actionPerformed(ActionEvent e) { … … 57 58 58 59 private class SelectAction extends JosmAction { 59 public SelectAction() { 60 super(marktr("Select"), "dialogs/select", tr("Set the selected elements on the map to the selected items in the list above."), null, false); 60 SelectAction() { 61 super(marktr("Select"), "dialogs/select", 62 tr("Set the selected elements on the map to the selected items in the list above."), null, false); 61 63 } 64 62 65 @Override 63 66 public void actionPerformed(ActionEvent e) { … … 67 70 68 71 private class DiffAction extends JosmAction { 69 publicDiffAction() {72 DiffAction() { 70 73 super(marktr("Diff"), "dialogs/diff", tr("Perform diff between current data set and existing OSM data."), null, false); 71 74 } 75 72 76 @Override 73 77 public void actionPerformed(ActionEvent e) { … … 77 81 } 78 82 } 79 83 80 84 private class ToolsAction extends JosmAction { 81 publicToolsAction() {85 ToolsAction() { 82 86 super(marktr("Tools"), "dialogs/utils", tr("Open tools menu for this data."), null, false); 83 87 } 88 84 89 @Override 85 90 public void actionPerformed(ActionEvent e) { … … 89 94 90 95 public OdDialog() { 91 super("OpenData", OdConstants.ICON_CORE_24, tr("Open the OpenData window."), 96 super("OpenData", OdConstants.ICON_CORE_24, tr("Open the OpenData window."), 92 97 Shortcut.registerShortcut("subwindow:opendata", tr("Toggle: {0}", "OpenData"), 93 98 KeyEvent.VK_A, Shortcut.ALT_CTRL_SHIFT), 150, false, OdPreferenceSetting.class); 94 99 95 100 this.buttons = Arrays.asList(new SideButton[] { 96 /*selectButton =*/ new SideButton(new SelectAction()), 97 downloadButton = new SideButton(new DownloadAction()), 101 /*selectButton =*/ new SideButton(new SelectAction()), 102 downloadButton = new SideButton(new DownloadAction()), 98 103 diffButton = new SideButton(new DiffAction()), 99 104 toolsButton = new SideButton(new ToolsAction()) 100 105 }); 101 106 102 107 this.toolsButton.addMouseListener(new MouseAdapter() { 103 108 @Override … … 112 117 } 113 118 }); 114 119 115 120 disableAllButtons(); 116 121 117 122 this.treeModel = new DefaultTreeModel(null); // TODO: treeNode 118 123 this.dataLayer = null; 119 124 120 125 createLayout(new JTree(treeModel), true, buttons); 121 126 122 127 Main.getLayerManager().addActiveLayerChangeListener(this); 123 128 } … … 137 142 dataLayer = null; 138 143 } 139 144 140 145 if (dataLayer != null) { 141 146 if (dataLayer.osmLayer == null) { -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/gui/OdPreferenceSetting.java
r30723 r32545 34 34 //private final JRadioButton rbCC43 = new JRadioButton(tr("CC43")); 35 35 //private final JRadioButton rbWGS84 = new JRadioButton(tr("WGS84")); 36 36 37 37 private final JTextField oapi = new JTextField(); 38 38 private final JTextField xapi = new JTextField(); 39 39 40 40 private final JCheckBox rawData = new JCheckBox(tr("Raw data")); 41 41 42 42 public final JTabbedPane tabPane = new JTabbedPane(); 43 43 public JPanel masterPanel; 44 44 45 45 private final ModulePreference modulePref = new ModulePreference(); 46 46 … … 51 51 "before any upload of data loaded by this plugin.")); 52 52 } 53 53 54 54 /** 55 55 * Replies the collection of module site URLs from where module lists can be downloaded 56 56 * 57 * @return 57 * @return the collection of module site URLs from where module lists can be downloaded 58 58 */ 59 59 public static final Collection<String> getModuleSites() { … … 69 69 Main.pref.putCollection(OdConstants.PREF_MODULES_SITES, sites); 70 70 } 71 71 72 72 @Override 73 73 public void addGui(PreferenceTabbedPane gui) { … … 75 75 modulePref.addGui(gui); 76 76 tabPane.add(createGeneralSettings()); 77 77 78 78 JScrollPane scrollpane = new JScrollPane(tabPane); 79 scrollpane.setBorder(BorderFactory.createEmptyBorder( 0, 0, 0, 0));79 scrollpane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); 80 80 masterPanel.add(scrollpane, GBC.eol().fill(GBC.BOTH)); 81 81 } … … 83 83 protected JPanel createGeneralSettings() { 84 84 JPanel general = new JPanel(new GridBagLayout()); 85 general.setBorder(BorderFactory.createEmptyBorder(0, 0,0,0));85 general.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); 86 86 general.setName(tr("General settings")); 87 87 … … 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)); 92 92 93 93 // separator 94 94 general.add(new JSeparator(SwingConstants.HORIZONTAL), GBC.eol().fill(GBC.HORIZONTAL)); 95 95 96 96 // option to select the coordinates to use 97 /* JLabel jLabelRes = new JLabel(tr("Coordinates system to read in CSV files:"));97 /* JLabel jLabelRes = new JLabel(tr("Coordinates system to read in CSV files:")); 98 98 p.add(jLabelRes, GBC.std().insets(0, 5, 10, 0)); 99 99 ButtonGroup bgCoordinates = new ButtonGroup(); … … 116 116 general.add(jLabelOapi, GBC.std().insets(0, 5, 10, 0)); 117 117 general.add(oapi, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 5, 200, 5)); 118 118 119 119 // option to set the XAPI server 120 120 JLabel jLabelXapi = new JLabel(tr("XAPI server:")); … … 123 123 general.add(jLabelXapi, GBC.std().insets(0, 5, 10, 0)); 124 124 general.add(xapi, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 5, 200, 5)); 125 125 126 126 // end of dialog, scroll bar 127 127 general.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.VERTICAL)); 128 128 129 129 return general; 130 130 } 131 131 132 132 @Override 133 133 public boolean ok() { 134 134 boolean result = modulePref.ok(); 135 136 137 138 139 135 //Main.pref.put(PREF_COORDINATES, rbWGS84.isSelected() ? VALUE_WGS84 : VALUE_CC9ZONES); 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 140 140 // create a task for downloading modules if the user has activated, yet not downloaded, 141 141 // new modules … … 143 143 final List<ModuleInformation> toDownload = modulePref.getModulesScheduledForUpdateOrDownload(); 144 144 final ModuleDownloadTask task; 145 if (toDownload != null && ! 145 if (toDownload != null && !toDownload.isEmpty()) { 146 146 task = new ModuleDownloadTask(masterPanel, toDownload, tr("Download modules")); 147 147 } else { 148 148 task = null; 149 149 } 150 150 151 151 // this is the task which will run *after* the modules are downloaded 152 152 // 153 153 final Runnable continuation = new Runnable() { 154 @Override 154 155 public void run() { 155 156 boolean requiresRestart = false; … … 195 196 Main.worker.submit( 196 197 new Runnable() { 198 @Override 197 199 public void run() { 198 200 SwingUtilities.invokeLater(continuation); -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/gui/ProjectionChooser.java
r30723 r32545 52 52 private JLabel projectionName = new JLabel(); 53 53 private JLabel bounds = new JLabel(); 54 54 55 55 /** 56 56 * This is the panel holding all projection preferences … … 68 68 this(parent, tr("Projection method"), new String[] {tr("OK"), tr("Cancel")}); 69 69 } 70 70 71 71 protected ProjectionChooser(Component parent, String title, String[] buttonTexts) { 72 72 super(parent, title, buttonTexts); … … 74 74 addGui(); 75 75 } 76 76 77 77 public void addGui() { 78 projPanel.setBorder(BorderFactory.createEmptyBorder( 0, 0, 0, 0));78 projPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); 79 79 projPanel.setLayout(new GridBagLayout()); 80 projPanel.add(new JLabel(tr("Projection method")), GBC.std().insets(5, 5,0,5));81 projPanel.add(GBC.glue(5, 0), GBC.std().fill(GBC.HORIZONTAL));82 projPanel.add(projectionCombo, GBC.eop().fill(GBC.HORIZONTAL).insets(0, 5,5,5));83 projPanel.add(projectionCodeLabel = new JLabel(tr("Projection code")), GBC.std().insets(25, 5,0,5));84 projPanel.add(projectionCodeGlue = GBC.glue(5, 0), GBC.std().fill(GBC.HORIZONTAL));85 projPanel.add(projectionCode, GBC.eop().fill(GBC.HORIZONTAL).insets(0, 5,5,5));86 projPanel.add(projectionNameLabel = new JLabel(tr("Projection name")), GBC.std().insets(25, 5,0,5));87 projPanel.add(projectionNameGlue = GBC.glue(5, 0), GBC.std().fill(GBC.HORIZONTAL));88 projPanel.add(projectionName, GBC.eop().fill(GBC.HORIZONTAL).insets(0, 5,5,5));89 projPanel.add(new JLabel(tr("Bounds")), GBC.std().insets(25, 5,0,5));90 projPanel.add(GBC.glue(5, 0), GBC.std().fill(GBC.HORIZONTAL));91 projPanel.add(bounds, GBC.eop().fill(GBC.HORIZONTAL).insets(0, 5,5,5));92 projPanel.add(projSubPrefPanelWrapper, GBC.eol().fill(GBC.HORIZONTAL).insets(20, 5,5,5));80 projPanel.add(new JLabel(tr("Projection method")), GBC.std().insets(5, 5, 0, 5)); 81 projPanel.add(GBC.glue(5, 0), GBC.std().fill(GBC.HORIZONTAL)); 82 projPanel.add(projectionCombo, GBC.eop().fill(GBC.HORIZONTAL).insets(0, 5, 5, 5)); 83 projPanel.add(projectionCodeLabel = new JLabel(tr("Projection code")), GBC.std().insets(25, 5, 0, 5)); 84 projPanel.add(projectionCodeGlue = GBC.glue(5, 0), GBC.std().fill(GBC.HORIZONTAL)); 85 projPanel.add(projectionCode, GBC.eop().fill(GBC.HORIZONTAL).insets(0, 5, 5, 5)); 86 projPanel.add(projectionNameLabel = new JLabel(tr("Projection name")), GBC.std().insets(25, 5, 0, 5)); 87 projPanel.add(projectionNameGlue = GBC.glue(5, 0), GBC.std().fill(GBC.HORIZONTAL)); 88 projPanel.add(projectionName, GBC.eop().fill(GBC.HORIZONTAL).insets(0, 5, 5, 5)); 89 projPanel.add(new JLabel(tr("Bounds")), GBC.std().insets(25, 5, 0, 5)); 90 projPanel.add(GBC.glue(5, 0), GBC.std().fill(GBC.HORIZONTAL)); 91 projPanel.add(bounds, GBC.eop().fill(GBC.HORIZONTAL).insets(0, 5, 5, 5)); 92 projPanel.add(projSubPrefPanelWrapper, GBC.eol().fill(GBC.HORIZONTAL).insets(20, 5, 5, 5)); 93 93 94 94 selectedProjectionChanged((ProjectionChoice) projectionCombo.getSelectedItem()); … … 102 102 setContent(projPanel); 103 103 } 104 104 105 105 private void selectedProjectionChanged(final ProjectionChoice pc) { 106 106 // Don't try to update if we're still starting up 107 107 int size = projPanel.getComponentCount(); 108 if (size < 1)108 if (size < 1) 109 109 return; 110 110 … … 124 124 updateMeta(pc); 125 125 } 126 126 127 127 private void updateMeta(ProjectionChoice pc) { 128 128 pc.setPreferences(pc.getPreferences(projSubPrefPanel)); … … 132 132 Bounds b = proj.getWorldBoundsLatLon(); 133 133 CoordinateFormat cf = CoordinateFormat.getDefaultFormat(); 134 bounds.setText(b.getMin().lonToString(cf)+", "+b.getMin().latToString(cf)+" : "+b.getMax().lonToString(cf)+", "+b.getMax().latToString(cf)); 134 bounds.setText(b.getMin().lonToString(cf)+", "+b.getMin().latToString(cf)+" : "+ 135 b.getMax().lonToString(cf)+", "+b.getMax().latToString(cf)); 135 136 boolean showCode = true; 136 137 boolean showName = false; -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/LambertCC9ZonesProjectionPatterns.java
r30723 r32545 10 10 11 11 public class LambertCC9ZonesProjectionPatterns extends ProjectionPatterns { 12 12 13 13 public static final Projection[] lambertCC9Zones = new Projection[9]; 14 14 static { 15 for (int i =0; i<lambertCC9Zones.length; i++) {15 for (int i = 0; i < lambertCC9Zones.length; i++) { 16 16 lambertCC9Zones[i] = Projections.getProjectionByCode("EPSG:"+Integer.toString(3942+i)); 17 17 } … … 32 32 String ccy = mx.group(1); 33 33 if (!ccx.equals(ccy)) { 34 throw new IllegalArgumentException(tr("''Lambert CC 9 zones'' coordinates found with different zone codes for X and Y: "+xFieldName+", "+yFieldName)); 34 throw new IllegalArgumentException( 35 tr("''Lambert CC 9 zones'' coordinates found with different zone codes for X and Y: "+xFieldName+", "+yFieldName)); 35 36 } 36 37 return lambertCC9Zones[Integer.parseInt(ccx)-42]; -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/NeptuneReader.java
r30795 r32545 22 22 import javax.xml.validation.SchemaFactory; 23 23 import javax.xml.validation.Validator; 24 25 import org.openstreetmap.josm.Main; 26 import org.openstreetmap.josm.data.coor.LatLon; 27 import org.openstreetmap.josm.data.osm.DataSet; 28 import org.openstreetmap.josm.data.osm.Node; 29 import org.openstreetmap.josm.data.osm.OsmPrimitive; 30 import org.openstreetmap.josm.data.osm.Relation; 31 import org.openstreetmap.josm.data.osm.RelationMember; 32 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 33 import org.openstreetmap.josm.io.AbstractReader; 34 import org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler; 35 import org.openstreetmap.josm.plugins.opendata.core.datasets.fr.FrenchConstants; 36 import org.xml.sax.SAXException; 24 37 25 38 import neptune.ChouetteAreaType; … … 37 50 import neptune.StopPointType; 38 51 import neptune.TridentObjectType; 39 40 import org.openstreetmap.josm.Main;41 import org.openstreetmap.josm.data.coor.LatLon;42 import org.openstreetmap.josm.data.osm.DataSet;43 import org.openstreetmap.josm.data.osm.Node;44 import org.openstreetmap.josm.data.osm.OsmPrimitive;45 import org.openstreetmap.josm.data.osm.Relation;46 import org.openstreetmap.josm.data.osm.RelationMember;47 import org.openstreetmap.josm.gui.progress.ProgressMonitor;48 import org.openstreetmap.josm.io.AbstractReader;49 import org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler;50 import org.openstreetmap.josm.plugins.opendata.core.datasets.fr.FrenchConstants;51 import org.xml.sax.SAXException;52 52 53 53 /** … … 127 127 Unmarshaller u = jc.createUnmarshaller(); 128 128 @SuppressWarnings("unchecked") 129 JAXBElement<T> doc = (JAXBElement<T>) u.unmarshal(inputStream);129 JAXBElement<T> doc = (JAXBElement<T>) u.unmarshal(inputStream); 130 130 return doc.getValue(); 131 131 } 132 132 133 private finalvoid linkTridentObjectToOsmPrimitive(TridentObjectType object, OsmPrimitive p) {133 private void linkTridentObjectToOsmPrimitive(TridentObjectType object, OsmPrimitive p) { 134 134 p.put("ref:neptune", object.getObjectId()); 135 135 if (tridentObjects.put(object.getObjectId(), p) != null) { … … 138 138 } 139 139 140 protected Node createNode(LatLon latlon) {140 protected Node createNode(LatLon latlon) { 141 141 Node n = new Node(latlon); 142 142 ds.addPrimitive(n); … … 152 152 } 153 153 154 protected Relation createRelation(String type) {154 protected Relation createRelation(String type) { 155 155 Relation r = new Relation(); 156 156 r.put("type", type); … … 159 159 } 160 160 161 protected Relation createPtRelation(String pt, TridentObjectType object) {161 protected Relation createPtRelation(String pt, TridentObjectType object) { 162 162 Relation r = createRelation(OSM_PUBLIC_TRANSPORT); 163 163 r.put(OSM_PUBLIC_TRANSPORT, pt); … … 349 349 } 350 350 351 private static finalboolean addStopToRoute(Relation route, OsmPrimitive stop) {352 if (route.getMembersCount() == 0 || !route.getMember(route.getMembersCount()-1).getMember().equals(stop) 351 private static boolean addStopToRoute(Relation route, OsmPrimitive stop) { 352 if (route.getMembersCount() == 0 || !route.getMember(route.getMembersCount()-1).getMember().equals(stop)) { 353 353 route.addMember(new RelationMember(stop.get(OSM_PUBLIC_TRANSPORT), stop)); 354 354 return true; -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/NetworkReader.java
r31937 r32545 42 42 private File file; 43 43 private String filename; 44 44 45 45 /** 46 46 * File readers … … 58 58 FILE_READERS.put(OdConstants.TAB_EXT, TabReader.class); 59 59 } 60 60 61 61 public static final Map<String, Class<? extends AbstractReader>> FILE_AND_ARCHIVE_READERS = new HashMap<>(FILE_READERS); 62 62 static { … … 72 72 this.promptUser = promptUser; 73 73 } 74 74 75 75 public final File getReadFile() { 76 76 return file; … … 105 105 } else if (contentType.startsWith("text/csv")) { 106 106 return CsvReader.class; 107 } else if (contentType.startsWith("text/plain")) { //TODO: extract charset107 } else if (contentType.startsWith("text/plain")) { //TODO: extract charset 108 108 return CsvReader.class; 109 109 } else if (contentType.startsWith("tdyn/html")) { … … 144 144 } 145 145 if (readerClass == null) { 146 throw new OsmTransferException("Cannot find appropriate reader !");//TODO handler job ?146 throw new OsmTransferException("Cannot find appropriate reader !"); //TODO handler job ? 147 147 } else if (findReaderByExtension(url) != null) { 148 148 filename = url.substring(url.lastIndexOf('/')+1); … … 150 150 instance = progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false); 151 151 if (readerClass.equals(ZipReader.class) || readerClass.equals(SevenZipReader.class)) { 152 ArchiveReader zipReader = readerClass.equals(ZipReader.class) 152 ArchiveReader zipReader = readerClass.equals(ZipReader.class) 153 153 ? new ZipReader(in, handler, promptUser) : new SevenZipReader(in, handler, promptUser); 154 DataSet ds = zipReader.parseDoc(instance);155 file = zipReader.getReadFile();156 return ds;154 DataSet ds = zipReader.parseDoc(instance); 155 file = zipReader.getReadFile(); 156 return ds; 157 157 } else if (readerClass.equals(KmlReader.class)) { 158 158 return KmlReader.parseDataSet(in, instance); … … 189 189 in.close(); 190 190 } 191 } catch (Exception e) {/* ignore it */} 191 } catch (Exception e) { 192 Main.trace(e); 193 } 192 194 } 193 195 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/OsmDownloader.java
r30723 r32545 9 9 import org.openstreetmap.josm.plugins.opendata.core.OdConstants; 10 10 11 public class OsmDownloader { 12 13 public static final void downloadOapi(String oapiReq) { 11 public final class OsmDownloader { 12 13 private OsmDownloader() { 14 // Hide default constructor for utilities classes 15 } 16 17 public static void downloadOapi(String oapiReq) { 14 18 if (oapiReq != null) { 15 19 try { … … 23 27 } 24 28 } 25 26 public static finalvoid downloadXapi(Collection<String> xapiReqs) {29 30 public static void downloadXapi(Collection<String> xapiReqs) { 27 31 if (xapiReqs != null) { 28 32 String xapiServer = Main.pref.get(OdConstants.PREF_XAPI, OdConstants.DEFAULT_XAPI); -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/OverpassApi.java
r30723 r32545 5 5 6 6 public enum OaQueryType { 7 NODE ("node"), 8 WAY ("way"), 9 RELATION ("relation"); 7 NODE("node"), 8 WAY("way"), 9 RELATION("relation"); 10 10 11 @Override 11 public String toString() { return this.value; } 12 private OaQueryType(final String value) { this.value = value; } 12 public String toString() { 13 return this.value; 14 } 15 16 OaQueryType(final String value) { 17 this.value = value; 18 } 19 13 20 private final String value; 14 21 } 15 22 16 23 public enum OaRecurseType { 17 RELATION_RELATION ("relation-relation"), 18 RELATION_BACKWARDS ("relation-backwards"), 19 RELATION_WAY ("relation-way"), 20 RELATION_NODE ("relation-node"), 21 WAY_NODE ("way-node"), 22 WAY_RELATION ("way-relation"), 23 NODE_RELATION ("node-relation"), 24 NODE_WAY ("node-way"); 24 RELATION_RELATION("relation-relation"), 25 RELATION_BACKWARDS("relation-backwards"), 26 RELATION_WAY("relation-way"), 27 RELATION_NODE("relation-node"), 28 WAY_NODE("way-node"), 29 WAY_RELATION("way-relation"), 30 NODE_RELATION("node-relation"), 31 NODE_WAY("node-way"); 32 25 33 @Override 26 public String toString() { return this.value; } 27 private OaRecurseType(final String value) { this.value = value; } 34 public String toString() { 35 return this.value; 36 } 37 38 OaRecurseType(final String value) { 39 this.value = value; 40 } 41 28 42 private final String value; 29 43 } 30 44 31 45 public static final String union(String ... queries) { 32 46 String result = "<union>\n"; … … 39 53 return result; 40 54 } 41 55 42 56 public static final String query(String bbox, OaQueryType type, String ... conditions) { 43 57 String result = "<query type=\""+type+"\" >\n"; … … 65 79 return result; 66 80 } 67 81 68 82 public static final String print() { 69 83 return "<print mode=\"meta\"/>"; 70 84 } 71 85 72 86 public static final String hasKey(String key) { 73 87 return hasKey(key, null); -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/archive/ArchiveHandler.java
r30723 r32545 6 6 public interface ArchiveHandler { 7 7 8 publicvoid notifyTempFileWritten(File file);8 void notifyTempFileWritten(File file); 9 9 10 publicboolean skipXsdValidation();10 boolean skipXsdValidation(); 11 11 12 publicvoid setSkipXsdValidation(boolean skip);12 void setSkipXsdValidation(boolean skip); 13 13 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/archive/ArchiveReader.java
r30795 r32545 52 52 this.promptUser = promptUser; 53 53 } 54 54 55 55 public final File getReadFile() { 56 56 return file; 57 57 } 58 58 59 59 protected abstract void extractArchive(final File temp, final List<File> candidates) throws IOException, FileNotFoundException; 60 60 61 61 protected abstract String getTaskMessage(); 62 62 63 63 protected Collection<File> getDocsToParse(final File temp, final ProgressMonitor progressMonitor) throws FileNotFoundException, IOException { 64 64 final List<File> candidates = new ArrayList<>(); 65 65 66 66 if (progressMonitor != null) { 67 67 progressMonitor.beginTask(getTaskMessage()); 68 68 } 69 69 extractArchive(temp, candidates); 70 70 71 71 if (promptUser && candidates.size() > 1) { 72 72 DialogPrompter<CandidateChooser> prompt = new DialogPrompter<CandidateChooser>() { … … 84 84 return Collections.emptyList(); 85 85 } 86 87 public Map<File, DataSet> parseDocs(final ProgressMonitor progressMonitor) throws IOException, XMLStreamException, FactoryConfigurationError, JAXBException { 86 87 public Map<File, DataSet> parseDocs(final ProgressMonitor progressMonitor) 88 throws IOException, XMLStreamException, FactoryConfigurationError, JAXBException { 88 89 Map<File, DataSet> result = new HashMap<>(); 89 90 File temp = OdUtils.createTempDir(); … … 104 105 return result; 105 106 } 106 107 public DataSet parseDoc(final ProgressMonitor progressMonitor) throws IOException, XMLStreamException, FactoryConfigurationError, JAXBException { 107 108 public DataSet parseDoc(final ProgressMonitor progressMonitor) 109 throws IOException, XMLStreamException, FactoryConfigurationError, JAXBException { 108 110 File temp = OdUtils.createTempDir(); 109 111 110 112 try { 111 file = null; 113 file = null; 112 114 Collection<File> files = getDocsToParse(temp, progressMonitor); 113 115 if (!files.isEmpty()) { 114 116 file = files.iterator().next(); 115 117 } 116 118 117 119 DataSet from = getDataForFile(file, progressMonitor); 118 120 if (from != null) { … … 127 129 } 128 130 } 129 131 130 132 return ds; 131 133 } … … 186 188 } 187 189 // Special treatment for XML files (check supported XSD), unless handler explicitely skip it 188 if (XmlImporter.XML_FILE_FILTER.accept(file) && ((archiveHandler != null && archiveHandler.skipXsdValidation()) 190 if (XmlImporter.XML_FILE_FILTER.accept(file) && ((archiveHandler != null && archiveHandler.skipXsdValidation()) 189 191 || OdPlugin.getInstance().xmlImporter.acceptFile(file))) { 190 192 candidates.add(file); -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/archive/CandidateChooser.java
r30723 r32545 32 32 this(parent, tr("File to load"), new String[] {tr("OK"), tr("Cancel")}, candidates); 33 33 } 34 34 35 35 private class Renderer extends DefaultListCellRenderer { 36 36 … … 40 40 super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); 41 41 if (value instanceof File) { 42 setText(((File) value).getName());42 setText(((File) value).getName()); 43 43 } 44 44 return this; 45 45 } 46 46 } 47 47 48 48 protected CandidateChooser(Component parent, String title, String[] buttonTexts, List<File> candidates) { 49 49 super(parent, title, buttonTexts); … … 52 52 addGui(candidates); 53 53 } 54 54 55 55 public void addGui(List<File> candidates) { 56 projPanel.setBorder(BorderFactory.createEmptyBorder( 0, 0, 0, 0));56 projPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); 57 57 projPanel.setLayout(new GridBagLayout()); 58 projPanel.add(new JLabel(tr("File to load")), GBC.std().insets(5, 5,0,5));59 projPanel.add(GBC.glue(5, 0), GBC.std().fill(GBC.HORIZONTAL));58 projPanel.add(new JLabel(tr("File to load")), GBC.std().insets(5, 5, 0, 5)); 59 projPanel.add(GBC.glue(5, 0), GBC.std().fill(GBC.HORIZONTAL)); 60 60 /*for (File file : candidates) { 61 61 JCheckBox cbox = new JCheckBox(file.getName()); 62 62 checkBoxes.put(cbox, file); 63 projPanel.add(cbox, GBC.eop().fill(GBC.HORIZONTAL).insets(0, 5,5,5));63 projPanel.add(cbox, GBC.eop().fill(GBC.HORIZONTAL).insets(0, 5, 5, 5)); 64 64 }*/ 65 projPanel.add(fileCombo, GBC.eop().fill(GBC.HORIZONTAL).insets(0, 5,5,5));65 projPanel.add(fileCombo, GBC.eop().fill(GBC.HORIZONTAL).insets(0, 5, 5, 5)); 66 66 setContent(projPanel); 67 67 } 68 68 69 69 /*public List<File> getSelectedFiles() { 70 70 List<File> result = new ArrayList<File>(); … … 76 76 return result; 77 77 }*/ 78 78 79 79 public File getSelectedFile() { 80 80 return (File) fileCombo.getSelectedItem(); -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/archive/SevenZipReader.java
r31924 r32545 33 33 34 34 private final IInArchive archive = new Handler(); 35 35 36 36 public SevenZipReader(InputStream in, AbstractDataSetHandler handler, boolean promptUser) throws IOException { 37 37 super(handler, handler != null ? handler.getArchiveHandler() : null, promptUser); … … 52 52 } 53 53 } 54 55 public static DataSet parseDataSet(InputStream in, AbstractDataSetHandler handler, ProgressMonitor instance, boolean promptUser) 54 55 public static DataSet parseDataSet(InputStream in, AbstractDataSetHandler handler, ProgressMonitor instance, boolean promptUser) 56 56 throws IOException, XMLStreamException, FactoryConfigurationError, JAXBException { 57 57 return new SevenZipReader(in, handler, promptUser).parseDoc(instance); 58 58 } 59 59 60 public static Map<File, DataSet> parseDataSets(InputStream in, AbstractDataSetHandler handler, ProgressMonitor instance, boolean promptUser) 60 public static Map<File, DataSet> parseDataSets(InputStream in, AbstractDataSetHandler handler, ProgressMonitor instance, boolean promptUser) 61 61 throws IOException, XMLStreamException, FactoryConfigurationError, JAXBException { 62 62 return new SevenZipReader(in, handler, promptUser).parseDocs(instance); … … 73 73 archive.close(); 74 74 } 75 75 76 76 private class ExtractCallback extends ArchiveExtractCallback { 77 77 private final List<File> candidates; 78 79 publicExtractCallback(IInArchive archive, File tempDir, List<File> candidates) {78 79 ExtractCallback(IInArchive archive, File tempDir, List<File> candidates) { 80 80 Init(archive); 81 81 super.outputDir = tempDir.getPath(); … … 83 83 } 84 84 85 @Override 85 @Override 86 86 public int GetStream(int index, OutputStream[] outStream, int askExtractMode) throws IOException { 87 87 int res = super.GetStream(index, outStream, askExtractMode); -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/AbstractMapInfoReader.java
r30795 r32545 23 23 protected static final String VERSION_450 = "450"; 24 24 25 protected static final String CHARSET_WINDOWS_LATIN 25 protected static final String CHARSET_WINDOWS_LATIN = "WindowsLatin1"; 26 26 protected static final String CHARSET_WINDOWS_CYRILLIC = "WindowsCyrillic"; 27 27 protected static final String CHARSET_NEUTRAL = "Neutral"; 28 protected static final String CHARSET_MAC 29 28 protected static final String CHARSET_MAC = "MacRoman"; 29 30 30 protected BufferedReader headerReader; 31 31 … … 47 47 return dataFile; 48 48 } 49 49 50 50 protected final BufferedReader getDataReader(File headerFile, String extension, Charset charset) throws IOException { 51 51 File dataFile = getDataFile(headerFile, extension); … … 76 76 version = words[1]; 77 77 } 78 78 79 79 protected void parseColumns(String[] words) { 80 80 columns = new ArrayList<>(); … … 88 88 line = line.replace(" ", " "); 89 89 } 90 String 90 String[] words = line.isEmpty() ? null : line.trim().split(" "); 91 91 if (words != null && words.length > 0) { 92 92 parseHeaderLine(words); … … 94 94 } 95 95 } 96 96 97 97 protected abstract void parseHeaderLine(String[] words) throws IOException; 98 98 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/DefaultShpHandler.java
r30795 r32545 37 37 public class DefaultShpHandler extends DefaultGeographicHandler implements ShpHandler { 38 38 39 private static final List<Pair<org.opengis.referencing.datum.Ellipsoid, Ellipsoid>> 40 39 private static final List<Pair<org.opengis.referencing.datum.Ellipsoid, Ellipsoid>> 40 ellipsoids = new ArrayList<>(); 41 41 static { 42 42 ellipsoids.add(new Pair<org.opengis.referencing.datum.Ellipsoid, Ellipsoid>(DefaultEllipsoid.GRS80, Ellipsoid.GRS80)); 43 43 ellipsoids.add(new Pair<org.opengis.referencing.datum.Ellipsoid, Ellipsoid>(DefaultEllipsoid.WGS84, Ellipsoid.WGS84)); 44 44 } 45 45 46 46 protected static final Double get(ParameterValueGroup values, ParameterDescriptor<?> desc) { 47 47 return (Double) values.parameter(desc.getName().getCode()).getValue(); 48 48 } 49 50 private static final boolean equals(Double a, Double b) { 51 boolean res = Math.abs(a - b) <= Main.pref.getDouble(OdConstants.PREF_CRS_COMPARISON_TOLERANCE, OdConstants.DEFAULT_CRS_COMPARISON_TOLERANCE); 49 50 private static boolean equals(Double a, Double b) { 51 boolean res = Math.abs(a - b) <= Main.pref.getDouble( 52 OdConstants.PREF_CRS_COMPARISON_TOLERANCE, OdConstants.DEFAULT_CRS_COMPARISON_TOLERANCE); 52 53 if (Main.pref.getBoolean(OdConstants.PREF_CRS_COMPARISON_DEBUG, false)) { 53 54 Main.debug("Comparing "+a+" and "+b+" -> "+res); 54 55 } 55 return res; 56 return res; 56 57 } 57 58 58 59 private Charset dbfCharset = null; 59 60 … … 80 81 ParameterValueGroup values = lambert.getParameterValues(); 81 82 Parameters params = ((LambertConformalConic) ap.getProj()).getParameters(); 82 83 83 84 ok = ok ? equals(get(values, AbstractProvider.LATITUDE_OF_ORIGIN), params.latitudeOrigin) : ok; 84 85 ok = ok ? equals(get(values, AbstractProvider.CENTRAL_MERIDIAN), ap.getCentralMeridian()) : ok; … … 86 87 ok = ok ? equals(get(values, AbstractProvider.FALSE_EASTING), ap.getFalseEasting()) : ok; 87 88 ok = ok ? equals(get(values, AbstractProvider.FALSE_NORTHING), ap.getFalseNorthing()) : ok; 88 89 89 90 if (lambert instanceof LambertConformal2SP && params instanceof Parameters2SP) { 90 91 Parameters2SP param = (Parameters2SP) params; 91 ok = ok ? equals(Math.min(get(values, AbstractProvider.STANDARD_PARALLEL_1),get(values, AbstractProvider.STANDARD_PARALLEL_2)), 92 Math.min(param.standardParallel1, param.standardParallel2)) : ok; 93 ok = ok ? equals(Math.max(get(values, AbstractProvider.STANDARD_PARALLEL_1), get(values, AbstractProvider.STANDARD_PARALLEL_2)), 94 Math.max(param.standardParallel1, param.standardParallel2)) : ok; 95 92 ok = ok ? equals(Math.min(get(values, AbstractProvider.STANDARD_PARALLEL_1), 93 get(values, AbstractProvider.STANDARD_PARALLEL_2)), 94 Math.min(param.standardParallel1, param.standardParallel2)) : ok; 95 ok = ok ? equals(Math.max(get(values, AbstractProvider.STANDARD_PARALLEL_1), 96 get(values, AbstractProvider.STANDARD_PARALLEL_2)), 97 Math.max(param.standardParallel1, param.standardParallel2)) : ok; 98 96 99 } else if (!(lambert instanceof LambertConformal1SP && params instanceof Parameters1SP)) { 97 100 ok = false; … … 130 133 dbfCharset = charset; 131 134 } 132 135 133 136 @Override 134 137 public Charset getDbfCharset() { -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/GeographicHandler.java
r30723 r32545 8 8 9 9 public interface GeographicHandler { 10 11 public void setPreferMultipolygonToSimpleWay(boolean prefer);12 10 13 public boolean preferMultipolygonToSimpleWay();11 void setPreferMultipolygonToSimpleWay(boolean prefer); 14 12 15 public void setCheckNodeProximity(boolean check); 16 17 public boolean checkNodeProximity(); 18 19 public void setUseNodeMap(boolean use); 20 21 public boolean useNodeMap(); 22 23 public CoordinateReferenceSystem getCrsFor(String crsName) throws NoSuchAuthorityCodeException, FactoryException; 13 boolean preferMultipolygonToSimpleWay(); 24 14 25 public MathTransform findMathTransform(CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS, boolean lenient) throws FactoryException; 15 void setCheckNodeProximity(boolean check); 16 17 boolean checkNodeProximity(); 18 19 void setUseNodeMap(boolean use); 20 21 boolean useNodeMap(); 22 23 CoordinateReferenceSystem getCrsFor(String crsName) throws NoSuchAuthorityCodeException, FactoryException; 24 25 MathTransform findMathTransform(CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS, boolean lenient) 26 throws FactoryException; 26 27 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/GeographicReader.java
r32494 r32545 66 66 } 67 67 } 68 68 69 69 private final GeographicHandler handler; 70 70 private final GeographicHandler[] defaultHandlers; 71 71 72 72 protected final Map<LatLon, Node> nodes; 73 73 … … 80 80 this.defaultHandlers = defaultHandlers; 81 81 } 82 82 83 83 protected Node getNode(Point p, LatLon key) { 84 84 Node n = nodes.get(key); … … 120 120 return n; 121 121 } 122 122 123 123 protected Node createOrGetEmptyNode(Point p) throws MismatchedDimensionException, TransformException { 124 124 Point p2 = (Point) JTS.transform(p, transform); … … 140 140 return n; 141 141 } 142 142 143 143 protected <T extends OsmPrimitive> T addOsmPrimitive(T p) { 144 144 ds.addPrimitive(p); … … 154 154 Way tempWay = new Way(); 155 155 if (ls != null) { 156 // Build list of nodes 157 for (int i =0; i<ls.getNumPoints(); i++) {156 // Build list of nodes 157 for (int i = 0; i < ls.getNumPoints(); i++) { 158 158 try { 159 159 tempWay.addNode(createOrGetNode(ls.getPointN(i))); … … 195 195 r.addMember(new RelationMember(role, w)); 196 196 } 197 197 198 198 /** 199 199 * returns true if the user wants to cancel, false if they … … 207 207 tr("Cannot transform to WGS84"), 208 208 new String[] {tr("Cancel"), tr("Continue")}); 209 // CHECKSTYLE.OFF: LineLength 209 210 dlg.setContent("<html>" + 210 211 tr("JOSM was unable to find a strict mathematical transformation between ''{0}'' and WGS84.<br /><br />"+ 211 212 212 "Do you want to try a <i>lenient</i> method, which will perform a non-precise transformation (<b>with location errors up to 1 km</b>) ?<br/><br/>"+ 213 "If so, <b>do NOT upload</b> such data to OSM !", crs.getName())+ 213 214 "</html>"); 214 dlg.setButtonIcons(new Icon[] { 215 // CHECKSTYLE.ON: LineLength 216 dlg.setButtonIcons(new Icon[] { 215 217 new ImageProvider("cancel").setMaxSize(ImageSizes.LARGEICON).get(), 216 218 new ImageProvider("ok").setMaxSize(ImageSizes.LARGEICON).addOverlay( 217 new ImageOverlay(new ImageProvider("warning-small"), 0.5, 0.5,1.0,1.0)).get()});219 new ImageOverlay(new ImageProvider("warning-small"), 0.5, 0.5, 1.0, 1.0)).get()}); 218 220 dlg.setToolTipTexts(new String[] { 219 221 tr("Cancel"), … … 225 227 }.promptInEdt().getValue() != 2; 226 228 } 227 228 private static finalvoid compareDebug(CoordinateReferenceSystem crs1, CoordinateReferenceSystem crs2) {229 230 private static void compareDebug(CoordinateReferenceSystem crs1, CoordinateReferenceSystem crs2) { 229 231 Main.debug("-- COMPARING "+crs1.getName()+" WITH "+crs2.getName()+" --"); 230 232 compareDebug("class", crs1.getClass(), crs2.getClass()); … … 235 237 Integer dim2 = cs2.getDimension(); 236 238 if (compareDebug("cs.dim", dim1, dim2)) { 237 for (int i = 0; i <dim1; i++) {239 for (int i = 0; i < dim1; i++) { 238 240 compareDebug("cs.axis"+i, cs1.getAxis(i), cs1.getAxis(i)); 239 241 } … … 258 260 Main.debug("-- COMPARING FINISHED --"); 259 261 } 260 261 private static finalboolean compareDebug(String text, Object o1, Object o2) {262 263 private static boolean compareDebug(String text, Object o1, Object o2) { 262 264 return compareDebug(text, o1.equals(o2), o1, o2); 263 265 } 264 265 private static finalboolean compareDebug(String text, IdentifiedObject o1, IdentifiedObject o2) {266 return compareDebug(text, (AbstractIdentifiedObject) o1, (AbstractIdentifiedObject)o2);267 } 268 269 private static finalboolean compareDebug(String text, AbstractIdentifiedObject o1, AbstractIdentifiedObject o2) {266 267 private static boolean compareDebug(String text, IdentifiedObject o1, IdentifiedObject o2) { 268 return compareDebug(text, (AbstractIdentifiedObject) o1, (AbstractIdentifiedObject) o2); 269 } 270 271 private static boolean compareDebug(String text, AbstractIdentifiedObject o1, AbstractIdentifiedObject o2) { 270 272 return compareDebug(text, o1.equals(o2, false), o1, o2); 271 273 } 272 274 273 private static finalboolean compareDebug(String text, boolean result, Object o1, Object o2) {275 private static boolean compareDebug(String text, boolean result, Object o1, Object o2) { 274 276 Main.debug(text + ": " + result + "("+o1+", "+o2+")"); 275 277 return result; 276 278 } 277 278 protected void findMathTransform(Component parent, boolean findSimiliarCrs) throws FactoryException, UserCancelException, GeoMathTransformException { 279 280 protected void findMathTransform(Component parent, boolean findSimiliarCrs) 281 throws FactoryException, UserCancelException, GeoMathTransformException { 279 282 try { 280 283 transform = CRS.findMathTransform(crs, wgs84); 281 284 } catch (OperationNotFoundException e) { 282 285 Main.info(crs.getName()+": "+e.getMessage()); // Bursa wolf parameters required. 283 284 if (findSimiliarCrs) { 286 287 if (findSimiliarCrs) { 285 288 List<CoordinateReferenceSystem> candidates = new ArrayList<>(); 286 289 287 290 // Find matching CRS with Bursa Wolf parameters in EPSG database 288 291 for (String code : CRS.getAuthorityFactory(false).getAuthorityCodes(ProjectedCRS.class)) { … … 290 293 CoordinateReferenceSystem candidate = CRS.decode(code); 291 294 if (candidate instanceof AbstractCRS && crs instanceof AbstractIdentifiedObject) { 292 293 Hints.putSystemDefault(Hints.COMPARISON_TOLERANCE, 294 Main.pref.getDouble(OdConstants.PREF_CRS_COMPARISON_TOLERANCE, OdConstants.DEFAULT_CRS_COMPARISON_TOLERANCE));295 if (((AbstractCRS) candidate).equals((AbstractIdentifiedObject)crs, false)) {295 296 Hints.putSystemDefault(Hints.COMPARISON_TOLERANCE, Main.pref.getDouble( 297 OdConstants.PREF_CRS_COMPARISON_TOLERANCE, OdConstants.DEFAULT_CRS_COMPARISON_TOLERANCE)); 298 if (((AbstractCRS) candidate).equals((AbstractIdentifiedObject) crs, false)) { 296 299 Main.info("Found a potential CRS: "+candidate.getName()); 297 300 candidates.add(candidate); … … 302 305 } 303 306 } catch (FactoryException ex) { 304 // Silently ignore exceptions305 } 306 } 307 307 Main.trace(ex); 308 } 309 } 310 308 311 if (candidates.size() > 1) { 309 312 Main.warn("Found several potential CRS: "+Arrays.toString(candidates.toArray())); 310 313 // TODO: ask user which one to use 311 314 } 312 315 313 316 if (candidates.size() > 0) { 314 317 CoordinateReferenceSystem newCRS = candidates.get(0); … … 320 323 } 321 324 } 322 325 323 326 if (transform == null) { 324 327 if (handler != null) { -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/GmlReader.java
r31655 r32545 62 62 public MathTransform transform; 63 63 public int dim; 64 publicCrsData(CoordinateReferenceSystem crs, MathTransform transform, int dim) {64 CrsData(CoordinateReferenceSystem crs, MathTransform transform, int dim) { 65 65 this.crs = crs; 66 66 this.transform = transform; … … 77 77 } 78 78 79 public static DataSet parseDataSet(InputStream in, AbstractDataSetHandler handler, ProgressMonitor instance) throws IOException, XMLStreamException { 79 public static DataSet parseDataSet(InputStream in, AbstractDataSetHandler handler, ProgressMonitor instance) 80 throws IOException, XMLStreamException { 80 81 InputStreamReader ir = UTFInputStreamReader.create(in, OdConstants.UTF8); 81 82 XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(ir); … … 87 88 } 88 89 89 private finalboolean isElement(String element) {90 private boolean isElement(String element) { 90 91 return parser.getLocalName().matches("(gml:)?"+element); 91 92 } 92 93 93 private DataSet parseDoc(ProgressMonitor instance) throws XMLStreamException, GeoCrsException, FactoryException, GeoMathTransformException, MismatchedDimensionException, TransformException { 94 private DataSet parseDoc(ProgressMonitor instance) throws XMLStreamException, GeoCrsException, FactoryException, 95 GeoMathTransformException, MismatchedDimensionException, TransformException { 94 96 Component parent = instance != null ? instance.getWindowParent() : Main.parent; 95 97 while (parser.hasNext()) { … … 147 149 } 148 150 149 private void parseFeatureMember(Component parent) throws XMLStreamException, GeoCrsException, FactoryException, UserCancelException, GeoMathTransformException, MismatchedDimensionException, TransformException { 151 private void parseFeatureMember(Component parent) throws XMLStreamException, GeoCrsException, FactoryException, 152 UserCancelException, GeoMathTransformException, MismatchedDimensionException, TransformException { 150 153 List<OsmPrimitive> list = new ArrayList<>(); 151 154 Way way = null; -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/KmlKmzImporter.java
r30723 r32545 14 14 15 15 public class KmlKmzImporter extends AbstractImporter { 16 16 17 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+")"); 18 OdConstants.KML_EXT+","+OdConstants.KMZ_EXT, OdConstants.KMZ_EXT, tr("KML/KMZ files") + 19 " (*."+OdConstants.KML_EXT+",*."+OdConstants.KMZ_EXT+")"); 19 20 20 21 public KmlKmzImporter() { -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/KmlReader.java
r32130 r32545 32 32 public class KmlReader extends AbstractReader { 33 33 34 // CHECKSTYLE.OFF: SingleSpaceSeparator 34 35 public static final String KML_PLACEMARK = "Placemark"; 35 36 public static final String KML_NAME = "name"; … … 43 44 public static final String KML_LINEAR_RING = "LinearRing"; 44 45 public static final String KML_COORDINATES = "coordinates"; 45 46 // CHECKSTYLE.ON: SingleSpaceSeparator 47 46 48 public static Pattern COLOR_PATTERN = Pattern.compile("\\p{XDigit}{8}"); 47 49 48 50 private XMLStreamReader parser; 49 51 private Map<LatLon, Node> nodes = new HashMap<>(); 50 52 51 53 public KmlReader(XMLStreamReader parser) { 52 54 this.parser = parser; 53 55 } 54 56 55 public static DataSet parseDataSet(InputStream in, ProgressMonitor instance) throws IOException, XMLStreamException, FactoryConfigurationError { 57 public static DataSet parseDataSet(InputStream in, ProgressMonitor instance) 58 throws IOException, XMLStreamException, FactoryConfigurationError { 56 59 InputStreamReader ir = UTFInputStreamReader.create(in); 57 60 XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(ir); … … 71 74 return ds; 72 75 } 73 76 74 77 private static boolean keyIsIgnored(String key) { 75 78 for (ProjectionPatterns pp : OdConstants.PROJECTIONS) { … … 80 83 return false; 81 84 } 82 85 83 86 private void parsePlaceMark(DataSet ds) throws XMLStreamException { 84 87 List<OsmPrimitive> list = new ArrayList<>(); … … 95 98 if (COLOR_PATTERN.matcher(s).matches()) { 96 99 // KML color format is aabbggrr, convert it to OSM (web) format: #rrggbb 97 tags.put(KML_COLOR, '#'+s.substring(6, 8)+s.substring(4,6)+s.substring(2,4));100 tags.put(KML_COLOR, '#'+s.substring(6, 8)+s.substring(4, 6)+s.substring(2, 4)); 98 101 } 99 102 } else if (parser.getLocalName().equals(KML_NAME)) { … … 122 125 } else if (parser.getLocalName().equals(KML_COORDINATES)) { 123 126 String[] tab = parser.getElementText().trim().split("\\s"); 124 for (int i = 0; i < tab.length; i 127 for (int i = 0; i < tab.length; i++) { 125 128 String[] values = tab[i].split(","); 126 129 if (values.length >= 2) { -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/KmzReader.java
r30723 r32545 20 20 21 21 private ZipInputStream zis; 22 22 23 23 public KmzReader(ZipInputStream zis) { 24 24 this.zis = zis; 25 25 } 26 26 27 public static DataSet parseDataSet(InputStream in, ProgressMonitor instance) throws IOException, XMLStreamException, FactoryConfigurationError { 27 public static DataSet parseDataSet(InputStream in, ProgressMonitor instance) 28 throws IOException, XMLStreamException, FactoryConfigurationError { 28 29 return new KmzReader(new ZipInputStream(in)).parseDoc(instance); 29 30 } 30 31 31 private DataSet parseDoc(ProgressMonitor instance) throws IOException, XMLStreamException, FactoryConfigurationError 32 private DataSet parseDoc(ProgressMonitor instance) throws IOException, XMLStreamException, FactoryConfigurationError { 32 33 ZipEntry entry; 33 34 do { … … 59 60 buffer = out.toByteArray(); 60 61 } 61 62 62 63 return KmlReader.parseDataSet(new ByteArrayInputStream(buffer), instance); 63 64 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/MifDatum.java
r30730 r32545 31 31 */ 32 32 public enum MifDatum { 33 // CHECKSTYLE.OFF: LineLength 33 34 ADINDAN(1, "Ethiopia, Mali, Senegal, Sudan", CLARKE_1880), 34 35 AFGOOYE(2, "Somalia", KRASSOVSKY), … … 153 154 ZANDERIJ(106, "", INTERNATIONAL), 154 155 CUSTOM(999, null, null); 156 // CHECKSTYLE.ON: LineLength 155 157 156 158 private final Integer code; 157 159 private final String area; 158 160 private final MifEllipsoid ellipsoid; 159 private MifDatum(Integer code, String area, MifEllipsoid ellipsoid) { 161 162 MifDatum(Integer code, String area, MifEllipsoid ellipsoid) { 160 163 this.code = code; 161 164 this.area = area; 162 165 this.ellipsoid = ellipsoid; 163 166 } 167 164 168 public final Integer getCode() { 165 169 return code; 166 170 } 171 167 172 public final String getArea() { 168 173 return area; 169 174 } 175 170 176 public final MifEllipsoid getEllipsoid() { 171 177 return ellipsoid; 172 178 } 179 173 180 public static MifDatum forCode(Integer code) { 174 181 for (MifDatum p : values()) { -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/MifHandler.java
r30583 r32545 6 6 public interface MifHandler extends GeographicHandler { 7 7 8 publicvoid setCoordSysNonEarthProjection(Projection p);9 10 publicProjection getCoordSysNonEarthProjection();8 void setCoordSysNonEarthProjection(Projection p); 9 10 Projection getCoordSysNonEarthProjection(); 11 11 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/MifProjection.java
r30723 r32545 36 36 Transverse_Mercator_modified_for_Danish_System_45_Bornholm(23, "tmerc"), 37 37 Transverse_Mercator_modified_for_Finnish_KKJ(24, "tmerc"); 38 38 39 39 private final Integer code; 40 40 private final String proj4id; 41 42 privateMifProjection(Integer code, String proj4id) {41 42 MifProjection(Integer code, String proj4id) { 43 43 this.code = code; 44 44 this.proj4id = proj4id; 45 45 } 46 46 47 47 public final Integer getCode() { 48 48 return code; 49 49 } 50 50 51 51 /** 52 52 * Replies the Proj.4 identifier. … … 58 58 return proj4id; 59 59 } 60 60 61 61 public static MifProjection forCode(Integer code) { 62 62 for (MifProjection p : values()) { -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/MifReader.java
r31655 r32545 44 44 * These files have been stored in reference directory to avoid future dead links. 45 45 */ 46 public class MifReader extends AbstractMapInfoReader {46 public final class MifReader extends AbstractMapInfoReader { 47 47 48 48 private enum State { … … 263 263 if ((datum == GEODETIC_REFERENCE_SYSTEM_1980_GRS_80 || datum == CUSTOM) && equals(originLon, 3.0)) { 264 264 // This sounds good for Lambert 93 or Lambert CC 9 265 if (equals(originLat, 46.5) && equals(stdP1, 44.0) && equals(stdP2, 49.0) && equals(falseEasting, 700000.0) && equals(falseNorthing, 6600000.0)) { 265 if (equals(originLat, 46.5) && equals(stdP1, 44.0) && equals(stdP2, 49.0) 266 && equals(falseEasting, 700000.0) && equals(falseNorthing, 6600000.0)) { 266 267 josmProj = Projections.getProjectionByCode("EPSG:2154"); // Lambert 93 267 268 } else if (equals(falseEasting, 1700000.0)) { 268 for (int i=0; josmProj == null && i<9; i++) { 269 if (equals(originLat, 42.0+i) && equals(stdP1, 41.25+i) && equals(stdP2, 42.75+i) && equals(falseNorthing, (i+1)*1000000.0 + 200000.0)) { 269 for (int i = 0; josmProj == null && i < 9; i++) { 270 if (equals(originLat, 42.0+i) && equals(stdP1, 41.25+i) && equals(stdP2, 42.75+i) 271 && equals(falseNorthing, (i+1)*1000000.0 + 200000.0)) { 270 272 josmProj = Projections.getProjectionByCode("EPSG:"+Integer.toString(3942 + i)); // LambertCC9Zones 271 273 } … … 317 319 318 320 private void parseCoordSys(String[] words) { 319 for (int i = 0; i <words.length; i++) {321 for (int i = 0; i < words.length; i++) { 320 322 words[i] = words[i].replace(",", ""); 321 323 } … … 327 329 parseCoordSysSyntax2(words); 328 330 331 // CHECKSTYLE.OFF: LineLength 329 332 // Syntax2 is not meant to be used for maps, and still... # 9592 happened 330 333 // From MapInfo documentation: … … 334 337 // the coordinate system. If the Projection clause is omitted, MapBasic uses a longitude, latitude coordinate system using the North American Datum of 1927 (NAD-27). 335 338 // Use syntax 2 to explicitly define a non-Earth coordinate system, such as the coordinate system used in a floor plan or other CAD drawing. 339 // CHECKSTYLE.ON: LineLength 336 340 337 341 if (handler != null && handler.getMifHandler() != null && handler.getMifHandler().getCoordSysNonEarthProjection() != null) { … … 596 600 Main.error("Incoherence between MID and MIF files ("+columns.size()+" columns vs "+fields.length+" fields)"); 597 601 } 598 for (int i =0; i<Math.min(columns.size(), fields.length); i++) {602 for (int i = 0; i < Math.min(columns.size(), fields.length); i++) { 599 603 String field = fields[i].trim(); 600 604 /*if (field.startsWith("\"") && field.endsWith("\"")) { … … 609 613 } 610 614 611 protected finalNode createNode(String x, String y) {615 protected Node createNode(String x, String y) { 612 616 Node node = new Node(josmProj.eastNorth2latlon(new EastNorth(Double.parseDouble(x), Double.parseDouble(y)))); 613 617 ds.addPrimitive(node); … … 617 621 /** Compare two doubles within a default epsilon */ 618 622 public static boolean equals(Double a, Double b) { 619 if (a ==b) return true;623 if (a == b) return true; 620 624 // If the difference is less than epsilon, treat as equal. 621 625 return Math.abs(a - b) < 0.0000001; -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/MifTabImporter.java
r30723 r32545 15 15 16 16 public class MifTabImporter extends AbstractImporter { 17 17 18 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+")"); 19 OdConstants.MIF_EXT+","+OdConstants.TAB_EXT, OdConstants.MIF_EXT, 20 tr("MapInfo files") + " (*."+OdConstants.MIF_EXT+",*."+OdConstants.TAB_EXT+")"); 20 21 21 22 public MifTabImporter() { -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/MifUnit.java
r30723 r32545 22 22 US_Survey_Feet(8), 23 23 Yards(4); 24 24 25 25 private final Integer code; 26 private MifUnit(Integer code) { 26 27 MifUnit(Integer code) { 27 28 this.code = code; 28 29 } 30 29 31 public final Integer getCode() { 30 32 return code; 31 33 } 34 32 35 public static MifUnit forCode(Integer code) { 33 36 for (MifUnit p : values()) { -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/ShpHandler.java
r30723 r32545 10 10 public interface ShpHandler extends GeographicHandler { 11 11 12 publicvoid notifyFeatureParsed(Object feature, DataSet result, Set<OsmPrimitive> featurePrimitives);12 void notifyFeatureParsed(Object feature, DataSet result, Set<OsmPrimitive> featurePrimitives); 13 13 14 publicvoid setDbfCharset(Charset charset);15 16 publicCharset getDbfCharset();14 void setDbfCharset(Charset charset); 15 16 Charset getDbfCharset(); 17 17 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/ShpReader.java
r32139 r32545 81 81 } 82 82 83 private void parseFeature(Feature feature, final Component parent) 84 throws UserCancelException, GeoMathTransformException,FactoryException, GeoCrsException, MismatchedDimensionException, TransformException {83 private void parseFeature(Feature feature, final Component parent) throws UserCancelException, GeoMathTransformException, 84 FactoryException, GeoCrsException, MismatchedDimensionException, TransformException { 85 85 featurePrimitives.clear(); 86 86 GeometryAttribute geometry = feature.getDefaultGeometryProperty(); … … 101 101 tr("Warning: CRS not found"), 102 102 JOptionPane.YES_NO_CANCEL_OPTION 103 )) {103 )) { 104 104 crs = wgs84; 105 105 } … … 131 131 Way w = null; 132 132 133 for (int i =0; i<nGeometries; i++) {133 for (int i = 0; i < nGeometries; i++) { 134 134 Geometry g = mp.getGeometryN(i); 135 135 if (g instanceof Polygon) { … … 137 137 // Do not create relation if there's only one polygon without interior ring 138 138 // except if handler prefers it 139 if (r == null && (nGeometries > 1 || p.getNumInteriorRing() > 0 || (handler != null && handler.preferMultipolygonToSimpleWay()))) { 139 if (r == null && (nGeometries > 1 || p.getNumInteriorRing() > 0 || 140 (handler != null && handler.preferMultipolygonToSimpleWay()))) { 140 141 r = createMultipolygon(); 141 142 } … … 143 144 if (r != null) { 144 145 addWayToMp(r, "outer", w); 145 for (int j =0; j<p.getNumInteriorRing(); j++) {146 for (int j = 0; j < p.getNumInteriorRing(); j++) { 146 147 addWayToMp(r, "inner", createOrGetWay(p.getInteriorRingN(j))); 147 148 } … … 211 212 String typeName = typeNames[0]; 212 213 213 FeatureSource<?, ?> featureSource = dataStore.getFeatureSource(typeName);214 FeatureCollection<?, ?> collection = featureSource.getFeatures();214 FeatureSource<?, ?> featureSource = dataStore.getFeatureSource(typeName); 215 FeatureCollection<?, ?> collection = featureSource.getFeatures(); 215 216 FeatureIterator<?> iterator = collection.features(); 216 217 … … 259 260 } 260 261 261 private static finalvoid readNonGeometricAttributes(Feature feature, OsmPrimitive primitive) {262 private static void readNonGeometricAttributes(Feature feature, OsmPrimitive primitive) { 262 263 try { 263 264 for (Property prop : feature.getProperties()) { -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/TabReader.java
r30795 r32545 32 32 private Charset datCharset; 33 33 private final AbstractDataSetHandler handler; 34 34 35 35 public TabReader(AbstractDataSetHandler handler) { 36 36 this.handler = handler; … … 41 41 return new TabReader(handler).parse(in, file, instance, Charset.forName(OdConstants.ISO8859_15)); 42 42 } 43 43 44 44 private class TabOsmReader extends SpreadSheetReader { 45 45 46 46 private final DbaseFileReader dbfReader; 47 publicTabOsmReader(SpreadSheetHandler handler, TabFiles tabFiles) throws IOException {47 TabOsmReader(SpreadSheetHandler handler, TabFiles tabFiles) throws IOException { 48 48 super(handler); 49 49 this.dbfReader = new DbaseFileReader(tabFiles, false, datCharset, null); … … 63 63 List<String> result = new ArrayList<>(); 64 64 Row row = dbfReader.readRow(); 65 for (int i =0; i<columns.size(); i++) {65 for (int i = 0; i < columns.size(); i++) { 66 66 Object o = row.read(i); 67 67 if (o != null) { -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/tabular/CsvHandler.java
r30723 r32545 6 6 public interface CsvHandler extends SpreadSheetHandler { 7 7 8 publicvoid setCharset(Charset charset);8 void setCharset(Charset charset); 9 9 10 publicvoid setCharset(String charset);10 void setCharset(String charset); 11 11 12 publicCharset getCharset();12 Charset getCharset(); 13 13 14 publicvoid setSeparator(String sep);15 16 publicString getSeparator();14 void setSeparator(String sep); 15 16 String getSeparator(); 17 17 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/tabular/CsvImporter.java
r30738 r32545 10 10 import java.io.InputStream; 11 11 12 import org.openstreetmap.josm.Main; 12 13 import org.openstreetmap.josm.actions.ExtensionFileFilter; 13 14 import org.openstreetmap.josm.data.osm.DataSet; … … 22 23 OdConstants.CSV_EXT, OdConstants.CSV_EXT, tr("CSV files") + " (*."+OdConstants.CSV_EXT+")"); 23 24 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"; 25 public static final String COLOMBUS_HEADER = 26 "INDEX,TAG,DATE,TIME,LATITUDE N/S,LONGITUDE E/W,HEIGHT,SPEED,HEADING,FIX MODE,VALID,PDOP,HDOP,VDOP,VOX"; 25 27 26 28 public CsvImporter() { … … 50 52 result = line != null && line.equalsIgnoreCase(COLOMBUS_HEADER); 51 53 } catch (IOException e) { 52 // Ignore exceptions54 Main.trace(e); 53 55 } 54 56 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/tabular/CsvReader.java
r30723 r32545 19 19 private final Charset charset; 20 20 private String sep; 21 21 22 22 private BufferedReader reader; 23 23 private String line; … … 32 32 this.sep = handler != null && handler.getSeparator() != null ? handler.getSeparator() : defaultSep; 33 33 } 34 34 35 35 public static DataSet parseDataSet(InputStream in, AbstractDataSetHandler handler, ProgressMonitor instance) throws IOException { 36 36 CsvHandler csvHandler = null; … … 65 65 return splitLine(); 66 66 } 67 68 private finalString[] splitLine() {67 68 private String[] splitLine() { 69 69 if (line != null) { 70 70 return OdUtils.stripQuotesAndExtraChars(line.split(sep), sep); -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/tabular/SpreadSheetHandler.java
r30723 r32545 12 12 public interface SpreadSheetHandler { 13 13 14 public void setSheetNumber(int n); 15 16 public int getSheetNumber(); 14 void setSheetNumber(int n); 17 15 18 public void setHandlesProjection(boolean handle); 19 20 public boolean handlesProjection(); 16 int getSheetNumber(); 21 17 22 public LatLon getCoor(EastNorth en, String[] fields);18 void setHandlesProjection(boolean handle); 23 19 24 public void setLineNumber(int n); 25 26 public int getLineNumber(); 20 boolean handlesProjection(); 27 21 28 public void setXCol(int i);22 LatLon getCoor(EastNorth en, String[] fields); 29 23 30 public void setYCol(int i); 31 32 public int getXCol(); 24 void setLineNumber(int n); 33 25 34 public int getYCol();26 int getLineNumber(); 35 27 36 public void nodesAdded(DataSet ds, Map<CoordinateColumns, Node> nodes, String[] fields, int lineNumber); 28 void setXCol(int i); 29 30 void setYCol(int i); 31 32 int getXCol(); 33 34 int getYCol(); 35 36 void nodesAdded(DataSet ds, Map<CoordinateColumns, Node> nodes, String[] fields, int lineNumber); 37 37 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/tabular/SpreadSheetReader.java
r30795 r32545 28 28 29 29 public abstract class SpreadSheetReader extends AbstractReader { 30 30 31 31 private static final NumberFormat formatFrance = NumberFormat.getInstance(Locale.FRANCE); 32 32 private static final NumberFormat formatUK = NumberFormat.getInstance(Locale.UK); 33 33 34 34 protected final SpreadSheetHandler handler; 35 35 … … 39 39 40 40 protected static double parseDouble(String value) throws ParseException { 41 if (value.contains(",")) { 41 if (value.contains(",")) { 42 42 return formatFrance.parse(value.replace(" ", "")).doubleValue(); 43 43 } else { … … 45 45 } 46 46 } 47 47 48 48 protected abstract void initResources(InputStream in, ProgressMonitor progressMonitor) throws IOException; 49 49 50 50 protected abstract String[] readLine(ProgressMonitor progressMonitor) throws IOException; 51 51 52 52 protected final int getSheetNumber() { 53 53 return handler != null && handler.getSheetNumber() > -1 ? handler.getSheetNumber() : 0; 54 54 } 55 55 56 56 protected final int getLineNumber() { 57 57 return handler != null ? handler.getLineNumber() : -1; 58 58 } 59 59 60 60 public static class CoordinateColumns { 61 61 public Projection proj = null; … … 65 65 return xCol > -1 && yCol > -1; 66 66 } 67 67 68 @Override 68 69 public String toString() { … … 70 71 } 71 72 } 72 73 private finalCoordinateColumns addCoorColIfNeeded(List<CoordinateColumns> columns, CoordinateColumns col) {73 74 private CoordinateColumns addCoorColIfNeeded(List<CoordinateColumns> columns, CoordinateColumns col) { 74 75 if (col == null || col.isOk()) { 75 76 columns.add(col = new CoordinateColumns()); … … 77 78 return col; 78 79 } 79 80 80 81 public DataSet doParse(String[] header, ProgressMonitor progressMonitor) throws IOException { 81 82 Main.info("Header: "+Arrays.toString(header)); 82 83 83 84 Map<ProjectionPatterns, List<CoordinateColumns>> projColumns = new HashMap<>(); 84 85 for (int i = 0; i <header.length; i++) {85 86 for (int i = 0; i < header.length; i++) { 86 87 for (ProjectionPatterns pp : OdConstants.PROJECTIONS) { 87 88 List<CoordinateColumns> columns = projColumns.get(pp); … … 101 102 102 103 final List<CoordinateColumns> columns = new ArrayList<>(); 103 104 104 105 for (ProjectionPatterns pp : projColumns.keySet()) { 105 106 for (CoordinateColumns col : projColumns.get(pp)) { … … 116 117 117 118 boolean projFound = false; 118 119 119 120 for (CoordinateColumns c : columns) { 120 121 if (c.proj != null) { … … 123 124 } 124 125 } 125 126 126 127 if (projFound) { 127 128 // projection identified, do nothing … … 140 141 } 141 142 } 142 143 143 144 } else { 144 145 throw new IllegalArgumentException(tr("No valid coordinates have been found.")); … … 152 153 message += c.proj + "("+header[c.xCol]+", "+header[c.yCol]+")"; 153 154 } 154 155 155 156 Main.info("Loading data using projections "+message); 156 157 157 158 final DataSet ds = new DataSet(); 158 159 int lineNumber = 1; 159 160 160 161 String[] fields; 161 162 while ((fields = readLine(progressMonitor)) != null) { … … 165 166 handler.setYCol(-1); 166 167 } 167 168 168 169 final Map<CoordinateColumns, EastNorth> ens = new HashMap<>(); 169 170 final Map<CoordinateColumns, Node> nodes = new HashMap<>(); … … 172 173 ens.put(c, new EastNorth(Double.NaN, Double.NaN)); 173 174 } 174 175 175 176 if (fields.length > header.length) { 176 177 Main.warn(tr("Invalid file. Bad length on line {0}. Expected {1} columns, got {2}.", lineNumber, header.length, fields.length)); 177 178 Main.warn(Arrays.toString(fields)); 178 179 } 179 180 for (int i = 0; i <Math.min(fields.length, header.length); i++) {180 181 for (int i = 0; i < Math.min(fields.length, header.length); i++) { 181 182 try { 182 183 boolean coordinate = false; … … 195 196 handler.setYCol(i); 196 197 } 197 } 198 } 198 199 } 199 200 if (!coordinate) { … … 219 220 firstNode = n; 220 221 } 221 if (n == firstNode || n.getCoor().greatCircleDistance(firstNode.getCoor()) > Main.pref.getDouble(OdConstants.PREF_TOLERANCE, OdConstants.DEFAULT_TOLERANCE)) { 222 if (n == firstNode || n.getCoor().greatCircleDistance(firstNode.getCoor()) 223 > Main.pref.getDouble(OdConstants.PREF_TOLERANCE, OdConstants.DEFAULT_TOLERANCE)) { 222 224 ds.addPrimitive(n); 223 225 } else { … … 230 232 } 231 233 } 232 234 233 235 return ds; 234 236 } 235 237 236 238 public final DataSet parse(InputStream in, ProgressMonitor progressMonitor) throws IOException { 237 239 238 240 initResources(in, progressMonitor); 239 241 240 242 String[] header = null; 241 243 int length = 0; 242 244 int n = 0; 243 245 244 246 while (header == null || length == 0) { 245 247 n++; … … 254 256 } 255 257 } 256 258 257 259 return doParse(header, progressMonitor); 258 260 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/layers/OdDataLayer.java
r32525 r32545 36 36 public OdDiffLayer diffLayer; 37 37 public OdOsmDataLayer osmLayer; 38 38 39 39 public final AbstractDataSetHandler handler; 40 40 41 41 private Bounds bounds; 42 42 43 43 public OdDataLayer(DataSet data, String name, File associatedFile, AbstractDataSetHandler handler) { 44 44 super(data, name, associatedFile); … … 57 57 Main.getLayerManager().addLayerChangeListener(this); 58 58 } 59 59 60 60 @Override public ImageProvider getBaseIconProvider() { 61 61 return OdUtils.getImageProvider(handler != null ? handler.getDataLayerIconName() : OdConstants.ICON_CORE_16); … … 74 74 } 75 75 } 76 76 77 77 public void addDiffLayer(OdDiffLayer layer) { 78 78 removeDiffLayer(); … … 80 80 Main.getLayerManager().addLayer(diffLayer); 81 81 } 82 82 83 83 public void removeDiffLayer() { 84 84 if (diffLayer != null) { … … 87 87 } 88 88 } 89 89 90 90 public final void downloadOsmData() { 91 91 String oapiReq = handler.getOverpassApiRequest(bounds); … … 140 140 } 141 141 if (this.handler != null) { 142 if (this.handler.getWikiURL() != null || this.handler.getLocalPortalURL() != null || this.handler.getNationalPortalURL() != null) { 142 if (this.handler.getWikiURL() != null || this.handler.getLocalPortalURL() != null || this.handler.getNationalPortalURL() != null) { 143 143 result.add(SeparatorLayerAction.INSTANCE); 144 144 } 145 if (this.handler.getWikiURL() != null) { 146 result.add(new OpenLinkAction(this.handler.getWikiURL(), OdConstants.ICON_OSM_24, 145 if (this.handler.getWikiURL() != null) { 146 result.add(new OpenLinkAction(this.handler.getWikiURL(), OdConstants.ICON_OSM_24, 147 147 tr("View OSM Wiki page"), tr("Launch browser to the OSM Wiki page of the selected data set"))); 148 148 } 149 if (this.handler.getLocalPortalURL() != null) { 150 result.add(new OpenLinkAction(this.handler.getLocalPortalURL(), this.handler.getLocalPortalIconName(), 149 if (this.handler.getLocalPortalURL() != null) { 150 result.add(new OpenLinkAction(this.handler.getLocalPortalURL(), this.handler.getLocalPortalIconName(), 151 151 tr("View Local Portal page"), tr("Launch browser to the local portal page of the selected data set"))); 152 152 } 153 if (this.handler.getNationalPortalURL() != null) { 154 result.add(new OpenLinkAction(this.handler.getNationalPortalURL(), this.handler.getNationalPortalIconName(), 153 if (this.handler.getNationalPortalURL() != null) { 154 result.add(new OpenLinkAction(this.handler.getNationalPortalURL(), this.handler.getNationalPortalIconName(), 155 155 tr("View National Portal page"), tr("Launch browser to the national portal page of the selected data set"))); 156 156 } … … 158 158 License lic = this.handler.getLicense(); 159 159 if (lic.getURL() != null && lic.getURL().getProtocol().startsWith("http")) { 160 result.add(new OpenLinkAction(lic.getURL(), OdConstants.ICON_AGREEMENT_24, 160 result.add(new OpenLinkAction(lic.getURL(), OdConstants.ICON_AGREEMENT_24, 161 161 tr("View License"), tr("Launch browser to the license page of the selected data set"))); 162 162 } 163 163 if (lic.getSummaryURL() != null && lic.getSummaryURL().getProtocol().startsWith("http")) { 164 result.add(new OpenLinkAction(lic.getSummaryURL(), OdConstants.ICON_AGREEMENT_24, 164 result.add(new OpenLinkAction(lic.getSummaryURL(), OdConstants.ICON_AGREEMENT_24, 165 165 tr("View License (summary)"), tr("Launch browser to the summary license page of the selected data set"))); 166 166 } 167 if ((lic.getURL() != null && !lic.getURL().getProtocol().startsWith("http")) || (lic.getSummaryURL() != null && !lic.getSummaryURL().getProtocol().startsWith("http"))) { 167 if ((lic.getURL() != null && !lic.getURL().getProtocol().startsWith("http")) || 168 (lic.getSummaryURL() != null && !lic.getSummaryURL().getProtocol().startsWith("http"))) { 168 169 result.add(new ViewLicenseAction(lic, tr("View License"), tr("View the license of the selected data set"))); 169 170 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/layers/OdDiffLayer.java
r30723 r32545 23 23 24 24 private final OdDataLayer dataLayer; 25 26 public final List<Pair<OsmPrimitive, OsmPrimitive>> differentPrimitives;25 26 public final List<Pair<OsmPrimitive, OsmPrimitive>> differentPrimitives; 27 27 public final List<OsmPrimitive> onlyInTlsPrimitives; 28 28 public final List<OsmPrimitive> onlyInOsmPrimitives; 29 29 30 30 public OdDiffLayer(OdDataLayer dataLayer, String name) { 31 31 super(name); … … 36 36 initDiff(dataLayer.data, dataLayer.osmLayer.data); 37 37 } 38 38 39 39 private void initDiff(DataSet tlsData, DataSet osmData) { 40 40 for (OsmPrimitive p1 : tlsData.allPrimitives()) { … … 56 56 } 57 57 } 58 58 59 59 private double distance(OsmPrimitive p1, OsmPrimitive p2) { 60 60 return p1.getBBox().getCenter().greatCircleDistance(p2.getBBox().getCenter()); 61 61 } 62 62 63 63 private OsmPrimitive findPrimitiveAt(DataSet dataSet, OsmPrimitive source) { 64 64 double maxDistance = Main.pref.getDouble(OdConstants.PREF_MAXDISTANCE, OdConstants.DEFAULT_MAXDISTANCE); … … 69 69 for (OsmPrimitive p : dataSet.allPrimitives()) { 70 70 if (dataLayer.handler.isRelevant(p)) { 71 double dist = distance(source, p); 71 double dist = distance(source, p); 72 72 if (dist <= maxDistance) { 73 73 if (dataLayer.handler.equals(p, source)) { -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/layers/OdLayer.java
r30723 r32545 3 3 4 4 public interface OdLayer { 5 publicOdDataLayer getDataLayer();5 OdDataLayer getDataLayer(); 6 6 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/licenses/License.java
r30723 r32545 13 13 14 14 public abstract class License { 15 15 16 16 public static final ODbL ODbL = new ODbL(); 17 17 public static final LOOL LOOL = new LOOL(); 18 18 19 19 private final Map<String, URL> urls = new HashMap<>(); 20 20 private final Map<String, URL> summaryURLs = new HashMap<>(); 21 21 22 22 private Icon icon; 23 24 private static finalURL getURL(Map<String, URL> map) {23 24 private static URL getURL(Map<String, URL> map) { 25 25 // Find URL for current language 26 26 String lang = OdUtils.getJosmLanguage(); … … 37 37 // If not found, return first non-null url 38 38 if (map.keySet().size() > 0) { 39 for (Iterator<String> it =map.keySet().iterator(); it.hasNext();) {39 for (Iterator<String> it = map.keySet().iterator(); it.hasNext();) { 40 40 url = map.get(it.next()); 41 41 if (url != null) { … … 55 55 return getURL(summaryURLs); 56 56 } 57 57 58 58 public final void setURL(URL url) { 59 59 setURL(url, "en"); -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/modules/AbstractModule.java
r30731 r32545 115 115 } 116 116 117 private finalList<AbstractDataSetHandler> getInstanciatedHandlers() {117 private List<AbstractDataSetHandler> getInstanciatedHandlers() { 118 118 if (instanciatedHandlers.isEmpty()) { 119 119 instanciatedHandlers.addAll(getNewlyInstanciatedHandlers()); -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/modules/Module.java
r30723 r32545 9 9 public interface Module { 10 10 11 publicString getDisplayedName();11 String getDisplayedName(); 12 12 13 publicList<Class<? extends AbstractDataSetHandler>> getHandlers();13 List<Class<? extends AbstractDataSetHandler>> getHandlers(); 14 14 15 publicList<AbstractDataSetHandler> getNewlyInstanciatedHandlers();15 List<AbstractDataSetHandler> getNewlyInstanciatedHandlers(); 16 16 17 publicSourceProvider getMapPaintStyleSourceProvider();18 19 publicSourceProvider getPresetSourceProvider();20 21 publicModuleInformation getModuleInformation();17 SourceProvider getMapPaintStyleSourceProvider(); 18 19 SourceProvider getPresetSourceProvider(); 20 21 ModuleInformation getModuleInformation(); 22 22 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/modules/ModuleDownloadTask.java
r30795 r32545 32 32 * 33 33 */ 34 public class ModuleDownloadTask extends PleaseWaitRunnable {34 public class ModuleDownloadTask extends PleaseWaitRunnable { 35 35 private final Collection<ModuleInformation> toUpdate = new LinkedList<>(); 36 36 private final Collection<ModuleInformation> failed = new LinkedList<>(); … … 48 48 * @throws IllegalArgumentException thrown if toUpdate is null 49 49 */ 50 public ModuleDownloadTask(Component parent, Collection<ModuleInformation> toUpdate, String title) throws IllegalArgumentException {50 public ModuleDownloadTask(Component parent, Collection<ModuleInformation> toUpdate, String title) throws IllegalArgumentException { 51 51 super(parent, title == null ? "" : title, false /* don't ignore exceptions */); 52 52 CheckParameterUtil.ensureParameterNotNull(toUpdate, "toUpdate"); … … 63 63 */ 64 64 public ModuleDownloadTask(ProgressMonitor monitor, Collection<ModuleInformation> toUpdate, String title) { 65 super(title, monitor == null ? NullProgressMonitor.INSTANCE: monitor, false /* don't ignore exceptions */);65 super(title, monitor == null ? NullProgressMonitor.INSTANCE : monitor, false /* don't ignore exceptions */); 66 66 CheckParameterUtil.ensureParameterNotNull(toUpdate, "toUpdate"); 67 67 this.toUpdate.addAll(toUpdate); … … 74 74 * @throws IllegalArgumentException thrown if toUpdate is null 75 75 */ 76 public void setModulesToDownload(Collection<ModuleInformation> toUpdate) throws IllegalArgumentException {76 public void setModulesToDownload(Collection<ModuleInformation> toUpdate) throws IllegalArgumentException { 77 77 CheckParameterUtil.ensureParameterNotNull(toUpdate, "toUpdate"); 78 78 this.toUpdate.clear(); … … 82 82 @Override protected void cancel() { 83 83 this.canceled = true; 84 synchronized (this) {84 synchronized (this) { 85 85 if (downloadConnection != null) { 86 86 downloadConnection.disconnect(); … … 91 91 @Override protected void finish() {} 92 92 93 protected void download(ModuleInformation pi, File file) throws ModuleDownloadException {93 protected void download(ModuleInformation pi, File file) throws ModuleDownloadException { 94 94 try { 95 95 if (pi.downloadlink == null) { … … 99 99 } 100 100 URL url = new URL(pi.downloadlink); 101 synchronized (this) {102 downloadConnection = (HttpURLConnection) url.openConnection();101 synchronized (this) { 102 downloadConnection = (HttpURLConnection) url.openConnection(); 103 103 downloadConnection.setRequestProperty("Cache-Control", "no-cache"); 104 downloadConnection.setRequestProperty("User-Agent", Version.getInstance().getAgentString());104 downloadConnection.setRequestProperty("User-Agent", Version.getInstance().getAgentString()); 105 105 downloadConnection.setRequestProperty("Host", url.getHost()); 106 106 downloadConnection.connect(); 107 107 } 108 108 try ( 109 InputStream in = downloadConnection.getInputStream();110 OutputStream out = new FileOutputStream(file)111 ) {109 InputStream in = downloadConnection.getInputStream(); 110 OutputStream out = new FileOutputStream(file) 111 ) { 112 112 byte[] buffer = new byte[8192]; 113 113 for (int read = in.read(buffer); read != -1; read = in.read(buffer)) { … … 115 115 } 116 116 } 117 } catch(MalformedURLException e) { 118 String msg = tr("Warning: Cannot download module ''{0}''. Its download link ''{1}'' is not a valid URL. Skipping download.", pi.name, pi.downloadlink); 117 } catch (MalformedURLException e) { 118 String msg = tr("Warning: Cannot download module ''{0}''. Its download link ''{1}'' is not a valid URL. Skipping download.", 119 pi.name, pi.downloadlink); 119 120 Main.warn(msg); 120 121 throw new ModuleDownloadException(msg); … … 124 125 throw new ModuleDownloadException(e); 125 126 } finally { 126 synchronized (this) {127 synchronized (this) { 127 128 downloadConnection = null; 128 129 } … … 147 148 try { 148 149 download(d, moduleFile); 149 } catch (ModuleDownloadException e) {150 } catch (ModuleDownloadException e) { 150 151 e.printStackTrace(); 151 152 failed.add(d); … … 160 161 * Replies true if the task was canceled by the user 161 162 * 162 * @return 163 * @return {@code true} if the task was canceled by the user 163 164 */ 164 165 public boolean isCanceled() { -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/modules/ModuleHandler.java
r31008 r32545 56 56 * 57 57 */ 58 public class ModuleHandler {58 public final class ModuleHandler { 59 59 60 60 /** 61 61 * All installed and loaded modules (resp. their main classes) 62 62 */ 63 public final staticCollection<Module> moduleList = new LinkedList<>();63 public static final Collection<Module> moduleList = new LinkedList<>(); 64 64 65 65 /** … … 77 77 } 78 78 79 private ModuleHandler() { 80 // Hide default constructor for utilities classes 81 } 82 79 83 public static Collection<ClassLoader> getResourceClassLoaders() { 80 84 return Collections.unmodifiableCollection(sources); … … 97 101 long last = Main.pref.getLong("opendata.modulemanager.lastupdate", 0); 98 102 Integer maxTime = Main.pref.getInteger("opendata.modulemanager.time-based-update.interval", 60); 99 long d = (tim - last) / (24 * 60 * 60 * 1000 l);103 long d = (tim - last) / (24 * 60 * 60 * 1000L); 100 104 if ((last <= 0) || (maxTime <= 0)) { 101 105 Main.pref.put("opendata.modulemanager.lastupdate", Long.toString(tim)); 102 106 } else if (d > maxTime) { 103 107 message = 104 "<html>"105 + tr("Last module update more than {0} days ago.", d)106 + "</html>";108 "<html>" 109 + tr("Last module update more than {0} days ago.", d) 110 + "</html>"; 107 111 togglePreferenceKey = "opendata.modulemanager.time-based-update.policy"; 108 112 } 109 113 if (message == null) return false; 110 114 111 ButtonSpec 115 ButtonSpec[] options = new ButtonSpec[] { 112 116 new ButtonSpec( 113 117 tr("Update modules"), … … 115 119 tr("Click to update the activated modules"), 116 120 null /* no specific help context */ 117 ),121 ), 118 122 new ButtonSpec( 119 123 tr("Skip update"), … … 121 125 tr("Click to skip updating the activated modules"), 122 126 null /* no specific help context */ 123 )127 ) 124 128 }; 125 129 … … 158 162 options[0], 159 163 null 160 );164 ); 161 165 162 166 if (pnlMessage.isRememberDecision()) { … … 247 251 + "Delete from preferences?</html>", module.name, module.className); 248 252 } 249 } 253 } catch (Exception e) { 250 254 Main.error(e); 251 255 } … … 309 313 try { 310 314 future.get(); 311 } catch (ExecutionException | InterruptedException e) {315 } catch (ExecutionException | InterruptedException e) { 312 316 Main.error(e); 313 317 return null; … … 344 348 JOptionPane.WARNING_MESSAGE, 345 349 HelpUtil.ht("/Module/Loading#MissingModuleInfos") 346 );350 ); 347 351 } 348 352 … … 356 360 public static List<ModuleInformation> buildListOfModulesToLoad(Component parent) { 357 361 Set<String> modules = new HashSet<>(); 358 modules.addAll(Main.pref.getCollection(OdConstants.PREF_MODULES, 362 modules.addAll(Main.pref.getCollection(OdConstants.PREF_MODULES, new LinkedList<String>())); 359 363 if (System.getProperty("josm."+OdConstants.PREF_MODULES) != null) { 360 364 modules.addAll(Arrays.asList(System.getProperty("josm."+OdConstants.PREF_MODULES).split(","))); … … 382 386 "Updating the following modules has failed:", 383 387 modules.size() 384 )385 );388 ) 389 ); 386 390 sb.append("<ul>"); 387 391 for (ModuleInformation pi: modules) { … … 393 397 "Please open the Preference Dialog after JOSM has started and try to update them manually.", 394 398 modules.size() 395 ));399 )); 396 400 sb.append("</html>"); 397 401 HelpAwareOptionPane.showOptionDialog( … … 401 405 JOptionPane.ERROR_MESSAGE, 402 406 HelpUtil.ht("/Module/Loading#FailedModuleUpdated") 403 );407 ); 404 408 } 405 409 … … 412 416 * @throws IllegalArgumentException thrown if modules is null 413 417 */ 414 public static List<ModuleInformation> 418 public static List<ModuleInformation> updateModules(Component parent, 415 419 List<ModuleInformation> modules, ProgressMonitor monitor) 416 throws IllegalArgumentException{420 throws IllegalArgumentException { 417 421 CheckParameterUtil.ensureParameterNotNull(modules, "modules"); 418 422 if (monitor == null) { … … 426 430 // 427 431 ReadRemoteModuleInformationTask task1 = new ReadRemoteModuleInformationTask( 428 monitor.createSubTaskMonitor(1, false),432 monitor.createSubTaskMonitor(1, false), 429 433 OdPreferenceSetting.getModuleSites() 430 );434 ); 431 435 Future<?> future = service.submit(task1); 432 436 try { 433 437 future.get(); 434 438 modules = buildListOfModulesToLoad(parent); 435 } catch (ExecutionException e) {439 } catch (ExecutionException e) { 436 440 Main.warn(tr("Warning: failed to download module information list")); 437 441 e.printStackTrace(); 438 442 // don't abort in case of error, continue with downloading modules below 439 } catch (InterruptedException e) {443 } catch (InterruptedException e) { 440 444 Main.warn(tr("Warning: failed to download module information list")); 441 445 e.printStackTrace(); … … 446 450 // 447 451 Collection<ModuleInformation> modulesToUpdate = new ArrayList<>(); 448 for (ModuleInformation pi: modules) {452 for (ModuleInformation pi: modules) { 449 453 if (pi.isUpdateRequired()) { 450 454 modulesToUpdate.add(pi); … … 456 460 // 457 461 ModuleDownloadTask task2 = new ModuleDownloadTask( 458 monitor.createSubTaskMonitor(1, false),462 monitor.createSubTaskMonitor(1, false), 459 463 modulesToUpdate, 460 464 tr("Update modules") 461 );465 ); 462 466 463 467 future = service.submit(task2); 464 468 try { 465 469 future.get(); 466 } catch (ExecutionException e) {470 } catch (ExecutionException e) { 467 471 e.printStackTrace(); 468 472 alertFailedModuleUpdate(parent, modulesToUpdate); 469 473 return modules; 470 } catch (InterruptedException e) {474 } catch (InterruptedException e) { 471 475 e.printStackTrace(); 472 476 alertFailedModuleUpdate(parent, modulesToUpdate); … … 475 479 // notify user if downloading a locally installed module failed 476 480 // 477 if (! 481 if (!task2.getFailedModules().isEmpty()) { 478 482 alertFailedModuleUpdate(parent, task2.getFailedModules()); 479 483 return modules; … … 497 501 */ 498 502 public static boolean confirmDisableModule(Component parent, String reason, String name) { 499 ButtonSpec 503 ButtonSpec[] options = new ButtonSpec[] { 500 504 new ButtonSpec( 501 505 tr("Disable module"), … … 503 507 tr("Click to delete the module ''{0}''", name), 504 508 null /* no specific help context */ 505 ),509 ), 506 510 new ButtonSpec( 507 511 tr("Keep module"), … … 509 513 tr("Click to keep the module ''{0}''", name), 510 514 null /* no specific help context */ 511 )515 ) 512 516 }; 513 517 int ret = HelpAwareOptionPane.showOptionDialog( … … 520 524 options[0], 521 525 null // FIXME: add help topic 522 );526 ); 523 527 return ret == 0; 524 528 } … … 543 547 public static void installDownloadedModules(boolean dowarn) { 544 548 File moduleDir = OdPlugin.getInstance().getModulesDirectory(); 545 if (! moduleDir.exists() || ! moduleDir.isDirectory() || !moduleDir.canWrite())549 if (!moduleDir.exists() || !moduleDir.isDirectory() || !moduleDir.canWrite()) 546 550 return; 547 551 … … 550 554 public boolean accept(File dir, String name) { 551 555 return name.endsWith(".jar.new"); 552 } });556 } }); 553 557 554 558 for (File updatedModule : files) { … … 556 560 File module = new File(filePath.substring(0, filePath.length() - 4)); 557 561 String moduleName = updatedModule.getName().substring(0, updatedModule.getName().length() - 8); 562 // CHECKSTYLE.OFF: LineLength 558 563 if (module.exists()) { 559 564 if (!module.delete() && dowarn) { … … 567 572 Main.warn(tr("Warning: failed to install already downloaded module ''{0}''. Skipping installation. JOSM is still going to load the old module version.", moduleName)); 568 573 } 574 // CHECKSTYLE.ON: LineLength 569 575 } 570 576 return; … … 736 742 }*/ 737 743 738 static privateclass UpdateModulesMessagePanel extends JPanel {744 private static class UpdateModulesMessagePanel extends JPanel { 739 745 private JMultilineLabel lblMessage; 740 746 private JCheckBox cbDontShowAgain; … … 747 753 gc.weightx = 1.0; 748 754 gc.weighty = 1.0; 749 gc.insets = new Insets(5, 5,5,5);755 gc.insets = new Insets(5, 5, 5, 5); 750 756 add(lblMessage = new JMultilineLabel(""), gc); 751 757 lblMessage.setFont(lblMessage.getFont().deriveFont(Font.PLAIN)); … … 754 760 gc.fill = GridBagConstraints.HORIZONTAL; 755 761 gc.weighty = 0.0; 756 add(cbDontShowAgain = new JCheckBox(tr("Do not ask again and remember my decision (go to Preferences->Modules to change it later)")), gc); 762 add(cbDontShowAgain = new JCheckBox( 763 tr("Do not ask again and remember my decision (go to Preferences->Modules to change it later)")), gc); 757 764 cbDontShowAgain.setFont(cbDontShowAgain.getFont().deriveFont(Font.PLAIN)); 758 765 } 759 766 760 publicUpdateModulesMessagePanel() {767 UpdateModulesMessagePanel() { 761 768 build(); 762 769 } … … 769 776 String policy = Main.pref.get(preferencesKey, "ask"); 770 777 policy = policy.trim().toLowerCase(); 771 cbDontShowAgain.setSelected(! 778 cbDontShowAgain.setSelected(!policy.equals("ask")); 772 779 } 773 780 -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/modules/ModuleInformation.java
r32071 r32545 72 72 * @throws ModuleException thrown if reading the manifest file fails 73 73 */ 74 public ModuleInformation(File file, String name) throws ModuleException {74 public ModuleInformation(File file, String name) throws ModuleException { 75 75 this.name = name; 76 76 this.file = file; … … 103 103 Manifest manifest = new Manifest(); 104 104 manifest.read(manifestStream); 105 if (url != null) {105 if (url != null) { 106 106 downloadlink = url; 107 107 } … … 133 133 } 134 134 135 private static final ImageIcon extractIcon(String iconPath, File jarFile, boolean suppressWarnings) { 136 return new ImageProvider(iconPath).setArchive(jarFile).setMaxWidth(24).setMaxHeight(24).setOptional(true).setSuppressWarnings(suppressWarnings).get(); 135 private static ImageIcon extractIcon(String iconPath, File jarFile, boolean suppressWarnings) { 136 return new ImageProvider(iconPath).setArchive(jarFile).setMaxWidth(24).setMaxHeight(24).setOptional(true) 137 .setSuppressWarnings(suppressWarnings).get(); 137 138 } 138 139 … … 156 157 link = s; 157 158 s = attr.getValue(lang+"Module-Description"); 158 if (s == null) {159 if (s == null) { 159 160 s = attr.getValue("Module-Description"); 160 if (s != null) {161 if (s != null) { 161 162 s = tr(s); 162 163 } … … 240 241 if (className == null) 241 242 return null; 242 try {243 try { 243 244 return (Class<? extends Module>) Class.forName(className, true, classLoader); 244 245 } catch (Exception t) { … … 276 277 public boolean isUpdateRequired(String referenceVersion) { 277 278 if (this.downloadlink == null) return false; 278 if (this.version == null && referenceVersion != null)279 if (this.version == null && referenceVersion != null) 279 280 return true; 280 281 if (this.version != null && !this.version.equals(referenceVersion)) … … 311 312 public boolean matches(String filter) { 312 313 if (filter == null) return true; 313 String words[]= filter.split("\\s+");314 String[] words = filter.split("\\s+"); 314 315 for (String word: words) { 315 316 if (matches(word, name) -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/modules/ModuleListParser.java
r30532 r32545 16 16 * A parser for the module list provided by an opendata Module Download Site. 17 17 * 18 * See <a href="http://svn.openstreetmap.org/applications/editors/josm/plugins/opendata/modules.txt"> http://svn.openstreetmap.org/applications/editors/josm/plugins/opendata/modules.txt</a>18 * See <a href="http://svn.openstreetmap.org/applications/editors/josm/plugins/opendata/modules.txt">OSM SVN</a> 19 19 * for a sample of the document. The format is a custom format, kind of mix of CSV and RFC822 style 20 20 * name/value-pairs. … … 30 30 * @param manifest the module manifest 31 31 * @return a module information object 32 * @throws ModuleListParseException 32 * @throws ModuleListParseException if the list cannot be parsed 33 33 */ 34 protected ModuleInformation createInfo(String name, String url, String manifest) throws ModuleListParseException {34 protected ModuleInformation createInfo(String name, String url, String manifest) throws ModuleListParseException { 35 35 try { 36 36 return new ModuleInformation( … … 38 38 name.substring(0, name.length() - 4), 39 39 url 40 );41 } catch (UnsupportedEncodingException e) {40 ); 41 } catch (UnsupportedEncodingException e) { 42 42 throw new ModuleListParseException(tr("Failed to create module information from manifest for module ''{0}''", name), e); 43 43 } catch (ModuleException e) { … … 49 49 * Parses a module information document and replies a list of module information objects. 50 50 * 51 * See <a href="http://svn.openstreetmap.org/applications/editors/josm/plugins/opendata/modules.txt"> http://svn.openstreetmap.org/applications/editors/josm/plugins/opendata/modules.txt</a>51 * See <a href="http://svn.openstreetmap.org/applications/editors/josm/plugins/opendata/modules.txt">OSM SVN</a> 52 52 * for a sample of the document. The format is a custom format, kind of mix of CSV and RFC822 style 53 53 * name/value-pairs. … … 57 57 * @throws ModuleListParseException thrown if something goes wrong while parsing 58 58 */ 59 public List<ModuleInformation> parse(InputStream in) throws ModuleListParseException {59 public List<ModuleInformation> parse(InputStream in) throws ModuleListParseException { 60 60 List<ModuleInformation> ret = new LinkedList<>(); 61 61 BufferedReader r = null; … … 73 73 } 74 74 B; 75 */75 */ 76 76 for (String line = r.readLine(); line != null; line = r.readLine()) { 77 77 if (line.startsWith("\t")) { … … 95 95 } 96 96 } 97 String x[]= line.split(";");98 if (x.length != 2)99 throw new IOException(tr("Illegal entry in module list."));97 String[] x = line.split(";"); 98 if (x.length != 2) 99 throw new IOException(tr("Illegal entry in module list.")); 100 100 name = x[0]; 101 101 url = x[1]; -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/modules/ReadLocalModuleInformationTask.java
r30795 r32545 31 31 * <li>.jar.new-files, assuming that these are downloaded but not yet installed modules</li> 32 32 * <li>cached lists of available modules, downloaded for instance from 33 * <a href="http://svn.openstreetmap.org/applications/editors/josm/plugins/opendata/modules.txt"> http://svn.openstreetmap.org/applications/editors/josm/plugins/opendata/modules.txt</a></li>33 * <a href="http://svn.openstreetmap.org/applications/editors/josm/plugins/opendata/modules.txt">OSM SVN</a></li> 34 34 * </ul> 35 *36 35 */ 37 36 public class ReadLocalModuleInformationTask extends PleaseWaitRunnable { … … 45 44 46 45 public ReadLocalModuleInformationTask(ProgressMonitor monitor) { 47 super(tr("Reading local module information.."), monitor, false);46 super(tr("Reading local module information.."), monitor, false); 48 47 availableModules = new HashMap<>(); 49 48 } … … 57 56 protected void finish() {} 58 57 59 protected void processJarFile(File f, String moduleName) throws ModuleException {58 protected void processJarFile(File f, String moduleName) throws ModuleException { 60 59 ModuleInformation info = new ModuleInformation( 61 60 f, 62 61 moduleName 63 );62 ); 64 63 if (!availableModules.containsKey(info.getName())) { 65 64 info.localversion = info.version; … … 84 83 } 85 84 } 86 );85 ); 87 86 if (siteCacheFiles == null || siteCacheFiles.length == 0) 88 87 return; … … 110 109 } 111 110 } 112 );111 ); 113 112 if (siteCacheFiles == null || siteCacheFiles.length == 0) 114 113 return; … … 121 120 if (pi.icon == null && pi.iconPath != null) { 122 121 pi.icon = new ImageProvider(pi.name+".jar/"+pi.iconPath) 123 124 125 126 122 .setArchive(f) 123 .setMaxWidth(24) 124 .setMaxHeight(24) 125 .setOptional(true).get(); 127 126 } 128 127 } … … 139 138 } 140 139 } 141 );140 ); 142 141 if (moduleFiles == null || moduleFiles.length == 0) 143 142 return; … … 155 154 processJarFile(f, moduleName); 156 155 } 157 } catch (ModuleException e){156 } catch (ModuleException e) { 158 157 Main.warn(tr("Warning: Failed to scan file ''{0}'' for module information. Skipping.", fname)); 159 158 e.printStackTrace(); … … 176 175 } 177 176 178 protected void processLocalModuleInformationFile(File file) throws ModuleListParseException {177 protected void processLocalModuleInformationFile(File file) throws ModuleListParseException { 179 178 try (FileInputStream fin = new FileInputStream(file)) { 180 179 List<ModuleInformation> pis = new ModuleListParser().parse(fin); … … 186 185 availableModules.put(pi.name, pi); 187 186 } 188 } catch (IOException e) {187 } catch (IOException e) { 189 188 throw new ModuleListParseException(e); 190 189 } … … 194 193 for (Module module : ModuleHandler.moduleList) { 195 194 ModuleInformation info = module.getModuleInformation(); 196 if (canceled) return;195 if (canceled) return; 197 196 if (!availableModules.containsKey(info.name)) { 198 197 availableModules.put(info.name, info); … … 212 211 getProgressMonitor().createSubTaskMonitor(1, false), 213 212 new File(location) 214 );213 ); 215 214 getProgressMonitor().worked(1); 216 if (canceled) return;215 if (canceled) return; 217 216 } 218 217 analyseInProcessModules(); 219 218 getProgressMonitor().worked(1); 220 if (canceled) return;219 if (canceled) return; 221 220 getProgressMonitor().worked(1); 222 221 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/modules/ReadRemoteModuleInformationTask.java
r30795 r32545 46 46 private List<ModuleInformation> availableModules; 47 47 48 protected enum CacheType { PLUGIN_LIST, ICON_LIST}49 50 protected void init(Collection<String> sites) {48 protected enum CacheType { PLUGIN_LIST, ICON_LIST } 49 50 protected void init(Collection<String> sites) { 51 51 this.sites = sites; 52 52 if (sites == null) { … … 54 54 } 55 55 availableModules = new LinkedList<>(); 56 57 } 56 } 57 58 58 /** 59 59 * Creates the task … … 73 73 */ 74 74 public ReadRemoteModuleInformationTask(ProgressMonitor monitor, Collection<String> sites) { 75 super(tr("Download module list..."), monitor == null ? NullProgressMonitor.INSTANCE : monitor, false /* don't ignore exceptions */);75 super(tr("Download module list..."), monitor == null ? NullProgressMonitor.INSTANCE : monitor, false /* don't ignore exceptions */); 76 76 init(sites); 77 77 } … … 80 80 protected void cancel() { 81 81 canceled = true; 82 synchronized (this) {82 synchronized (this) { 83 83 if (connection != null) { 84 84 connection.disconnect(); … … 110 110 } 111 111 String path = url.getPath(); 112 for (int i = 0;i<path.length()-4; i++) {112 for (int i = 0; i < path.length()-4; i++) { 113 113 char c = path.charAt(i); 114 114 if (Character.isLetterOrDigit(c)) { … … 127 127 } 128 128 name = sb.toString(); 129 } catch (MalformedURLException e) {129 } catch (MalformedURLException e) { 130 130 name = "site-unknown.txt"; 131 131 } … … 150 150 151 151 URL url = new URL(printsite); 152 synchronized (this) {153 connection = (HttpURLConnection) url.openConnection();152 synchronized (this) { 153 connection = (HttpURLConnection) url.openConnection(); 154 154 connection.setRequestProperty("Cache-Control", "no-cache"); 155 connection.setRequestProperty("User-Agent", Version.getInstance().getAgentString());155 connection.setRequestProperty("User-Agent", Version.getInstance().getAgentString()); 156 156 connection.setRequestProperty("Host", url.getHost()); 157 157 connection.setRequestProperty("Accept-Charset", "utf-8"); … … 159 159 try (BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"))) { 160 160 String line; 161 while ((line = in.readLine()) != null) {161 while ((line = in.readLine()) != null) { 162 162 sb.append(line).append("\n"); 163 163 } 164 164 return sb.toString(); 165 165 } 166 } catch (MalformedURLException e) {166 } catch (MalformedURLException e) { 167 167 if (canceled) return null; 168 168 e.printStackTrace(); 169 169 return null; 170 } catch (IOException e) {170 } catch (IOException e) { 171 171 if (canceled) return null; 172 172 e.printStackTrace(); 173 173 return null; 174 174 } finally { 175 synchronized (this) {175 synchronized (this) { 176 176 if (connection != null) { 177 177 connection.disconnect(); … … 197 197 198 198 URL url = new URL(site); 199 synchronized (this) {200 connection = (HttpURLConnection) url.openConnection();199 synchronized (this) { 200 connection = (HttpURLConnection) url.openConnection(); 201 201 connection.setRequestProperty("Cache-Control", "no-cache"); 202 connection.setRequestProperty("User-Agent", Version.getInstance().getAgentString());202 connection.setRequestProperty("User-Agent", Version.getInstance().getAgentString()); 203 203 connection.setRequestProperty("Host", url.getHost()); 204 204 } 205 205 try ( 206 InputStream in = connection.getInputStream();207 OutputStream out = new FileOutputStream(destFile)208 ) {206 InputStream in = connection.getInputStream(); 207 OutputStream out = new FileOutputStream(destFile) 208 ) { 209 209 byte[] buffer = new byte[8192]; 210 210 for (int read = in.read(buffer); read != -1; read = in.read(buffer)) { … … 212 212 } 213 213 } 214 } catch (MalformedURLException e) {214 } catch (MalformedURLException e) { 215 215 if (canceled) return; 216 216 e.printStackTrace(); 217 217 return; 218 } catch (IOException e) {218 } catch (IOException e) { 219 219 if (canceled) return; 220 220 e.printStackTrace(); 221 221 return; 222 222 } finally { 223 synchronized (this) {223 synchronized (this) { 224 224 if (connection != null) { 225 225 connection.disconnect(); … … 232 232 if (pi.icon == null && pi.iconPath != null) { 233 233 pi.icon = new ImageProvider(pi.name+".jar/"+pi.iconPath) 234 235 236 237 234 .setArchive(destFile) 235 .setMaxWidth(24) 236 .setMaxHeight(24) 237 .setOptional(true).get(); 238 238 } 239 239 } … … 250 250 File moduleDir = OdPlugin.getInstance().getModulesDirectory(); 251 251 if (!moduleDir.exists()) { 252 if (! 252 if (!moduleDir.mkdirs()) { 253 253 Main.warn(tr("Warning: failed to create module directory ''{0}''. Cannot cache module list from module site ''{1}''.", 254 254 moduleDir.toString(), site)); … … 277 277 InputStream in = new ByteArrayInputStream(doc.getBytes("UTF-8")); 278 278 availableModules.addAll(new ModuleListParser().parse(in)); 279 } catch (UnsupportedEncodingException e) {279 } catch (UnsupportedEncodingException e) { 280 280 Main.error(tr("Failed to parse module list document from site ''{0}''. Skipping site. Exception was: {1}", site, e.toString())); 281 281 e.printStackTrace(); 282 } catch (ModuleListParseException e) {282 } catch (ModuleListParseException e) { 283 283 Main.error(tr("Failed to parse module list document from site ''{0}''. Skipping site. Exception was: {1}", site, e.toString())); 284 284 e.printStackTrace(); … … 295 295 List<File> siteCacheFiles = new LinkedList<>(); 296 296 for (String location : ModuleInformation.getModuleLocations()) { 297 File 297 File[] f = new File(location).listFiles( 298 298 new FilenameFilter() { 299 299 @Override 300 300 public boolean accept(File dir, String name) { 301 301 return name.matches("^([0-9]+-)?site.*\\.txt$") || 302 name.matches("^([0-9]+-)?site.*-icons\\.zip$");302 name.matches("^([0-9]+-)?site.*-icons\\.zip$"); 303 303 } 304 304 } 305 );306 if (f != null && f.length > 0) {305 ); 306 if (f != null && f.length > 0) { 307 307 siteCacheFiles.addAll(Arrays.asList(f)); 308 308 } … … 316 316 siteCacheFiles.remove(createSiteCacheFile(moduleDir, site, CacheType.PLUGIN_LIST)); 317 317 siteCacheFiles.remove(createSiteCacheFile(moduleDir, site, CacheType.ICON_LIST)); 318 if(list != null) 319 { 318 if (list != null) { 320 319 getProgressMonitor().worked(1); 321 320 cacheModuleList(site, list); … … 327 326 if (canceled) return; 328 327 } 329 downloadModuleIcons(site.replace(".txt", "")+"-icons.zip", createSiteCacheFile(moduleDir, site, CacheType.ICON_LIST), getProgressMonitor().createSubTaskMonitor(0, false)); 330 } 331 for (File file: siteCacheFiles) /* remove old stuff or whole update process is broken */ 332 { 328 downloadModuleIcons(site.replace(".txt", "")+"-icons.zip", 329 createSiteCacheFile(moduleDir, site, CacheType.ICON_LIST), getProgressMonitor().createSubTaskMonitor(0, false)); 330 } 331 for (File file: siteCacheFiles) { 332 // remove old stuff or whole update process is broken 333 333 file.delete(); 334 334 } … … 337 337 /** 338 338 * Replies true if the task was canceled 339 * @return 339 * @return {@code true} if the task was canceled 340 340 */ 341 341 public boolean isCanceled() { -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/util/NamesFrUtils.java
r30795 r32545 26 26 result += " "; 27 27 } 28 result += dictionary.containsKey(word) ? 28 result += dictionary.containsKey(word) ? dictionary.get(word) : word; 29 29 } 30 30 return result; … … 95 95 } else if (label.equals("Jardin")) { 96 96 return label; 97 } else if (label.startsWith("L'") || label.equals("La") || label.equals("Le") || label.equals("Les") || label.equals("Saint")) { // Lieux-dits 97 } else if (label.startsWith("L'") || label.equals("La") || label.equals("Le") || label.equals("Les") || 98 label.equals("Saint")) { // Lieux-dits 98 99 return label; 99 100 } else if (label.equals("Lot")) { -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/util/OdUtils.java
r31116 r32545 21 21 22 22 public abstract class OdUtils { 23 23 24 24 private static final String TEMP_DIR_PREFIX = "josm_opendata_temp_"; 25 25 26 26 public static final boolean isMultipolygon(OsmPrimitive p) { 27 27 return p instanceof Relation && ((Relation) p).isMultipolygon(); 28 28 } 29 29 30 30 public static final String[] stripQuotesAndExtraChars(String[] split, String sep) { 31 31 List<String> result = new ArrayList<>(); 32 32 boolean append = false; 33 for (int i = 0; i <split.length; i++) {33 for (int i = 0; i < split.length; i++) { 34 34 if (append) { 35 35 int index = result.size()-1; … … 53 53 return result.toArray(new String[0]); 54 54 } 55 55 56 56 public static final ImageIcon getImageIcon(String iconName) { 57 57 return getImageIcon(iconName, false); 58 58 } 59 59 60 60 public static final ImageIcon getImageIcon(String iconName, boolean optional) { 61 61 return getImageProvider(iconName, optional).get(); 62 62 } 63 63 64 64 public static final ImageProvider getImageProvider(String iconName) { 65 65 return getImageProvider(iconName, false); 66 66 } 67 67 68 68 public static final ImageProvider getImageProvider(String iconName, boolean optional) { 69 69 return new ImageProvider(iconName).setOptional(optional).setAdditionalClassLoaders(ModuleHandler.getResourceClassLoaders()); 70 70 } 71 71 72 72 public static final String getJosmLanguage() { 73 73 String lang = Main.pref.get("language"); … … 77 77 return lang; 78 78 } 79 79 80 80 public static final double convertMinuteSecond(double minute, double second) { 81 81 return (minute/60.0) + (second/3600.0); … … 85 85 return degree + convertMinuteSecond(minute, second); 86 86 } 87 87 88 88 public static final File createTempDir() throws IOException { 89 89 final File temp = File.createTempFile(TEMP_DIR_PREFIX, Long.toString(System.nanoTime())); … … 96 96 throw new IOException("Could not create temp directory: " + temp.getAbsolutePath()); 97 97 } 98 98 99 99 return temp; 100 100 } 101 101 102 102 public static final void deleteDir(File dir) { 103 103 for (File file : dir.listFiles()) { … … 110 110 } 111 111 } 112 112 113 113 public static final void deletePreviousTempDirs() { 114 114 File tmpDir = new File(System.getProperty("java.io.tmpdir")); -
applications/editors/josm/plugins/opendata/test/unit/org/openstreetmap/josm/plugins/opendata/core/io/geographic/MifReaderTest.java
r32355 r32545 26 26 @Rule 27 27 public JOSMTestRules rules = new JOSMTestRules().preferences(); 28 28 29 29 private static AbstractDataSetHandler newHandler(final String epsgCode) { 30 30 AbstractDataSetHandler handler = new AbstractDataSetHandler() { … … 33 33 return true; 34 34 } 35 35 36 @Override 36 37 public void updateDataSet(DataSet ds) { … … 42 43 return handler; 43 44 } 44 45 45 46 /** 46 47 * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/9592">#9592</a> -
applications/editors/josm/plugins/opendata/test/unit/org/openstreetmap/josm/plugins/opendata/core/io/geographic/ShpReaderTest.java
r32360 r32545 31 31 32 32 /** 33 * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/12714">#12714 /a>33 * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/12714">#12714</a> 34 34 * @throws IOException if an error occurs during reading 35 35 */ … … 55 55 } 56 56 } 57 57 58 58 /** 59 59 * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/8309">#8309</a> -
applications/editors/josm/plugins/opendata/test/unit/org/openstreetmap/josm/plugins/opendata/core/io/tabular/CsvReaderTest.java
r32355 r32545 29 29 @Rule 30 30 public JOSMTestRules rules = new JOSMTestRules().preferences(); 31 31 32 32 private static AbstractDataSetHandler newHandler(final String epsgCode) { 33 33 AbstractDataSetHandler handler = new AbstractDataSetHandler() { … … 36 36 return true; 37 37 } 38 38 39 @Override 39 40 public void updateDataSet(DataSet ds) { … … 45 46 return true; 46 47 } 48 47 49 @Override 48 50 public LatLon getCoor(EastNorth en, String[] fields) { … … 52 54 return handler; 53 55 } 54 56 55 57 /** 56 58 * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/10214">#10214</a> … … 63 65 } 64 66 } 65 67 66 68 /** 67 69 * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/8805">#8805</a> -
applications/editors/josm/plugins/opendata/util/opendata/ModuleListGenerator.java
r30910 r32545 15 15 import java.util.zip.ZipOutputStream; 16 16 17 public class ModuleListGenerator {17 public final class ModuleListGenerator { 18 18 19 /** 20 * @param args 21 */ 22 public static void main(String[] args) { 23 final String url = "http://svn.openstreetmap.org/applications/editors/josm/plugins/opendata/dist/"; 24 String baseDir = ""; 25 if (args.length > 0) { 26 baseDir = args[0]; 27 } 28 try ( 29 BufferedWriter list = new BufferedWriter(new FileWriter(baseDir+"modules.txt")); 30 ZipOutputStream zip = new ZipOutputStream(new FileOutputStream(baseDir+"modules-icons.zip")); 31 ) { 32 for (File file : new File(baseDir+"dist").listFiles(new FilenameFilter() { 33 @Override 34 public boolean accept(File dir, String name) { 35 return name.endsWith(".jar"); 36 } 37 })) { 38 try { 39 String filename = file.getName(); 40 System.out.println("Processing "+filename); 41 list.write(filename+";"+url+filename); list.newLine(); 42 Manifest mf = new JarFile(file).getManifest(); 43 for (Object att : mf.getMainAttributes().keySet()) { 44 Object value = mf.getMainAttributes().get(att); 45 if (value != null) { 46 list.write("\t"+att+": "+value.toString()); list.newLine(); 47 if (att.toString().equals("Module-Icon")) { 48 // Directory with jar name, including extension 49 String name = filename+"/"; 50 zip.putNextEntry(new ZipEntry(name)); 51 // Directory tree to image 52 String[] items = value.toString().split("/"); 53 for (int i=0; i<items.length-1; i++) { 54 zip.putNextEntry(new ZipEntry(name += items[i]+"/")); 55 } 56 // Image file 57 zip.putNextEntry(new ZipEntry(name += items[items.length-1])); 58 try { 59 FileInputStream in; 60 try { 61 in = new FileInputStream(baseDir+"modules/"+filename.replace(".jar", "/")+value.toString()); 62 } catch (FileNotFoundException e) { 63 // If not in module dir, may be in main images directory 64 if (value.toString().startsWith("images/")) { 65 in = new FileInputStream(baseDir+value.toString()); 66 } else { 67 throw e; 68 } 69 } 70 try { 71 byte[] buffer = new byte[4096]; 72 int n = -1; 73 while ((n = in.read(buffer)) > 0) { 74 zip.write(buffer, 0, n); 75 } 76 } finally { 77 in.close(); 78 } 79 } catch (IOException e) { 80 System.err.println("Cannot load Image-Icon: "+value.toString()); 81 } finally { 82 zip.closeEntry(); 83 } 84 } 85 } 86 } 87 88 } catch (IOException e) { 89 e.printStackTrace(); 90 } 91 } 92 } catch (IOException e) { 93 e.printStackTrace(); 94 } 95 } 19 private ModuleListGenerator() { 20 // Hide default constructor for utilities classes 21 } 22 23 /** 24 * @param args Main program arguments 25 */ 26 public static void main(String[] args) { 27 final String url = "http://svn.openstreetmap.org/applications/editors/josm/plugins/opendata/dist/"; 28 String baseDir = ""; 29 if (args.length > 0) { 30 baseDir = args[0]; 31 } 32 try ( 33 BufferedWriter list = new BufferedWriter(new FileWriter(baseDir+"modules.txt")); 34 ZipOutputStream zip = new ZipOutputStream(new FileOutputStream(baseDir+"modules-icons.zip")); 35 ) { 36 for (File file : new File(baseDir+"dist").listFiles(new FilenameFilter() { 37 @Override 38 public boolean accept(File dir, String name) { 39 return name.endsWith(".jar"); 40 } 41 })) { 42 try { 43 String filename = file.getName(); 44 System.out.println("Processing "+filename); 45 list.write(filename+";"+url+filename); list.newLine(); 46 Manifest mf = new JarFile(file).getManifest(); 47 for (Object att : mf.getMainAttributes().keySet()) { 48 Object value = mf.getMainAttributes().get(att); 49 if (value != null) { 50 list.write("\t"+att+": "+value.toString()); list.newLine(); 51 if (att.toString().equals("Module-Icon")) { 52 // Directory with jar name, including extension 53 String name = filename+"/"; 54 zip.putNextEntry(new ZipEntry(name)); 55 // Directory tree to image 56 String[] items = value.toString().split("/"); 57 for (int i = 0; i < items.length-1; i++) { 58 zip.putNextEntry(new ZipEntry(name += items[i]+"/")); 59 } 60 // Image file 61 zip.putNextEntry(new ZipEntry(name += items[items.length-1])); 62 try { 63 FileInputStream in; 64 try { 65 in = new FileInputStream(baseDir+"modules/"+filename.replace(".jar", "/")+value.toString()); 66 } catch (FileNotFoundException e) { 67 // If not in module dir, may be in main images directory 68 if (value.toString().startsWith("images/")) { 69 in = new FileInputStream(baseDir+value.toString()); 70 } else { 71 throw e; 72 } 73 } 74 try { 75 byte[] buffer = new byte[4096]; 76 int n = -1; 77 while ((n = in.read(buffer)) > 0) { 78 zip.write(buffer, 0, n); 79 } 80 } finally { 81 in.close(); 82 } 83 } catch (IOException e) { 84 System.err.println("Cannot load Image-Icon: "+value.toString()); 85 } finally { 86 zip.closeEntry(); 87 } 88 } 89 } 90 } 91 92 } catch (IOException e) { 93 e.printStackTrace(); 94 } 95 } 96 } catch (IOException e) { 97 e.printStackTrace(); 98 } 99 } 96 100 }
Note:
See TracChangeset
for help on using the changeset viewer.