-
Notifications
You must be signed in to change notification settings - Fork 442
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
Improve how zero-length linestring are handled by relate #346
Open
mukoki
wants to merge
2
commits into
locationtech:master
Choose a base branch
from
mukoki:zero-length-linestring
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
118 changes: 118 additions & 0 deletions
118
modules/core/src/test/java/org/locationtech/jts/geom/CollapsedGeometryDimensionTest.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,118 @@ | ||
package org.locationtech.jts.geom; | ||
|
||
import junit.framework.TestCase; | ||
import junit.textui.TestRunner; | ||
import org.locationtech.jts.io.ParseException; | ||
import org.locationtech.jts.io.WKTReader; | ||
|
||
|
||
public class CollapsedGeometryDimensionTest extends TestCase { | ||
|
||
public static void main(String args[]) { | ||
TestRunner.run(CollapsedGeometryDimensionTest.class); | ||
} | ||
|
||
private GeometryFactory factory = new GeometryFactory(); | ||
private WKTReader reader = new WKTReader(factory); | ||
|
||
public CollapsedGeometryDimensionTest(String name) { super(name); } | ||
|
||
public void testMock() | ||
{ | ||
assertTrue(true); | ||
} | ||
|
||
public void testPoint() throws ParseException | ||
{ | ||
// empty | ||
assertTrue(reader.read("Point Empty").getDimension() == 0); | ||
// normal | ||
assertTrue(reader.read("Point(0 0)").getDimension() == 0); | ||
// collapsed | ||
assertTrue(reader.read("Point Empty").getDimension() == 0); | ||
} | ||
|
||
public void testLineString() throws ParseException | ||
{ | ||
// empty | ||
assertTrue(reader.read("LineString Empty").getDimension() == 1); | ||
// normal (open/closed) | ||
assertTrue(reader.read("LineString(0 0, 1 0)").getDimension() == 1); | ||
assertTrue(reader.read("LineString(0 0, 1 0, 0.5 0.5, 0 0)").getDimension() == 1); | ||
// collapsed | ||
assertTrue(reader.read("LineString(0 0, 0 0)").getDimension() == 0); | ||
} | ||
|
||
public void testPolygon() throws ParseException | ||
{ | ||
// empty | ||
assertTrue(reader.read("Polygon Empty").getDimension() == 2); | ||
// normal | ||
assertTrue(reader.read("Polygon((0 0, 1 0, 0.5 0.5, 0 0))").getDimension() == 2); | ||
// collapsed in dimension 1 (not yet detected -> dimension 2) | ||
assertTrue(reader.read("Polygon((0 0, 1 0, 2 0, 0 0))").getDimension() == 2); | ||
// collapsed | ||
assertTrue(reader.read("Polygon((0 0, 0 0, 0 0, 0 0))").getDimension() == 0); | ||
// cannot be initialized (linear ring not closed) | ||
//assertTrue(reader.read("Polygon((0 0, 1 0, 1 0, 1 0))").getDimension() == 1); | ||
} | ||
|
||
public void testLinearRing() throws ParseException | ||
{ | ||
// empty | ||
assertTrue(reader.read("LinearRing Empty").getDimension() == 1); | ||
// normal | ||
assertTrue(reader.read("LinearRing(0 0, 1 0, 0.5 0.5, 0 0)").getDimension() == 1); | ||
assertTrue(reader.read("LinearRing(0 0, 1 0, 2 0, 0 0)").getDimension() == 1); | ||
// collapsed | ||
assertTrue(reader.read("LinearRing(0 0, 0 0, 0 0, 0 0)").getDimension() == 0); | ||
} | ||
|
||
public void testMultiPoint() throws ParseException | ||
{ | ||
// empty | ||
assertTrue(reader.read("MultiPoint Empty").getDimension() == 0); | ||
// normal | ||
assertTrue(reader.read("MultiPoint((0 0), (1 1))").getDimension() == 0); | ||
// normal | ||
assertTrue(reader.read("MultiPoint((0 0), (0 0))").getDimension() == 0); | ||
} | ||
|
||
public void testMultiLineString() throws ParseException | ||
{ | ||
// empty | ||
assertTrue(reader.read("MultiLineString Empty").getDimension() == 1); | ||
// normal (open/closed) | ||
assertTrue(reader.read("MultiLineString((0 0, 1 0), (2 0, 3 0))").getDimension() == 1); | ||
assertTrue(reader.read("MultiLineString((0 0, 1 0, 0.5 0.5, 0 0))").getDimension() == 1); | ||
// partially collapsed | ||
assertTrue(reader.read("MultiLineString((0 0, 0 0), (1 0, 2 0))").getDimension() == 1); | ||
// collapsed | ||
assertTrue(reader.read("MultiLineString((0 0, 0 0), (1 0, 1 0))").getDimension() == 0); | ||
} | ||
|
||
public void testMultiPolygon() throws ParseException | ||
{ | ||
// empty | ||
assertTrue(reader.read("MultiPolygon Empty").getDimension() == 2); | ||
// normal | ||
assertTrue(reader.read("MultiPolygon(((0 0, 1 0, 0.5 0.5, 0 0)),((10 0, 11 0, 10.5 0.5, 10 0)))").getDimension() == 2); | ||
// partially collapsed | ||
assertTrue(reader.read("MultiPolygon(((0 0, 1 0, 0.5 0.5, 0 0)),((0 0, 0 0, 0 0, 0 0)))").getDimension() == 2); | ||
// collapsed | ||
assertTrue(reader.read("MultiPolygon(((0 0, 0 0, 0 0, 0 0)),((1 1, 1 1, 1 1, 1 1)))").getDimension() == 0); | ||
} | ||
|
||
public void tesGeometryCollection() throws ParseException | ||
{ | ||
// empty | ||
assertTrue(reader.read("GeometryCollection Empty").getDimension() == 0); | ||
// normal | ||
assertTrue(reader.read("GeometryCollection (Point(0 0),LineString(0 0, 1 0)").getDimension() == 1); | ||
assertTrue(reader.read("GeometryCollection (Point(0 0),LineString(0 0, 1 0), Polygon((0 0, 1 0, 0.5 0.5, 0 0))").getDimension() == 2); | ||
// collapsed | ||
assertTrue(reader.read("GeometryCollection (Point(0 0),LineString(0 0, 0 0)").getDimension() == 0); | ||
assertTrue(reader.read("GeometryCollection (Point(0 0),Polygon((0 0, 0 0, 0 0, 0 0))").getDimension() == 0); | ||
} | ||
|
||
} |
Oops, something went wrong.
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.
There should be a BIG comment here indicating that this is an enhancement to standard OGC semantics, and is potentially a source of (as yet unknown) logic bugs.