Changeset 29185 in osm


Ignore:
Timestamp:
2013-01-10T00:56:38+01:00 (12 years ago)
Author:
malcolmh
Message:

save

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

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/smed2/src/seamap/Renderer.java

    r29184 r29185  
    5454        public static Object getAttVal(Feature feature, Obj obj, int idx, Att att) {
    5555                AttMap atts = getAtts(feature, obj, idx);
    56                 if (atts == null) return  S57val.nullVal(att);
     56                if (atts == null) return S57val.nullVal(att);
    5757                else {
    5858                        AttItem item = atts.get(att);
     
    6262        }
    6363
     64        public static double calcArea(Feature feature) {
     65          if (feature.flag == Fflag.AREA) {
     66                        ArrayList<Long> way = map.ways.get(feature.refs);
     67                        Coord coord = map.nodes.get(way.get(0));
     68            double llat = coord.lat;
     69            double llon = coord.lon;
     70            double area = 0.0;
     71                        for (long node : way) {
     72                                coord = map.nodes.get(node);
     73              area += ((llon * coord.lat) - (llat * coord.lon));
     74              llat = coord.lat;
     75              llon = coord.lon;
     76            }
     77            return Math.abs(area) / 2.0 * 60.0 * 60.0;
     78          }
     79          return 0.0;
     80        }
     81
    6482        public static Coord findCentroid(Feature feature) {
     83                Coord coord;
     84                ArrayList<Long> way = map.ways.get(feature.refs);
     85                switch (feature.flag) {
     86                case NODE:
     87                        return map.nodes.get(feature.refs);
     88                case WAY:
     89                        coord = map.nodes.get(way.get(1));
     90                        break;
     91                case AREA:
     92                default:
     93                        coord = map.nodes.get(way.get(0));
     94                }
     95    double slat = 0.0;
    6596    double slon = 0.0;
    66     double slat = 0.0;
    6797    double sarc = 0.0;
    68     double llon = 0.0;
    69     double llat = 0.0;
    70                 if (feature.flag == Fflag.NODE) {
    71                         return map.nodes.get(feature.refs);
    72                 }
    73                 ArrayList<Long> way = map.ways.get(feature.refs);
    74                 if (feature.flag == Fflag.WAY) {
    75                         llon = map.nodes.get(way.get(1)).lon;
    76                         llat = map.nodes.get(way.get(1)).lat;
    77                 } else {
    78                         llon = map.nodes.get(way.get(0)).lon;
    79                         llat = map.nodes.get(way.get(0)).lat;
    80                 }
     98    double llat = coord.lat;
     99    double llon = coord.lon;
    81100                for (long node : way) {
    82       double lon = map.nodes.get(node).lon;
    83       double lat = map.nodes.get(node).lat;
     101                        coord = map.nodes.get(node);
     102      double lon = coord.lon;
     103      double lat = coord.lat;
    84104      double arc = Math.sqrt(Math.pow((lon-llon), 2) + Math.pow((lat-llat), 2));
     105      slat += (lat * arc);
    85106      slon += (lon * arc);
    86       slat += (lat * arc);
    87107      sarc += arc;
     108      llat = lat;
    88109      llon = lon;
    89       llat = lat;
    90110                }
    91111                return map.new Coord((sarc > 0.0 ? slat/sarc : 0.0), (sarc > 0.0 ? slon/sarc : 0.0));
  • applications/editors/josm/plugins/smed2/src/seamap/Rules.java

    r29184 r29185  
    123123                        ArrayList<Instr> fncSym = Landmarks.Funcs.get(fncs.get(0));
    124124                        if ((fncs.get(0) == FncFNC.FNC_CHCH) && (cats.get(0) == CatLMK.LMK_TOWR)) catSym = Landmarks.ChurchTower;
    125                         if ((cats.get(0) == CatLMK.LMK_UNKN) && (fncs.get(0) == FncFNC.FNC_UNKN)) catSym = Beacons.LightMajor;
     125                        if ((cats.get(0) == CatLMK.LMK_UNKN) && (fncs.get(0) == FncFNC.FNC_UNKN) && (feature.objs.get(Obj.LIGHTS) != null)) catSym = Beacons.LightMajor;
     126                        if (cats.get(0) == CatLMK.LMK_RADR) fncSym = Landmarks.RadioTV;
    126127                        Renderer.symbol(feature, catSym, feature.type);
    127128                        Renderer.symbol(feature, fncSym, feature.type);
  • applications/editors/josm/plugins/smed2/src/symbols/Beacons.java

    r29176 r29185  
    1212import java.awt.BasicStroke;
    1313import java.awt.Color;
     14import java.awt.geom.Arc2D;
    1415import java.awt.geom.Ellipse2D;
    1516import java.awt.geom.GeneralPath;
     
    6162                Cairn.add(new Instr(Prim.ELPS, new Ellipse2D.Double(-18,-70,36,36)));
    6263        }
     64        public static final ArrayList<Instr> FogSignal = new ArrayList<Instr>();
     65        static {
     66                FogSignal.add(new Instr(Prim.STRK, new BasicStroke(3.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND)));
     67                FogSignal.add(new Instr(Prim.FILL, Color.black));
     68                FogSignal.add(new Instr(Prim.ELPS, new Ellipse2D.Double(-10,-10,20,20)));
     69                FogSignal.add(new Instr(Prim.STRK, new BasicStroke(10.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND)));
     70                FogSignal.add(new Instr(Prim.FILL, new Color(0xd400d4)));
     71                FogSignal.add(new Instr(Prim.EARC, new Arc2D.Double(-120.0,-120.0,240.0,240.0,190.0,50.0,Arc2D.OPEN)));
     72                FogSignal.add(new Instr(Prim.EARC, new Arc2D.Double(-92.5,-92.5,185.0,185.0,190.0,50.0,Arc2D.OPEN)));
     73                FogSignal.add(new Instr(Prim.EARC, new Arc2D.Double(-65.0,-65.0,130.0,130.0,190.0,50.0,Arc2D.OPEN)));
     74        }
     75        public static final ArrayList<Instr> LightFlare = new ArrayList<Instr>();
     76        static {
     77                LightFlare.add(new Instr(Prim.RSHP, new Ellipse2D.Double(-3,-3,6,6)));
     78                Path2D.Double p = new Path2D.Double();
     79                p.moveTo(0.0,-25.0); p.lineTo(15.0,-95.0); p.curveTo(20.0,-123.0,-20.0,-123.0,-15.0,-95.0);
     80                p.closePath();
     81                LightFlare.add(new Instr(Prim.PGON, p));
     82        }
    6383        public static final ArrayList<Instr> LightMajor = new ArrayList<Instr>();
    6484        static {
     
    95115                PerchStarboard.add(new Instr(Prim.LINE, new Line2D.Double(-25,-40,0,-68.7)));
    96116        }
     117        public static final ArrayList<Instr> RadarStation = new ArrayList<Instr>();
     118        static {
     119                RadarStation.add(new Instr(Prim.STRK, new BasicStroke(2.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND)));
     120                RadarStation.add(new Instr(Prim.FILL, new Color(0xd400d4)));
     121                RadarStation.add(new Instr(Prim.ELPS, new Ellipse2D.Double(-125,-125,250,250)));
     122        }
    97123        public static final ArrayList<Instr> Stake = new ArrayList<Instr>();
    98124        static {
     
    111137                p = new Path2D.Double(); p.moveTo(-2.0,-17.5); p.lineTo(-2.0,-35.0); p.lineTo(2.0,-35.0); p.lineTo(2.0,-17.5); p.closePath();
    112138                colours.add(new Instr(Prim.H5, p));
    113     Stake.add(new Instr(Prim.COLR, colours));
     139                Stake.add(new Instr(Prim.COLR, colours));
    114140                Stake.add(new Instr(Prim.FILL, Color.black));
    115141                Stake.add(new Instr(Prim.LINE, new Line2D.Double(-10,0,10,0)));
  • applications/editors/josm/plugins/smed2/src/symbols/Landmarks.java

    r29176 r29185  
    122122                Mast.add(new Instr(Prim.PLIN, p));
    123123        }
    124         public static final ArrayList<Instr> RadioMast = new ArrayList<Instr>();
    125         static {
    126                 RadioMast.add(new Instr(Prim.SYMB, new Symbols.Symbol(Landmarks.Mast, 1.0, 0, 0, null, null)));
    127                 RadioMast.add(new Instr(Prim.STRK, new BasicStroke(4.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL)));
    128                 RadioMast.add(new Instr(Prim.FILL, Color.black));
    129                 RadioMast.add(new Instr(Prim.EARC, new Arc2D.Double(-30.0,-180.0,60.0,60.0,45.0,-90.0,Arc2D.OPEN)));
    130                 RadioMast.add(new Instr(Prim.EARC, new Arc2D.Double(-45.0,-195.0,90.0,90.0,45.0,-90.0,Arc2D.OPEN)));
    131                 RadioMast.add(new Instr(Prim.EARC, new Arc2D.Double(-30.0,-180.0,60.0,60.0,225.0,-90.0,Arc2D.OPEN)));
    132                 RadioMast.add(new Instr(Prim.EARC, new Arc2D.Double(-45.0,-195.0,90.0,90.0,225.0,-90.0,Arc2D.OPEN)));
    133         }
    134124        public static final ArrayList<Instr> Monument = new ArrayList<Instr>();
    135125        static {
     
    147137                Platform.add(new Instr(Prim.RECT, new Rectangle2D.Double(-48,-48,96,96)));
    148138                Platform.add(new Instr(Prim.RSHP, new Ellipse2D.Double(-4,-4,8,8)));
     139        }
     140        public static final ArrayList<Instr> RadioTV = new ArrayList<Instr>();
     141        static {
     142                RadioTV.add(new Instr(Prim.STRK, new BasicStroke(4.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL)));
     143                RadioTV.add(new Instr(Prim.FILL, Color.black));
     144                RadioTV.add(new Instr(Prim.EARC, new Arc2D.Double(-30.0,-180.0,60.0,60.0,45.0,-90.0,Arc2D.OPEN)));
     145                RadioTV.add(new Instr(Prim.EARC, new Arc2D.Double(-45.0,-195.0,90.0,90.0,45.0,-90.0,Arc2D.OPEN)));
     146                RadioTV.add(new Instr(Prim.EARC, new Arc2D.Double(-30.0,-180.0,60.0,60.0,225.0,-90.0,Arc2D.OPEN)));
     147                RadioTV.add(new Instr(Prim.EARC, new Arc2D.Double(-45.0,-195.0,90.0,90.0,225.0,-90.0,Arc2D.OPEN)));
    149148        }
    150149        public static final ArrayList<Instr> Spire = new ArrayList<Instr>();
     
    220219                Shapes.put(CatLMK.LMK_CLMN, Landmarks.Monument); Shapes.put(CatLMK.LMK_MEML, Landmarks.Monument); Shapes.put(CatLMK.LMK_OBLK, Landmarks.Monument);
    221220                Shapes.put(CatLMK.LMK_STAT, Landmarks.Monument); Shapes.put(CatLMK.LMK_CROS, Landmarks.Cross); Shapes.put(CatLMK.LMK_DOME, Landmarks.Dome);
    222                 Shapes.put(CatLMK.LMK_RADR, Landmarks.RadioMast); Shapes.put(CatLMK.LMK_TOWR, Landmarks.LandTower); Shapes.put(CatLMK.LMK_WNDM, Landmarks.Windmill);
     221                Shapes.put(CatLMK.LMK_RADR, Landmarks.Mast); Shapes.put(CatLMK.LMK_TOWR, Landmarks.LandTower); Shapes.put(CatLMK.LMK_WNDM, Landmarks.Windmill);
    223222                Shapes.put(CatLMK.LMK_WNDG, Landmarks.WindMotor); Shapes.put(CatLMK.LMK_SPIR, Landmarks.Spire); Shapes.put(CatLMK.LMK_BLDR, Beacons.Cairn);
    224223                Shapes.put(CatLMK.LMK_MNRT, Landmarks.Minaret); Shapes.put(CatLMK.LMK_WTRT, Landmarks.WaterTower);
     
    229228                Funcs.put(FncFNC.FNC_CHCH, Landmarks.Church); Funcs.put(FncFNC.FNC_CHPL, Landmarks.Church); Funcs.put(FncFNC.FNC_TMPL, Landmarks.Temple);
    230229                Funcs.put(FncFNC.FNC_PGDA, Landmarks.Temple); Funcs.put(FncFNC.FNC_SHSH, Landmarks.Temple); Funcs.put(FncFNC.FNC_BTMP, Landmarks.Temple);
    231                 Funcs.put(FncFNC.FNC_MOSQ, Landmarks.Minaret); Funcs.put(FncFNC.FNC_MRBT, Landmarks.Spire); Funcs.put(FncFNC.FNC_COMM, Landmarks.RadioMast);
    232                 Funcs.put(FncFNC.FNC_TV, Landmarks.RadioMast); Funcs.put(FncFNC.FNC_RADO, Landmarks.RadioMast); Funcs.put(FncFNC.FNC_RADR, Landmarks.RadioMast);
    233                 Funcs.put(FncFNC.FNC_LGHT, Beacons.LightMajor); Funcs.put(FncFNC.FNC_MCWV, Landmarks.RadioMast);
     230                Funcs.put(FncFNC.FNC_MOSQ, Landmarks.Minaret); Funcs.put(FncFNC.FNC_MRBT, Landmarks.Spire); Funcs.put(FncFNC.FNC_COMM, Landmarks.RadioTV);
     231                Funcs.put(FncFNC.FNC_TV, Landmarks.RadioTV); Funcs.put(FncFNC.FNC_RADO, Landmarks.RadioTV); Funcs.put(FncFNC.FNC_RADR, Landmarks.RadioTV);
     232                Funcs.put(FncFNC.FNC_LGHT, Beacons.LightMajor); Funcs.put(FncFNC.FNC_MCWV, Landmarks.RadioTV);
    234233        }
    235234}
  • applications/editors/josm/plugins/smed2/src/symbols/Topmarks.java

    r29126 r29185  
    1313import java.awt.Color;
    1414import java.awt.Rectangle;
     15import java.awt.geom.AffineTransform;
    1516import java.awt.geom.Ellipse2D;
    1617import java.awt.geom.Line2D;
    1718import java.awt.geom.Path2D;
    1819import java.util.ArrayList;
    19 
    20 import symbols.Symbols.Instr;
    21 import symbols.Symbols.Prim;
     20import java.util.EnumMap;
     21
     22import s57.S57val.*;
     23import symbols.Symbols.*;
    2224
    2325public class Topmarks {
     
    226228                TopX.add(new Instr(Prim.PLIN, p));
    227229        }
     230       
     231        public static final EnumMap<BoySHP, Delta> Buoys = new EnumMap<BoySHP, Delta>(BoySHP.class);
     232        static {
     233                Buoys.put(BoySHP.BOY_PILR, new Delta(Handle.BC, new AffineTransform(0.948324, 0.317305, -0.3173047, 0.948324, 31.5, -95.0)));
     234                Buoys.put(BoySHP.BOY_SPAR, new Delta(Handle.BC, new AffineTransform(0.948324, 0.317305, -0.3173047, 0.948324, 31.5, -95.0)));
     235                Buoys.put(BoySHP.BOY_CAN, new Delta(Handle.BC, new AffineTransform(0.948324, 0.317305, -0.3173047, 0.948324, 12.7, -37.9)));
     236                Buoys.put(BoySHP.BOY_CONE, new Delta(Handle.BC, new AffineTransform(0.948324, 0.317305, -0.3173047, 0.948324, 12.7, -37.9)));
     237                Buoys.put(BoySHP.BOY_SPHR, new Delta(Handle.BC, new AffineTransform(0.948324, 0.317305, -0.3173047, 0.948324, 12.7, -37.9)));
     238                Buoys.put(BoySHP.BOY_BARL, new Delta(Handle.BC, new AffineTransform(0.948324, 0.317305, -0.3173047, 0.948324, 12.7, -37.9)));
     239                Buoys.put(BoySHP.BOY_SUPR, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0.0, -42.0)));
     240                Buoys.put(BoySHP.BOY_ICE, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0.0, -25.0)));
     241        }
     242        public static final Delta Floats = new Delta(Handle.BC, AffineTransform.getTranslateInstance(0.0, -70.0));
     243
    228244}
Note: See TracChangeset for help on using the changeset viewer.