Skip to content

Commit 777fb2e

Browse files
committed
auto update z and m values
1 parent d5bede7 commit 777fb2e

6 files changed

Lines changed: 26 additions & 8 deletions

File tree

src/main/java/mil/nga/sf/CompoundCurve.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ public void setLineStrings(List<LineString> lineStrings) {
104104
*/
105105
public void addLineString(LineString lineString) {
106106
lineStrings.add(lineString);
107+
updateZM(lineString);
107108
}
108109

109110
/**
@@ -113,7 +114,9 @@ public void addLineString(LineString lineString) {
113114
* line strings
114115
*/
115116
public void addLineStrings(List<LineString> lineStrings) {
116-
this.lineStrings.addAll(lineStrings);
117+
for (LineString lineString : lineStrings) {
118+
addLineString(lineString);
119+
}
117120
}
118121

119122
/**

src/main/java/mil/nga/sf/CurvePolygon.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ public void setRings(List<T> rings) {
122122
*/
123123
public void addRing(T ring) {
124124
rings.add(ring);
125+
updateZM(ring);
125126
}
126127

127128
/**
@@ -131,7 +132,9 @@ public void addRing(T ring) {
131132
* rings
132133
*/
133134
public void addRings(List<T> rings) {
134-
this.rings.addAll(rings);
135+
for (T ring : rings) {
136+
addRing(ring);
137+
}
135138
}
136139

137140
/**

src/main/java/mil/nga/sf/GeometryCollection.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ public GeometryCollection(GeometryCollection<T> geometryCollection) {
9191
* @param hasM
9292
* has m
9393
*/
94-
protected GeometryCollection(GeometryType type, boolean hasZ, boolean hasM) {
94+
protected GeometryCollection(GeometryType type, boolean hasZ,
95+
boolean hasM) {
9596
super(type, hasZ, hasM);
9697
}
9798

@@ -122,6 +123,7 @@ public void setGeometries(List<T> geometries) {
122123
*/
123124
public void addGeometry(T geometry) {
124125
geometries.add(geometry);
126+
updateZM(geometry);
125127
}
126128

127129
/**
@@ -131,7 +133,9 @@ public void addGeometry(T geometry) {
131133
* geometries
132134
*/
133135
public void addGeometries(List<T> geometries) {
134-
this.geometries.addAll(geometries);
136+
for (T geometry : geometries) {
137+
addGeometry(geometry);
138+
}
135139
}
136140

137141
/**
@@ -189,8 +193,8 @@ public GeometryType getCollectionType() {
189193
}
190194
break;
191195
default:
192-
throw new SFException("Unexpected Geometry Collection Type: "
193-
+ geometryType);
196+
throw new SFException(
197+
"Unexpected Geometry Collection Type: " + geometryType);
194198
}
195199

196200
return geometryType;

src/main/java/mil/nga/sf/LineString.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ public void setPoints(List<Point> points) {
107107
*/
108108
public void addPoint(Point point) {
109109
points.add(point);
110+
updateZM(point);
110111
}
111112

112113
/**
@@ -116,7 +117,9 @@ public void addPoint(Point point) {
116117
* points
117118
*/
118119
public void addPoints(List<Point> points) {
119-
this.points.addAll(points);
120+
for (Point point : points) {
121+
addPoint(point);
122+
}
120123
}
121124

122125
/**

src/main/java/mil/nga/sf/Point.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ public Double getZ() {
171171
*/
172172
public void setZ(Double z) {
173173
this.z = z;
174+
setHasZ(z != null);
174175
}
175176

176177
/**
@@ -190,6 +191,7 @@ public Double getM() {
190191
*/
191192
public void setM(Double m) {
192193
this.m = m;
194+
setHasM(m != null);
193195
}
194196

195197
/**

src/main/java/mil/nga/sf/PolyhedralSurface.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ public void setPatches(List<Polygon> patches) {
138138
*/
139139
public void addPolygon(Polygon polygon) {
140140
polygons.add(polygon);
141+
updateZM(polygon);
141142
}
142143

143144
/**
@@ -158,7 +159,9 @@ public void addPatch(Polygon patch) {
158159
* polygons
159160
*/
160161
public void addPolygons(List<Polygon> polygons) {
161-
this.polygons.addAll(polygons);
162+
for (Polygon polygon : polygons) {
163+
addPolygon(polygon);
164+
}
162165
}
163166

164167
/**

0 commit comments

Comments
 (0)