Changeset 31027 in osm for applications/editors/josm/plugins/seachart/src/s57
- Timestamp:
- 2015-02-19T21:52:40+01:00 (10 years ago)
- Location:
- applications/editors/josm/plugins/seachart/src/s57
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/seachart/src/s57/S57map.java
r31014 r31027 18 18 import s57.S57val; 19 19 import s57.S57val.*; 20 import s57.S57osm; 21 import s57.S57osm.*; 20 22 21 23 public class S57map { … … 482 484 483 485 public void tagsDone(long id) { 484 if (feature.type == Obj.UNKOBJ) { 485 for (OSMtag tag : osmtags) { 486 Obj obj = S57obj.OSMobj(tag.key, tag.val); 487 if (obj != Obj.UNKOBJ) { 488 feature.type = obj; 489 ObjTab objs = feature.objs.get(obj); 490 if (objs == null) { 491 objs = new ObjTab(); 492 feature.objs.put(obj, objs); 493 } 494 AttMap atts = objs.get(0); 495 if (atts == null) { 496 atts = new AttMap(); 497 objs.put(0, atts); 498 } 499 AttVal<?> attval = S57val.OSMatt(tag.key, tag.val); 500 if (attval.att != Att.UNKATT) { 501 atts.put(attval.att, attval); 502 } 503 break; 504 } 486 for (OSMtag tag : osmtags) { 487 KeyVal kv = S57osm.OSMtag(tag.key, tag.val); 488 if (kv.obj != Obj.UNKOBJ) { 489 if (feature.type == Obj.UNKOBJ) { 490 feature.type = kv.obj; 491 } 492 ObjTab objs = feature.objs.get(kv.obj); 493 if (objs == null) { 494 objs = new ObjTab(); 495 feature.objs.put(kv.obj, objs); 496 } 497 AttMap atts = objs.get(0); 498 if (atts == null) { 499 atts = new AttMap(); 500 objs.put(0, atts); 501 } 502 if (kv.att != Att.UNKATT) { 503 atts.put(kv.att, new AttVal(kv.att, kv.conv, kv.val)); 504 } 505 break; 505 506 } 506 507 } … … 594 595 nedge.last = first; 595 596 switch (lext) { 596 case NE:597 597 case N: 598 if (( fext != Ext.NE) &&(fext != Ext.N)) {598 if ((lext == fext) || (fext != Ext.N)) { 599 599 nedge.nodes.add(1L); 600 if ((fext != Ext. NW) && (fext != Ext.W)) {600 if ((fext != Ext.W)) { 601 601 nedge.nodes.add(2L); 602 if ((fext != Ext.S W) && (fext != Ext.S)) {602 if ((fext != Ext.S)) { 603 603 nedge.nodes.add(3L); 604 if ((fext != Ext. SE) && (fext != Ext.W)) {604 if ((fext != Ext.W)) { 605 605 nedge.nodes.add(4L); 606 606 } … … 609 609 } 610 610 break; 611 case NW:612 611 case W: 613 if (( fext != Ext.NW) &&(fext != Ext.W)) {612 if ((lext == fext) || (fext != Ext.W)) { 614 613 nedge.nodes.add(2L); 615 if ((fext != Ext.S W) && (fext != Ext.S)) {614 if ((fext != Ext.S)) { 616 615 nedge.nodes.add(3L); 617 if ((fext != Ext. SE) && (fext != Ext.E)) {616 if ((fext != Ext.E)) { 618 617 nedge.nodes.add(4L); 619 if ( (fext != Ext.NE) &&(fext != Ext.N)) {618 if ( (fext != Ext.N)) { 620 619 nedge.nodes.add(1L); 621 620 } … … 624 623 } 625 624 break; 626 case SW:627 625 case S: 628 if (( fext != Ext.SW) &&(fext != Ext.S)) {626 if ((lext == fext) || (fext != Ext.S)) { 629 627 nedge.nodes.add(3L); 630 if ((fext != Ext. SE) && (fext != Ext.E)) {628 if ((fext != Ext.E)) { 631 629 nedge.nodes.add(4L); 632 if ((fext != Ext.N E) && (fext != Ext.N)) {630 if ((fext != Ext.N)) { 633 631 nedge.nodes.add(1L); 634 if ((fext != Ext. NW) && (fext != Ext.W)) {632 if ((fext != Ext.W)) { 635 633 nedge.nodes.add(2L); 636 634 } … … 639 637 } 640 638 break; 641 case SE:642 639 case E: 643 if (( fext != Ext.SE) &&(fext != Ext.E)) {640 if ((lext == fext) || (fext != Ext.E)) { 644 641 nedge.nodes.add(4L); 645 if ((fext != Ext.N E) && (fext != Ext.N)) {642 if ((fext != Ext.N)) { 646 643 nedge.nodes.add(1L); 647 if ((fext != Ext. NW) && (fext != Ext.W)) {644 if ((fext != Ext.W)) { 648 645 nedge.nodes.add(2L); 649 if ((fext != Ext.S W) && (fext != Ext.S)) {646 if ((fext != Ext.S)) { 650 647 nedge.nodes.add(3L); 651 648 } … … 661 658 features.get(Obj.LNDARE).add(land); 662 659 } 660 return; 663 661 } 664 662 665 663 // Utility methods 666 664 667 enum Ext {I, N, NW, W, SW, S, SE, E, NE } 665 enum Ext {I, N, W, S, E } 666 class Xnode { 667 double lat; 668 double lon; 669 Ext ext; 670 } 668 671 Ext outsideBounds(long ref) { 669 672 Snode node = nodes.get(ref); 670 673 if (node.lat >= bounds.maxlat) { 671 if (node.lon <= bounds.minlon) {672 return Ext.NW;673 } else if (node.lon >= bounds.maxlon) {674 return Ext.NE;675 }676 674 return Ext.N; 677 675 } 678 676 if (node.lat <= bounds.minlat) { 679 if (node.lon <= bounds.minlon) {680 return Ext.SW;681 } else if (node.lon >= bounds.maxlon) {682 return Ext.SE;683 }684 677 return Ext.S; 685 678 } 686 679 if (node.lon >= bounds.maxlon) { 687 if (node.lat <= bounds.minlat) {688 return Ext.SE;689 } else if (node.lat >= bounds.maxlat) {690 return Ext.NE;691 }692 680 return Ext.E; 693 681 } 694 682 if (node.lon <= bounds.minlon) { 695 if (node.lat <= bounds.minlat) {696 return Ext.SW;697 } else if (node.lat >= bounds.maxlat) {698 return Ext.NW;699 }700 683 return Ext.W; 701 684 } … … 904 887 int ec; 905 888 long lastref; 906 889 907 890 public GeomIterator(Geom g) { 908 891 geom = g; -
applications/editors/josm/plugins/seachart/src/s57/S57obj.java
r31014 r31027 178 178 } 179 179 180 private static final HashMap<String, Obj> OSMtags = new HashMap<String, Obj>();181 static {182 OSMtags.put("natural=coastline", Obj.COALNE); OSMtags.put("natural=water", Obj.LAKARE);183 OSMtags.put("waterway=riverbank", Obj.RIVBNK); OSMtags.put("waterway=river", Obj.RIVERS); OSMtags.put("waterway=canal", Obj.CANALS);184 OSMtags.put("wetland=tidalflat", Obj.DEPARE);185 }186 187 public static Obj OSMobj(String key, String val) {188 Obj obj = OSMtags.get(key + "=" + val);189 if (obj != null) {190 return obj;191 }192 return Obj.UNKOBJ;193 }194 195 180 } -
applications/editors/josm/plugins/seachart/src/s57/S57val.java
r31014 r31027 1242 1242 } 1243 1243 1244 static class KeyVal {1245 Att key;1246 Object val;1247 KeyVal(Att k, Object v) {1248 key = k;1249 val = v;1250 }1251 }1252 1253 private static final HashMap<String, KeyVal> OSMtags = new HashMap<String, KeyVal>();1254 static {1255 OSMtags.put("wetland=tidalflat", new KeyVal(Att.DRVAL2, (double)0));1256 }1257 1258 public static AttVal OSMatt(String key, String val) {1259 KeyVal att = OSMtags.get(key + "=" + val);1260 if (att != null) {1261 return new AttVal(att.key, Conv.F, att.val);1262 }1263 return new AttVal(Att.UNKATT, Conv.A, null);1264 }1265 1266 1244 }
Note:
See TracChangeset
for help on using the changeset viewer.