Changeset 32082 in osm for applications/editors/josm/plugins/seachart/src/s57
- Timestamp:
- 2016-02-27T09:09:45+01:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/seachart/src/s57
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/seachart/src/s57/S57att.java
r31955 r32082 122 122 AttStr.put(Att.SHIPAM, "shift"); AttStr.put(Att.SIGFRQ, "frequency"); AttStr.put(Att.SIGGEN, "generation"); AttStr.put(Att.SIGGRP, "group"); 123 123 AttStr.put(Att.SIGPER, "period"); AttStr.put(Att.SIGSEQ, "sequence"); AttStr.put(Att.SOUACC, "sounding_accuracy"); AttStr.put(Att.SDISMX, "maximum_sounding"); 124 AttStr.put(Att.SDISMN, "minimum_sounding"); AttStr.put(Att.SORDAT, ""); AttStr.put(Att.SORIND, ""); AttStr.put(Att.STATUS, "status"); 124 AttStr.put(Att.SDISMN, "minimum_sounding"); AttStr.put(Att.SORDAT, "source_date"); AttStr.put(Att.SORIND, "source"); AttStr.put(Att.STATUS, "status"); 125 125 AttStr.put(Att.SURATH, "authority"); AttStr.put(Att.SUREND, "survey_end"); AttStr.put(Att.SURSTA, "survey_start"); AttStr.put(Att.SURTYP, "survey"); 126 126 AttStr.put(Att.TECSOU, "technique"); AttStr.put(Att.TXTDSC, "document"); AttStr.put(Att.TIMEND, "end_time"); AttStr.put(Att.TIMSTA, "start_time"); -
applications/editors/josm/plugins/seachart/src/s57/S57box.java
r31846 r32082 18 18 19 19 enum Ext {I, N, W, S, E } 20 21 static Ext getExt(S57map map, double lat, double lon) { 22 if ((lat >= map.bounds.maxlat) && (lon < map.bounds.maxlon)) { 23 return Ext.N; 24 } else if (lon <= map.bounds.minlon) { 25 return Ext.W; 26 } else if (lat <= map.bounds.minlat) { 27 return Ext.S; 28 } else if (lon >= map.bounds.maxlon) { 29 return Ext.E; 30 } return Ext.I; 31 } 20 32 21 33 public static void bBox(S57map map) { … … 105 117 } 106 118 for (Land land : lands) { 107 GeomIterator git = map.new GeomIterator(land.land.geom); 108 Snode prev = null; 109 Ext bprev = Ext.I; 110 Ext ext; 111 land.ebound = land.sbound = Ext.I; 112 while (git.hasComp()) { 113 git.nextComp(); 114 while (git.hasEdge()) { 115 git.nextEdge(); 116 while (git.hasNode()) { 117 long ref = git.nextRef(false); 118 Snode node = map.nodes.get(ref); 119 if (node == null) 120 continue; 121 if (land.first == 0) { 122 land.first = ref; 123 } 124 if (prev == null) { 125 prev = node; 126 } 127 if ((node.lat >= map.bounds.maxlat) && (node.lon < map.bounds.maxlon)) { 128 ext = Ext.N; 129 } else if (node.lon <= map.bounds.minlon) { 130 ext = Ext.W; 131 } else if (node.lat <= map.bounds.minlat) { 132 ext = Ext.S; 133 } else if (node.lon >= map.bounds.maxlon) { 134 ext = Ext.E; 135 } else { 136 ext = Ext.I; 137 } 138 if (ext == Ext.I) { 139 if (land.start == null) { 140 land.start = prev; 141 land.sbound = bprev; 142 } 143 land.end = null; 144 land.ebound = Ext.I; 145 } else { 146 if ((land.start != null) && (land.end == null)) { 147 land.end = node; 148 land.ebound = ext; 149 } 150 } 151 prev = node; 152 bprev = ext; 153 land.last = ref; 154 } 155 } 156 } 119 land.first = map.edges.get(land.land.geom.elems.get(0).id).first; 120 land.start = map.nodes.get(land.first); 121 land.sbound = getExt(map, land.start.lat, land.start.lon); 122 land.last = map.edges.get(land.land.geom.elems.get(land.land.geom.comps.get(0).size - 1).id).last; 123 land.end = map.nodes.get(land.last); 124 land.ebound = getExt(map, land.end.lat, land.end.lon); 157 125 } 158 126 islands = new ArrayList<>(); … … 165 133 lands.remove(island); 166 134 } 167 while (lands.size() > 0) { 168 Land land = lands.get(0); 135 for (Land land : lands) { 169 136 Edge nedge = map.new Edge(); 170 137 nedge.first = land.last; 138 nedge.last = land.first; 171 139 Ext bound = land.ebound; 172 Snode last = land.end; 173 double delta = Math.PI; 174 int idx = -1; 175 Land next = null; 176 while (idx < 0) { 177 for (int i = 0; i < lands.size(); i++) { 178 next = lands.get(i); 179 if (next.sbound == bound) { 180 double diff = -Math.PI; 181 switch (bound) { 182 case N: 183 diff = last.lon - next.start.lon; 184 break; 185 case W: 186 diff = last.lat - next.start.lat; 187 break; 188 case S: 189 diff = next.start.lon - last.lon; 190 break; 191 case E: 192 diff = next.start.lat - last.lat; 193 break; 194 default: 195 continue; 196 } 197 if ((diff >= 0.0) && (diff < delta)) { 198 delta = diff; 199 idx = i; 200 } 201 } 202 } 203 if (idx < 0) { 204 long ref = (long) bound.ordinal(); 205 last = map.nodes.get(ref); 206 nedge.nodes.add(ref); 207 ref = ref < 4 ? ++ref : 1; 208 for (Ext e : Ext.values()) { 209 if (ref == e.ordinal()) { 210 bound = e; 211 break; 212 } 213 } 140 while (bound != land.sbound) { 141 switch (bound) { 142 case N: 143 nedge.nodes.add(1l); 144 bound = Ext.W; 145 break; 146 case W: 147 nedge.nodes.add(2l); 148 bound = Ext.S; 149 break; 150 case S: 151 nedge.nodes.add(3l); 152 bound = Ext.E; 153 break; 154 case E: 155 nedge.nodes.add(4l); 156 bound = Ext.N; 157 break; 158 default: 159 continue; 214 160 } 215 161 } 216 next = lands.get(idx);217 nedge.last = next.first;218 162 map.edges.put(++map.xref, nedge); 219 163 land.land.geom.elems.add(map.new Prim(map.xref)); 220 if (next != land) { 221 land.land.geom.elems.addAll(next.land.geom.elems); 222 land.ebound = next.ebound; 223 land.end = next.end; 224 land.last = next.last; 225 lands.remove(idx); 226 } 227 map.sortGeom(land.land); 228 if (land.land.geom.prim == Pflag.AREA) { 229 map.features.get(Obj.LNDARE).add(land.land); 230 lands.remove(land); 231 } 164 land.land.geom.comps.get(0).size++; 165 land.land.geom.prim = Pflag.AREA; 166 map.features.get(Obj.LNDARE).add(land.land); 232 167 } 233 168 } -
applications/editors/josm/plugins/seachart/src/s57/S57map.java
r31955 r32082 234 234 private Feature feature; 235 235 private Edge edge; 236 private KeyVal<?> osm = S57osm.OSMtag("", "");236 private ArrayList<KeyVal<?>> osm; 237 237 private boolean sea; 238 238 … … 375 375 feature.geom.elems.add(new Prim(id)); 376 376 edge = null; 377 osm = S57osm.OSMtag("", "");377 osm = new ArrayList<>(); 378 378 } 379 379 … … 385 385 feature.geom.elems.add(new Prim(id)); 386 386 edge = new Edge(); 387 osm = S57osm.OSMtag("", "");387 osm = new ArrayList<>(); 388 388 } 389 389 … … 406 406 feature.geom.prim = Pflag.AREA; 407 407 edge = null; 408 osm = S57osm.OSMtag("", "");408 osm = new ArrayList<>(); 409 409 } 410 410 … … 475 475 } 476 476 } else if (!sea) { 477 KeyVal<?> kv = S57osm.OSMtag(key, val); 478 if (kv.obj != Obj.UNKOBJ) { 479 osm.obj = kv.obj; 480 if (kv.att != Att.UNKATT) { 481 osm = kv; 482 } 483 } 477 S57osm.OSMtag(osm, key, val); 484 478 } 485 479 } … … 489 483 case POINT: 490 484 Snode node = nodes.get(id); 491 if ((node.flg != Nflag.CONN) && (node.flg != Nflag.DPTH) && (!feature.objs.isEmpty() || (osm.obj != Obj.UNKOBJ))) {485 if ((node.flg != Nflag.CONN) && (node.flg != Nflag.DPTH) && (!feature.objs.isEmpty() || !osm.isEmpty())) { 492 486 node.flg = Nflag.ISOL; 493 487 } … … 507 501 } 508 502 if (sortGeom(feature) && !((edge != null) && (edge.last == 0))) { 509 if (osm.obj != Obj.UNKOBJ) { 503 if (feature.type != Obj.UNKOBJ) { 504 index.put(id, feature); 505 if (features.get(feature.type) == null) { 506 features.put(feature.type, new ArrayList<Feature>()); 507 } 508 features.get(feature.type).add(feature); 509 } 510 for (KeyVal<?> kvx : osm) { 511 Feature base = new Feature(); 512 base.reln = Rflag.MASTER; 513 base.geom = feature.geom; 514 base.type = kvx.obj; 515 ObjTab objs = new ObjTab(); 516 base.objs.put(kvx.obj, objs); 517 AttMap atts = new AttMap(); 518 objs.put(0, atts); 519 if (kvx.att != Att.UNKATT) { 520 atts.put(kvx.att, new AttVal<>(kvx.conv, kvx.val)); 521 } 522 index.put(++xref, base); 523 if (features.get(kvx.obj) == null) { 524 features.put(kvx.obj, new ArrayList<Feature>()); 525 } 526 features.get(kvx.obj).add(base); 527 } 528 /* if (!osm.isEmpty()) { 510 529 if (feature.type == Obj.UNKOBJ) { 511 530 feature.type = osm.obj; … … 541 560 features.get(osm.obj).add(base); 542 561 } 543 } 544 if (feature.type != Obj.UNKOBJ) { 545 index.put(id, feature); 546 if (features.get(feature.type) == null) { 547 features.put(feature.type, new ArrayList<Feature>()); 548 } 549 features.get(feature.type).add(feature); 550 } 562 }*/ 551 563 } 552 564 } … … 575 587 feature.geom.centre = nodes.get(feature.geom.elems.get(0).id); 576 588 return true; 577 } else { 578 int sweep = feature.geom.elems.size(); 579 while (!feature.geom.elems.isEmpty()) { 580 Prim prim = feature.geom.elems.remove(0); 581 Edge edge = edges.get(prim.id); 582 if (edge == null) { 583 return false; 584 } 585 if (next == true) { 586 next = false; 587 first = edge.first; 589 } 590 Geom outer = new Geom(feature.geom.prim); 591 Geom inner = new Geom(feature.geom.prim); 592 for (Prim prim : feature.geom.elems) { 593 if (prim.outer) { 594 outer.elems.add(prim); 595 } else { 596 inner.elems.add(prim); 597 } 598 } 599 boolean outin = true; 600 int sweep = outer.elems.size(); 601 if (sweep == 0) { 602 return false; 603 } 604 int prev = sweep; 605 int top = 0; 606 while (!outer.elems.isEmpty()) { 607 Prim prim = outer.elems.remove(0); 608 Edge edge = edges.get(prim.id); 609 if (edge == null) { 610 return false; 611 } 612 if (next == true) { 613 next = false; 614 first = edge.first; 615 last = edge.last; 616 prim.forward = true; 617 sort.elems.add(prim); 618 if (prim.outer) { 619 sort.outers++; 620 } else { 621 sort.inners++; 622 } 623 comp = new Comp(cref++, 1); 624 sort.comps.add(comp); 625 } else { 626 if (edge.first == last) { 627 sort.elems.add(prim); 588 628 last = edge.last; 589 629 prim.forward = true; 630 comp.size++; 631 } else if (edge.last == first) { 632 sort.elems.add(top, prim); 633 first = edge.first; 634 prim.forward = true; 635 comp.size++; 636 } else if (edge.last == last) { 590 637 sort.elems.add(prim); 591 if (prim.outer) { 592 sort.outers++; 593 } else { 594 sort.inners++; 638 last = edge.first; 639 prim.forward = false; 640 comp.size++; 641 } else if (edge.first == first) { 642 sort.elems.add(top, prim); 643 first = edge.last; 644 prim.forward = false; 645 comp.size++; 646 } else { 647 outer.elems.add(prim); 648 } 649 } 650 if (--sweep == 0) { 651 sweep = outer.elems.size(); 652 if ((sweep == 0) || (sweep == prev)) { 653 if ((sort.prim == Pflag.AREA) && (first != last)) { 654 return false; 595 655 } 596 comp = new Comp(cref++, 1); 597 sort.comps.add(comp); 598 } else { 599 if (edge.first == last) { 600 sort.elems.add(prim); 601 last = edge.last; 602 prim.forward = true; 603 comp.size++; 604 } else if (edge.last == first) { 605 sort.elems.add(0, prim); 606 first = edge.first; 607 prim.forward = true; 608 comp.size++; 609 } else if (edge.last == last) { 610 sort.elems.add(prim); 611 last = edge.first; 612 prim.forward = false; 613 comp.size++; 614 } else if (edge.first == first) { 615 sort.elems.add(0, prim); 616 first = edge.last; 617 prim.forward = false; 618 comp.size++; 619 } else { 620 feature.geom.elems.add(prim); 656 if (outin) { 657 if (sweep != 0) { 658 return false; 659 } 660 outer = inner; 661 outin = false; 662 sweep = outer.elems.size(); 621 663 } 622 }623 if (--sweep == 0) {624 664 next = true; 625 sweep = feature.geom.elems.size(); 626 } 627 } 628 if ((sort.prim == Pflag.LINE) && (sort.outers == 1) && (sort.inners == 0) && (first == last)) { 629 sort.prim = Pflag.AREA; 630 } 631 feature.geom = sort; 632 } 665 top = sort.elems.size(); 666 } 667 prev = sweep; 668 } 669 } 670 if ((sort.prim == Pflag.LINE) && (sort.outers == 1) && (sort.inners == 0) && (first == last)) { 671 sort.prim = Pflag.AREA; 672 } 673 feature.geom = sort; 633 674 if (feature.geom.prim == Pflag.AREA) { 634 675 int ie = 0; -
applications/editors/josm/plugins/seachart/src/s57/S57osm.java
r31955 r32082 35 35 static { 36 36 OSMtags.put("natural=coastline", new KeyVal<>(Obj.COALNE, Att.UNKATT, null, null)); OSMtags.put("natural=water", new KeyVal<>(Obj.LAKARE, Att.UNKATT, null, null)); 37 OSMtags.put("water=river", new KeyVal<>(Obj.RIVERS, Att.UNKATT, null, null)); OSMtags.put("water=canal", new KeyVal<>(Obj.CANALS, Att.UNKATT, null, null)); 37 38 OSMtags.put("waterway=riverbank", new KeyVal<>(Obj.RIVERS, Att.UNKATT, null, null)); OSMtags.put("waterway=dock", new KeyVal<>(Obj.HRBBSN, Att.UNKATT, null, null)); 38 39 OSMtags.put("waterway=lock", new KeyVal<>(Obj.HRBBSN, Att.UNKATT, null, null)); OSMtags.put("landuse=basin", new KeyVal<>(Obj.LAKARE, Att.UNKATT, null, null)); … … 51 52 } 52 53 53 public static KeyVal<?> OSMtag(String key, String val) {54 public static void OSMtag(ArrayList<KeyVal<?>> osm, String key, String val) { 54 55 KeyVal<?> kv = OSMtags.get(key + "=" + val); 55 56 if (kv != null) { … … 57 58 ArrayList<Enum<?>> list = new ArrayList<Enum<?>>(); 58 59 list.add((Enum<?>)kv.val); 59 return new KeyVal<>(kv.obj, kv.att, kv.conv, list); 60 } 61 return kv; 62 } 63 return new KeyVal<>(Obj.UNKOBJ, Att.UNKATT, null, null); 64 } 65 66 public static void OSMmap(BufferedReader in, S57map map) throws Exception { 60 osm.add(new KeyVal<>(kv.obj, kv.att, kv.conv, list)); 61 } else { 62 osm.add(kv); 63 } 64 } 65 KeyVal<?> kvl = null; 66 KeyVal<?> kvd = null; 67 boolean rc = false; 68 boolean rcl = false; 69 for (KeyVal<?> kvx : osm) { 70 if (kvx.obj == Obj.LAKARE) { 71 kvl = kvx; 72 } else if ((kvx.obj == Obj.RIVERS) || (kvx.obj == Obj.CANALS)) { 73 rc = true; 74 } 75 if (kvx.obj == Obj.DEPARE) { 76 kvd = kvx; 77 } else if ((kvx.obj == Obj.RIVERS) || (kvx.obj == Obj.CANALS) || (kvx.obj == Obj.LAKARE)) { 78 rcl = true; 79 } 80 } 81 if (rc && (kvl != null)) { 82 osm.remove(kvl); 83 } 84 if (rcl && (kvd != null)) { 85 osm.remove(kvd); 86 } 87 return; 88 } 89 90 public static void OSMmap(BufferedReader in, S57map map, boolean bb) throws Exception { 67 91 String k = ""; 68 92 String v = ""; … … 84 108 while ((ln = in.readLine()) != null) { 85 109 if (inOsm) { 86 if (ln.contains("<bounds")) { 110 if (ln.contains("<bounds") && !bb) { 87 111 for (String token : ln.split("[ ]+")) { 88 112 if (token.matches("^minlat=.+")) { -
applications/editors/josm/plugins/seachart/src/s57/S57val.java
r31846 r32082 616 616 private static final EnumMap<NatSUR, S57enum> Natsur = new EnumMap<>(NatSUR.class); static { Natsur.put(NatSUR.SUR_UNKN, new S57enum(0, "")); 617 617 Natsur.put(NatSUR.SUR_MUD, new S57enum(1, "mud")); Natsur.put(NatSUR.SUR_CLAY, new S57enum(2, "clay")); Natsur.put(NatSUR.SUR_SILT, new S57enum(3, "silt")); 618 Natsur.put(NatSUR.SUR_SAND, new S57enum(4, "sand")); Natsur.put(NatSUR.SUR_STON, new S57enum(5, "stone")); Natsur.put(NatSUR.SUR_GRVL, new S57enum(6, "gravel")); 619 Natsur.put(NatSUR.SUR_PBBL, new S57enum(7, "pebbles")); Natsur.put(NatSUR.SUR_CBBL, new S57enum(8, "cobbles")); Natsur.put(NatSUR.SUR_ROCK, new S57enum(9, "rock")); 618 Natsur.put(NatSUR.SUR_SAND, new S57enum(4, "sand")); Natsur.put(NatSUR.SUR_STON, new S57enum(5, "stones")); Natsur.put(NatSUR.SUR_GRVL, new S57enum(6, "gravel")); 619 Natsur.put(NatSUR.SUR_PBBL, new S57enum(7, "pebbles")); Natsur.put(NatSUR.SUR_CBBL, new S57enum(8, "cobbles")); Natsur.put(NatSUR.SUR_ROCK, new S57enum(9, "rocky")); 620 620 Natsur.put(NatSUR.SUR_LAVA, new S57enum(11, "lava")); Natsur.put(NatSUR.SUR_CORL, new S57enum(14, "coral")); Natsur.put(NatSUR.SUR_SHEL, new S57enum(17, "shells")); 621 Natsur.put(NatSUR.SUR_BLDR, new S57enum(18, "boulder")); 621 Natsur.put(NatSUR.SUR_BLDR, new S57enum(18, "boulders")); 622 622 } 623 623 public enum NatQUA { QUA_UNKN, QUA_FINE, QUA_MEDM, QUA_CORS, QUA_BRKN, QUA_STKY, QUA_SOFT, QUA_STIF, QUA_VCNC, QUA_CALC, QUA_HARD } … … 1094 1094 keys.put(Att.LC_DR1, new S57key(Conv.F, null)); keys.put(Att.LC_DR2, new S57key(Conv.F, null)); keys.put(Att.LC_SP1, new S57key(Conv.F, null)); 1095 1095 keys.put(Att.LC_SP2, new S57key(Conv.F, null)); keys.put(Att.LC_WD1, new S57key(Conv.F, null)); keys.put(Att.LC_WD2, new S57key(Conv.F, null)); 1096 keys.put(Att.LITRAD, new S57key(Conv. A, null)); keys.put(Att.CATCVR, new S57key(Conv.E, Catcvr));1096 keys.put(Att.LITRAD, new S57key(Conv.F, null)); keys.put(Att.CATCVR, new S57key(Conv.E, Catcvr)); 1097 1097 } 1098 1098
Note:
See TracChangeset
for help on using the changeset viewer.