Ejemplo n.º 1
0
 // Test for getEndHeading()
 public void testGetEndHeading() {
   assertEquals(featZeroStart.getEndHeading(), s1.getHeading(), TOLERANCE);
   assertEquals(feat1.getEndHeading(), s1.getHeading(), TOLERANCE);
   assertEquals(feat2.getEndHeading(), s2.getHeading(), TOLERANCE);
   assertEquals(feat3.getEndHeading(), s3.getHeading(), TOLERANCE);
   assertEquals(featLoop.getEndHeading(), s4.getHeading(), TOLERANCE);
 }
Ejemplo n.º 2
0
 // Test for getStartHeading()
 public void testGetStartHeading() {
   assertEquals(featZeroEnd.getStartHeading(), s1.getHeading(), TOLERANCE);
   assertEquals(feat1.getStartHeading(), s1.getHeading(), TOLERANCE);
   assertEquals(feat2.getStartHeading(), s1.getHeading(), TOLERANCE);
   assertEquals(feat3.getStartHeading(), s1.getHeading(), TOLERANCE);
   assertEquals(featLoop.getStartHeading(), s1.getHeading(), TOLERANCE);
 }
Ejemplo n.º 3
0
  public void testGeoFeature() {
    GeoFeature gf = null;
    GeoSegment gs = new GeoSegment("Test", p1, p2);
    try {
      gf = makeGeoFeature("Test", p1, p1);
    } catch (Exception ex) {
      // Failed
      fail("Constructor failed when geoSegment had zero length");
      return;
    }

    try {
      gf = new GeoFeature(gs);
    } catch (Exception ex) {
      // Failed
      fail("Constructor failed with valid arguments");
      return;
    }

    if (gf.getName() != "Test") {
      fail("Name should have been set to 'Name', it was set to '" + gf.getName() + "' instead.");
    } else if (!gf.getStart().equals(p1)) {
      fail("start not set correctly");
    } else if (!gf.getEnd().equals(p2)) {
      fail("end not set correctly");
    } else {
      assertEquals(
          "StartHeading not set properly", gf.getStartHeading(), gs.getHeading(), TOLERANCE);
      assertEquals("EndHeading not set properly", gf.getEndHeading(), gs.getHeading(), TOLERANCE);
    }
  }
Ejemplo n.º 4
0
 // Test for addSegment()
 public void testAddSegment() {
   GeoFeature gf = null;
   gf = addGeoSegment(feat1, "Feature", p2, p2); // add zero length segment
   checkAdd(gf, s1.getLength(), p2);
   gf = addGeoSegment(feat1, "Feature", p2, p3); // add 1 segment
   checkAdd(gf, s1.getLength() + s2.getLength(), p3);
   gf = addGeoSegment(gf, "Feature", p3, p4); // add another segment
   checkAdd(gf, s1.getLength() + s2.getLength() + s3.getLength(), p4);
   gf = addGeoSegment(gf, "Feature", p4, p1); // added segment makes a loop
   checkAdd(gf, s1.getLength() + s2.getLength() + s3.getLength() + s4.getLength(), p1);
 }
Ejemplo n.º 5
0
 // Test for getLength()
 public void testGetLength() {
   assertEquals(featZero.getLength(), 0, TOLERANCE);
   assertEquals(featZeroStart.getLength(), s1.getLength(), TOLERANCE);
   assertEquals(featZeroEnd.getLength(), s1.getLength(), TOLERANCE);
   assertEquals(feat1.getLength(), s1.getLength(), TOLERANCE);
   assertEquals(feat2.getLength(), s1.getLength() + s2.getLength(), TOLERANCE);
   assertEquals(feat3.getLength(), s1.getLength() + s2.getLength() + s3.getLength(), TOLERANCE);
   assertEquals(
       featLoop.getLength(),
       s1.getLength() + s2.getLength() + s3.getLength() + s4.getLength(),
       TOLERANCE);
 }
Ejemplo n.º 6
0
  private GeoSegment getQQLineSegment() {

    SummaryStatistics stats = new SummaryStatistics();
    for (int i = 0; i < sortedData.length; i++) {
      stats.addValue(sortedData[i]);
    }
    double sd = stats.getStandardDeviation();
    double mean = stats.getMean();
    double min = stats.getMin();
    double max = stats.getMax();

    // qq line: y = (1/sd)x - mean/sd

    GeoPoint startPoint = new GeoPoint(cons);
    startPoint.setCoords(min, (min / sd) - mean / sd, 1.0);
    GeoPoint endPoint = new GeoPoint(cons);
    endPoint.setCoords(max, (max / sd) - mean / sd, 1.0);
    GeoSegment seg = new GeoSegment(cons, startPoint, endPoint);
    seg.calcLength();

    return seg;
  }
Ejemplo n.º 7
0
 /** Creates new AlgoJoinPoints */
 AlgoJoinPointsSegment(Construction cons, String label, GeoPoint P, GeoPoint Q) {
   this(cons, P, Q, null);
   s.setLabel(label);
 }
Ejemplo n.º 8
0
 // calc the line g through P and Q
 protected final void compute() {
   // g = P v Q  <=>  g_n : n = P x Q
   // g = cross(P, Q)
   GeoVec3D.lineThroughPoints(P, Q, s);
   s.calcLength();
 }