Ignore:
Timestamp:
2013-01-06T16:33:30+01:00 (12 years ago)
Author:
malcolmh
Message:

save

Location:
applications/editors/josm/plugins/smed2/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/smed2/src/s57/S57val.java

    r29172 r29175  
    10861086        }
    10871087       
     1088        public static Object nullVal(Att att) {
     1089                switch (keys.get(att).conv) {
     1090                case A:
     1091                case S:
     1092                        return "";
     1093                case E:
     1094                        for (Enum<?> key : keys.get(att).map.keySet())
     1095                                return key;
     1096                case L:
     1097                        ArrayList<Enum<?>> list = new ArrayList<Enum<?>>();
     1098                        for (Enum<?> key : keys.get(att).map.keySet()) {
     1099                                list.add(key);
     1100                                return list;
     1101                        }
     1102                case I:
     1103                        return null;
     1104                case F:
     1105                        return null;
     1106                }
     1107                return null;
     1108        }
     1109       
    10881110        public static String decodeValue(String val, Integer attl) {          // Convert S57 attribute value string to OSeaM attribute value string
    10891111                Att att = S57att.lookupAttribute(attl);
  • applications/editors/josm/plugins/smed2/src/seamap/Renderer.java

    r29174 r29175  
    1414import java.awt.geom.Point2D;
    1515import java.util.ArrayList;
     16import java.util.EnumMap;
     17import java.util.HashMap;
    1618
     19import s57.S57att.Att;
     20import s57.S57obj.Obj;
     21import s57.S57val.ColCOL;
     22import s57.S57val.*;
     23import s57.S57val;
    1724import seamap.SeaMap.*;
    1825import symbols.Symbols;
     
    4047        }
    4148       
    42         public static void symbol(Feature feature, ArrayList<Instr> symbol) {
     49        public static EnumMap<Att, AttItem> getAtts(Feature feature, Obj obj, int idx) {
     50                HashMap<Integer, EnumMap<Att, AttItem>> objs = feature.objs.get(obj);
     51                if (objs == null) return null;
     52                else return objs.get(idx);
     53        }
     54       
     55        public static Object getAttVal(Feature feature, Obj obj, int idx, Att att) {
     56                EnumMap<Att, AttItem> atts = getAtts(feature, obj, idx);
     57                if (atts == null) return  S57val.nullVal(att);
     58                else {
     59                        AttItem item = atts.get(att);
     60                        if (item == null) return S57val.nullVal(att);
     61                        return item.val;
     62                }
     63        }
     64       
     65        public static void symbol(Feature feature, ArrayList<Instr> symbol, Obj obj) {
    4366                Point2D point = helper.getPoint(map.nodes.get(feature.refs));
    44                 Symbols.drawSymbol(g2, symbol, sScale, point.getX(), point.getY(), null, null);
     67                ArrayList<ColCOL> colours = (ArrayList<ColCOL>) getAttVal(feature, obj, 0, Att.COLOUR);
     68                ArrayList<ColPAT> pattern = (ArrayList<ColPAT>) getAttVal(feature, obj, 0, Att.COLPAT);
     69                Symbols.drawSymbol(g2, symbol, sScale, point.getX(), point.getY(), null, new Scheme(pattern, colours));
    4570        }
    4671       
  • applications/editors/josm/plugins/smed2/src/seamap/Rules.java

    r29174 r29175  
    1111
    1212import java.util.ArrayList;
    13 import java.util.EnumMap;
    14 import java.util.HashMap;
    1513
    16 import s57.S57att;
    17 import s57.S57val.BcnSHP;
     14import s57.S57val.*;
    1815import s57.S57att.*;
    19 import s57.S57obj;
    2016import s57.S57obj.*;
    21 import s57.S57val;
    22 import s57.S57val.*;
    2317
    2418import seamap.SeaMap.AttItem;
    2519import seamap.SeaMap.Feature;
    2620import symbols.Beacons;
    27 import symbols.Symbols.Instr;
     21import symbols.Buoys;
    2822
    2923public class Rules {
     
    106100       
    107101        private static void shoreline(ArrayList<Feature> features) {
    108                 for (Feature feature : features) {
    109                 }
     102//              for (Feature feature : features) {
     103//              }
    110104        }
    111105        private static void pipelines(ArrayList<Feature> features) {}
     
    131125        private static void gauges(ArrayList<Feature> features) {}
    132126        private static void platforms(ArrayList<Feature> features) {}
    133         private static void buoys(ArrayList<Feature> features) {}
     127        private static void buoys(ArrayList<Feature> features) {
     128                for (Feature feature : features) {
     129                        BoySHP shape = (BoySHP) Renderer.getAttVal(feature, feature.type, 0, Att.BOYSHP);
     130                        Renderer.symbol(feature, Buoys.Shapes.get(shape), feature.type);
     131                }
     132        }
    134133        private static void beacons(ArrayList<Feature> features) {
    135134                for (Feature feature : features) {
    136                         BcnSHP shape;
    137                         HashMap<Integer, EnumMap<Att, AttItem>> objs = feature.objs.get(feature.type);
    138                         if (objs == null) shape = BcnSHP.BCN_UNKN;
    139                         else {
    140                                 EnumMap<Att, AttItem> atts = objs.get(0);
    141                                 if (atts == null) shape = BcnSHP.BCN_UNKN;
    142                                 else {
    143                                         AttItem item = atts.get(Att.BCNSHP);
    144                                         if (item == null) shape = BcnSHP.BCN_UNKN;
    145                                         else shape = (BcnSHP) item.val;
     135                        BcnSHP shape = (BcnSHP) Renderer.getAttVal(feature, feature.type, 0, Att.BCNSHP);
     136                        if (((shape == BcnSHP.BCN_PRCH) || (shape == BcnSHP.BCN_WTHY)) && (feature.type == Obj.BCNLAT)) {
     137                                CatLAM cat = (CatLAM) Renderer.getAttVal(feature, feature.type, 0, Att.CATLAM);
     138                                switch (cat) {
     139                                case LAM_PORT:
     140                                        if (shape == BcnSHP.BCN_PRCH)
     141                                                Renderer.symbol(feature, Beacons.PerchPort, feature.type);
     142                                        else
     143                                                Renderer.symbol(feature, Beacons.WithyPort, feature.type);
     144                                        break;
     145                                case LAM_STBD:
     146                                        if (shape == BcnSHP.BCN_PRCH)
     147                                                Renderer.symbol(feature, Beacons.PerchStarboard, feature.type);
     148                                        else
     149                                                Renderer.symbol(feature, Beacons.WithyStarboard, feature.type);
     150                                        break;
     151                                default:
     152                                        Renderer.symbol(feature, Beacons.Stake, feature.type);
    146153                                }
    147                         }
    148                         if (shape == BcnSHP.BCN_PRCH) {
    149                                
    150                         } else if (shape == BcnSHP.BCN_WTHY) {
    151                                        
    152154                        } else {
    153                                 Renderer.symbol(feature, Beacons.Shapes.get(shape));
     155                                Renderer.symbol(feature, Beacons.Shapes.get(shape), feature.type);
    154156                        }
    155157                }
  • applications/editors/josm/plugins/smed2/src/smed2/MapImage.java

    r29174 r29175  
    2424
    2525        private SeaMap mapdata;
    26 //      private Params imageParams;
    27         private Renderer renderer;
    2826
    29         private double top;
    30         private double bottom;
    31         private double left;
    32         private double right;
    33         private double width;
    34         private double height;
    35         private int zoom;
     27        double top;
     28        double bottom;
     29        double left;
     30        double right;
     31        double width;
     32        double height;
     33        int zoom;
    3634       
    3735        public MapImage(ImageryInfo info, SeaMap map) {
  • applications/editors/josm/plugins/smed2/src/smed2/Smed2Action.java

    r29174 r29175  
    1212import org.openstreetmap.josm.gui.MapView;
    1313import org.openstreetmap.josm.gui.MapView.EditLayerChangeListener;
    14 import org.openstreetmap.josm.gui.NavigatableComponent.ZoomChangeListener;
    1514import org.openstreetmap.josm.gui.layer.*;
    1615import org.openstreetmap.josm.data.SelectionChangedListener;
  • applications/editors/josm/plugins/smed2/src/symbols/Buoys.java

    r29110 r29175  
    1414import java.awt.geom.*;
    1515import java.util.ArrayList;
    16 
     16import java.util.EnumMap;
     17
     18import s57.S57val.BoySHP;
    1719import symbols.Symbols.*;
    1820
     
    247249    Super.add(new Instr(Prim.PLIN, p));
    248250        }
     251       
     252        public static final EnumMap<BoySHP, ArrayList<Instr>> Shapes = new EnumMap<BoySHP, ArrayList<Instr>>(BoySHP.class);
     253        static {
     254                Shapes.put(BoySHP.BOY_UNKN, Buoys.Pillar); Shapes.put(BoySHP.BOY_CONE, Buoys.Cone); Shapes.put(BoySHP.BOY_CAN, Buoys.Can);
     255                Shapes.put(BoySHP.BOY_SPHR, Buoys.Sphere); Shapes.put(BoySHP.BOY_PILR, Buoys.Pillar); Shapes.put(BoySHP.BOY_SPAR, Buoys.Spar);
     256                Shapes.put(BoySHP.BOY_BARL, Buoys.Barrel); Shapes.put(BoySHP.BOY_SUPR, Buoys.Super); Shapes.put(BoySHP.BOY_ICE, Buoys.Ice);
     257        }
    249258}
Note: See TracChangeset for help on using the changeset viewer.