Changeset 29172 in osm for applications/editors
- Timestamp:
- 2013-01-05T16:09:17+01:00 (12 years ago)
- 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 1052 1052 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)); 1053 1053 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)); 1055 1055 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)); 1056 1056 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)); … … 1134 1134 return ""; 1135 1135 } 1136 1137 public static Enum<?> enumValue(String val, Att att) { 1136 1137 public static Enum<?> enumValue(String val, Att att) { // Convert OSeaM attribute value string to OSeaM enumeration 1138 1138 EnumMap<?, ?> map = keys.get(att).map; 1139 1139 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 } 1144 1147 } 1145 1148 return unkn; 1146 1149 } 1147 1148 public static AttVal convertValue(String val, Att att) { 1150 1151 public static AttVal convertValue(String val, Att att) { // Convert OSeaM attribute value string to OSeaM value struct 1149 1152 switch (keys.get(att).conv) { 1150 1153 case A: 1151 1154 case S: 1152 return new AttVal(att, keys.get(att).conv, val);1155 return new AttVal(att, Conv.S, val); 1153 1156 case E: 1154 keys.get(att).conv, enumValue(val, att));1157 return new AttVal(att, Conv.E, enumValue(val, att)); 1155 1158 case L: 1156 ArrayList list = new ArrayList(); 1159 ArrayList<Enum<?>> list = new ArrayList<Enum<?>>(); 1157 1160 for (String item : val.split(";")) { 1158 1161 list.add(enumValue(item, att)); 1159 1162 } 1160 return new AttVal(att, keys.get(att).conv, list);1163 return new AttVal(att, Conv.L, list); 1161 1164 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 } 1163 1171 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 } 1165 1178 } 1166 1179 return new AttVal(att, keys.get(att).conv, null); -
applications/editors/josm/plugins/smed2/src/seamap/Rules.java
r29157 r29172 10 10 package seamap; 11 11 12 import s57.S57obj.Obj; 13 import seamap.SeaMap.Feature; 14 12 15 public class Rules { 13 16 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 14 112 } -
applications/editors/josm/plugins/smed2/src/seamap/SeaMap.java
r29156 r29172 21 21 import s57.S57val.*; 22 22 23 public class Map { 23 public class SeaMap { 24 24 25 25 public enum Fflag { … … 66 66 public HashMap<Long, ArrayList<Long>> ways; 67 67 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; 69 73 70 74 private Feature feature; 71 75 private ArrayList<Long> list; 72 76 73 public Map() { 77 public SeaMap() { 74 78 nodes = new HashMap<Long, Coord>(); 75 79 ways = new HashMap<Long, ArrayList<Long>>(); 76 80 mpolys = new HashMap<Long, ArrayList<Long>>(); 77 81 feature = new Feature(); 78 features = new HashMap<Long,Feature>();82 features = new EnumMap<Obj, ArrayList<Feature>>(Obj.class); 79 83 } 80 84 … … 115 119 feature.flag = Fflag.AREA; 116 120 } 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); 118 125 } 119 126 } … … 144 151 } 145 152 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)); 147 154 } else { 148 155 if (subkeys[1].equals("type")) { … … 152 159 if (att != Att.UNKATT) { 153 160 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)); 155 162 } 156 163 } -
applications/editors/josm/plugins/smed2/src/smed2/Smed2Action.java
r29156 r29172 12 12 import org.openstreetmap.josm.gui.MapView; 13 13 import org.openstreetmap.josm.gui.MapView.EditLayerChangeListener; 14 import org.openstreetmap.josm.gui. layer.ImageryLayer;15 import org.openstreetmap.josm.gui.layer. OsmDataLayer;14 import org.openstreetmap.josm.gui.NavigatableComponent.ZoomChangeListener; 15 import org.openstreetmap.josm.gui.layer.*; 16 16 import org.openstreetmap.josm.data.SelectionChangedListener; 17 17 import org.openstreetmap.josm.data.imagery.ImageryInfo; … … 21 21 22 22 import s57.S57dat; 23 import seamap.Map; 23 import seamap.SeaMap; 24 24 25 25 import panels.PanelMain; … … 33 33 private boolean isOpen = false; 34 34 public static PanelMain panelMain = null; 35 public ImageryLayerrendering;36 public Map map = null; 35 public MapImage rendering; 36 public SeaMap map = null; 37 37 public Collection<OsmPrimitive> data = null; 38 38 … … 120 120 frame.add(panelS57); 121 121 // System.out.println("hello"); 122 rendering = ImageryLayer.create(new ImageryInfo("OpenSeaMap"));122 rendering = new MapImage(new ImageryInfo("OpenSeaMap"), map); 123 123 Main.main.addLayer(rendering); 124 124 } … … 127 127 if (isOpen) { 128 128 Main.main.removeLayer(rendering); 129 MapView.removeEditLayerChangeListener(this); 129 130 frame.setVisible(false); 130 131 frame.dispose(); … … 157 158 158 159 void reMap() { 159 map = new Map(); 160 map = new SeaMap(); 160 161 for (OsmPrimitive osm : data) { 161 System.out.println(osm);162 162 if ((osm instanceof Node) || (osm instanceof Way)) { 163 163 if (osm instanceof Node) { … … 182 182 } 183 183 } 184 185 184 }
Note:
See TracChangeset
for help on using the changeset viewer.