Skip to content

Commit b98b428

Browse files
authored
Merge pull request #193 from tdcmeehan/emptysize
Fix NPE on estimateMemorySize against empty multipart geometries
2 parents 6f36a43 + acc5861 commit b98b428

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

src/main/java/com/esri/core/geometry/MultiPathImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ public long estimateMemorySize()
6666
+ (m_envelope != null ? m_envelope.estimateMemorySize() : 0)
6767
+ (m_moveToPoint != null ? m_moveToPoint.estimateMemorySize() : 0)
6868
+ (m_cachedRingAreas2D != null ? m_cachedRingAreas2D.estimateMemorySize() : 0)
69-
+ m_paths.estimateMemorySize()
70-
+ m_pathFlags.estimateMemorySize()
69+
+ (m_paths != null ? m_paths.estimateMemorySize() : 0)
70+
+ (m_pathFlags != null ? m_pathFlags.estimateMemorySize() : 0)
7171
+ (m_segmentFlags != null ? m_segmentFlags.estimateMemorySize() : 0)
7272
+ (m_segmentParamIndex != null ? m_segmentParamIndex.estimateMemorySize() : 0)
7373
+ (m_segmentParams != null ? m_segmentParams.estimateMemorySize() : 0);

src/test/java/com/esri/core/geometry/TestEstimateMemorySize.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,36 +77,71 @@ public void testPoint() {
7777
testGeometry(parseWkt("POINT (1 2)"));
7878
}
7979

80+
@Test
81+
public void testEmptyPoint() {
82+
testGeometry(parseWkt("POINT EMPTY"));
83+
}
84+
8085
@Test
8186
public void testMultiPoint() {
8287
testGeometry(parseWkt("MULTIPOINT (0 0, 1 1, 2 3)"));
8388
}
8489

90+
@Test
91+
public void testEmptyMultiPoint() {
92+
testGeometry(parseWkt("MULTIPOINT EMPTY"));
93+
}
94+
8595
@Test
8696
public void testLineString() {
8797
testGeometry(parseWkt("LINESTRING (0 1, 2 3, 4 5)"));
8898
}
8999

100+
@Test
101+
public void testEmptyLineString() {
102+
testGeometry(parseWkt("LINESTRING EMPTY"));
103+
}
104+
90105
@Test
91106
public void testMultiLineString() {
92107
testGeometry(parseWkt("MULTILINESTRING ((0 1, 2 3, 4 5), (1 1, 2 2))"));
93108
}
94109

110+
@Test
111+
public void testEmptyMultiLineString() {
112+
testGeometry(parseWkt("MULTILINESTRING EMPTY"));
113+
}
114+
95115
@Test
96116
public void testPolygon() {
97117
testGeometry(parseWkt("POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))"));
98118
}
99119

120+
@Test
121+
public void testEmptyPolygon() {
122+
testGeometry(parseWkt("POLYGON EMPTY"));
123+
}
124+
100125
@Test
101126
public void testMultiPolygon() {
102127
testGeometry(parseWkt("MULTIPOLYGON (((30 20, 45 40, 10 40, 30 20)), ((15 5, 40 10, 10 20, 5 10, 15 5)))"));
103128
}
104129

130+
@Test
131+
public void testEmptyMultiPolygon() {
132+
testGeometry(parseWkt("MULTIPOLYGON EMPTY"));
133+
}
134+
105135
@Test
106136
public void testGeometryCollection() {
107137
testGeometry(parseWkt("GEOMETRYCOLLECTION (POINT(4 6), LINESTRING(4 6,7 10))"));
108138
}
109139

140+
@Test
141+
public void testEmptyGeometryCollection() {
142+
testGeometry(parseWkt("GEOMETRYCOLLECTION EMPTY"));
143+
}
144+
110145
private void testGeometry(OGCGeometry geometry) {
111146
assertTrue(geometry.estimateMemorySize() > 0);
112147
}

0 commit comments

Comments
 (0)