Skip to content

Commit ecaedf4

Browse files
authored
Merge pull request #178 from Esri/stolstov/collection_methods
Stolstov/collection methods
2 parents bbfe1d3 + e1cbb52 commit ecaedf4

19 files changed

Lines changed: 1437 additions & 74 deletions

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ public static int getDimensionFromType(int type) {
456456
* @param type
457457
* The integer value from geometry enumeration. You can use the
458458
* method {@link Type#value()} to get at the integer value.
459-
* @return TRUE if the geometry is a point.
459+
* @return TRUE if the geometry is a point (a Point or a Multipoint).
460460
*/
461461
public static boolean isPoint(int type) {
462462
return (type & 0x20) != 0;
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*
2+
Copyright 1995-2018 Esri
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
16+
For additional information, contact:
17+
Environmental Systems Research Institute, Inc.
18+
Attn: Contracts Dept
19+
380 New York Street
20+
Redlands, California, USA 92373
21+
22+
email: contracts@esri.com
23+
*/
24+
package com.esri.core.geometry;
25+
26+
//An internal helper class. Do not use.
27+
public class OGCStructureInternal {
28+
private static class EditShapeCursor extends GeometryCursor {
29+
EditShape m_shape;
30+
int m_geom;
31+
int m_index;
32+
33+
EditShapeCursor(EditShape shape, int index) {
34+
m_shape = shape;
35+
m_geom = -1;
36+
m_index = index;
37+
}
38+
@Override
39+
public Geometry next() {
40+
if (m_shape != null) {
41+
if (m_geom == -1)
42+
m_geom = m_shape.getFirstGeometry();
43+
else
44+
m_geom = m_shape.getNextGeometry(m_geom);
45+
46+
if (m_geom == -1) {
47+
m_shape = null;
48+
}
49+
else {
50+
return m_shape.getGeometry(m_geom);
51+
}
52+
53+
}
54+
55+
return null;
56+
}
57+
58+
@Override
59+
public int getGeometryID() {
60+
return m_shape.getGeometryUserIndex(m_geom, m_index);
61+
}
62+
63+
};
64+
65+
public static GeometryCursor prepare_for_ops_(GeometryCursor geoms, SpatialReference sr) {
66+
assert(geoms != null);
67+
EditShape editShape = new EditShape();
68+
int geomIndex = editShape.createGeometryUserIndex();
69+
for (Geometry g = geoms.next(); g != null; g = geoms.next()) {
70+
int egeom = editShape.addGeometry(g);
71+
editShape.setGeometryUserIndex(egeom, geomIndex, geoms.getGeometryID());
72+
}
73+
74+
Envelope2D env = editShape.getEnvelope2D();
75+
double tolerance = InternalUtils.calculateToleranceFromGeometry(sr,
76+
env, true);
77+
78+
CrackAndCluster.execute(editShape, tolerance, null, true);
79+
return OperatorSimplifyOGC.local().execute(new EditShapeCursor(editShape, geomIndex), sr, false, null);
80+
}
81+
}
82+

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

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,6 @@ static Geometry difference(Geometry geometry_a, Geometry geometry_b,
8181
if (!env_a_inflated.isIntersecting(env_b))
8282
return geometry_a;
8383

84-
if (dimension_a == 1 && dimension_b == 2)
85-
return polylineMinusArea_(geometry_a, geometry_b, type_b,
86-
spatial_reference, progress_tracker);
87-
8884
if (type_a == Geometry.GeometryType.Point) {
8985
Geometry geometry_b_;
9086
if (MultiPath.isSegment(type_b)) {
@@ -357,36 +353,5 @@ static Geometry multiPointMinusPoint_(MultiPoint multi_point, Point point,
357353

358354
return new_multipoint;
359355
}
360-
361-
static Geometry polylineMinusArea_(Geometry geometry, Geometry area,
362-
int area_type, SpatialReference sr, ProgressTracker progress_tracker) {
363-
// construct the complement of the Polygon (or Envelope)
364-
Envelope envelope = new Envelope();
365-
geometry.queryEnvelope(envelope);
366-
Envelope2D env_2D = new Envelope2D();
367-
area.queryEnvelope2D(env_2D);
368-
envelope.merge(env_2D);
369-
double dw = 0.1 * envelope.getWidth();
370-
double dh = 0.1 * envelope.getHeight();
371-
envelope.inflate(dw, dh);
372-
373-
Polygon complement = new Polygon();
374-
complement.addEnvelope(envelope, false);
375-
376-
MultiPathImpl complementImpl = (MultiPathImpl) (complement._getImpl());
377-
378-
if (area_type == Geometry.GeometryType.Polygon) {
379-
MultiPathImpl polygonImpl = (MultiPathImpl) (area._getImpl());
380-
complementImpl.add(polygonImpl, true);
381-
} else
382-
complementImpl.addEnvelope((Envelope) (area), true);
383-
384-
OperatorFactoryLocal projEnv = OperatorFactoryLocal.getInstance();
385-
OperatorIntersection operatorIntersection = (OperatorIntersection) projEnv
386-
.getOperator(Operator.Type.Intersection);
387-
Geometry difference = operatorIntersection.execute(geometry,
388-
complement, sr, progress_tracker);
389-
return difference;
390-
}
391-
392356
}
357+

0 commit comments

Comments
 (0)