Package chunmap.model.coord

Examples of chunmap.model.coord.CPoint


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.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

    assertTrue(b3);
  }

  @Test
  public void testDingBiFenDian() {
    CPoint p1 = new Coordinate2D(10, 10);
    CPoint p2 = new Coordinate2D(20, 20);
    CPoint p3 = new Coordinate2D(12, 12);
    LineSegment lseg1 = new LineSegment(p1, p2);

    assertTrue(lseg1.getMiddlePoint().equals(lseg1.dingBiFenDian(1)));
    assertTrue(p3.equals(lseg1.dingBiFenDian(0.25)));
  }
View Full Code Here

    assertTrue(p3.equals(lseg1.dingBiFenDian(0.25)));
  }

  @Test
  public void testContainLineSegment() {
    CPoint p1 = new Coordinate2D(10, 10);
    CPoint p2 = new Coordinate2D(0, 0);
    CPoint p3 = new Coordinate2D(5, 5);
    LineSegment lseg1 = new LineSegment(p1, p2);
    LineSegment lseg2 = new LineSegment(p2, p3);
    assertTrue(lseg1.containLineSegment(lseg2));
    assertTrue(lseg1.containLineSegment(lseg1));
  }
View Full Code Here

   * {@link chunmap.model.elem.Envelope#getCenter()} 的测试方法。
   */
  @Test
  public void testGetCenter() {
    Envelope envelop = new Envelope(10, 16, 20, 22);
    CPoint p = envelop.getCenter();
    CPoint expected = new Coordinate2D(15, 19);
    boolean b = p.equals(expected);
    assertTrue(b);
  }
View Full Code Here

TOP

Related Classes of chunmap.model.coord.CPoint

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.