Skip to content

Commit c885e79

Browse files
committed
Fixes for issues 52, 51, 48, 46, 45, 41, 40, 36
1 parent a1906bd commit c885e79

File tree

120 files changed

+5412
-3191
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+5412
-3191
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,8 +571,10 @@ public void eraseRange(int index, int count, int validSize) {
571571
if (index + count > m_size)
572572
throw new GeometryException("invalid_call");
573573

574-
System.arraycopy(m_buffer, index + count, m_buffer, index, validSize
575-
- (index + count));
574+
if (validSize - (index + count) > 0) {
575+
System.arraycopy(m_buffer, index + count, m_buffer, index, validSize
576+
- (index + count));
577+
}
576578
m_size -= count;
577579
}
578580

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,10 @@ public int getLast() {
303303
return m_buffer[m_size - 1];
304304
}
305305

306+
public void setLast(int v) {
307+
m_buffer[m_size - 1] = v;
308+
}
309+
306310
public void removeLast() {
307311
resize(m_size - 1);
308312
}

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

Lines changed: 69 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,52 @@
2424
package com.esri.core.geometry;
2525

2626
class Boundary {
27+
28+
static boolean hasNonEmptyBoundary(Geometry geom,
29+
ProgressTracker progress_tracker) {
30+
if (geom.isEmpty())
31+
return false;
32+
33+
Geometry.Type gt = geom.getType();
34+
if (gt == Geometry.Type.Polygon) {
35+
if (geom.calculateArea2D() == 0)
36+
return false;
37+
38+
return true;
39+
} else if (gt == Geometry.Type.Polyline) {
40+
boolean[] b = new boolean[1];
41+
b[0] = false;
42+
calculatePolylineBoundary_(geom._getImpl(), progress_tracker, true,
43+
b);
44+
return b[0];
45+
} else if (gt == Geometry.Type.Envelope) {
46+
return true;
47+
} else if (Geometry.isSegment(gt.value())) {
48+
if (!((Segment) geom).isClosed()) {
49+
return true;
50+
}
51+
52+
return false;
53+
} else if (Geometry.isPoint(gt.value())) {
54+
return false;
55+
}
56+
57+
return false;
58+
}
59+
2760
static Geometry calculate(Geometry geom, ProgressTracker progress_tracker) {
2861
int gt = geom.getType().value();
2962
if (gt == Geometry.GeometryType.Polygon) {
3063
Polyline dst = new Polyline(geom.getDescription());
31-
if (!geom.isEmpty()) {
32-
((MultiPathImpl)geom._getImpl())._copyToUnsafe((MultiPathImpl)dst._getImpl());
64+
if (!geom.isEmpty()) {
65+
((MultiPathImpl) geom._getImpl())
66+
._copyToUnsafe((MultiPathImpl) dst._getImpl());
3367
}
3468

3569
return dst;
3670
} else if (gt == Geometry.GeometryType.Polyline) {
37-
return calculatePolylineBoundary_(geom._getImpl(), progress_tracker);
71+
return calculatePolylineBoundary_(geom._getImpl(),
72+
progress_tracker, false, null);
3873
} else if (gt == Geometry.GeometryType.Envelope) {
3974
Polyline dst = new Polyline(geom.getDescription());
4075
if (!geom.isEmpty())
@@ -98,9 +133,15 @@ public double getValue(int index) {
98133
}
99134

100135
static MultiPoint calculatePolylineBoundary_(Object impl,
101-
ProgressTracker progress_tracker) {
136+
ProgressTracker progress_tracker,
137+
boolean only_check_non_empty_boundary, boolean[] not_empty) {
138+
if (not_empty != null)
139+
not_empty[0] = false;
102140
MultiPathImpl mpImpl = (MultiPathImpl) impl;
103-
MultiPoint dst = new MultiPoint(mpImpl.getDescription());
141+
MultiPoint dst = null;
142+
if (!only_check_non_empty_boundary)
143+
dst = new MultiPoint(mpImpl.getDescription());
144+
104145
if (!mpImpl.isEmpty()) {
105146
AttributeStreamOfInt32 indices = new AttributeStreamOfInt32(0);
106147
indices.reserve(mpImpl.getPathCount() * 2);
@@ -151,6 +192,12 @@ static MultiPoint calculatePolylineBoundary_(Object impl,
151192
} else {
152193
if ((counter & 1) == 0) {// remove boundary point
153194
indices.set(ind, NumberUtils.intMax());
195+
} else {
196+
if (only_check_non_empty_boundary) {
197+
if (not_empty != null)
198+
not_empty[0] = true;
199+
return null;
200+
}
154201
}
155202

156203
ptPrev.setCoords(pt);
@@ -161,20 +208,30 @@ static MultiPoint calculatePolylineBoundary_(Object impl,
161208

162209
if ((counter & 1) == 0) {// remove the point
163210
indices.set(ind, NumberUtils.intMax());
211+
} else {
212+
if (only_check_non_empty_boundary) {
213+
if (not_empty != null)
214+
not_empty[0] = true;
215+
return null;
216+
}
164217
}
218+
if (!only_check_non_empty_boundary) {
219+
indices.sort(0, indices.size());
165220

166-
indices.sort(0, indices.size());
167-
168-
for (int i = 0, n = indices.size(); i < n; i++) {
169-
if (indices.get(i) == NumberUtils.intMax())
170-
break;
221+
for (int i = 0, n = indices.size(); i < n; i++) {
222+
if (indices.get(i) == NumberUtils.intMax())
223+
break;
171224

172-
mpImpl.getPointByVal(indices.get(i), point);
173-
dst.add(point);
225+
mpImpl.getPointByVal(indices.get(i), point);
226+
dst.add(point);
227+
}
174228
}
175229
}
176230
}
177231

232+
if (only_check_non_empty_boundary)
233+
return null;
234+
178235
return dst;
179236
}
180237
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ private Geometry buffer_() {
470470
case Geometry.GeometryType.Envelope:
471471
return bufferEnvelope_();
472472
default:
473-
throw new GeometryException("internal error");
473+
throw GeometryException.GeometryInternalError();
474474
}
475475
}
476476

@@ -796,7 +796,7 @@ private Polygon bufferConvexPath_(MultiPath src, int ipath) {
796796
src_mp.getXY(path_start + (i + 2) % path_size, pt_3);
797797
v_1.sub(pt_2, pt_1);
798798
if (v_1.length() == 0)
799-
throw new GeometryException("internal error");
799+
throw GeometryException.GeometryInternalError();
800800

801801
v_1.leftPerpendicular();
802802
v_1.normalize();
@@ -813,7 +813,7 @@ private Polygon bufferConvexPath_(MultiPath src, int ipath) {
813813

814814
v_2.sub(pt_3, pt_2);
815815
if (v_2.length() == 0)
816-
throw new GeometryException("internal error");
816+
throw GeometryException.GeometryInternalError();
817817

818818
v_2.leftPerpendicular();
819819
v_2.normalize();
@@ -1085,7 +1085,7 @@ private int bufferClosedPath_(Geometry input_geom, int ipath,
10851085
pt_current, BufferCommand.Flags.enum_arc,
10861086
m_buffer_commands.size() + 1,
10871087
m_buffer_commands.size() - 1));
1088-
} else if (!pt_left_prev.equals(pt)) {
1088+
} else if (!pt_left_prev.isEqual(pt)) {
10891089
m_buffer_commands.add(new BufferCommand(pt_left_prev,
10901090
pt_current, m_buffer_commands.size() + 1,
10911091
m_buffer_commands.size() - 1, "dummy"));

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,7 +1180,7 @@ static Geometry clip(Geometry geometry, Envelope2D extent,
11801180
.queryEnvelopeInGeometry(extent);
11811181
if (hit == RasterizedGeometry2D.HitType.Inside) {
11821182
if (geomtype != Geometry.Type.Polygon.value())
1183-
throw new GeometryException("internal error");
1183+
throw GeometryException.GeometryInternalError();
11841184

11851185
Polygon poly = new Polygon(geometry.getDescription());
11861186
poly.addEnvelope(extent, false);
@@ -1242,7 +1242,7 @@ static Geometry clip(Geometry geometry, Envelope2D extent,
12421242
densify_dist);
12431243
default:
12441244
assert (false);
1245-
throw new GeometryException("internal error");
1245+
throw GeometryException.GeometryInternalError();
12461246
}
12471247
}
12481248

0 commit comments

Comments
 (0)