Skip to content

Commit

Permalink
sweep line updates
Browse files Browse the repository at this point in the history
  • Loading branch information
bosborn committed Jan 25, 2018
1 parent 6d36991 commit 197ded1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 44 deletions.
20 changes: 10 additions & 10 deletions src/main/java/mil/nga/wkb/util/centroid/CentroidSurface.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,6 @@ private void add(Polygon polygon) {
}
}

/**
* Add a line string to the centroid total
*
* @param lineString
* line string
*/
private void add(LineString lineString) {
add(true, lineString);
}

/**
* Add a curve polygon to the centroid total
*
Expand Down Expand Up @@ -194,6 +184,16 @@ private void add(CurvePolygon<Curve> curvePolygon) {
}
}

/**
* Add a line string to the centroid total
*
* @param lineString
* line string
*/
private void add(LineString lineString) {
add(true, lineString);
}

/**
* Add a line string hole to subtract from the centroid total
*
Expand Down
31 changes: 0 additions & 31 deletions src/main/java/mil/nga/wkb/util/sweep/Segment.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,35 +133,4 @@ public void setBelow(Segment below) {
this.below = below;
}

/**
* {@inheritDoc}
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + edge;
result = prime * result + ring;
return result;
}

/**
* {@inheritDoc}
*/
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Segment other = (Segment) obj;
if (edge != other.edge)
return false;
if (ring != other.ring)
return false;
return true;
}

}
13 changes: 10 additions & 3 deletions src/main/java/mil/nga/wkb/util/sweep/SweepLine.java
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,13 @@ public boolean intersect(Segment segment1, Segment segment2) {
*/
public void remove(Segment segment) {

if (tree.remove(segment)) {
boolean removed = tree.remove(segment);
if (!removed) {
comparator.setX(segment.getLeftPoint().getX());
removed = tree.remove(segment);
}

if (removed) {

Segment above = segment.getAbove();
Segment below = segment.getBelow();
Expand Down Expand Up @@ -306,12 +312,13 @@ public static int xyOrder(Point point1, Point point2) {
* point
* @return > 0 if left, 0 if on, < 0 if right
*/
public static double isLeft(Segment segment, Point point) {
private static double isLeft(Segment segment, Point point) {
return isLeft(segment.getLeftPoint(), segment.getRightPoint(), point);
}

/**
* Check where point 2 is (left, on, right) relative to the line from point
* 0 to point 1
*
* @param point0
* point 0
Expand All @@ -321,7 +328,7 @@ public static double isLeft(Segment segment, Point point) {
* point 2
* @return > 0 if left, 0 if on, < 0 if right
*/
public static double isLeft(Point point0, Point point1, Point point2) {
private static double isLeft(Point point0, Point point1, Point point2) {
return (point1.getX() - point0.getX())
* (point2.getY() - point0.getY())
- (point2.getX() - point0.getX())
Expand Down

0 comments on commit 197ded1

Please sign in to comment.