Changeset 31014 in osm for applications/editors/josm/plugins/seachart
- Timestamp:
- 2015-02-17T14:05:54+01:00 (10 years ago)
- Location:
- applications/editors/josm/plugins/seachart/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/seachart/src/render/Renderer.java
r30894 r31014 251 251 while (git.hasComp()) { 252 252 git.nextComp(); 253 boolean first = true; 253 254 while (git.hasEdge()) { 254 255 git.nextEdge(); 255 256 point = context.getPoint(git.next()); 256 p.moveTo(point.getX(), point.getY()); 257 if (first) { 258 p.moveTo(point.getX(), point.getY()); 259 first = false; 260 } else { 261 p.lineTo(point.getX(), point.getY()); 262 } 257 263 while (git.hasNode()) { 258 264 point = context.getPoint(git.next()); -
applications/editors/josm/plugins/seachart/src/render/Rules.java
r30992 r31014 28 28 public class Rules { 29 29 30 public static final Color Yland = new Color(0xeca818); 31 public static final Color Bwater = new Color(0x2ea8d8); 30 public static final Color Yland = new Color(0xdcb820); 31 public static final Color Bwater = new Color(0x3ea8c8); 32 public static final Color Gdries = new Color(0x50b050); 32 33 public static final Color Mline = new Color(0xc480ff); 33 34 public static final Color Msymb = new Color(0xa30075); … … 176 177 public static void rules () { 177 178 ArrayList<Feature> objects; 179 if ((objects = Renderer.map.features.get(Obj.LNDARE)) != null) for (Feature feature : objects) if (feature.reln == Rflag.MASTER) areas(feature); 180 if ((objects = Renderer.map.features.get(Obj.LAKARE)) != null) for (Feature feature : objects) if (feature.reln == Rflag.MASTER) areas(feature); 181 if ((objects = Renderer.map.features.get(Obj.RIVBNK)) != null) for (Feature feature : objects) if (feature.reln == Rflag.MASTER) areas(feature); 182 if ((objects = Renderer.map.features.get(Obj.RIVERS)) != null) for (Feature feature : objects) if (feature.reln == Rflag.MASTER) waterways(feature); 183 if ((objects = Renderer.map.features.get(Obj.CANALS)) != null) for (Feature feature : objects) if (feature.reln == Rflag.MASTER) waterways(feature); 184 if ((objects = Renderer.map.features.get(Obj.DOCARE)) != null) for (Feature feature : objects) if (feature.reln == Rflag.MASTER) areas(feature); 185 if ((objects = Renderer.map.features.get(Obj.DEPARE)) != null) for (Feature feature : objects) if (feature.reln == Rflag.MASTER) areas(feature); 178 186 if ((objects = Renderer.map.features.get(Obj.COALNE)) != null) for (Feature feature : objects) if (feature.reln == Rflag.MASTER) areas(feature); 179 187 if ((objects = Renderer.map.features.get(Obj.SLCONS)) != null) for (Feature feature : objects) if (feature.reln == Rflag.MASTER) shoreline(feature); … … 199 207 if ((objects = Renderer.map.features.get(Obj.UWTROC)) != null) for (Feature feature : objects) if (feature.reln == Rflag.MASTER) obstructions(feature); 200 208 if ((objects = Renderer.map.features.get(Obj.MARCUL)) != null) for (Feature feature : objects) if (feature.reln == Rflag.MASTER) areas(feature); 201 if ((objects = Renderer.map.features.get(Obj.WTWAXS)) != null) for (Feature feature : objects) if (feature.reln == Rflag.MASTER) waterways(feature);202 209 if ((objects = Renderer.map.features.get(Obj.RECTRC)) != null) for (Feature feature : objects) if (feature.reln == Rflag.MASTER) transits(feature); 203 210 if ((objects = Renderer.map.features.get(Obj.NAVLNE)) != null) for (Feature feature : objects) if (feature.reln == Rflag.MASTER) transits(feature); … … 255 262 switch (feature.type) { 256 263 case COALNE: 257 Renderer.lineVector(feature, new LineStyle(Color.black, 8, Yland)); 264 Renderer.lineVector(feature, new LineStyle(Color.black, 10)); 265 break; 266 case DEPARE: 267 Double depmax = 0.0; 268 if (((depmax = (Double) getAttVal(feature, feature.type, 0, Att.DRVAL2)) != null) && (depmax <= 0.0)) { 269 Renderer.lineVector(feature, new LineStyle(Gdries)); 270 } 271 break; 272 case DOCARE: 273 case LAKARE: 274 case RIVBNK: 275 Renderer.lineVector(feature, new LineStyle(Bwater)); 258 276 break; 259 277 case DRGARE: … … 272 290 } else { 273 291 if (Renderer.zoom >= 14) 274 Renderer.lineVector(feature, new LineStyle(null, 0, new Color(0x40ffffff, true))); 275 } 292 Renderer.lineVector(feature, new LineStyle(new Color(0x40ffffff, true))); 293 } 294 break; 295 case LNDARE: 296 Renderer.lineVector(feature, new LineStyle(Yland)); 276 297 break; 277 298 case MARCUL: … … 930 951 case TSSRON: 931 952 if (Renderer.zoom <= 15) 932 Renderer.lineVector(feature, new LineStyle(n ull, 0, null, new Color(0x80c48080, true)));953 Renderer.lineVector(feature, new LineStyle(new Color(0x80c48080, true))); 933 954 else 934 955 Renderer.lineVector(feature, new LineStyle(new Color(0x80c48080, true), 20, null, null)); … … 1108 1129 1109 1130 private static void waterways(Feature feature) { 1110 1131 Renderer.lineVector(feature, new LineStyle(Bwater, 20)); 1111 1132 } 1112 1133 -
applications/editors/josm/plugins/seachart/src/s57/S57att.java
r30992 r31014 10 10 package s57; 11 11 12 import java.util.EnumMap; 13 import java.util.HashMap; 14 import java.util.Map; 12 import java.util.*; 15 13 16 14 import s57.S57obj.*; -
applications/editors/josm/plugins/seachart/src/s57/S57map.java
r30996 r31014 27 27 public double maxlon; 28 28 public MapBounds() { 29 minlat = 90;30 minlon = 180;31 maxlat = -90;32 maxlon = -180;29 minlat = Math.toRadians(90); 30 minlon = Math.toRadians(180); 31 maxlat = Math.toRadians(-90); 32 maxlon = Math.toRadians(-180); 33 33 } 34 34 } … … 221 221 } 222 222 } 223 224 class OSMtag { 225 String key; 226 String val; 227 OSMtag(String k, String v) { 228 key = k; 229 val = v; 230 } 231 } 232 233 ArrayList<OSMtag> osmtags; 223 234 224 235 public NodeTab nodes; … … 227 238 public FtrMap features; 228 239 public FtrTab index; 229 230 public long ref; 240 241 public MapBounds bounds; 242 243 public long cref; 244 public long xref; 231 245 private Feature feature; 232 246 private Edge edge; … … 238 252 features = new FtrMap(); // All features in map, grouped by type 239 253 index = new FtrTab(); // Feature look-up table 240 ref = 0x0000ffffffff0000L;// Compound reference generator 254 bounds = new MapBounds(); 255 cref = 0x0000ffffffff0000L;// Compound reference generator 256 xref = 0x0fff000000000000L;// Extras reference generator 241 257 } 242 258 … … 371 387 feature.geom.prim = Pflag.POINT; 372 388 feature.geom.elems.add(new Prim(id)); 389 osmtags = new ArrayList<OSMtag>(); 373 390 edge = null; 374 391 } … … 379 396 feature.geom.prim = Pflag.LINE; 380 397 feature.geom.elems.add(new Prim(id)); 398 osmtags = new ArrayList<OSMtag>(); 381 399 edge = new Edge(); 382 400 } … … 398 416 feature.reln = Rflag.UNKN; 399 417 feature.geom.prim = Pflag.AREA; 418 osmtags = new ArrayList<OSMtag>(); 400 419 edge = null; 401 420 } … … 457 476 } 458 477 } 478 } else { 479 osmtags.add(new OSMtag(key, val)); 459 480 } 460 481 } 461 482 462 483 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 } 505 } 506 } 463 507 switch (feature.geom.prim) { 464 508 case POINT: … … 490 534 } 491 535 } 536 537 public void mapDone() { 538 ArrayList<Feature> coasts = new ArrayList<Feature>(); 539 ArrayList<Feature> lands = new ArrayList<Feature>(); 540 if (features.get(Obj.LNDARE) == null) { 541 features.put(Obj.LNDARE, new ArrayList<Feature>()); 542 } 543 for (Feature feature : features.get(Obj.COALNE)) { 544 Feature land = new Feature(); 545 land.type = Obj.LNDARE; 546 land.reln = Rflag.MASTER; 547 land.objs.put(Obj.LNDARE, new ObjTab()); 548 if (feature.geom.prim == Pflag.AREA) { 549 land.geom = feature.geom; 550 features.get(Obj.LNDARE).add(land); 551 } else if (feature.geom.prim == Pflag.LINE) { 552 land.geom.prim = Pflag.LINE; 553 for (int i = 0; i < feature.geom.elems.size(); i++) { 554 land.geom.elems.add(feature.geom.elems.get(i)); 555 } 556 coasts.add(land); 557 } 558 } 559 while (coasts.size() > 0) { 560 Feature land = coasts.remove(0); 561 Edge fedge = edges.get(land.geom.elems.get(0).id); 562 long first = fedge.first; 563 long last = edges.get(land.geom.elems.get(land.geom.elems.size() - 1).id).last; 564 if (coasts.size() > 0) { 565 boolean added = true; 566 while (added) { 567 added = false; 568 for (int i = 0; i < coasts.size(); i++) { 569 Feature coast = coasts.get(i); 570 Edge edge = edges.get(coast.geom.elems.get(0).id); 571 if (edge.first == last) { 572 land.geom.elems.add(coast.geom.elems.get(0)); 573 last = edge.last; 574 coasts.remove(i--); 575 added = true; 576 } else if (edge.last == first) { 577 land.geom.elems.add(0, coast.geom.elems.get(0)); 578 first = edge.first; 579 coasts.remove(i--); 580 added = true; 581 } 582 } 583 } 584 } 585 lands.add(land); 586 } 587 for (Feature land : lands) { 588 long first = edges.get(land.geom.elems.get(0).id).first; 589 long last = edges.get(land.geom.elems.get(land.geom.elems.size()-1).id).last; 590 Ext fext = outsideBounds(first); 591 Ext lext = outsideBounds(last); 592 Edge nedge = new Edge(); 593 nedge.first = last; 594 nedge.last = first; 595 switch (lext) { 596 case NE: 597 case N: 598 if ((fext != Ext.NE) && (fext != Ext.N)) { 599 nedge.nodes.add(1L); 600 if ((fext != Ext.NW) && (fext != Ext.W)) { 601 nedge.nodes.add(2L); 602 if ((fext != Ext.SW) && (fext != Ext.S)) { 603 nedge.nodes.add(3L); 604 if ((fext != Ext.SE) && (fext != Ext.W)) { 605 nedge.nodes.add(4L); 606 } 607 } 608 } 609 } 610 break; 611 case NW: 612 case W: 613 if ((fext != Ext.NW) && (fext != Ext.W)) { 614 nedge.nodes.add(2L); 615 if ((fext != Ext.SW) && (fext != Ext.S)) { 616 nedge.nodes.add(3L); 617 if ((fext != Ext.SE) && (fext != Ext.E)) { 618 nedge.nodes.add(4L); 619 if ((fext != Ext.NE) && (fext != Ext.N)) { 620 nedge.nodes.add(1L); 621 } 622 } 623 } 624 } 625 break; 626 case SW: 627 case S: 628 if ((fext != Ext.SW) && (fext != Ext.S)) { 629 nedge.nodes.add(3L); 630 if ((fext != Ext.SE) && (fext != Ext.E)) { 631 nedge.nodes.add(4L); 632 if ((fext != Ext.NE) && (fext != Ext.N)) { 633 nedge.nodes.add(1L); 634 if ((fext != Ext.NW) && (fext != Ext.W)) { 635 nedge.nodes.add(2L); 636 } 637 } 638 } 639 } 640 break; 641 case SE: 642 case E: 643 if ((fext != Ext.SE) && (fext != Ext.E)) { 644 nedge.nodes.add(4L); 645 if ((fext != Ext.NE) && (fext != Ext.N)) { 646 nedge.nodes.add(1L); 647 if ((fext != Ext.NW) && (fext != Ext.W)) { 648 nedge.nodes.add(2L); 649 if ((fext != Ext.SW) && (fext != Ext.S)) { 650 nedge.nodes.add(3L); 651 } 652 } 653 } 654 } 655 break; 656 default: 657 } 658 edges.put(++xref, nedge); 659 land.geom.elems.add(new Prim(xref)); 660 sortGeom(land); 661 features.get(Obj.LNDARE).add(land); 662 } 663 } 492 664 493 665 // Utility methods 666 667 enum Ext {I, N, NW, W, SW, S, SE, E, NE } 668 Ext outsideBounds(long ref) { 669 Snode node = nodes.get(ref); 670 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 return Ext.N; 677 } 678 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 return Ext.S; 685 } 686 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 return Ext.E; 693 } 694 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 return Ext.W; 701 } 702 return Ext.I; 703 } 494 704 495 705 public boolean sortGeom(Feature feature) { … … 526 736 sort.inners++; 527 737 } 528 comp = new Comp(ref++, 1); 738 comp = new Comp(cref++, 1); 529 739 sort.refs.add(comp); 530 740 } else { -
applications/editors/josm/plugins/seachart/src/s57/S57obj.java
r30992 r31014 10 10 package s57; 11 11 12 import java.util.EnumMap; 13 import java.util.HashMap; 14 import java.util.Map; 12 import java.util.*; 15 13 16 14 public class S57obj { … … 179 177 return Obj.UNKOBJ; 180 178 } 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 } 181 194 182 195 } -
applications/editors/josm/plugins/seachart/src/s57/S57val.java
r30992 r31014 10 10 package s57; 11 11 12 import java.util.ArrayList; 13 import java.util.EnumMap; 12 import java.util.*; 14 13 15 14 import s57.S57att.*; … … 1243 1242 } 1244 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 1245 1266 } -
applications/editors/josm/plugins/seachart/src/seachart/SeachartAction.java
r30996 r31014 21 21 import org.openstreetmap.josm.gui.MapView.LayerChangeListener; 22 22 import org.openstreetmap.josm.gui.layer.*; 23 import org.openstreetmap.josm.data.Bounds; 23 24 import org.openstreetmap.josm.data.coor.LatLon; 24 25 import org.openstreetmap.josm.data.imagery.ImageryInfo; … … 146 147 map = new S57map(); 147 148 if (data != null) { 149 double minlat = 90; 150 double maxlat = -90; 151 double minlon = 180; 152 double maxlon = -180; 153 for (Bounds bounds : data.getDataSourceBounds()) { 154 if (bounds.getMinLat() < minlat) { 155 minlat = bounds.getMinLat(); 156 } 157 if (bounds.getMaxLat() > maxlat) { 158 maxlat = bounds.getMaxLat(); 159 } 160 if (bounds.getMinLon() < minlon) { 161 minlon = bounds.getMinLon(); 162 } 163 if (bounds.getMaxLon() > maxlon) { 164 maxlon = bounds.getMaxLon(); 165 } 166 } 167 map.addNode(1, maxlat, minlon); 168 map.addNode(2, minlat, minlon); 169 map.addNode(3, minlat, maxlon); 170 map.addNode(4, maxlat, maxlon); 171 map.bounds.minlat = Math.toRadians(minlat); 172 map.bounds.maxlat = Math.toRadians(maxlat); 173 map.bounds.minlon = Math.toRadians(minlon); 174 map.bounds.maxlon = Math.toRadians(maxlon); 148 175 for (Node node : data.getNodes()) { 149 176 LatLon coor = node.getCoor(); … … 181 208 } 182 209 } 210 map.mapDone(); 183 211 if (rendering != null) rendering.zoomChanged(); 184 212 } -
applications/editors/josm/plugins/seachart/src/symbols/Symbols.java
r30894 r31014 95 95 public Color fill; 96 96 97 public LineStyle(Color ifill) { 98 line = null; 99 width = 0; 100 dash = null; 101 fill = ifill; 102 } 97 103 public LineStyle(Color iline, float iwidth) { 98 104 line = iline;
Note:
See TracChangeset
for help on using the changeset viewer.