Package org.geotools.geometry.iso.primitive

Examples of org.geotools.geometry.iso.primitive.CurveImpl


    PositionFactory positionFactory = (PositionFactory ) container.getComponentInstanceOfType( PositionFactory.class );
   
    DirectPosition positionA = positionFactory.createDirectPosition(new double[]{10, 10});
    DirectPosition positionB = positionFactory.createDirectPosition(new double[]{70, 30});
   
    CurveImpl expected = createCurve(positionA, positionB);   
    CurveImpl actual = createCurve(positionA, positionB);
   
    assertEquals( expected, actual );
  }
View Full Code Here


  private CurveImpl createCurve(DirectPosition positionA, DirectPosition positionB) {
    List segments = new ArrayList(1);
    segments.add( new LineSegmentImpl( positionA.getCoordinateReferenceSystem(), positionA.getCoordinate(), positionB.getCoordinate(), 0) );
   
    return new CurveImpl( positionA.getCoordinateReferenceSystem(), segments )
  }
View Full Code Here

    /* Set parent curve for LineString */
    ArrayList<CurveSegment> tLineList = new ArrayList<CurveSegment>();
    tLineList.add(line1);

    // PrimitiveFactory.createCurve(List<CurveSegment>)
    CurveImpl curve1 = tPrimFactory.createCurve(tLineList);
    //System.out.println("\nCurve1: " + curve1);
   
    assertTrue(curve1.isCycle() == false);
   
    // Set curve for further LineString tests
    line1.setCurve(curve1);

    //System.out.println("\n*** TEST: Curve\n" + curve1);
   
    // ***** getStartPoint()
    //System.out.println("\n*** TEST: .getStartPoint()\n" + curve1.getStartPoint());
    assertTrue(curve1.getStartPoint().getOrdinate(0) == -50);
    assertTrue(curve1.getStartPoint().getOrdinate(1) == 0);
   
    // ***** getEndPoint()
    //System.out.println("\n*** TEST: .getEndPoint()\n" + curve1.getEndPoint());
    assertTrue(curve1.getEndPoint().getOrdinate(0) == 50);
    assertTrue(curve1.getEndPoint().getOrdinate(1) == 0);

    // ***** getStartParam()
    //System.out.println("\n*** TEST: .getStartParam()\n" + curve1.getStartParam());
    assertTrue(curve1.getStartParam() == 0.0);

    // ***** getEndParam()
    //System.out.println("\n*** TEST: .getEndParam()\n" + curve1.getEndParam());
    assertTrue(Math.round(line1.getEndParam()) == 144.0);

    // ***** getStartConstructiveParam()
    //System.out.println("\n*** TEST: .getStartConstructiveParam()\n" + curve1.getStartConstructiveParam());
    assertTrue(curve1.getStartConstructiveParam() == 0.0);

    // ***** getEndConstructiveParam()
    //System.out.println("\n*** TEST: .getEndConstructiveParam()\n" + curve1.getEndConstructiveParam());
    assertTrue(curve1.getEndConstructiveParam() == 1.0);

    // ***** getBoundary()
    //System.out.println("\n*** TEST: .getBoundary()\n" + curve1.getBoundary());
    CurveBoundary cb = curve1.getBoundary();
    assertTrue(cb != null);
    double[] dp = cb.getStartPoint().getDirectPosition().getCoordinate();
    assertTrue(dp[0] == -50);
    assertTrue(dp[1] == 0);
    dp = cb.getEndPoint().getDirectPosition().getCoordinate();
    assertTrue(dp[0] == 50);
    assertTrue(dp[1] == 0);
   
    // ***** getEnvelope()
    //System.out.println("\n*** TEST: .getEnvelope()\n" + curve1.getEnvelope());
    assertTrue(curve1.getEnvelope() != null);
    dp = curve1.getEnvelope().getLowerCorner().getCoordinate();
    assertTrue(dp[0] == -50);
    assertTrue(dp[1] == 0);
    dp = curve1.getEnvelope().getUpperCorner().getCoordinate();
    assertTrue(dp[0] == 50);
    assertTrue(dp[1] == 50);
   
    // ***** forParam(double distance) : DirectPosition
    dp = curve1.forParam(0).getCoordinate();
    assertTrue(dp[0] == -50);
    assertTrue(dp[1] == 0.0);
   
    dp = curve1.forParam(curve1.length()).getCoordinate();
    assertTrue(dp[0] == 50);
    assertTrue(dp[1] == 0.0);
   
    dp = curve1.forParam(50).getCoordinate();
    ////System.out.println("forParam: " + dp[0] + "," + dp[1]);
    assertTrue(Math.round(dp[0]*1000) == -18397);
    assertTrue(Math.round(dp[1]*1000) == 37735);

    // ***** forConstructiveParam(double distance)
    dp = curve1.forConstructiveParam(0.0).getCoordinate();
    assertTrue(dp[0] == -50);
    assertTrue(dp[1] == 0.0);

    dp = curve1.forConstructiveParam(1.0).getCoordinate();
    assertTrue(dp[0] == 50);
    assertTrue(dp[1] == 0.0);
   
    dp = curve1.forConstructiveParam(50 / curve1.length()).getCoordinate();
    assertTrue(Math.round(dp[0]*1000) == -18397);
    assertTrue(Math.round(dp[1]*1000) == 37735);
   
    // ***** getTangent(double distance)
    dp = curve1.getTangent(0);
    ////System.out.println("tangent: " + dp[0] + "," + dp[1]);
    assertTrue(Math.round(dp[0]*1000) == -49445);
    assertTrue(Math.round(dp[1]*1000) == 832);

    dp = curve1.getTangent(40);
    assertTrue(Math.round(dp[0]*100) == -2589);
    assertTrue(Math.round(dp[1]*100) == 3274);

    dp = curve1.getTangent(curve1.getEndParam());
    //System.out.println("tangent: " + dp[0] + "," + dp[1]);
    assertTrue(Math.round(dp[0]*100) == 5055);
    assertTrue(Math.round(dp[1]*100) == -83);
   
    // ***** getRepresentativePoint()
    dp = curve1.getRepresentativePoint().getCoordinate();
    ////System.out.print("REPRER" + dp);
    assertTrue(dp[0] == 0);
    assertTrue(dp[1] == 50);
   
   
    // ***** Curve.Merge(Curve)
   
    DirectPosition p6 = tCoordFactory.createDirectPosition(new double[]{8020});
    DirectPosition p7 = tCoordFactory.createDirectPosition(new double[]{13060});
   
    List<DirectPosition> directPositions = new ArrayList<DirectPosition>();
   
    directPositions.add(p5.getDirectPosition());
    directPositions.add(p6);
    directPositions.add(p7);
    CurveImpl curve2 = (CurveImpl) tPrimFactory.createCurveByDirectPositions(directPositions);
   
    CurveImpl curve3 = curve1.merge(curve2);
    //System.out.println("Curve1: " + curve1);
    //System.out.println("Curve2: " + curve2);
    //System.out.println("Merge: " + curve3);
    // Lists of line1 and line2 are not modified
    assertTrue(curve1.asDirectPositions().size() == 5);
    assertTrue(curve2.asDirectPositions().size() == 3);
    // New LineString has combined positions
    assertTrue(curve3.asDirectPositions().size() == 7);

    curve3 = curve2.merge(curve1);
    //System.out.println("Curve1: " + curve1);
    //System.out.println("Curve2: " + curve2);
    //System.out.println("Merge: " + curve3);
    // Lists of line1 and line2 are not modified
    assertTrue(curve1.asDirectPositions().size() == 5);
    assertTrue(curve2.asDirectPositions().size() == 3);
    // New LineString has combined positions
    assertTrue(curve3.asDirectPositions().size() == 7);
   
    directPositions.remove(0);
    curve2 = (CurveImpl) tPrimFactory.createCurveByDirectPositions(directPositions);
    curve3 =  null;
    try {
View Full Code Here

  private void checkConsistency() {
    /* Check plausibility, if all curve elements are continuous */
    Iterator<? extends Primitive> ci = this.elements.iterator();
    if (!ci.hasNext())
      throw new IllegalArgumentException("Curve has no elements."); //$NON-NLS-1$
    CurveImpl c0 = (CurveImpl) ci.next();
    ;
    //this.envelope = new EnvelopeImpl(c0.getEnvelope());
    this.envelope = new EnvelopeImpl(c0.getEnvelope());
    while (ci.hasNext()) {
      CurveImpl c1 = (CurveImpl) ci.next();
      this.envelope.expand(c1.getEnvelope());
     
      DirectPosition startPoint = c1.getStartPoint();
      DirectPosition endPoint = c0.getEndPoint();
      if (!endPoint.equals(startPoint)){
        throw new IllegalArgumentException(
            "Curve elements are not continous. The end point of a curve has to accord to the start point of the following curve."); //$NON-NLS-1$
      }
View Full Code Here

      return null;
    // JR error: parameter maxSpacing and maxOffset were not passed
    LineStringImpl result = ((CurveImpl) primitives.get(0)).asLineString(
        maxSpacing, maxOffset);
    for (int i = 1; i < primitives.size(); ++i) {
      CurveImpl curve = ((CurveImpl) primitives.get(i));
      result = result.merge(curve.asLineString(maxSpacing, maxOffset));
    }
    return result;

  }
View Full Code Here

            List<Position> positions = CoordinateArrays.toPositionList(crs, e
                    .getCoordinates());
      LineString line = new LineStringImpl(new PointArrayImpl( positions ), 0.0); //coordinateFactory.createLineString( positions );         
      LinkedList<CurveSegment> tLineStrings = new LinkedList<CurveSegment>();
      tLineStrings.add((CurveSegment) line);
      CurveImpl curve = new CurveImpl(crs, (List<CurveSegment>) tLineStrings); //primitiveFactory.createCurve((List<CurveSegment>) tLineStrings);
      resultLineList.add(curve);
      e.setInResult(true);

    }
  }
