Skip to content

Commit

Permalink
Fix documentation orient2d
Browse files Browse the repository at this point in the history
  • Loading branch information
maesenka committed Nov 20, 2022
1 parent 325e1b8 commit 543eef5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ The library is published on Maven Central. For Maven, you can include the follow
<dependency>
<groupId>org.geolatte</groupId>
<artifactId>geolatte-geom</artifactId>
<version>1.8.0</version>
<version>1.9.0</version>
</dependency>
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ public GeometryPositionEquality() {
this.pointSeqEq = new PositionSequencePositionEquality(pointEquality);
}


//FIXME - provide a means to also inject an PositionSequenceEquality, e.g.
// for rings equal except one is shifted n positions w.r.t the other.


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public static boolean isCounterClockwise(LinearRing<?> ring) {
* This uses Newell's method (see Graphics Gems III, V. 5)
*
* @param ring the linear ring
* @return +1 if the specified ring is clockwise, -1 if counterclockwise, 0 if all vertices are collinear
* @return -1 if the specified ring is clockwise, +1 if counterclockwise, 0 if all vertices are collinear
*/
public static double orient2d(LinearRing<?> ring) {
return orient2d(ring.getPositions());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,15 @@ public void testColinearZigZag() {

@Test
public void testCounterClockwiseLineString() {
LinearRing<C2D> cwLinestring = ring(xy, c(0, 0), c(1, 0), c(2, 0.5), c(1, -1), c(0, 0));
LinearRing<C2D> ccwLinestring = ring(xy, c(0, 0), c(1, 0), c(2, 0.5), c(1, 0.5), c(0, 0));
LinearRing<C2D> cwLinestring = ring(xy, c(0, 0), c(0, 1), c(1, 1), c(1, 0), c(0, 0));
LinearRing<C2D> ccwLinestring = ring(xy, c(0, 0), c(1, 0), c(1, 1), c(0, 1), c(0, 0));

assertFalse(NumericalMethods.isCounterClockwise(cwLinestring));
assertEquals((int)orient2d(cwLinestring), -1);

assertTrue(NumericalMethods.isCounterClockwise(ccwLinestring));
assertEquals((int)orient2d(ccwLinestring), 1);

}

@Test
Expand Down

0 comments on commit 543eef5

Please sign in to comment.