Changeset 29184 in osm for applications/editors/josm/plugins/smed2/src/seamap/Renderer.java
- Timestamp:
- 2013-01-08T21:26:40+01:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/smed2/src/seamap/Renderer.java
r29175 r29184 14 14 import java.awt.geom.Point2D; 15 15 import java.util.ArrayList; 16 import java.util.EnumMap;17 16 import java.util.HashMap; 18 17 … … 43 42 g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); 44 43 g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_GASP); 45 Rules. MainRules(map, zoom);44 Rules.rules(map, zoom); 46 45 } 47 46 } 48 47 49 public static EnumMap<Att, AttItem>getAtts(Feature feature, Obj obj, int idx) {50 HashMap<Integer, EnumMap<Att, AttItem>> objs = feature.objs.get(obj);48 public static AttMap getAtts(Feature feature, Obj obj, int idx) { 49 HashMap<Integer, AttMap> objs = feature.objs.get(obj); 51 50 if (objs == null) return null; 52 51 else return objs.get(idx); … … 54 53 55 54 public static Object getAttVal(Feature feature, Obj obj, int idx, Att att) { 56 EnumMap<Att, AttItem>atts = getAtts(feature, obj, idx);55 AttMap atts = getAtts(feature, obj, idx); 57 56 if (atts == null) return S57val.nullVal(att); 58 57 else { … … 62 61 } 63 62 } 63 64 public static Coord findCentroid(Feature feature) { 65 double slon = 0.0; 66 double slat = 0.0; 67 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 } 81 for (long node : way) { 82 double lon = map.nodes.get(node).lon; 83 double lat = map.nodes.get(node).lat; 84 double arc = Math.sqrt(Math.pow((lon-llon), 2) + Math.pow((lat-llat), 2)); 85 slon += (lon * arc); 86 slat += (lat * arc); 87 sarc += arc; 88 llon = lon; 89 llat = lat; 90 } 91 return map.new Coord((sarc > 0.0 ? slat/sarc : 0.0), (sarc > 0.0 ? slon/sarc : 0.0)); 92 } 64 93 65 94 public static void symbol(Feature feature, ArrayList<Instr> symbol, Obj obj) { 66 Point2D point = helper.getPoint( map.nodes.get(feature.refs));95 Point2D point = helper.getPoint(findCentroid(feature)); 67 96 ArrayList<ColCOL> colours = (ArrayList<ColCOL>) getAttVal(feature, obj, 0, Att.COLOUR); 68 97 ArrayList<ColPAT> pattern = (ArrayList<ColPAT>) getAttVal(feature, obj, 0, Att.COLPAT);
Note:
See TracChangeset
for help on using the changeset viewer.
