comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/map/HWS.java @ 5838:5aa05a7a34b7

Rename modules to more fitting names.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 15:23:37 +0200
parents flys-artifacts/src/main/java/org/dive4elements/river/artifacts/model/map/HWS.java@bd047b71ab37
children 4897a58c8746
comparison
equal deleted inserted replaced
5837:d9901a08d0a6 5838:5aa05a7a34b7
1 package org.dive4elements.river.artifacts.model.map;
2
3 import org.geotools.feature.simple.SimpleFeatureBuilder;
4 import org.opengis.feature.simple.SimpleFeature;
5 import org.opengis.feature.simple.SimpleFeatureType;
6
7 import com.vividsolutions.jts.geom.Geometry;
8
9 import org.dive4elements.river.artifacts.model.NamedObjectImpl;
10 import org.dive4elements.river.utils.GeometryUtils;
11
12
13 public class HWS
14 extends NamedObjectImpl
15 {
16
17 public enum TYPE {LINE, POINT};
18
19 private Geometry geom;
20 private String id;
21 private int kind;
22 private int official;
23 private String fedState;
24 private String description;
25 private TYPE type;
26
27 public HWS() {
28 this.geom = null;
29 // TODO Auto-generated constructor stub
30 }
31
32 public HWS(String name) {
33 super(name);
34 this.geom = null;
35 }
36
37 public HWS(
38 String name,
39 Geometry geom,
40 String id,
41 int kind,
42 int official,
43 String fedState,
44 String description,
45 TYPE type
46 ) {
47 super(name);
48 this.geom = geom;
49 this.id = id;
50 this.kind = kind;
51 this.official = official;
52 this.fedState = fedState;
53 this.description = description;
54 this.type = type;
55 }
56
57 public Geometry getGeom() {
58 return geom;
59 }
60
61 public void setGeom(Geometry geom) {
62 this.geom = geom;
63 }
64
65 public String getId() {
66 return id;
67 }
68
69 public void setId(String id) {
70 this.id = id;
71 }
72
73 public int getKind() {
74 return kind;
75 }
76
77 public void setKind(int kind) {
78 this.kind = kind;
79 }
80
81 public boolean isOfficial() {
82 return official == 1;
83 }
84
85 public void setOfficial(boolean o) {
86 this.official = o ? 1 : 0;
87 }
88
89 public String getFedState() {
90 return fedState;
91 }
92
93 public void setFedState(String fedState) {
94 this.fedState = fedState;
95 }
96
97 public String getDescription() {
98 return description;
99 }
100
101 public void setDescription(String description) {
102 this.description = description;
103 }
104
105 public TYPE getType() {
106 return type;
107 }
108
109 public void setType(TYPE type) {
110 this.type = type;
111 }
112
113 public SimpleFeatureType getFeatureType() {
114 int srid = this.geom.getSRID();
115 String srs = "EPSG:" + srid;
116
117 Object[][] attrs = new Object[5][];
118 attrs[0] = new Object[] { "name", String.class };
119 attrs[1] = new Object[] { "description", String.class };
120 attrs[2] = new Object[] { "TYP", String.class };
121 attrs[3] = new Object[] { "fed_state", String.class };
122 attrs[4] = new Object[] { "official", Integer.class };
123 SimpleFeatureType ft =
124 GeometryUtils.buildFeatureType(
125 "hws", srs, this.geom.getClass(), attrs);
126 return ft;
127 }
128
129 public SimpleFeature getFeature() {
130 SimpleFeatureType ft = getFeatureType();
131
132 SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(ft);
133 featureBuilder.add(this.geom);
134 featureBuilder.add(this.name);
135 featureBuilder.add(this.description);
136 if (this.kind == 1) {
137 featureBuilder.add("Rohr 1");
138 }
139 else if (this.kind == 2) {
140 featureBuilder.add("Damm");
141 }
142 else if (this.kind == 3) {
143 featureBuilder.add("Graben");
144 }
145 else {
146 featureBuilder.add("");
147 }
148 featureBuilder.add(this.fedState);
149 featureBuilder.add(this.official);
150
151 return featureBuilder.buildFeature(null);
152 }
153 }

http://dive4elements.wald.intevation.org