private boolean testVerticesEquality(Geometry geom1, Geometry geom2) { if ( geom1.getNumPoints() != geom2.getNumPoints() ) { return false; } for ( int i = 0; i < geom1.getNumPoints(); i++ ) { Coordinate cn1 = geom1.getCoordinates()[i]; Coordinate cn2 = geom2.getCoordinates()[i]; if ( !cn1.equals2D( cn2 ) ) { return false; } } return true; } }
private boolean testVerticesEquality(Geometry geom1, Geometry geom2) { if ( geom1.getNumPoints() != geom2.getNumPoints() ) { return false; } for ( int i = 0; i < geom1.getNumPoints(); i++ ) { Coordinate cn1 = geom1.getCoordinates()[i]; Coordinate cn2 = geom2.getCoordinates()[i]; if ( !cn1.equals2D( cn2 ) ) { return false; } } return true; } }
public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } Circle circle = (Circle) o; if (Double.compare(circle.radius, this.radius) != 0) { return false; } if (this.center != null ? !this.center.equals2D(circle.center) : circle.center != null) { return false; } return true; }
private void determineArcAngle() { double diff; if (this.p1.equals2D(this.p2)) { diff = TWO_PI; } else if (this.clockwise) { diff = this.p1Angle - this.p2Angle; } else { diff = this.p2Angle - this.p1Angle; } this.arcAngle = Circle.normalizeAngle(diff); }
/** * Determine whether or not this LinearRing is ready to be created. * * @param message The current geometry type in the GML stream. * @return Ready for creation flag. */ public boolean isComplete(String message) { // makes sure that this LinearRing has more than one coordinate and its first and last are // identical if (coordinateList.size() > 1) { Coordinate firstCoordinate = (Coordinate) coordinateList.get(0); Coordinate lastCoordinate = (Coordinate) coordinateList.get(coordinateList.size() - 1); if (lastCoordinate.equals2D(firstCoordinate)) { return true; } else { return false; } } else { return false; } }
private Arc(Coordinate p1, Coordinate p2, boolean isClockwise) { this.p1 = p1; this.p2 = p2; this.clockwise = isClockwise; this.p1Angle = getAngle(p1); if (p1.equals2D(p2)) { this.p2Angle = TWO_PI + this.p1Angle; } else { this.p2Angle = getAngle(p2); } determineArcAngle(); }
private List<Coordinate> linearizeInternal( List<Coordinate> coordinates, Arc arc, double tolerence) { if (coordinates == null) { coordinates = new ArrayList<Coordinate>(); } double arcHt = arc.getArcHeight(); if (Double.compare(arcHt, tolerence) <= 0 || Double.isNaN(arcHt) || Double.isInfinite(arcHt)) { int lastIndex = coordinates.size() - 1; Coordinate lastCoord = lastIndex >= 0 ? coordinates.get(lastIndex) : null; if (lastCoord == null || !arc.getP1().equals2D(lastCoord)) { coordinates.add(arc.getP1()); coordinates.add(arc.getP2()); } else { coordinates.add(arc.getP2()); } } else { // otherwise, split Arc[] splits = arc.split(); linearizeInternal(coordinates, splits[0], tolerence); linearizeInternal(coordinates, splits[1], tolerence); } return coordinates; }
/** * If possible, merge the two lines together (ie. their start/end points are equal) returns null * if not possible * * @param major * @param minor */ private LineString merge(LineString major, LineString minor) { Coordinate major_s = major.getCoordinateN(0); Coordinate major_e = major.getCoordinateN(major.getNumPoints() - 1); Coordinate minor_s = minor.getCoordinateN(0); Coordinate minor_e = minor.getCoordinateN(minor.getNumPoints() - 1); if (major_s.equals2D(minor_s)) { // reverse minor -> major return mergeSimple(reverse(minor), major); } else if (major_s.equals2D(minor_e)) { // minor -> major return mergeSimple(minor, major); } else if (major_e.equals2D(minor_s)) { // major -> minor return mergeSimple(major, minor); } else if (major_e.equals2D(minor_e)) { // major -> reverse(minor) return mergeSimple(major, reverse(minor)); } return null; // no merge }
private Arc(Coordinate p1, Coordinate midPt, Coordinate p2) { this.p1 = p1; this.p2 = p2; this.p1Angle = getAngle(p1); // See if this arc covers the whole circle if (p1.equals2D(p2)) { this.p2Angle = TWO_PI + this.p1Angle; this.arcAngle = TWO_PI; } else { this.p2Angle = getAngle(p2); double midPtAngle = getAngle(midPt); // determine the direction double ccDegrees = Circle.subtractAngles(this.p1Angle, midPtAngle) + Circle.subtractAngles(midPtAngle, this.p2Angle); if (ccDegrees < TWO_PI) { this.clockwise = false; this.arcAngle = ccDegrees; } else { this.clockwise = true; this.arcAngle = TWO_PI - ccDegrees; } } }
if (!coords[0].equals2D(coords[4])) { return false;
private void rescale(Coordinate[] pts) { for (int i = 0; i < pts.length; i++) { pts[i].x = pts[i].x / scaleFactor + offsetX; pts[i].y = pts[i].y / scaleFactor + offsetY; } if (pts.length == 2 && pts[0].equals2D(pts[1])) { System.out.println(pts); } }
private Coordinate findSnapForVertex(Coordinate pt, Coordinate[] snapPts) { for (int i = 0; i < snapPts.length; i++) { // if point is already equal to a src pt, don't snap if (pt.equals2D(snapPts[i])) return null; if (pt.distance(snapPts[i]) < snapTolerance) return snapPts[i]; } return null; }
/** * Tests whether this edge has the given orig and dest vertices. * * @param p0 the origin vertex to test * @param p1 the destination vertex to test * @return true if the vertices are equal to the ones of this edge */ public boolean equals(Coordinate p0, Coordinate p1) { return orig.equals2D(p0) && sym.orig.equals(p1); }
private int locateOnPoint(Coordinate p, Point pt) { // no point in doing envelope test, since equality test is just as fast Coordinate ptCoord = pt.getCoordinate(); if (ptCoord.equals2D(p)) return Location.INTERIOR; return Location.EXTERIOR; }
private static Coordinate[] getRing(List coordList) { List closedPts = coordList; Coordinate p0 = (Coordinate) coordList.get(0); Coordinate pn = (Coordinate) coordList.get(coordList.size() - 1); if (! p0.equals2D(pn)) { closedPts = new ArrayList(coordList); closedPts.add(p0.clone()); } Coordinate[] pts = CoordinateArrays.toCoordinateArray(closedPts); return pts; }
public SegmentNode(NodedSegmentString segString, Coordinate coord, int segmentIndex, int segmentOctant) { this.segString = segString; this.coord = new Coordinate(coord); this.segmentIndex = segmentIndex; this.segmentOctant = segmentOctant; isInterior = ! coord.equals2D(segString.getCoordinate(segmentIndex)); }
public void testEquals2DWithinTolerance() { Coordinate c = new Coordinate(100.0, 200.0, 50.0); Coordinate aBitOff = new Coordinate(100.1, 200.1, 50.0); assertTrue(c.equals2D(aBitOff, 0.2)); }
public void testPtNotInList1() { assertTrue(CoordinateArrays.ptNotInList( new Coordinate[] { new Coordinate(1, 1), new Coordinate(2, 2), new Coordinate(3, 3) }, new Coordinate[] { new Coordinate(1, 1), new Coordinate(1, 2), new Coordinate(1, 3) } ).equals2D(new Coordinate(2, 2)) ); } public void testPtNotInList2()