1 | /* Copyright 2015 Malcolm Herring
|
---|
2 | *
|
---|
3 | * This is free software: you can redistribute it and/or modify
|
---|
4 | * it under the terms of the GNU General Public License as published by
|
---|
5 | * the Free Software Foundation, version 3 of the License.
|
---|
6 | *
|
---|
7 | * For a copy of the GNU General Public License, see <http://www.gnu.org/licenses/>.
|
---|
8 | */
|
---|
9 |
|
---|
10 | package s57;
|
---|
11 |
|
---|
12 | import java.util.ArrayList;
|
---|
13 | import java.util.HashMap;
|
---|
14 |
|
---|
15 | import s57.S57obj.*;
|
---|
16 | import s57.S57att.*;
|
---|
17 | import s57.S57val.*;
|
---|
18 |
|
---|
19 | public class S57osm {
|
---|
20 |
|
---|
21 | static class KeyVal<V> {
|
---|
22 | Obj obj;
|
---|
23 | Att att;
|
---|
24 | Conv conv;
|
---|
25 | V val;
|
---|
26 | KeyVal(Obj o, Att a, Conv c, V v) {
|
---|
27 | obj = o;
|
---|
28 | att = a;
|
---|
29 | conv = c;
|
---|
30 | val = v;
|
---|
31 | }
|
---|
32 | }
|
---|
33 |
|
---|
34 | private static final HashMap<String, KeyVal<?>> OSMtags = new HashMap<String, KeyVal<?>>();
|
---|
35 | static {
|
---|
36 | OSMtags.put("natural=coastline", new KeyVal<>(Obj.COALNE, Att.UNKATT, null, null)); OSMtags.put("natural=water", new KeyVal<>(Obj.LAKARE, Att.UNKATT, null, null));
|
---|
37 | OSMtags.put("waterway=riverbank", new KeyVal<>(Obj.RIVBNK, Att.UNKATT, null, null)); OSMtags.put("waterway=river", new KeyVal<>(Obj.RIVERS, Att.UNKATT, null, null));
|
---|
38 | OSMtags.put("waterway=canal", new KeyVal<>(Obj.CANALS, Att.UNKATT, null, null)); OSMtags.put("waterway=dock", new KeyVal<>(Obj.HRBBSN, Att.UNKATT, null, null));
|
---|
39 | OSMtags.put("waterway=lock", new KeyVal<>(Obj.HRBBSN, Att.UNKATT, null, null));
|
---|
40 | OSMtags.put("wetland=tidalflat", new KeyVal<Double>(Obj.DEPARE, Att.DRVAL2, Conv.F, (Double)0.0)); OSMtags.put("tidal=yes", new KeyVal<Double>(Obj.DEPARE, Att.DRVAL2, Conv.F, (Double)0.0));
|
---|
41 | OSMtags.put("natural=mud", new KeyVal<>(Obj.DEPARE, Att.UNKATT, null, null)); OSMtags.put("natural=sand", new KeyVal<>(Obj.DEPARE, Att.UNKATT, null, null));
|
---|
42 | OSMtags.put("highway=motorway", new KeyVal<>(Obj.ROADWY, Att.CATROD, Conv.E, CatROD.ROD_MWAY)); OSMtags.put("highway=trunk", new KeyVal<>(Obj.ROADWY, Att.CATROD, Conv.E, CatROD.ROD_MAJR));
|
---|
43 | OSMtags.put("highway=primary", new KeyVal<>(Obj.ROADWY, Att.CATROD, Conv.E, CatROD.ROD_MAJR)); OSMtags.put("highway=secondary", new KeyVal<>(Obj.ROADWY, Att.CATROD, Conv.E, CatROD.ROD_MINR));
|
---|
44 | OSMtags.put("highway=tertiary", new KeyVal<>(Obj.ROADWY, Att.CATROD, Conv.E, CatROD.ROD_MINR)); OSMtags.put("highway=residential", new KeyVal<>(Obj.ROADWY, Att.UNKATT, null, null));
|
---|
45 | OSMtags.put("highway=unclassified", new KeyVal<>(Obj.ROADWY, Att.UNKATT, null, null)); OSMtags.put("railway=rail", new KeyVal<>(Obj.RAILWY, Att.UNKATT, null, null));
|
---|
46 | OSMtags.put("man_made=breakwater", new KeyVal<>(Obj.SLCONS, Att.UNKATT, null, null)); OSMtags.put("man_made=groyne", new KeyVal<>(Obj.SLCONS, Att.UNKATT, null, null));
|
---|
47 | OSMtags.put("man_made=pier", new KeyVal<>(Obj.SLCONS, Att.UNKATT, null, null)); OSMtags.put("man_made=jetty", new KeyVal<>(Obj.SLCONS, Att.UNKATT, null, null));
|
---|
48 | OSMtags.put("landuse=industrial", new KeyVal<>(Obj.BUAARE, Att.UNKATT, null, null)); OSMtags.put("landuse=commercial", new KeyVal<>(Obj.BUAARE, Att.UNKATT, null, null));
|
---|
49 | OSMtags.put("landuse=retail", new KeyVal<>(Obj.BUAARE, Att.UNKATT, null, null)); OSMtags.put("landuse=residential", new KeyVal<>(Obj.BUAARE, Att.UNKATT, null, null));
|
---|
50 | }
|
---|
51 |
|
---|
52 | public static KeyVal<?> OSMtag(String key, String val) {
|
---|
53 | KeyVal<?> kv = OSMtags.get(key + "=" + val);
|
---|
54 | if (kv != null) {
|
---|
55 | if (kv.conv == Conv.E) {
|
---|
56 | ArrayList<Enum<?>> list = new ArrayList<Enum<?>>();
|
---|
57 | list.add((Enum<?>)kv.val);
|
---|
58 | return new KeyVal<>(kv.obj, kv.att, kv.conv, list);
|
---|
59 | }
|
---|
60 | return kv;
|
---|
61 | }
|
---|
62 | return new KeyVal<>(Obj.UNKOBJ, Att.UNKATT, null, null);
|
---|
63 | }
|
---|
64 |
|
---|
65 | }
|
---|