public boolean contains(DirectPosition point) { return point.equals(position); }
public Curve createCurve(PointArray points, boolean closed) throws MismatchedReferenceSystemException, MismatchedDimensionException { if (points == null) throw new NullPointerException("Points are required to create a curve"); if (points.size() < 2) throw new IllegalArgumentException( "At least two points are required to create a curve"); // A curve will be created // - The curve will be set as parent curves for the Curve segments // - Start and end params for the CurveSegments will be set List /* <LineSegment> */ segmentList = new ArrayList /* <LineSegment> */(); for (int i = 0; i < points.size() - 1; i++) { int start = i; int end = i + 1; DirectPosition point1 = points.getDirectPosition(start, null); DirectPosition point2 = points.getDirectPosition(end, null); LineSegment segment = createLineSegment(point1, point2); segmentList.add(segment); } if (closed) { LineSegment first = (LineSegment) segmentList.get(0); LineSegment last = (LineSegment) segmentList.get(segmentList.size() - 1); if (!first.getStartPoint().equals(last.getEndPoint())) { LineSegment segment = createLineSegment(last.getEndPoint(), first.getStartPoint()); segmentList.add(segment); } } return getPrimitiveFactory().createCurve(segmentList); }
/** * Tests {@link GeneralDirectPosition#equals} method between different implementations. The * purpose of this test is also to run the assertion in the direct position implementations. */ @Test public void testEquals() { assertTrue(GeneralDirectPosition.class.desiredAssertionStatus()); assertTrue(DirectPosition2D.class.desiredAssertionStatus()); CoordinateReferenceSystem WGS84 = DefaultGeographicCRS.WGS84; DirectPosition p1 = new DirectPosition2D(WGS84, 48.543261561072285, -123.47009555832284); GeneralDirectPosition p2 = new GeneralDirectPosition(48.543261561072285, -123.47009555832284); assertFalse(p1.equals(p2)); assertFalse(p2.equals(p1)); p2.setCoordinateReferenceSystem(WGS84); assertTrue(p1.equals(p2)); assertTrue(p2.equals(p1)); } }
protected boolean compareDirectPositionResult(final DirectPosition result) { if (expectedResult instanceof DirectPosition) { DirectPosition expect = (DirectPosition)expectedResult; return result.equals(expect); } else { return false; } }
/** * Tests {@link DirectPosition2D#equals(Object)} method between different implementations. * The purpose of this test is also to run the assertion in the direct position implementations. */ @Test public void testEquals() { assertTrue(DirectPosition2D .class.desiredAssertionStatus()); assertTrue(GeneralDirectPosition.class.desiredAssertionStatus()); DirectPosition p1 = new DirectPosition2D (48.543261561072285, -123.47009555832284); DirectPosition p2 = new GeneralDirectPosition(48.543261561072285, -123.47009555832284); assertTrue(p1.equals(p2)); assertTrue(p2.equals(p1)); assertEquals(p2.hashCode(), p1.hashCode()); p1.setOrdinate(0, p1.getOrdinate(0) + 1); assertFalse(p1.equals(p2)); assertFalse(p2.equals(p1)); assertFalse(p2.hashCode() == p1.hashCode()); }
/** * Tests {@link DirectPosition2D#equals(Object)} method between different implementations. * The purpose of this test is also to run the assertion in the direct position implementations. */ @Test public void testEquals() { assertTrue(DirectPosition1D .class.desiredAssertionStatus()); assertTrue(GeneralDirectPosition.class.desiredAssertionStatus()); DirectPosition p1 = new DirectPosition1D (48.543261561072285); DirectPosition p2 = new GeneralDirectPosition(48.543261561072285); assertTrue(p1.equals(p2)); assertTrue(p2.equals(p1)); assertEquals(p2.hashCode(), p1.hashCode()); p1.setOrdinate(0, p1.getOrdinate(0) + 1); assertFalse(p1.equals(p2)); assertFalse(p2.equals(p1)); assertFalse(p2.hashCode() == p1.hashCode()); }
assertEquals("DirectPosition: hashCode shall be compliant to the contract given in javadoc.", hashCode, object.hashCode()); assertTrue("DirectPosition: shall be equal to itself.", object.equals(object));
assertFalse(e1.getLowerCorner().equals(e1.getUpperCorner()));
assertEquals("DirectPosition: hashCode must be compliant to the contract given in javadoc.", hashCode, object.hashCode()); assertTrue("DirectPosition: must be equals to itself.", object.equals(object));
assertFalse(e1.getLowerCorner().equals(e1.getUpperCorner()));