Changeset 32846 in osm for applications/editors
- Timestamp:
- 2016-08-20T04:16:31+02:00 (8 years ago)
- Location:
- applications/editors/josm/plugins/pointInfo
- Files:
-
- 1 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pointInfo/.settings/org.eclipse.jdt.core.prefs
r32844 r32846 1 1 eclipse.preferences.version=1 2 org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled 3 org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore 4 org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull 5 org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault 6 org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable 7 org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled 2 8 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 9 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 10 org.eclipse.jdt.core.compiler.compliance=1.8 11 org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning 5 12 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 13 org.eclipse.jdt.core.compiler.problem.autoboxing=ignore 14 org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning 15 org.eclipse.jdt.core.compiler.problem.deadCode=warning 16 org.eclipse.jdt.core.compiler.problem.deprecation=warning 17 org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled 18 org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled 19 org.eclipse.jdt.core.compiler.problem.discouragedReference=warning 20 org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore 6 21 org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 22 org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore 23 org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore 24 org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled 25 org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore 26 org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning 27 org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning 28 org.eclipse.jdt.core.compiler.problem.forbiddenReference=error 29 org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning 30 org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled 31 org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning 32 org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning 33 org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore 34 org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore 35 org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning 36 org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore 37 org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore 38 org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled 39 org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore 40 org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore 41 org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled 42 org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning 43 org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore 44 org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning 45 org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning 46 org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore 47 org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning 48 org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error 49 org.eclipse.jdt.core.compiler.problem.nullReference=warning 50 org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error 51 org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning 52 org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning 53 org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore 54 org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore 55 org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore 56 org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore 57 org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning 58 org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning 59 org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore 60 org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning 61 org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning 62 org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore 63 org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore 64 org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled 65 org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning 66 org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled 67 org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled 68 org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled 69 org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore 70 org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning 71 org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled 72 org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning 73 org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning 74 org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore 75 org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning 76 org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore 77 org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore 78 org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore 79 org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore 80 org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled 81 org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled 82 org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled 83 org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore 84 org.eclipse.jdt.core.compiler.problem.unusedImport=warning 85 org.eclipse.jdt.core.compiler.problem.unusedLabel=warning 86 org.eclipse.jdt.core.compiler.problem.unusedLocal=warning 87 org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore 88 org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore 89 org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled 90 org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled 91 org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled 92 org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning 93 org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore 94 org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning 95 org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning 7 96 org.eclipse.jdt.core.compiler.source=1.8 -
applications/editors/josm/plugins/pointInfo/.settings/org.eclipse.jdt.ui.prefs
r32844 r32846 16 16 sp_cleanup.convert_functional_interfaces=false 17 17 sp_cleanup.convert_to_enhanced_for_loop=false 18 sp_cleanup.correct_indentation= true18 sp_cleanup.correct_indentation=false 19 19 sp_cleanup.format_source_code=false 20 20 sp_cleanup.format_source_code_changes_only=false -
applications/editors/josm/plugins/pointInfo/src/org/openstreetmap/josm/plugins/pointinfo/PointInfoAction.java
r32845 r32846 25 25 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 26 26 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 27 import org.openstreetmap.josm.gui.util.GuiHelper; 27 28 import org.openstreetmap.josm.plugins.pointinfo.ruian.RuianModule; 28 29 import org.openstreetmap.josm.tools.ImageProvider; … … 143 144 progressMonitor.invalidate(); 144 145 if (htmlText.length() == 0) { 145 PointInfoUtils.showNotification(tr("Data not available.")+ "\n(" + pos.toDisplayString() + ")", "warning"); 146 GuiHelper.runInEDTAndWait( 147 () -> PointInfoUtils.showNotification(tr("Data not available.")+ "\n(" + pos.toDisplayString() + ")", "warning")); 146 148 return; 147 149 } -
applications/editors/josm/plugins/pointInfo/src/org/openstreetmap/josm/plugins/pointinfo/PointInfoUtils.java
r32844 r32846 46 46 DecimalFormat df = new DecimalFormat("#.00000", symbols); 47 47 48 r = "(" + df.format(lat) + ", " + 49 df.format(lon) + ")"; 48 r = "(" + df.format(lat) + ", " + df.format(lon) + ")"; 50 49 return r; 51 50 } -
applications/editors/josm/plugins/pointInfo/src/org/openstreetmap/josm/plugins/pointinfo/ruian/RuianModule.java
r32845 r32846 2 2 package org.openstreetmap.josm.plugins.pointinfo.ruian; 3 3 4 import java.net.URL; 5 4 6 import org.openstreetmap.josm.Main; 5 7 import org.openstreetmap.josm.data.coor.LatLon; 6 import org.openstreetmap.josm. plugins.pointinfo.PointInfoServer;8 import org.openstreetmap.josm.tools.HttpClient; 7 9 8 10 /** … … 14 16 private String m_text = ""; 15 17 private String URL = "http://josm.poloha.net/pointInfo/v4/index.php"; 16 protected PointInfoServer server = new PointInfoServer();17 18 18 19 private RuianRecord m_record = new RuianRecord(); … … 46 47 try { 47 48 String request = URL + "?lat=" + pos.lat() + "&lon=" + pos.lon(); 48 System.out.println("Request: "+ request); 49 String content = server.callServer(request); 50 System.out.println("Reply: " + content); 51 m_record.parseJSON(content); 49 m_record.parseJSON(HttpClient.create(new URL(request)).connect().fetchContent()); 52 50 } catch (Exception e) { 53 51 Main.warn(e); -
applications/editors/josm/plugins/pointInfo/src/org/openstreetmap/josm/plugins/pointinfo/ruian/RuianRecord.java
r32845 r32846 5 5 6 6 import java.io.ByteArrayInputStream; 7 import java.nio.charset.StandardCharsets; 7 8 import java.util.ArrayList; 8 9 import java.util.Arrays; … … 14 15 import javax.json.JsonObject; 15 16 import javax.json.JsonReader; 17 import javax.json.JsonValue; 16 18 17 19 import org.openstreetmap.josm.Main; … … 24 26 import org.openstreetmap.josm.data.osm.Tag; 25 27 import org.openstreetmap.josm.data.osm.TagCollection; 28 import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils; 26 29 import org.openstreetmap.josm.plugins.pointinfo.PointInfoUtils; 27 import org.openstreetmap.josm.tools.Utils;28 30 29 31 /** … … 107 109 m_err_note = ""; 108 110 109 m_so_bez_geometrie = new ArrayList< ObjectWithoutGeometry>();110 m_adresni_mista = new ArrayList< AddrPlaces>();111 m_so_bez_geometrie = new ArrayList<>(); 112 m_adresni_mista = new ArrayList<>(); 111 113 112 114 m_parcela_ruian_id = 0; … … 137 139 init(); 138 140 139 JsonReader jsonReader = Json.createReader(new ByteArrayInputStream(jsonStr.getBytes( )));141 JsonReader jsonReader = Json.createReader(new ByteArrayInputStream(jsonStr.getBytes(StandardCharsets.UTF_8))); 140 142 JsonObject obj = jsonReader.readObject(); 141 143 jsonReader.close(); … … 163 165 // ========================================================================= 164 166 parseKatastr(obj); 167 } 168 169 private JsonObject getSafeJsonObject(JsonObject obj, String key) { 170 JsonValue val = obj.get(key); 171 if (val instanceof JsonObject) { 172 return (JsonObject) val; 173 } else if (val instanceof JsonArray) { 174 JsonArray array = (JsonArray) val; 175 if (!array.isEmpty()) { 176 return array.getJsonObject(0); 177 } 178 } 179 throw new IllegalArgumentException("No value for " + key); 165 180 } 166 181 … … 171 186 try { 172 187 m_coor_lat = Double.parseDouble(coorObjekt.getString("lat")); 173 } catch ( Exception e) {174 System.out.println("coordinates.lat: " + e.getMessage());188 } catch (NumberFormatException e) { 189 Main.warn(e, "coordinates.lat:"); 175 190 } 176 191 177 192 try { 178 193 m_coor_lon = Double.parseDouble(coorObjekt.getString("lon")); 179 } catch ( Exception e) {180 System.out.println("coordinates.lon: " + e.getMessage());194 } catch (NumberFormatException e) { 195 Main.warn(e, "coordinates.lon:"); 181 196 } 182 197 183 198 try { 184 199 m_source = obj.getString("source"); 185 } catch ( Exception e) {186 System.out.println("source: " + e.getMessage());200 } catch (RuntimeException e) { 201 Main.warn(e, "source:"); 187 202 } 188 203 189 204 } catch (Exception e) { 190 System.out.println("coordinates: " + e.getMessage());205 Main.warn(e, "coordinates:"); 191 206 } 192 207 } … … 194 209 private void parseStavebniObjekt(JsonObject obj) { 195 210 try { 196 JsonObject stavebniObjekt = obj.getJsonObject("stavebni_objekt");211 JsonObject stavebniObjekt = getSafeJsonObject(obj, "stavebni_objekt"); 197 212 198 213 try { 199 214 m_objekt_ruian_id = Long.parseLong(stavebniObjekt.getString("ruian_id")); 200 215 } catch (Exception e) { 201 System.out.println("stavebni_objekt.ruian_id: " + e.getMessage());216 Main.warn(e, "stavebni_objekt.ruian_id:"); 202 217 } 203 218 … … 205 220 m_objekt_podlazi = Integer.parseInt(stavebniObjekt.getString("pocet_podlazi")); 206 221 } catch (Exception e) { 207 System.out.println("stavebni_objekt.pocet_podlazi: " + e.getMessage());222 Main.warn(e, "stavebni_objekt.pocet_podlazi:"); 208 223 } 209 224 … … 211 226 m_objekt_byty = Integer.parseInt(stavebniObjekt.getString("pocet_bytu")); 212 227 } catch (Exception e) { 213 System.out.println("stavebni_objekt.pocet_bytu: " + e.getMessage());228 Main.warn(e, "stavebni_objekt.pocet_bytu:"); 214 229 } 215 230 … … 217 232 m_objekt_zpusob_vyuziti = stavebniObjekt.getString("zpusob_vyuziti"); 218 233 } catch (Exception e) { 219 System.out.println("stavebni_objekt.zpusob_vyuziti: " + e.getMessage());234 Main.warn(e, "stavebni_objekt.zpusob_vyuziti:"); 220 235 } 221 236 … … 223 238 m_objekt_zpusob_vyuziti_kod = stavebniObjekt.getString("zpusob_vyuziti_kod"); 224 239 } catch (Exception e) { 225 System.out.println("stavebni_objekt.m_objekt_zpusob_vyuziti_kod: " + e.getMessage());240 Main.warn(e, "stavebni_objekt.m_objekt_zpusob_vyuziti_kod:"); 226 241 } 227 242 … … 229 244 m_objekt_zpusob_vyuziti_key = stavebniObjekt.getString("zpusob_vyuziti_key"); 230 245 } catch (Exception e) { 231 System.out.println("stavebni_objekt.zpusob_vyuziti_key: " + e.getMessage());246 Main.warn(e, "stavebni_objekt.zpusob_vyuziti_key:"); 232 247 } 233 248 … … 235 250 m_objekt_zpusob_vyuziti_val = stavebniObjekt.getString("zpusob_vyuziti_val"); 236 251 } catch (Exception e) { 237 System.out.println("stavebni_objekt.m_objekt_zpusob_vyuziti_val: " + e.getMessage());252 Main.warn(e, "stavebni_objekt.m_objekt_zpusob_vyuziti_val:"); 238 253 } 239 254 … … 241 256 m_objekt_plati_od = stavebniObjekt.getString("plati_od"); 242 257 } catch (Exception e) { 243 System.out.println("stavebni_objekt.plati_od: " + e.getMessage());258 Main.warn(e, "stavebni_objekt.plati_od:"); 244 259 } 245 260 … … 247 262 m_objekt_dokonceni = stavebniObjekt.getString("dokonceni"); 248 263 } catch (Exception e) { 249 System.out.println("stavebni_objekt.dokonceni: " + e.getMessage());264 Main.warn(e, "stavebni_objekt.dokonceni:"); 250 265 } 251 266 252 267 } catch (Exception e) { 253 System.out.println("stavebni_objekt: " + e.getMessage());268 Main.warn(e, "stavebni_objekt:"); 254 269 } 255 270 } … … 257 272 private void parseNahlasenyProblem(JsonObject obj) { 258 273 try { 259 JsonObject errObjekt = obj.getJsonObject("nahlaseny_problem");274 JsonObject errObjekt = getSafeJsonObject(obj, "nahlaseny_problem"); 260 275 261 276 try { 262 277 m_err_user = errObjekt.getString("uzivatel"); 263 278 } catch (Exception e) { 264 System.out.println("nahlaseny_problem.uzivatel: " + e.getMessage());279 Main.warn(e, "nahlaseny_problem.uzivatel:"); 265 280 } 266 281 … … 268 283 m_err_date = errObjekt.getString("datum"); 269 284 } catch (Exception e) { 270 System.out.println("nahlaseny_problem.datum: " + e.getMessage());285 Main.warn(e, "nahlaseny_problem.datum:"); 271 286 } 272 287 … … 274 289 m_err_type = errObjekt.getString("duvod"); 275 290 } catch (Exception e) { 276 System.out.println("nahlaseny_problem.duvod: " + e.getMessage());291 Main.warn(e, "nahlaseny_problem.duvod:"); 277 292 } 278 293 … … 280 295 m_err_note = errObjekt.getString("poznamka"); 281 296 } catch (Exception e) { 282 System.out.println("nahlaseny_problem.poznamka: " + e.getMessage());297 Main.warn(e, "nahlaseny_problem.poznamka:"); 283 298 } 284 299 285 300 } catch (Exception e) { 286 System.out.println("nahlaseny_problem: " + e.getMessage());301 Main.warn(e, "nahlaseny_problem:"); 287 302 } 288 303 } … … 299 314 so.setRuianID(Long.parseLong(soBezGeom.getString("ruian_id"))); 300 315 } catch (Exception e) { 301 System.out.println("so_bez_geometrie.ruian_id: " + e.getMessage());316 Main.warn(e, "so_bez_geometrie.ruian_id:"); 302 317 } 303 318 … … 305 320 so.setPodlazi(Integer.parseInt(soBezGeom.getString("pocet_podlazi"))); 306 321 } catch (Exception e) { 307 System.out.println("so_bez_geometrie.pocet_podlazi: " + e.getMessage());322 Main.warn(e, "so_bez_geometrie.pocet_podlazi:"); 308 323 } 309 324 … … 311 326 so.setByty(Integer.parseInt(soBezGeom.getString("pocet_bytu"))); 312 327 } catch (Exception e) { 313 System.out.println("so_bez_geometrie.pocet_bytu: " + e.getMessage());328 Main.warn(e, "so_bez_geometrie.pocet_bytu:"); 314 329 } 315 330 … … 317 332 so.setZpusobVyuziti(soBezGeom.getString("zpusob_vyuziti")); 318 333 } catch (Exception e) { 319 System.out.println("so_bez_geometrie.zpusob_vyuziti: " + e.getMessage());334 Main.warn(e, "so_bez_geometrie.zpusob_vyuziti:"); 320 335 } 321 336 … … 323 338 so.setZpusobVyuzitiKod(soBezGeom.getString("zpusob_vyuziti_kod")); 324 339 } catch (Exception e) { 325 System.out.println("so_bez_geometrie.zpusob_vyuziti_kod: " + e.getMessage());340 Main.warn(e, "so_bez_geometrie.zpusob_vyuziti_kod:"); 326 341 } 327 342 … … 329 344 so.setZpusobVyuzitiKey(soBezGeom.getString("zpusob_vyuziti_key")); 330 345 } catch (Exception e) { 331 System.out.println("so_bez_geometrie.zpusob_vyuziti_key: " + e.getMessage());346 Main.warn(e, "so_bez_geometrie.zpusob_vyuziti_key:"); 332 347 } 333 348 … … 335 350 so.setZpusobVyuzitiVal(soBezGeom.getString("zpusob_vyuziti_val")); 336 351 } catch (Exception e) { 337 System.out.println("so_bez_geometrie.zpusob_vyuziti_val: " + e.getMessage());352 Main.warn(e, "so_bez_geometrie.zpusob_vyuziti_val:"); 338 353 } 339 354 … … 341 356 so.setDokonceni(soBezGeom.getString("dokonceni")); 342 357 } catch (Exception e) { 343 System.out.println("so_bez_geometrie.dokonceni: " + e.getMessage());358 Main.warn(e, "so_bez_geometrie.dokonceni:"); 344 359 } 345 360 … … 347 362 so.setPlatiOd(soBezGeom.getString("plati_od")); 348 363 } catch (Exception e) { 349 System.out.println("so_bez_geometrie.plati_od: " + e.getMessage());364 Main.warn(e, "so_bez_geometrie.plati_od:"); 350 365 } 351 366 … … 353 368 so.setVzdalenost(Float.parseFloat(soBezGeom.getString("vzdalenost"))); 354 369 } catch (Exception e) { 355 System.out.println("so_bez_geometrie.vzdalenost: " + e.getMessage());370 Main.warn(e, "so_bez_geometrie.vzdalenost:"); 356 371 } 357 372 … … 359 374 } 360 375 } catch (Exception e) { 361 System.out.println("so_bez_geometrie: " + e.getMessage());376 Main.warn(e, "so_bez_geometrie:"); 362 377 } 363 378 } … … 374 389 am.setRuianID(Long.parseLong(adresniMisto.getString("ruian_id"))); 375 390 } catch (Exception e) { 376 System.out.println("adresni_mista.ruian_id: " + e.getMessage());391 Main.warn(e, "adresni_mista.ruian_id:"); 377 392 } 378 393 … … 384 399 ); 385 400 } catch (Exception e) { 386 System.out.println("adresni_mista.pozice: " + e.getMessage());401 Main.warn(e, "adresni_mista.pozice:"); 387 402 } 388 403 … … 390 405 am.setBudovaID(Long.parseLong(adresniMisto.getString("budova_kod"))); 391 406 } catch (Exception e) { 392 System.out.println("adresni_mista.budova_kod: " + e.getMessage());407 Main.warn(e, "adresni_mista.budova_kod:"); 393 408 } 394 409 … … 396 411 am.setCisloTyp(adresniMisto.getString("cislo_typ")); 397 412 } catch (Exception e) { 398 System.out.println("adresni_mista.cislo_typ: " + e.getMessage());413 Main.warn(e, "adresni_mista.cislo_typ:"); 399 414 } 400 415 … … 402 417 am.setCisloDomovni(adresniMisto.getString("cislo_domovni")); 403 418 } catch (Exception e) { 404 System.out.println("adresni_mista.cislo_domovni: " + e.getMessage());419 Main.warn(e, "adresni_mista.cislo_domovni:"); 405 420 } 406 421 … … 408 423 am.setCisloOrientacni(adresniMisto.getString("cislo_orientacni")); 409 424 } catch (Exception e) { 410 System.out.println("adresni_mista.cislo_orientacni: " + e.getMessage());425 Main.warn(e, "adresni_mista.cislo_orientacni:"); 411 426 } 412 427 … … 414 429 am.setUliceID(Long.parseLong(adresniMisto.getString("ulice_kod"))); 415 430 } catch (Exception e) { 416 System.out.println("adresni_mista.ulice_kod: " + e.getMessage());431 Main.warn(e, "adresni_mista.ulice_kod:"); 417 432 } 418 433 … … 420 435 am.setUlice(adresniMisto.getString("ulice")); 421 436 } catch (Exception e) { 422 System.out.println("adresni_mista.ulice: " + e.getMessage());437 Main.warn(e, "adresni_mista.ulice:"); 423 438 } 424 439 … … 426 441 am.setCastObceID(Long.parseLong(adresniMisto.getString("cast_obce_kod"))); 427 442 } catch (Exception e) { 428 System.out.println("adresni_mista.cast_obce_kod: " + e.getMessage());443 Main.warn(e, "adresni_mista.cast_obce_kod:"); 429 444 } 430 445 … … 432 447 am.setCastObce(adresniMisto.getString("cast_obce")); 433 448 } catch (Exception e) { 434 System.out.println("adresni_mista.m_cast_obce: " + e.getMessage());449 Main.warn(e, "adresni_mista.m_cast_obce:"); 435 450 } 436 451 … … 438 453 am.setMestskaCastID(Long.parseLong(adresniMisto.getString("mestska_cast_kod"))); 439 454 } catch (Exception e) { 440 System.out.println("adresni_mista.mestska_cast_kod: " + e.getMessage());455 Main.warn(e, "adresni_mista.mestska_cast_kod:"); 441 456 } 442 457 … … 444 459 am.setMestskaCast(adresniMisto.getString("mestska_cast")); 445 460 } catch (Exception e) { 446 System.out.println("adresni_mista.mestska_cast: " + e.getMessage());461 Main.warn(e, "adresni_mista.mestska_cast:"); 447 462 } 448 463 … … 450 465 am.setObecID(Long.parseLong(adresniMisto.getString("obec_kod"))); 451 466 } catch (Exception e) { 452 System.out.println("adresni_mista.obec:_kod " + e.getMessage());467 Main.warn(e, "adresni_mista.obec_kod:"); 453 468 } 454 469 … … 456 471 am.setObec(adresniMisto.getString("obec")); 457 472 } catch (Exception e) { 458 System.out.println("adresni_mista.obec: " + e.getMessage());473 Main.warn(e, "adresni_mista.obec:"); 459 474 } 460 475 … … 462 477 am.setOkresID(Long.parseLong(adresniMisto.getString("okres_kod"))); 463 478 } catch (Exception e) { 464 System.out.println("adresni_mista.okres_kod: " + e.getMessage());479 Main.warn(e, "adresni_mista.okres_kod:"); 465 480 } 466 481 … … 468 483 am.setOkres(adresniMisto.getString("okres")); 469 484 } catch (Exception e) { 470 System.out.println("adresni_mista.okres: " + e.getMessage());485 Main.warn(e, "adresni_mista.okres:"); 471 486 } 472 487 … … 474 489 am.setKrajID(Long.parseLong(adresniMisto.getString("kraj_kod"))); 475 490 } catch (Exception e) { 476 System.out.println("adresni_mista.kraj_kod: " + e.getMessage());491 Main.warn(e, "adresni_mista.kraj_kod:"); 477 492 } 478 493 … … 480 495 am.setKraj(adresniMisto.getString("kraj")); 481 496 } catch (Exception e) { 482 System.out.println("adresni_mista.kraj: " + e.getMessage());497 Main.warn(e, "adresni_mista.kraj:"); 483 498 } 484 499 … … 486 501 am.setPsc(adresniMisto.getString("psc")); 487 502 } catch (Exception e) { 488 System.out.println("adresni_mista.psc: " + e.getMessage());503 Main.warn(e, "adresni_mista.psc:"); 489 504 } 490 505 … … 492 507 am.setVzdalenost(Float.parseFloat(adresniMisto.getString("vzdalenost"))); 493 508 } catch (Exception e) { 494 System.out.println("adresni_mista.vzdalenost: " + e.getMessage());509 Main.warn(e, "adresni_mista.vzdalenost:"); 495 510 } 496 511 … … 498 513 } 499 514 } catch (Exception e) { 500 System.out.println("adresni_mista: " + e.getMessage());515 Main.warn(e, "adresni_mista:"); 501 516 } 502 517 } … … 504 519 private void parseParcela(JsonObject obj) { 505 520 try { 506 JsonObject parcela = obj.getJsonObject("parcela");521 JsonObject parcela = getSafeJsonObject(obj, "parcela"); 507 522 508 523 try { 509 524 m_parcela_ruian_id = Long.parseLong(parcela.getString("ruian_id")); 510 525 } catch (Exception e) { 511 System.out.println("parcela.ruian_id: " + e.getMessage());526 Main.warn(e, "parcela.ruian_id:"); 512 527 } 513 528 … … 515 530 m_parcela_druh_pozemku = parcela.getString("druh_pozemku"); 516 531 } catch (Exception e) { 517 System.out.println("parcela.druh_pozemku: " + e.getMessage());532 Main.warn(e, "parcela.druh_pozemku:"); 518 533 } 519 534 … … 521 536 m_parcela_zpusob_vyuziti = parcela.getString("zpusob_vyuziti"); 522 537 } catch (Exception e) { 523 System.out.println("parcela.zpusob_vyuziti: " + e.getMessage());538 Main.warn(e, "parcela.zpusob_vyuziti:"); 524 539 } 525 540 … … 527 542 m_parcela_plati_od = parcela.getString("plati_od"); 528 543 } catch (Exception e) { 529 System.out.println("parcela.plati_od: " + e.getMessage());544 Main.warn(e, "parcela.plati_od:"); 530 545 } 531 546 532 547 } catch (Exception e) { 533 System.out.println("parcela: " + e.getMessage());548 Main.warn(e, "parcela:"); 534 549 } 535 550 } … … 537 552 private void parseUlice(JsonObject obj) { 538 553 try { 539 JsonObject ulice = obj.getJsonObject("ulice");554 JsonObject ulice = getSafeJsonObject(obj, "ulice"); 540 555 541 556 try { 542 557 m_ulice_ruian_id = Long.parseLong(ulice.getString("ruian_id")); 543 558 } catch (Exception e) { 544 System.out.println("ulice.ruian_id: " + e.getMessage());559 Main.warn(e, "ulice.ruian_id:"); 545 560 } 546 561 … … 548 563 m_ulice_jmeno = ulice.getString("jmeno"); 549 564 } catch (Exception e) { 550 System.out.println("ulice.jmeno: " + e.getMessage());565 Main.warn(e, "ulice.jmeno:"); 551 566 } 552 567 553 568 } catch (Exception e) { 554 System.out.println("ulice: " + e.getMessage());569 Main.warn(e, "ulice:"); 555 570 } 556 571 } … … 558 573 private void parseKatastr(JsonObject obj) { 559 574 try { 560 JsonObject katastr = obj.getJsonObject("katastr");575 JsonObject katastr = getSafeJsonObject(obj, "katastr"); 561 576 562 577 try { 563 578 m_katastr_ruian_id = Long.parseLong(katastr.getString("ruian_id")); 564 579 } catch (Exception e) { 565 System.out.println("katastr.ruian_id: " + e.getMessage());580 Main.warn(e, "katastr.ruian_id:"); 566 581 } 567 582 … … 569 584 m_katastr_nazev = katastr.getString("nazev"); 570 585 } catch (Exception e) { 571 System.out.println("katastr.nazev: " + e.getMessage());586 Main.warn(e, "katastr.nazev:"); 572 587 } 573 588 … … 575 590 m_katastr_obec_kod = Long.parseLong(katastr.getString("obec_kod")); 576 591 } catch (Exception e) { 577 System.out.println("katastr.obec_kod: " + e.getMessage());592 Main.warn(e, "katastr.obec_kod:"); 578 593 } 579 594 … … 581 596 m_katastr_obec = katastr.getString("obec"); 582 597 } catch (Exception e) { 583 System.out.println("katastr.okres: " + e.getMessage());598 Main.warn(e, "katastr.okres:"); 584 599 } 585 600 … … 587 602 m_katastr_okres_kod = Long.parseLong(katastr.getString("okres_kod")); 588 603 } catch (Exception e) { 589 System.out.println("katastr.okres_kod: " + e.getMessage());604 Main.warn(e, "katastr.okres_kod:"); 590 605 } 591 606 … … 593 608 m_katastr_okres = katastr.getString("okres"); 594 609 } catch (Exception e) { 595 System.out.println("katastr.okres: " + e.getMessage());610 Main.warn(e, "katastr.okres:"); 596 611 } 597 612 … … 599 614 m_katastr_kraj_kod = Long.parseLong(katastr.getString("kraj_kod")); 600 615 } catch (Exception e) { 601 System.out.println("katastr.kraj_kod: " + e.getMessage());616 Main.warn(e, "katastr.kraj_kod:"); 602 617 } 603 618 … … 605 620 m_katastr_kraj = katastr.getString("kraj"); 606 621 } catch (Exception e) { 607 System.out.println("katastr.kraj: " + e.getMessage());622 Main.warn(e, "katastr.kraj:"); 608 623 } 609 624 610 625 } catch (Exception e) { 611 System.out.println("katastr: " + e.getMessage());626 Main.warn(e, "katastr:"); 612 627 } 613 628 } … … 907 922 String[] parts = ruianDate.split("\\."); 908 923 try { 909 int day = Integer. parseInt(parts[0]);910 int month = Integer. parseInt(parts[1]);911 int year = Integer. parseInt(parts[2]);912 r = new Integer(year).toString() + "-" + String.format("%02d", month) + "-" + String.format("%02d", day);924 int day = Integer.valueOf(parts[0]); 925 int month = Integer.valueOf(parts[1]); 926 int year = Integer.valueOf(parts[2]); 927 r = Integer.toString(year) + "-" + String.format("%02d", month) + "-" + String.format("%02d", day); 913 928 } catch (Exception e) { 914 929 Main.warn(e); … … 940 955 if (keyType.equals("building") && m_objekt_ruian_id > 0) { 941 956 c.append(tagToString("ref:ruian:building", Long.toString(m_objekt_ruian_id))); 942 if ( m_objekt_zpusob_vyuziti_key.length() > 0&&943 m_objekt_zpusob_vyuziti_val.length() > 0957 if (!m_objekt_zpusob_vyuziti_key.isEmpty() && 958 !m_objekt_zpusob_vyuziti_val.isEmpty() 944 959 ) { 945 960 c.append(tagToString(m_objekt_zpusob_vyuziti_key, m_objekt_zpusob_vyuziti_val)); … … 960 975 } 961 976 962 if (keyType.startsWith("ghost") && m_so_bez_geometrie.size() > 0) {977 if (keyType.startsWith("ghost") && !m_so_bez_geometrie.isEmpty()) { 963 978 String[] key = keyType.split(":"); 964 int i = new Integer(key[1]);979 int i = Integer.valueOf(key[1]); 965 980 System.out.println("Ghost ID: " + i); 966 981 … … 988 1003 // Copy address tags to clipboard 989 1004 if (keyType.startsWith("address")) { 990 if ( m_adresni_mista.size() > 0) {1005 if (!m_adresni_mista.isEmpty()) { 991 1006 int i; 992 1007 993 if (m_adresni_mista. size() == 0) {1008 if (m_adresni_mista.isEmpty()) { 994 1009 i = 0; 995 1010 } else { 996 1011 String[] key = keyType.split(":"); 997 i = new Integer(key[1]);998 System.out.println("Address ID: " + i);1012 i = Integer.valueOf(key[1]); 1013 Main.info("Address ID: " + i); 999 1014 } 1000 1015 … … 1079 1094 */ 1080 1095 void createAddrPoint(String cmd, String t) { 1081 Collection<Command> commands = new LinkedList< Command>();1096 Collection<Command> commands = new LinkedList<>(); 1082 1097 Node node; 1083 1098 if (cmd.startsWith("tags.create-on-place")) { 1084 1099 String[] key = cmd.split(":"); 1085 int i = new Integer(key[1]);1100 int i = Integer.valueOf(key[1]); 1086 1101 node = new Node(m_adresni_mista.get(i).getPosition()); 1087 1102 } else { … … 1090 1105 commands.add(new AddCommand(node)); 1091 1106 1092 Collection<OsmPrimitive> coll = new LinkedList< OsmPrimitive>();1107 Collection<OsmPrimitive> coll = new LinkedList<>(); 1093 1108 coll.add(node); 1094 1109 1095 1110 TagCollection tc = new TagCollection(); 1096 ArrayList<String> list = new ArrayList< String>(Arrays.asList(t.split("\n")));1111 ArrayList<String> list = new ArrayList<>(Arrays.asList(t.split("\n"))); 1097 1112 for (String line : list) { 1098 1113 String[] tag = line.split("\"=\""); 1099 System.out.println("<" + tag[0] + ">. <" + tag[1] +">");1114 Main.info("<" + tag[0] + ">. <" + tag[1] +">"); 1100 1115 tc.add(new Tag(tag[0].substring(1), tag[1].substring(0, tag[1].length()-1))); 1101 1116 } … … 1113 1128 public void performAction(String act) { 1114 1129 1115 System.out.println("act: " + act.substring(7));1130 Main.info("act: " + act.substring(7)); 1116 1131 String[] params = act.substring(7).split("/"); 1117 1132 if (!params[0].equals("tags.copy") && !params[0].startsWith("tags.create")) { … … 1123 1138 // Copy tags to clipboard 1124 1139 if (params[0].equals("tags.copy")) { 1125 if ( task.length() > 0) {1126 Utils.copyToClipboard(task);1140 if (!task.isEmpty()) { 1141 ClipboardUtils.copyString(task); 1127 1142 PointInfoUtils.showNotification(tr("Tags copied to clipboard."), "info"); 1128 1143 } … … 1131 1146 // Create address node 1132 1147 if (params[0].startsWith("tags.create")) { 1133 if ( task.length() > 0) {1148 if (!task.isEmpty()) { 1134 1149 createAddrPoint(act.substring(7), task); 1135 1150 PointInfoUtils.showNotification(tr("New address point added."), "info");
Note:
See TracChangeset
for help on using the changeset viewer.