Changeset 29172 in osm


Ignore:
Timestamp:
2013-01-05T16:09:17+01:00 (12 years ago)
Author:
malcolmh
Message:

save

Location:
applications/editors/josm/plugins/smed2/src
Files:
1 added
3 edited
1 moved

Legend:

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

    r29152 r29172  
    10521052                keys.put(Att.VALMXR, new S57key(Conv.F, null)); keys.put(Att.VALNMR, new S57key(Conv.F, null)); keys.put(Att.VALSOU, new S57key(Conv.F, null));
    10531053                keys.put(Att.VERACC, new S57key(Conv.F, null)); keys.put(Att.VERCLR, new S57key(Conv.F, null)); keys.put(Att.VERCCL, new S57key(Conv.F, null));
    1054                 keys.put(Att.VERCOP, new S57key(Conv.F, null)); keys.put(Att.VERCSA, new S57key(Conv.F, null)); keys.put(Att.VERDAT, new S57key(Conv.E, null));
     1054                keys.put(Att.VERCOP, new S57key(Conv.F, null)); keys.put(Att.VERCSA, new S57key(Conv.F, null)); keys.put(Att.VERDAT, new S57key(Conv.E, Verdat));
    10551055                keys.put(Att.VERLEN, new S57key(Conv.F, null)); keys.put(Att.WATLEV, new S57key(Conv.E, Watlev)); keys.put(Att.CAT_TS, new S57key(Conv.E, Cat_ts));
    10561056                keys.put(Att.PUNITS, new S57key(Conv.E, Punits)); keys.put(Att.NINFOM, new S57key(Conv.S, null)); keys.put(Att.NOBJNM, new S57key(Conv.S, null));
     
    11341134                return "";
    11351135        }
    1136        
    1137         public static Enum<?> enumValue(String val, Att att) {           // Convert OSeaM attribute value string to OSeaM enumeration
     1136
     1137        public static Enum<?> enumValue(String val, Att att) { // Convert OSeaM attribute value string to OSeaM enumeration
    11381138                EnumMap<?, ?> map = keys.get(att).map;
    11391139                Enum<?> unkn = null;
    1140                 for (Object item : map.keySet()) {
    1141                         if (unkn == null) unkn = (Enum<?>)item;
    1142                         if (((S57enum)map.get(item)).val.equals(val))
    1143                                 return (Enum<?>)item;
     1140                if (map != null) {
     1141                        for (Object item : map.keySet()) {
     1142                                if (unkn == null)
     1143                                        unkn = (Enum<?>) item;
     1144                                if (((S57enum) map.get(item)).val.equals(val))
     1145                                        return (Enum<?>) item;
     1146                        }
    11441147                }
    11451148                return unkn;
    11461149        }
    1147        
    1148         public static AttVal convertValue(String val, Att att) {         // Convert OSeaM attribute value string to OSeaM value struct
     1150
     1151        public static AttVal convertValue(String val, Att att) {                                // Convert OSeaM attribute value string to OSeaM value struct
    11491152                switch (keys.get(att).conv) {
    11501153                case A:
    11511154                case S:
    1152                         return new AttVal(att, keys.get(att).conv, val);
     1155                        return new AttVal(att, Conv.S, val);
    11531156                case E:
    1154                                 return new AttVal(att, keys.get(att).conv, enumValue(val, att));
     1157                        return new AttVal(att, Conv.E, enumValue(val, att));
    11551158                case L:
    1156                         ArrayList list = new ArrayList();
     1159                        ArrayList<Enum<?>> list = new ArrayList<Enum<?>>();
    11571160                        for (String item : val.split(";")) {
    11581161                                list.add(enumValue(item, att));
    11591162                        }
    1160                         return new AttVal(att, keys.get(att).conv, list);
     1163                        return new AttVal(att, Conv.L, list);
    11611164                case I:
    1162                         return new AttVal(att, keys.get(att).conv, Integer.parseInt(val));
     1165                        try {
     1166                                long i = Long.parseLong(val);
     1167                                return new AttVal(att, Conv.I, i);
     1168                        } catch (Exception e) {
     1169                                break;
     1170                        }
    11631171                case F:
    1164                         return new AttVal(att, keys.get(att).conv, Float.parseFloat(val));
     1172                        try {
     1173                                double f = Double.parseDouble(val);
     1174                                return new AttVal(att, Conv.F, f);
     1175                        } catch (Exception e) {
     1176                                break;
     1177                        }
    11651178                }
    11661179                return new AttVal(att, keys.get(att).conv, null);
  • applications/editors/josm/plugins/smed2/src/seamap/Rules.java

    r29157 r29172  
    1010package seamap;
    1111
     12import s57.S57obj.Obj;
     13import seamap.SeaMap.Feature;
     14
    1215public class Rules {
    1316
     17        public static void MainRules (SeaMap map) {
     18                for (Feature feature : map.features.get(Obj.SLCONS)) shoreline(feature);
     19                for (Feature feature : map.features.get(Obj.PIPSOL)) pipelines(feature);
     20                for (Feature feature : map.features.get(Obj.CBLSUB)) cables(feature);
     21                for (Feature feature : map.features.get(Obj.PIPOHD)) pipelines(feature);
     22                for (Feature feature : map.features.get(Obj.CBLOHD)) cables(feature);
     23                for (Feature feature : map.features.get(Obj.TSEZNE)) separation(feature);
     24                for (Feature feature : map.features.get(Obj.TSSCRS)) separation(feature);
     25                for (Feature feature : map.features.get(Obj.TSSRON)) separation(feature);
     26                for (Feature feature : map.features.get(Obj.TSELNE)) separation(feature);
     27                for (Feature feature : map.features.get(Obj.TSSLPT)) separation(feature);
     28                for (Feature feature : map.features.get(Obj.TSSBND)) separation(feature);
     29                for (Feature feature : map.features.get(Obj.SNDWAV)) areas(feature);
     30                for (Feature feature : map.features.get(Obj.OSPARE)) areas(feature);
     31                for (Feature feature : map.features.get(Obj.FAIRWY)) areas(feature);
     32                for (Feature feature : map.features.get(Obj.DRGARE)) areas(feature);
     33                for (Feature feature : map.features.get(Obj.RESARE)) areas(feature);
     34                for (Feature feature : map.features.get(Obj.SPLARE)) areas(feature);
     35                for (Feature feature : map.features.get(Obj.SEAARE)) areas(feature);
     36                for (Feature feature : map.features.get(Obj.OBSTRN)) obstructions(feature);
     37                for (Feature feature : map.features.get(Obj.UWTROC)) obstructions(feature);
     38                for (Feature feature : map.features.get(Obj.MARCUL)) areas(feature);
     39                for (Feature feature : map.features.get(Obj.WTWAXS)) waterways(feature);
     40                for (Feature feature : map.features.get(Obj.RECTRC)) transits(feature);
     41                for (Feature feature : map.features.get(Obj.NAVLNE)) transits(feature);
     42                for (Feature feature : map.features.get(Obj.HRBFAC)) harbours(feature);
     43                for (Feature feature : map.features.get(Obj.ACHARE)) harbours(feature);
     44                for (Feature feature : map.features.get(Obj.ACHBRT)) harbours(feature);
     45                for (Feature feature : map.features.get(Obj.LOKBSN)) locks(feature);
     46                for (Feature feature : map.features.get(Obj.LKBSPT)) locks(feature);
     47                for (Feature feature : map.features.get(Obj.GATCON)) locks(feature);
     48                for (Feature feature : map.features.get(Obj.DISMAR)) distances(feature);
     49                for (Feature feature : map.features.get(Obj.HULKES)) ports(feature);
     50                for (Feature feature : map.features.get(Obj.CRANES)) ports(feature);
     51                for (Feature feature : map.features.get(Obj.LNDMRK)) landmarks(feature);
     52                for (Feature feature : map.features.get(Obj.MORFAC)) moorings(feature);
     53                for (Feature feature : map.features.get(Obj.NOTMRK)) notices(feature);
     54                for (Feature feature : map.features.get(Obj.SMCFAC)) marinas(feature);
     55                for (Feature feature : map.features.get(Obj.BRIDGE)) bridges(feature);
     56                for (Feature feature : map.features.get(Obj.LITMAJ)) lights(feature);
     57                for (Feature feature : map.features.get(Obj.LITMIN)) lights(feature);
     58                for (Feature feature : map.features.get(Obj.LIGHTS)) lights(feature);
     59                for (Feature feature : map.features.get(Obj.SISTAT)) signals(feature);
     60                for (Feature feature : map.features.get(Obj.SISTAW)) signals(feature);
     61                for (Feature feature : map.features.get(Obj.CGUSTA)) signals(feature);
     62                for (Feature feature : map.features.get(Obj.RDOSTA)) signals(feature);
     63                for (Feature feature : map.features.get(Obj.RADSTA)) signals(feature);
     64                for (Feature feature : map.features.get(Obj.RSCSTA)) signals(feature);
     65                for (Feature feature : map.features.get(Obj.PILBOP)) signals(feature);
     66                for (Feature feature : map.features.get(Obj.WTWGAG)) gauges(feature);
     67                for (Feature feature : map.features.get(Obj.OFSPLF)) platforms(feature);
     68                for (Feature feature : map.features.get(Obj.WRECKS)) wrecks(feature);
     69                for (Feature feature : map.features.get(Obj.LITVES)) floats(feature);
     70                for (Feature feature : map.features.get(Obj.LITFLT)) floats(feature);
     71                for (Feature feature : map.features.get(Obj.BOYINB)) floats(feature);
     72                for (Feature feature : map.features.get(Obj.BOYLAT)) buoys(feature);
     73                for (Feature feature : map.features.get(Obj.BOYCAR)) buoys(feature);
     74                for (Feature feature : map.features.get(Obj.BOYISD)) buoys(feature);
     75                for (Feature feature : map.features.get(Obj.BOYSAW)) buoys(feature);
     76                for (Feature feature : map.features.get(Obj.BOYSPP)) buoys(feature);
     77                for (Feature feature : map.features.get(Obj.BOYWTW)) buoys(feature);
     78                for (Feature feature : map.features.get(Obj.BCNLAT)) beacons(feature);
     79                for (Feature feature : map.features.get(Obj.BCNCAR)) beacons(feature);
     80                for (Feature feature : map.features.get(Obj.BCNISD)) beacons(feature);
     81                for (Feature feature : map.features.get(Obj.BCNSAW)) beacons(feature);
     82                for (Feature feature : map.features.get(Obj.BCNSPP)) beacons(feature);
     83                for (Feature feature : map.features.get(Obj.BCNWTW)) beacons(feature);
     84        }
     85       
     86        private static void shoreline(Feature feature) {}
     87        private static void pipelines(Feature feature) {}
     88        private static void cables(Feature feature) {}
     89        private static void separation(Feature feature) {}
     90        private static void areas(Feature feature) {}
     91        private static void obstructions(Feature feature) {}
     92        private static void waterways(Feature feature) {}
     93        private static void transits(Feature feature) {}
     94        private static void harbours(Feature feature) {}
     95        private static void locks(Feature feature) {}
     96        private static void distances(Feature feature) {}
     97        private static void ports(Feature feature) {}
     98        private static void landmarks(Feature feature) {}
     99        private static void moorings(Feature feature) {}
     100        private static void notices(Feature feature) {}
     101        private static void marinas(Feature feature) {}
     102        private static void bridges(Feature feature) {}
     103        private static void lights(Feature feature) {}
     104        private static void floats(Feature feature) {}
     105        private static void signals(Feature feature) {}
     106        private static void wrecks(Feature feature) {}
     107        private static void gauges(Feature feature) {}
     108        private static void platforms(Feature feature) {}
     109        private static void buoys(Feature feature) {}
     110        private static void beacons(Feature feature) {}
     111
    14112}
  • applications/editors/josm/plugins/smed2/src/seamap/SeaMap.java

    r29156 r29172  
    2121import s57.S57val.*;
    2222
    23 public class Map {
     23public class SeaMap {
    2424
    2525        public enum Fflag {
     
    6666        public HashMap<Long, ArrayList<Long>> ways;
    6767        public HashMap<Long, ArrayList<Long>> mpolys;
    68         public HashMap<Long, Feature> features;
     68        public EnumMap<Obj, ArrayList<Feature>> features;
     69        public double minlat;
     70        public double minlon;
     71        public double maxlat;
     72        public double maxlon;
    6973
    7074        private Feature feature;
    7175        private ArrayList<Long> list;
    7276
    73         public Map() {
     77        public SeaMap() {
    7478                nodes = new HashMap<Long, Coord>();
    7579                ways = new HashMap<Long, ArrayList<Long>>();
    7680                mpolys = new HashMap<Long, ArrayList<Long>>();
    7781                feature = new Feature();
    78                 features = new HashMap<Long, Feature>();
     82                features = new EnumMap<Obj, ArrayList<Feature>>(Obj.class);
    7983        }
    8084
     
    115119                                feature.flag = Fflag.AREA;
    116120                        }
    117                         features.put(feature.refs, feature);
     121                        if (features.get(feature.type) == null) {
     122                                features.put(feature.type, new ArrayList<Feature>());
     123                        }
     124                        features.get(feature.type).add(feature);
    118125                }
    119126        }
     
    144151                                }
    145152                                AttVal attval = S57val.convertValue(val, att);
    146                                 atts.put(att, new AttItem(attval.conv, attval.val));
     153                                if (attval.val != null) atts.put(att, new AttItem(attval.conv, attval.val));
    147154                        } else {
    148155                                if (subkeys[1].equals("type")) {
     
    152159                                        if (att != Att.UNKATT) {
    153160                                                AttVal attval = S57val.convertValue(val, att);
    154                                                 feature.atts.put(att, new AttItem(attval.conv, attval.val));
     161                                                if (attval.val != null) feature.atts.put(att, new AttItem(attval.conv, attval.val));
    155162                                        }
    156163                                }
  • applications/editors/josm/plugins/smed2/src/smed2/Smed2Action.java

    r29156 r29172  
    1212import org.openstreetmap.josm.gui.MapView;
    1313import org.openstreetmap.josm.gui.MapView.EditLayerChangeListener;
    14 import org.openstreetmap.josm.gui.layer.ImageryLayer;
    15 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     14import org.openstreetmap.josm.gui.NavigatableComponent.ZoomChangeListener;
     15import org.openstreetmap.josm.gui.layer.*;
    1616import org.openstreetmap.josm.data.SelectionChangedListener;
    1717import org.openstreetmap.josm.data.imagery.ImageryInfo;
     
    2121
    2222import s57.S57dat;
    23 import seamap.Map;
     23import seamap.SeaMap;
    2424
    2525import panels.PanelMain;
     
    3333        private boolean isOpen = false;
    3434        public static PanelMain panelMain = null;
    35         public ImageryLayer rendering;
    36         public Map map = null;
     35        public MapImage rendering;
     36        public SeaMap map = null;
    3737        public Collection<OsmPrimitive> data = null;
    3838
     
    120120                frame.add(panelS57);
    121121                // System.out.println("hello");
    122                 rendering = ImageryLayer.create(new ImageryInfo("OpenSeaMap"));
     122                rendering = new MapImage(new ImageryInfo("OpenSeaMap"), map);
    123123                Main.main.addLayer(rendering);
    124124        }
     
    127127                if (isOpen) {
    128128                        Main.main.removeLayer(rendering);
     129                        MapView.removeEditLayerChangeListener(this);
    129130                        frame.setVisible(false);
    130131                        frame.dispose();
     
    157158
    158159        void reMap() {
    159                 map = new Map();
     160                map = new SeaMap();
    160161                for (OsmPrimitive osm : data) {
    161                         System.out.println(osm);
    162162                        if ((osm instanceof Node) || (osm instanceof Way)) {
    163163                                if (osm instanceof Node) {
     
    182182                }
    183183        }
    184 
    185184}
Note: See TracChangeset for help on using the changeset viewer.