-
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
e3e0d6e
Adding collection handling methods
satol 91a0bda
Fixed distance
satol 13c1fa3
added missing file
satol 559fe2f
Fixed a couple of review comments
satol 0618e30
a few fixes, added intersection and difference for collections
satol af34eaf
Equals for collection, reducFromMulti
satol aefd7d7
update some comments
satol b06e579
comment out unused code
satol c47a0e4
reflect review comments. fix formatting in a test
stolstov 873d073
fix a typo in disjoint and a test
stolstov 7e19e6f
Reflect review comments, throw from unsupported methods
stolstov 104c2ef
Added a test from @mbasmanova
stolstov 7030d57
Fix OGCCollection#reduceFromMulti and add test
mbasmanova 40b324e
Add tests for distance and flatten
mbasmanova 8c20f1d
Simplify intersection and difference
mbasmanova 7b2bc6a
Block overlaps and symDifference for geometry collections
mbasmanova b0b407e
Merge pull request #2 from stolstov/geometry-collections
stolstov c5fb343
Merge pull request #1 from stolstov/ogc_fixes
stolstov e1cbb52
Merge pull request #180 from stolstov/stolstov/collection_methods
stolstov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
added missing file
- Loading branch information
commit 13c1fa322441f8a24d89899a5a6d54454a2b467a
There are no files selected for viewing
89 changes: 89 additions & 0 deletions
89
src/main/java/com/esri/core/geometry/OGCStructureInternal.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
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; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import com.esri.core.geometry.ogc.OGCConcreteGeometryCollection; | ||
import com.esri.core.geometry.ogc.OGCGeometry; | ||
import com.esri.core.geometry.ogc.OGCGeometryCollection; | ||
|
||
//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); | ||
} | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.