View Full Code Here

   * @param curve1
   * @param curve2
   * @return new curve
   */
  public CurveImpl merge(CurveImpl curve1, CurveImpl curve2) {
    CurveImpl firstCurve = null;
    CurveImpl secondCurve = null;
   
    if (curve1.getStartPoint().equals(curve2.getEndPoint())) {
      firstCurve = curve2;
      secondCurve = curve1;
    } else
View Full Code Here

      throw new NullPointerException();
   
    // A curve will be created
    // - The curve will be set as parent curves for the Curve segments
    // - Start and end params for the CurveSegments will be set
    return new CurveImpl( crs, segments);
  }
View Full Code Here

        dpList), 0.0);
    List<CurveSegment> segments = new ArrayList<CurveSegment>();
    segments.add(lineString);
   
    // Create List of OrientableCurveĀ“s (CurveĀ“s)
    OrientableCurve curve = new CurveImpl(crs, segments);
    List<OrientableCurve> orientableCurves = new ArrayList<OrientableCurve>();
    orientableCurves.add(curve);

    this.ring = new RingImpl(orientableCurves);   
    // this.ring = (RingImpl) this.mFeatGeomFactory.getPrimitiveFactory().createRingByDirectPositions(dpList);
View Full Code Here

              DirectPosition p2 = new DirectPositionImpl(this.forParam(actualParam+newSpacing));
              LineSegmentImpl seg = new LineSegmentImpl(p1, p2, 0);
              //(LineSegmentImpl)cf.createLineSegment(cf.createPosition(this.forParam(actualParam)),cf.createPosition(this.forParam(actualParam+newSpacing)));

              /* Search maximum of all distances */
              CurveImpl curve = new CurveImpl(seg);
              maxDistance = curve.distance( new PointImpl(segments.get(firstSegment).getStartPoint()) );
              //maxDistance = seg.distance(segments.get(firstSegment).getStartPoint());
              double actDistance = 0;
              for (i=firstSegment; i<lastSegment; i++) {
                actDistance = curve.distance( new PointImpl(segments.get(i).getEndPoint()) );
                //actDistance = seg.distance(segments.get(i).getEndPoint());
                if (actDistance > maxDistance) {
                  maxDistance = actDistance;
                }
              }
View Full Code Here

TOP

Related Classes of org.geotools.geometry.iso.primitive.CurveImpl

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.