示例#1
0
  @Test
  public void testPointLineCreation() {
    List<Point> pts = createPoints();

    // construct MultiPoint
    MultiPoint mp = new MultiPoint(pts);
    assertEquals(pts.size(), mp.getNumParts());
    assertEquals(pts.size(), mp.getNumPoints());
    assertFalse(mp.is3D());

    // construct Line
    Line line = new Line(new ArrayList<Point>(pts));
    assertEquals(1, line.getNumParts());
    assertEquals(pts.size(), line.getNumPoints());
    assertFalse(line.is3D());

    Iterator<Point> it1 = line.iterator();
    Iterator<Point> it2 = mp.iterator();
    while (it1.hasNext() && it2.hasNext()) {
      assertEquals(it1.next(), it2.next());
    }
    assertFalse(it1.hasNext());
    assertFalse(it2.hasNext());

    List<Point> linePts = line.getPoints();
    List<Point> multiPts = mp.getPoints();
    assertEquals(linePts.size(), multiPts.size());
    for (int i = 0; i < linePts.size(); i++) {
      assertEquals(linePts.get(i), multiPts.get(i));
    }

    assertEquals(mp.getCenter(), line.getCenter());
  }
示例#2
0
  /** Construct mixed dimension MultiLine (2d + 3d Lines) which downgrades to 2d. */
  @Test
  public void testMixedMultiLine() {
    List<Line> lines = new ArrayList<Line>();
    List<Point> pts = new ArrayList<Point>();
    for (int i = 0; i < 10; i++) {
      pts.add(new Point(i * .01 + 0.1, i * .01 + 0.1, 500));
    }
    Line line = new Line(pts);
    line.setAltitudeMode(AltitudeModeEnumType.absolute);
    line.setTessellate(true);
    assertTrue(line.is3D());
    lines.add(line);

    pts = new ArrayList<Point>();
    for (int i = 0; i < 10; i++) {
      pts.add(new Point(i * .03 + 0.3, i * .03 + 0.3)); // 2-d points
    }
    line = new Line(pts);
    line.setTessellate(false);
    lines.add(line);
    MultiLine geo = new MultiLine(lines);
    assertEquals(2, geo.getNumParts());
    assertEquals(20, geo.getNumPoints());
    assertFalse(geo.is3D());
  }