Skip to content

Commit 4d4bfef

Browse files
committed
methods for abstract multi curves and multi surfaces
1 parent f246cce commit 4d4bfef

File tree

4 files changed

+134
-12
lines changed

4 files changed

+134
-12
lines changed

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

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package mil.nga.sf;
22

3+
import java.util.List;
4+
35
/**
46
* A restricted form of GeometryCollection where each Geometry in the collection
57
* must be of type Curve.
@@ -22,6 +24,65 @@ protected MultiCurve(GeometryType type, boolean hasZ, boolean hasM) {
2224
super(type, hasZ, hasM);
2325
}
2426

27+
/**
28+
* Get the curves
29+
*
30+
* @return curves
31+
*/
32+
public List<T> getCurves() {
33+
return getGeometries();
34+
}
35+
36+
/**
37+
* Set the curves
38+
*
39+
* @param curves
40+
* curves
41+
*/
42+
public void setCurves(List<T> curves) {
43+
setGeometries(curves);
44+
}
45+
46+
/**
47+
* Add a curve
48+
*
49+
* @param curve
50+
* curve
51+
*/
52+
public void addCurve(T curve) {
53+
addGeometry(curve);
54+
}
55+
56+
/**
57+
* Add curves
58+
*
59+
* @param curves
60+
* curves
61+
*/
62+
public void addCurves(List<T> curves) {
63+
addGeometries(curves);
64+
}
65+
66+
/**
67+
* Get the number of curves
68+
*
69+
* @return number of curves
70+
*/
71+
public int numCurves() {
72+
return numGeometries();
73+
}
74+
75+
/**
76+
* Returns the Nth curve
77+
*
78+
* @param n
79+
* nth line curve to return
80+
* @return curve
81+
*/
82+
public T getCurve(int n) {
83+
return getGeometry(n);
84+
}
85+
2586
/**
2687
* Determine if this Multi Curve is closed for each Curve (start point = end
2788
* point)

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public MultiLineString(MultiLineString multiLineString) {
7272
* @return line strings
7373
*/
7474
public List<LineString> getLineStrings() {
75-
return getGeometries();
75+
return getCurves();
7676
}
7777

7878
/**
@@ -82,7 +82,7 @@ public List<LineString> getLineStrings() {
8282
* line strings
8383
*/
8484
public void setLineStrings(List<LineString> lineStrings) {
85-
setGeometries(lineStrings);
85+
setCurves(lineStrings);
8686
}
8787

8888
/**
@@ -92,7 +92,7 @@ public void setLineStrings(List<LineString> lineStrings) {
9292
* line string
9393
*/
9494
public void addLineString(LineString lineString) {
95-
addGeometry(lineString);
95+
addCurve(lineString);
9696
}
9797

9898
/**
@@ -102,7 +102,7 @@ public void addLineString(LineString lineString) {
102102
* line strings
103103
*/
104104
public void addLineStrings(List<LineString> lineStrings) {
105-
addGeometries(lineStrings);
105+
addCurves(lineStrings);
106106
}
107107

108108
/**
@@ -111,7 +111,7 @@ public void addLineStrings(List<LineString> lineStrings) {
111111
* @return number of line strings
112112
*/
113113
public int numLineStrings() {
114-
return numGeometries();
114+
return numCurves();
115115
}
116116

117117
/**
@@ -122,7 +122,7 @@ public int numLineStrings() {
122122
* @return line string
123123
*/
124124
public LineString getLineString(int n) {
125-
return getGeometry(n);
125+
return getCurve(n);
126126
}
127127

128128
/**

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public MultiPolygon(MultiPolygon multiPolygon) {
7272
* @return polygons
7373
*/
7474
public List<Polygon> getPolygons() {
75-
return getGeometries();
75+
return getSurfaces();
7676
}
7777

7878
/**
@@ -82,7 +82,7 @@ public List<Polygon> getPolygons() {
8282
* polygons
8383
*/
8484
public void setPolygons(List<Polygon> polygons) {
85-
setGeometries(polygons);
85+
setSurfaces(polygons);
8686
}
8787

8888
/**
@@ -92,7 +92,7 @@ public void setPolygons(List<Polygon> polygons) {
9292
* polygon
9393
*/
9494
public void addPolygon(Polygon polygon) {
95-
addGeometry(polygon);
95+
addSurface(polygon);
9696
}
9797

9898
/**
@@ -102,7 +102,7 @@ public void addPolygon(Polygon polygon) {
102102
* polygons
103103
*/
104104
public void addPolygons(List<Polygon> polygons) {
105-
addGeometries(polygons);
105+
addSurfaces(polygons);
106106
}
107107

108108
/**
@@ -111,7 +111,7 @@ public void addPolygons(List<Polygon> polygons) {
111111
* @return number of polygons
112112
*/
113113
public int numPolygons() {
114-
return numGeometries();
114+
return numSurfaces();
115115
}
116116

117117
/**
@@ -122,7 +122,7 @@ public int numPolygons() {
122122
* @return polygon
123123
*/
124124
public Polygon getPolygon(int n) {
125-
return getGeometry(n);
125+
return getSurface(n);
126126
}
127127

128128
/**

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

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package mil.nga.sf;
22

3+
import java.util.List;
4+
35
/**
46
* A restricted form of GeometryCollection where each Geometry in the collection
57
* must be of type Surface.
@@ -23,4 +25,63 @@ protected MultiSurface(GeometryType type, boolean hasZ, boolean hasM) {
2325
super(type, hasZ, hasM);
2426
}
2527

28+
/**
29+
* Get the surfaces
30+
*
31+
* @return surfaces
32+
*/
33+
public List<T> getSurfaces() {
34+
return getGeometries();
35+
}
36+
37+
/**
38+
* Set the surfaces
39+
*
40+
* @param surfaces
41+
* surfaces
42+
*/
43+
public void setSurfaces(List<T> surfaces) {
44+
setGeometries(surfaces);
45+
}
46+
47+
/**
48+
* Add a surface
49+
*
50+
* @param surface
51+
* surface
52+
*/
53+
public void addSurface(T surface) {
54+
addGeometry(surface);
55+
}
56+
57+
/**
58+
* Add surfaces
59+
*
60+
* @param surfaces
61+
* surfaces
62+
*/
63+
public void addSurfaces(List<T> surfaces) {
64+
addGeometries(surfaces);
65+
}
66+
67+
/**
68+
* Get the number of surfaces
69+
*
70+
* @return number of surfaces
71+
*/
72+
public int numSurfaces() {
73+
return numGeometries();
74+
}
75+
76+
/**
77+
* Returns the Nth surface
78+
*
79+
* @param n
80+
* nth line surface to return
81+
* @return surface
82+
*/
83+
public T getSurface(int n) {
84+
return getGeometry(n);
85+
}
86+
2687
}

0 commit comments

Comments
 (0)