-
Notifications
You must be signed in to change notification settings - Fork 260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stolstov/collection methods #178
Changes from 8 commits
e3e0d6e
91a0bda
13c1fa3
559fe2f
0618e30
af34eaf
aefd7d7
b06e579
c47a0e4
873d073
7e19e6f
104c2ef
7030d57
40b324e
8c20f1d
7b2bc6a
b0b407e
c5fb343
e1cbb52
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
Copyright 1995-2018 Esri | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
|
||
For additional information, contact: | ||
Environmental Systems Research Institute, Inc. | ||
Attn: Contracts Dept | ||
380 New York Street | ||
Redlands, California, USA 92373 | ||
|
||
email: contracts@esri.com | ||
*/ | ||
package com.esri.core.geometry; | ||
|
||
//An internal helper class. Do not use. | ||
public class OGCStructureInternal { | ||
private static class EditShapeCursor extends GeometryCursor { | ||
EditShape m_shape; | ||
int m_geom; | ||
int m_index; | ||
|
||
EditShapeCursor(EditShape shape, int index) { | ||
m_shape = shape; | ||
m_geom = -1; | ||
m_index = index; | ||
} | ||
@Override | ||
public Geometry next() { | ||
if (m_shape != null) { | ||
if (m_geom == -1) | ||
m_geom = m_shape.getFirstGeometry(); | ||
else | ||
m_geom = m_shape.getNextGeometry(m_geom); | ||
|
||
if (m_geom == -1) { | ||
m_shape = null; | ||
} | ||
else { | ||
return m_shape.getGeometry(m_geom); | ||
} | ||
|
||
} | ||
|
||
return null; | ||
} | ||
|
||
@Override | ||
public int getGeometryID() { | ||
return m_shape.getGeometryUserIndex(m_geom, m_index); | ||
} | ||
|
||
}; | ||
|
||
public static GeometryCursor prepare_for_ops_(GeometryCursor geoms, SpatialReference sr) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like this method simplifies the shapes. Would it be clearer to rename it to |
||
assert(geoms != null); | ||
EditShape editShape = new EditShape(); | ||
int geomIndex = editShape.createGeometryUserIndex(); | ||
for (Geometry g = geoms.next(); g != null; g = geoms.next()) { | ||
int egeom = editShape.addGeometry(g); | ||
editShape.setGeometryUserIndex(egeom, geomIndex, geoms.getGeometryID()); | ||
} | ||
|
||
Envelope2D env = editShape.getEnvelope2D(); | ||
double tolerance = InternalUtils.calculateToleranceFromGeometry(sr, | ||
env, true); | ||
|
||
CrackAndCluster.execute(editShape, tolerance, null, true); | ||
return OperatorSimplifyOGC.local().execute(new EditShapeCursor(editShape, geomIndex), sr, false, null); | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,9 +81,9 @@ static Geometry difference(Geometry geometry_a, Geometry geometry_b, | |
if (!env_a_inflated.isIntersecting(env_b)) | ||
return geometry_a; | ||
|
||
if (dimension_a == 1 && dimension_b == 2) | ||
/*if (dimension_a == 1 && dimension_b == 2) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why comment out and not delete this code? |
||
return polylineMinusArea_(geometry_a, geometry_b, type_b, | ||
spatial_reference, progress_tracker); | ||
spatial_reference, progress_tracker);*/ | ||
|
||
if (type_a == Geometry.GeometryType.Point) { | ||
Geometry geometry_b_; | ||
|
@@ -358,7 +358,9 @@ static Geometry multiPointMinusPoint_(MultiPoint multi_point, Point point, | |
return new_multipoint; | ||
} | ||
|
||
static Geometry polylineMinusArea_(Geometry geometry, Geometry area, | ||
/* | ||
This optimization causes a bug when polyline segments are on the boundary. | ||
static Geometry polylineMinusArea_(Geometry geometry, Geometry area, | ||
int area_type, SpatialReference sr, ProgressTracker progress_tracker) { | ||
// construct the complement of the Polygon (or Envelope) | ||
Envelope envelope = new Envelope(); | ||
|
@@ -387,6 +389,6 @@ static Geometry polylineMinusArea_(Geometry geometry, Geometry area, | |
Geometry difference = operatorIntersection.execute(geometry, | ||
complement, sr, progress_tracker); | ||
return difference; | ||
} | ||
}*/ | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
m_shape can be null, in which case this will throw NPE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's ok to crash as this is internal method and calling getGeometryID after iterator was exhausted is a bug.