Changeset 30367 in osm for applications/editors/josm/plugins/pointInfo/src/org/openstreetmap
- Timestamp:
- 2014-03-26T00:05:28+01:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pointInfo/src/org/openstreetmap/josm/plugins/pointinfo/ruianModule.java
r30334 r30367 25 25 import org.openstreetmap.josm.data.osm.OsmPrimitive; 26 26 import org.openstreetmap.josm.data.coor.LatLon; 27 import org.openstreetmap.josm.data.osm.Node; 28 import org.openstreetmap.josm.data.osm.Tag; 29 import org.openstreetmap.josm.data.osm.TagCollection; 30 import org.openstreetmap.josm.gui.Notification; 27 31 import org.openstreetmap.josm.tools.Utils; 28 import org.openstreetmap.josm.gui.Notification; 29 // import org.openstreetmap.josm.actions.PasteTagsAction; 32 30 33 import org.openstreetmap.josm.command.AddCommand; 31 34 import org.openstreetmap.josm.command.Command; 32 35 import org.openstreetmap.josm.command.SequenceCommand; 33 import org.openstreetmap.josm.data.osm.Node; 34 35 import org.openstreetmap.josm.data.osm.Tag; 36 import org.openstreetmap.josm.data.osm.TagCollection; 37 38 import org.json.JSONObject; 39 import org.json.JSONArray; 36 37 import java.io.InputStream; 38 import java.io.ByteArrayInputStream; 39 40 import javax.json.Json; 41 import javax.json.JsonException; 42 import javax.json.JsonArray; 43 import javax.json.JsonObject; 44 import javax.json.JsonReader; 45 import javax.json.JsonValue; 46 40 47 41 48 import java.util.*; … … 279 286 init(); 280 287 281 282 try {283 JSONObject obj = new JSONObject(jsonStr);288 JsonReader jsonReader = Json.createReader(new ByteArrayInputStream(jsonStr.getBytes())); 289 JsonObject obj = jsonReader.readObject(); 290 jsonReader.close(); 284 291 285 292 try { 286 m_coor_lat = obj.getJSONObject("coordinates").getDouble("lat"); 293 JsonObject coorObjekt = obj.getJsonObject("coordinates"); 294 295 try { 296 m_coor_lat = Double.parseDouble(coorObjekt.getString("lat")); 297 } catch (Exception e) { 298 System.out.println("coordinates.lat: " + e.getMessage()); 299 } 300 301 try { 302 m_coor_lon = Double.parseDouble(coorObjekt.getString("lon")); 303 } catch (Exception e) { 304 System.out.println("coordinates.lon: " + e.getMessage()); 305 } 306 307 try { 308 m_source = obj.getString("source"); 309 } catch (Exception e) { 310 System.out.println("source: " + e.getMessage()); 311 } 312 287 313 } catch (Exception e) { 288 } 289 290 try { 291 m_coor_lon = obj.getJSONObject("coordinates").getDouble("lon"); 292 } catch (Exception e) { 293 } 294 295 try { 296 m_source = obj.getString("source"); 297 } catch (Exception e) { 314 System.out.println("coordinates: " + e.getMessage()); 298 315 } 299 316 300 317 // ========================================================================= 301 318 try { 302 JSONObject stavebniObjekt = obj.getJSONObject("stavebni_objekt"); 303 304 try { 305 m_objekt_ruian_id = stavebniObjekt.getLong("ruian_id"); 306 } catch (Exception e) { 307 } 308 309 try { 310 m_objekt_podlazi = stavebniObjekt.getInt("pocet_podlazi"); 311 } catch (Exception e) { 312 } 313 314 try { 315 m_objekt_byty = stavebniObjekt.getInt("pocet_bytu"); 316 } catch (Exception e) { 319 JsonObject stavebniObjekt = obj.getJsonObject("stavebni_objekt"); 320 321 try { 322 m_objekt_ruian_id = Long.parseLong(stavebniObjekt.getString("ruian_id")); 323 } catch (Exception e) { 324 System.out.println("stavebni_objekt.ruian_id: " + e.getMessage()); 325 } 326 327 try { 328 m_objekt_podlazi = Integer.parseInt(stavebniObjekt.getString("pocet_podlazi")); 329 } catch (Exception e) { 330 System.out.println("stavebni_objekt.pocet_podlazi: " + e.getMessage()); 331 } 332 333 try { 334 m_objekt_byty = Integer.parseInt(stavebniObjekt.getString("pocet_bytu")); 335 } catch (Exception e) { 336 System.out.println("stavebni_objekt.pocet_bytu: " + e.getMessage()); 317 337 } 318 338 … … 320 340 m_objekt_zpusob_vyuziti = stavebniObjekt.getString("zpusob_vyuziti"); 321 341 } catch (Exception e) { 342 System.out.println("stavebni_objekt.zpusob_vyuziti: " + e.getMessage()); 322 343 } 323 344 … … 325 346 m_objekt_zpusob_vyuziti_kod = stavebniObjekt.getString("zpusob_vyuziti_kod"); 326 347 } catch (Exception e) { 348 System.out.println("stavebni_objekt.m_objekt_zpusob_vyuziti_kod: " + e.getMessage()); 327 349 } 328 350 … … 330 352 m_objekt_zpusob_vyuziti_key = stavebniObjekt.getString("zpusob_vyuziti_key"); 331 353 } catch (Exception e) { 354 System.out.println("stavebni_objekt.zpusob_vyuziti_key: " + e.getMessage()); 332 355 } 333 356 … … 335 358 m_objekt_zpusob_vyuziti_val = stavebniObjekt.getString("zpusob_vyuziti_val"); 336 359 } catch (Exception e) { 360 System.out.println("stavebni_objekt.m_objekt_zpusob_vyuziti_val: " + e.getMessage()); 337 361 } 338 362 … … 340 364 m_objekt_plati_od = stavebniObjekt.getString("plati_od"); 341 365 } catch (Exception e) { 366 System.out.println("stavebni_objekt.plati_od: " + e.getMessage()); 342 367 } 343 368 … … 345 370 m_objekt_dokonceni = stavebniObjekt.getString("dokonceni"); 346 371 } catch (Exception e) { 347 } 372 System.out.println("stavebni_objekt.dokonceni: " + e.getMessage()); 373 } 374 348 375 } catch (Exception e) { 376 System.out.println("stavebni_objekt: " + e.getMessage()); 349 377 } 350 378 351 379 // ========================================================================= 352 380 try { 353 J SONArray arr = obj.getJSONArray("adresni_mista");354 355 for(int i = 0; i < arr. length(); i++)381 JsonArray arr = obj.getJsonArray("adresni_mista"); 382 383 for(int i = 0; i < arr.size(); i++) 356 384 { 357 J SONObject adresniMisto = arr.getJSONObject(i);385 JsonObject adresniMisto = arr.getJsonObject(i); 358 386 addrPlaces am = new addrPlaces(); 359 387 360 388 try { 361 am.setRuianID(adresniMisto.getLong("ruian_id")); 362 } catch (Exception e) { 363 } 364 365 try { 366 JSONArray node = adresniMisto.getJSONArray("pozice"); 389 am.setRuianID(Long.parseLong(adresniMisto.getString("ruian_id"))); 390 } catch (Exception e) { 391 System.out.println("adresni_mista.ruian_id: " + e.getMessage()); 392 } 393 394 try { 395 JsonArray node = adresniMisto.getJsonArray("pozice"); 367 396 am.setPosition(new LatLon( 368 LatLon.roundToOsmPrecisionStrict(node.getDouble(1)), 369 LatLon.roundToOsmPrecisionStrict(node.getDouble(0))) 370 ); 371 } catch (Exception e) { 372 } 373 374 try { 375 am.setBudovaID(adresniMisto.getLong("budova_kod")); 376 } catch (Exception e) { 397 LatLon.roundToOsmPrecisionStrict(node.getJsonNumber(1).doubleValue()), 398 LatLon.roundToOsmPrecisionStrict(node.getJsonNumber(0).doubleValue())) 399 ); 400 } catch (Exception e) { 401 System.out.println("adresni_mista.pozice: " + e.getMessage()); 402 } 403 404 try { 405 am.setBudovaID(Long.parseLong(adresniMisto.getString("budova_kod"))); 406 } catch (Exception e) { 407 System.out.println("adresni_mista.budova_kod: " + e.getMessage()); 377 408 } 378 409 … … 380 411 am.setCisloTyp(adresniMisto.getString("cislo_typ")); 381 412 } catch (Exception e) { 413 System.out.println("adresni_mista.cislo_typ: " + e.getMessage()); 382 414 } 383 415 … … 385 417 am.setCisloDomovni(adresniMisto.getString("cislo_domovni")); 386 418 } catch (Exception e) { 419 System.out.println("adresni_mista.cislo_domovni: " + e.getMessage()); 387 420 } 388 421 … … 390 423 am.setCisloOrientacni(adresniMisto.getString("cislo_orientacni")); 391 424 } catch (Exception e) { 425 System.out.println("adresni_mista.cislo_orientacni: " + e.getMessage()); 392 426 } 393 427 … … 395 429 am.setUlice(adresniMisto.getString("ulice")); 396 430 } catch (Exception e) { 431 System.out.println("adresni_mista.ulice: " + e.getMessage()); 397 432 } 398 433 … … 400 435 am.setCastObce(adresniMisto.getString("cast_obce")); 401 436 } catch (Exception e) { 437 System.out.println("adresni_mista.m_cast_obce: " + e.getMessage()); 402 438 } 403 439 … … 405 441 am.setMestskaCast(adresniMisto.getString("mestska_cast")); 406 442 } catch (Exception e) { 443 System.out.println("adresni_mista.mestska_cast: " + e.getMessage()); 407 444 } 408 445 … … 410 447 am.setObec(adresniMisto.getString("obec")); 411 448 } catch (Exception e) { 449 System.out.println("adresni_mista.obec: " + e.getMessage()); 412 450 } 413 451 … … 415 453 am.setOkres(adresniMisto.getString("okres")); 416 454 } catch (Exception e) { 455 System.out.println("adresni_mista.okres: " + e.getMessage()); 417 456 } 418 457 … … 420 459 am.setKraj(adresniMisto.getString("kraj")); 421 460 } catch (Exception e) { 461 System.out.println("adresni_mista.kraj: " + e.getMessage()); 422 462 } 423 463 … … 425 465 am.setPsc(adresniMisto.getString("psc")); 426 466 } catch (Exception e) { 467 System.out.println("adresni_mista.psc: " + e.getMessage()); 427 468 } 428 469 … … 430 471 } 431 472 } catch (Exception e) { 473 System.out.println("adresni_mista: " + e.getMessage()); 432 474 } 433 475 434 476 // ========================================================================= 435 477 try { 436 JSONObject parcela = obj.getJSONObject("parcela"); 437 438 try { 439 m_parcela_ruian_id = parcela.getLong("ruian_id"); 440 } catch (Exception e) { 441 } 442 ; 478 JsonObject parcela = obj.getJsonObject("parcela"); 479 480 try { 481 m_parcela_ruian_id = Long.parseLong(parcela.getString("ruian_id")); 482 } catch (Exception e) { 483 System.out.println("parcela.ruian_id: " + e.getMessage()); 484 } 485 443 486 try { 444 487 m_parcela_druh_pozemku = parcela.getString("druh_pozemku"); 445 488 } catch (Exception e) { 489 System.out.println("parcela.druh_pozemku: " + e.getMessage()); 446 490 } 447 491 … … 449 493 m_parcela_zpusob_vyuziti = parcela.getString("zpusob_vyuziti"); 450 494 } catch (Exception e) { 495 System.out.println("parcela.zpusob_vyuziti: " + e.getMessage()); 451 496 } 452 497 … … 454 499 m_parcela_plati_od = parcela.getString("plati_od"); 455 500 } catch (Exception e) { 501 System.out.println("parcela.plati_od: " + e.getMessage()); 456 502 } 457 503 458 504 } catch (Exception e) { 505 System.out.println("parcela: " + e.getMessage()); 459 506 } 460 507 461 508 // ========================================================================= 462 509 try { 463 JSONObject ulice = obj.getJSONObject("ulice"); 464 465 try { 466 m_ulice_ruian_id = ulice.getLong("ruian_id"); 467 } catch (Exception e) { 510 JsonObject ulice = obj.getJsonObject("ulice"); 511 512 try { 513 m_ulice_ruian_id = Long.parseLong(ulice.getString("ruian_id")); 514 } catch (Exception e) { 515 System.out.println("ulice.ruian_id: " + e.getMessage()); 468 516 } 469 517 … … 471 519 m_ulice_jmeno = ulice.getString("jmeno"); 472 520 } catch (Exception e) { 521 System.out.println("ulice.jmeno: " + e.getMessage()); 473 522 } 474 523 475 524 } catch (Exception e) { 525 System.out.println("ulice: " + e.getMessage()); 476 526 } 477 527 478 528 // ========================================================================= 479 529 try { 480 JSONObject katastr = obj.getJSONObject("katastr"); 481 482 try { 483 m_katastr_ruian_id = katastr.getLong("ruian_id"); 484 } catch (Exception e) { 530 JsonObject katastr = obj.getJsonObject("katastr"); 531 532 try { 533 m_katastr_ruian_id = Long.parseLong(katastr.getString("ruian_id")); 534 } catch (Exception e) { 535 System.out.println("katastr.ruian_id: " + e.getMessage()); 485 536 } 486 537 … … 488 539 m_katastr_nazev = katastr.getString("nazev"); 489 540 } catch (Exception e) { 541 System.out.println("katastr.nazev: " + e.getMessage()); 490 542 } 491 543 … … 493 545 m_katastr_obec = katastr.getString("obec"); 494 546 } catch (Exception e) { 547 System.out.println("katastr.okres: " + e.getMessage()); 495 548 } 496 549 … … 498 551 m_katastr_okres = katastr.getString("okres"); 499 552 } catch (Exception e) { 553 System.out.println("katastr.okres: " + e.getMessage()); 500 554 } 501 555 … … 503 557 m_katastr_kraj = katastr.getString("kraj"); 504 558 } catch (Exception e) { 559 System.out.println("katastr.kraj: " + e.getMessage()); 505 560 } 506 561 507 562 } catch (Exception e) { 508 } 509 } catch (Exception e) { 510 } 511 563 System.out.println("katastr: " + e.getMessage()); 564 } 512 565 } 513 566
Note:
See TracChangeset
for help on using the changeset viewer.