Ejemplo n.º 1
0
 @Test
 public void testLineSegmentsOnEmptyPointSequence() {
   PointSequenceBuilder builder = new FixedSizePointSequenceBuilder(0, DimensionalFlag.XYZM);
   PointSequence sequence = builder.toPointSequence();
   for (LineSegment ls : new LineSegments(sequence)) {
     fail();
   }
 }
 private CoordinateSequence fromCoordinateArray(Coordinate[] coordinates, DimensionalFlag dim) {
   PointSequenceBuilder builder = PointSequenceBuilders.fixedSized(coordinates.length, dim);
   double[] ordinates = new double[dim.getCoordinateDimension()];
   for (Coordinate co : coordinates) {
     copy(co, ordinates, dim);
     builder.add(ordinates);
   }
   return (CoordinateSequence) builder.toPointSequence();
 }
Ejemplo n.º 3
0
 @Test
 public void testLineSegments() {
   PointSequenceBuilder builder = new FixedSizePointSequenceBuilder(3, DimensionalFlag.XYZM);
   builder.add(new double[] {1, 1, 1, 1});
   builder.add(new double[] {2, 2, 2, 2});
   builder.add(new double[] {3, 3, 3, 3});
   PointSequence sequence = builder.toPointSequence();
   int cnt = 0;
   double startX = 1.0d;
   for (LineSegment ls : new LineSegments(sequence)) {
     assertEquals(startX, ls.getStartPoint().getX(), Math.ulp(1.0d));
     startX = ls.getEndPoint().getX();
     cnt++;
   }
   assertEquals(2, cnt);
 }