8000 Lower LinearRing min vertex limit to 3 by dr-jts · Pull Request #682 · locationtech/jts · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Lower LinearRing min vertex limit to 3 #682

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

Merged
merged 1 commit into from
Feb 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
8000
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,10 @@ public Geometry read( EndianDataInputStream file , GeometryFactory geometryFacto
offset++;
}
LinearRing ring = geometryFactory.createLinearRing(points);
if(Orientation.isCCW(points)){
/**
* Allow reading a 3-point ring, and treat it as a shell.
*/
if(points.length >= 4 && Orientation.isCCW(points)){
holes.add(ring);
}
else{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,26 @@
* A <code>LinearRing</code> is a {@link LineString} which is both closed and simple.
* In other words,
* the first and last coordinate in the ring must be equal,
* and the interior of the ring must not self-intersect.
* and the ring must not self-intersect.
* Either orientation of the ring is allowed.
* <p>
* A ring must have either 0 or 4 or more points.
* A ring must have either 0 or 3 or more points.
* The first and last points must be equal (in 2D).
* If these conditions are not met, the constructors throw
* an {@link IllegalArgumentException}
* an {@link IllegalArgumentException}.
* A ring with 3 points is invalid, because it is collapsed
* and thus has a self-intersection. It is allowed to be constructed
* so that it can be represented, and repaired if needed.
*
* @version 1.7
*/
public class LinearRing extends LineString
{
/**
* The minimum number of vertices allowed in a valid non-empty ring (= 4).
* The minimum number of vertices allowed in a valid non-empty ring.
* Empty rings with 0 vertices are also valid.
*/
public static final int MINIMUM_VALID_SIZE = 4;
public static final int MINIMUM_VALID_SIZE = 3;

private static final long serialVersionUID = -4261142084085851829L;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@
import junit.framework.TestCase;
import junit.framework.TestSuite;
import junit.textui.TestRunner;
import test.jts.GeometryTestCase;


/**
* Test for com.vividsolutions.jts.geom.impl.LineStringImpl.
*
* @version 1.7
*/
public class LineStringImplTest extends TestCase {
public class LineStringImplTest extends GeometryTestCase {

PrecisionModel precisionModel = new PrecisionModel(1000);
GeometryFactory geometryFactory = new GeometryFactory(precisionModel, 0);
Expand Down Expand Up @@ -169,17 +170,14 @@ public void testFiveZeros() {
}

public void testLinearRingConstructor() throws Exception {
try {
LinearRing ring =
new GeometryFactory().createLinearRing(
new Coordinate[] {
new Coordinate(0, 0),
new Coordinate(10, 10),
new Coordinate(0, 0)});
assertTrue(false);
} catch (IllegalArgumentException e) {
assertTrue(true);
}
Geometry ringFromWKT = read("LINEARRING (0 0, 10 10, 0 0)");
checkEqual(ring, ringFromWKT);
}

}
0