Package chunmap.model.coord

Examples of chunmap.model.coord.Coordinate2D


public class MyDoubleTest {

  @Test
  public void testApproximateEqualsDoubleDouble() {
    CPoint coord1 = new Coordinate2D(10d, 20d);
    CPoint coord2 = new Coordinate2D(10.00001d, 20d);
    assertFalse(coord1.approximateEquals(coord2));
    MyDouble.setThreshold(0.01);
    assertTrue(coord1.approximateEquals(coord2));
  }
View Full Code Here


  @Test
  public void testContain() {
    WktReader wkt = new WktReader();
    Geometry g = wkt.read("LINESTRING(1 2,3 1,4 0,3 -2,0 0,1 2)");
    Ring lr = ((LineString) g).toLinearRing();
    CPoint p1 = new Coordinate2D(1, 0);
    CPoint p2 = new Coordinate2D(1, 2);
    CPoint p3 = new Coordinate2D(2, 3);
    CPoint p4 = new Coordinate2D(0.5, 1);

    assertTrue(lr.containIn(p1));
    assertTrue(lr.containIn(p2));
    assertTrue(!lr.containIn(p3));
    assertTrue(lr.containIn(p4));
View Full Code Here

  /**
   * {@link chunmap.model.elem.Angle#computeAngle()} 的测试方法。
   */
  @Test
  public void testComputeAngle() {
    CPoint p1 = new Coordinate2D(2, 2);
    CPoint p2 = new Coordinate2D(0, 0);
    CPoint p3 = new Coordinate2D(2, 0);

    Angle a = new Angle(p1, p2, p3);
    double d = a.computeAngle();
    assertTrue(MyDouble.approximateEquals(Math.toDegrees(d), 45));

View Full Code Here

    assertTrue(MyDouble.approximateEquals(Math.toDegrees(d2), -45));
  }

  @Test
  public void testComputeAngle2() {
    CPoint p1 = new Coordinate2D(1, 0);
    CPoint p2 = new Coordinate2D(0, 0);
    CPoint p3 = new Coordinate2D(2, 0);

    Angle a = new Angle(p1, p2, p3);
    double d = a.computeAngle();
    assertTrue(MyDouble.approximateEquals(Math.toDegrees(d), 0));
View Full Code Here

  /**
   * {@link chunmap.model.elem.Triangle#computeArea()} 的测试方法。
   */
  @Test
  public void testComputeArea2() {
    CPoint p1 = new Coordinate2D(2, 2);
    CPoint p2 = new Coordinate2D(0, 0);
    CPoint p3 = new Coordinate2D(2, 0);
    Triangle tria = new Triangle(p1, p2, p3);
    double are = tria.computeArea();

    assertTrue(MyDouble.approximateEquals(are, 2.0));
  }
View Full Code Here

  /**
   * {@link chunmap.model.elem.Triangle#computeOuterCenter()} 的测试方法。
   */
  @Test
  public void testComputeOuterCenter() {
    CPoint p1 = new Coordinate2D(2, 2);
    CPoint p2 = new Coordinate2D(0, 0);
    CPoint p3 = new Coordinate2D(2, 0);
    Triangle tria = new Triangle(p1, p2, p3);
    CPoint p = tria.computeOuterCenter();
    CPoint ep = new Coordinate2D(1, 1);
    assertTrue(p.equals(ep));
  }
View Full Code Here

    assertTrue(p.equals(ep));
  }

  @Test
  public void testComputeCenter() {
    CPoint p1 = new Coordinate2D(-1, 0);
    CPoint p2 = new Coordinate2D(1, 0);
    CPoint p3 = new Coordinate2D(0, 2);
    Triangle tria = new Triangle(p1, p2, p3);
    CPoint p = tria.computeCenter();
    CPoint ep = new Coordinate2D(0, 2d / 3d);
    assertTrue(p.equals(ep));
  }
View Full Code Here

   * {@link chunmap.model.elem.LineSegment#intersection(chunmap.model.elem.LineSegment)}
   * 的测试方法。
   */
  @Test
  public void testIntersection() {
    CPoint p1 = new Coordinate2D(10, 10);
    CPoint p2 = new Coordinate2D(0, 0);
    CPoint p3 = new Coordinate2D(0, 10);
    CPoint p4 = new Coordinate2D(10, 0);
    CPoint p5 = new Coordinate2D(5, 5);
    CPoint p6 = new Coordinate2D(-1, -1);
    CPoint p7 = new Coordinate2D(-1, 7);

    LineSegment lseg1 = new LineSegment(p1, p2);
    LineSegment lseg2 = new LineSegment(p3, p4);

    CPoint p = (CPoint) lseg1.intersection(lseg2);
    CPoint ep = new Coordinate2D(5, 5);
    assertTrue(p.equals(ep));

    LineSegment lseg3 = new LineSegment(p5, p6);

    LineString l = new LineString((CPoint[]) lseg1.intersection(lseg3));
View Full Code Here

    assertTrue(lseg1.intersection(lseg4) == null);
  }

  @Test
  public void testIntersection2() {
    CPoint p1 = new Coordinate2D(3, 1);
    CPoint p2 = new Coordinate2D(4, 0);
    CPoint p3 = new Coordinate2D(1, 0.5);
    CPoint p4 = new Coordinate2D(3, 0.5);

    LineSegment lseg1 = new LineSegment(p1, p2);
    LineSegment lseg2 = new LineSegment(p3, p4);

    assertTrue(lseg1.intersection(lseg2) == null);
View Full Code Here

   * {@link chunmap.model.elem.LineSegment#onLineSegment(chunmap.model.geom.CPoint)}
   * 的测试方法。
   */
  @Test
  public void testOnLineSegment() {
    CPoint p1 = new Coordinate2D(10, 10);
    CPoint p2 = new Coordinate2D(0, 0);
    CPoint p3 = new Coordinate2D(0, 10);
    CPoint p4 = new Coordinate2D(10, 10);
    CPoint p5 = new Coordinate2D(5, 5);

    LineSegment lseg1 = new LineSegment(p1, p2);

    boolean b1 = lseg1.onLineSegment(p5);
    boolean b2 = lseg1.onLineSegment(p3);
View Full Code Here

TOP

Related Classes of chunmap.model.coord.Coordinate2D

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.