| 1 | /* Copyright 2012 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 seamap;
|
|---|
| 11 |
|
|---|
| 12 | import java.util.ArrayList;
|
|---|
| 13 | import java.util.EnumMap;
|
|---|
| 14 | import java.util.HashMap;
|
|---|
| 15 |
|
|---|
| 16 | import s57.S57att.Att;
|
|---|
| 17 | import s57.S57obj.Obj;
|
|---|
| 18 | import s57.S57val.Conv;
|
|---|
| 19 |
|
|---|
| 20 | public class Map {
|
|---|
| 21 |
|
|---|
| 22 | public enum Fflag { NODE, WAY, AREA }
|
|---|
| 23 |
|
|---|
| 24 | public class AttItem {
|
|---|
| 25 | Conv conv;
|
|---|
| 26 | Object val;
|
|---|
| 27 | }
|
|---|
| 28 |
|
|---|
| 29 | public class ObjItem {
|
|---|
| 30 | int idx;
|
|---|
| 31 | ArrayList<EnumMap<Att, AttItem>> atts;
|
|---|
| 32 | }
|
|---|
| 33 |
|
|---|
| 34 | public class Feature {
|
|---|
| 35 | public long id;
|
|---|
| 36 | public Fflag flag;
|
|---|
| 37 | public ArrayList<Long> refs;
|
|---|
| 38 | public Obj type;
|
|---|
| 39 | public EnumMap<Att, AttItem> atts;
|
|---|
| 40 | public EnumMap<Obj, ArrayList<ObjItem>> objs;
|
|---|
| 41 | }
|
|---|
| 42 |
|
|---|
| 43 | public class Coord {
|
|---|
| 44 | double lat;
|
|---|
| 45 | double lon;
|
|---|
| 46 | Coord (double ilat, double ilon) {
|
|---|
| 47 | lat = ilat;
|
|---|
| 48 | lon = ilon;
|
|---|
| 49 | }
|
|---|
| 50 | }
|
|---|
| 51 |
|
|---|
| 52 | public HashMap<Long, Coord> nodes;
|
|---|
| 53 | public HashMap<Long, ArrayList<Long>> ways;
|
|---|
| 54 | public HashMap<Long, ArrayList<Long>> mpolys;
|
|---|
| 55 | public ArrayList<Feature> features;
|
|---|
| 56 |
|
|---|
| 57 | public Map () {
|
|---|
| 58 | nodes = new HashMap<Long, Coord>();
|
|---|
| 59 | ways = new HashMap<Long, ArrayList<Long>>();
|
|---|
| 60 | mpolys = new HashMap<Long, ArrayList<Long>>();
|
|---|
| 61 | features = new ArrayList<Feature>();
|
|---|
| 62 | }
|
|---|
| 63 |
|
|---|
| 64 | public void addNode(long id, double lat, double lon) {
|
|---|
| 65 | nodes.put(id, new Coord(lat, lon));
|
|---|
| 66 | }
|
|---|
| 67 |
|
|---|
| 68 | public void addWay(long id) {
|
|---|
| 69 | ways.put(id, new ArrayList<Long>());
|
|---|
| 70 | }
|
|---|
| 71 |
|
|---|
| 72 | public void addToWay(long way, long node) {
|
|---|
| 73 | ways.get(way).add(node);
|
|---|
| 74 | }
|
|---|
| 75 | public void addRelation(long id) {
|
|---|
| 76 | mpolys.put(id, new ArrayList<Long>());
|
|---|
| 77 | }
|
|---|
| 78 |
|
|---|
| 79 | public void addToRelation(long rel, long way) {
|
|---|
| 80 | mpolys.get(rel).add(way);
|
|---|
| 81 | }
|
|---|
| 82 | }
|
|---|