Changeset 29185 in osm for applications/editors/josm/plugins/smed2/src/seamap
- Timestamp:
- 2013-01-10T00:56:38+01:00 (12 years ago)
- Location:
- applications/editors/josm/plugins/smed2/src/seamap
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/smed2/src/seamap/Renderer.java
r29184 r29185 54 54 public static Object getAttVal(Feature feature, Obj obj, int idx, Att att) { 55 55 AttMap atts = getAtts(feature, obj, idx); 56 if (atts == null) return 56 if (atts == null) return S57val.nullVal(att); 57 57 else { 58 58 AttItem item = atts.get(att); … … 62 62 } 63 63 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 64 82 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; 65 96 double slon = 0.0; 66 double slat = 0.0;67 97 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; 81 100 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; 84 104 double arc = Math.sqrt(Math.pow((lon-llon), 2) + Math.pow((lat-llat), 2)); 105 slat += (lat * arc); 85 106 slon += (lon * arc); 86 slat += (lat * arc);87 107 sarc += arc; 108 llat = lat; 88 109 llon = lon; 89 llat = lat;90 110 } 91 111 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 123 123 ArrayList<Instr> fncSym = Landmarks.Funcs.get(fncs.get(0)); 124 124 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; 126 127 Renderer.symbol(feature, catSym, feature.type); 127 128 Renderer.symbol(feature, fncSym, feature.type);
Note:
See TracChangeset
for help on using the changeset viewer.