Package org.geotools.geometry.iso

Examples of org.geotools.geometry.iso.PositionFactoryImpl


   
  }

  public void testPoint() throws Exception {

    PositionFactory positionFactory = new PositionFactoryImpl(crs1, new PrecisionModel());
    PrimitiveFactory primitiveFactory = new PrimitiveFactoryImpl(crs1, positionFactory);
   
    PointImpl point1 = (PointImpl) primitiveFactory.createPoint( new double[]{-123.47009555832284, 48.543261561072285} );
    PointImpl point2 = (PointImpl) point1.transform(crs2);
   
    // create expected result
    PositionFactory expectedPosF2 = new PositionFactoryImpl(crs2, new PrecisionModel());
    PrimitiveFactory expectedPrimF2 = new PrimitiveFactoryImpl(crs2, expectedPosF2);
   
    PointImpl expectedPoint2 = (PointImpl) expectedPrimF2.createPoint( new double[]{1187128.000000001, 395268.0000000004} );
   
    //System.out.println(point1);
View Full Code Here


   
  }

  public void testCurve() throws Exception {

    PositionFactory positionFactory = new PositionFactoryImpl(crs1, new PrecisionModel());
    PrimitiveFactory primitiveFactory = new PrimitiveFactoryImpl(crs1, positionFactory);
    GeometryFactory geometryFactory = new GeometryFactoryImpl(crs1, positionFactory);
   
    List<Position> points = new ArrayList<Position>();
    points.add(primitiveFactory.createPoint( new double[]{-123.47009555832284,48.543261561072285} ));
    points.add(primitiveFactory.createPoint( new double[]{-123.46972894676578,48.55009592117936} ));
    points.add(primitiveFactory.createPoint( new double[]{-123.45463828850829,48.54973520267305} ));
    points.add(primitiveFactory.createPoint( new double[]{-123.4550070827961,48.54290089070186} ));
        LineString lineString = geometryFactory.createLineString(points);
        List curveSegmentList = Collections.singletonList(lineString);
       
        CurveImpl curve1 = (CurveImpl) primitiveFactory.createCurve(curveSegmentList);
        CurveImpl curve2 = (CurveImpl) curve1.transform(crs2);
       
    // create expected result
    PositionFactory expectedPosF2 = new PositionFactoryImpl(crs2, new PrecisionModel());
    PrimitiveFactory expectedPrimF2 = new PrimitiveFactoryImpl(crs2, expectedPosF2);
    GeometryFactory ExpectedGeomF2 = new GeometryFactoryImpl(crs2, expectedPosF2);
   
    List<Position> expectedPoints = new ArrayList<Position>();
    expectedPoints.add(expectedPrimF2.createPoint( new double[]{1187128.000000001, 395268.0000000004} ));
View Full Code Here

    assertEquals(curve2, expectedCurve, 0.9);
  }
 
  public void testRing() throws Exception {

    PositionFactory positionFactory = new PositionFactoryImpl(crs1, new PrecisionModel());
    PrimitiveFactory primitiveFactory = new PrimitiveFactoryImpl(crs1, positionFactory);
    GeometryFactory geometryFactory = new GeometryFactoryImpl(crs1, positionFactory);
   
    List<Position> points1 = new ArrayList<Position>();
    points1.add(primitiveFactory.createPoint( new double[]{-123.47009555832284,48.543261561072285} ));
    points1.add(primitiveFactory.createPoint( new double[]{-123.46972894676578,48.55009592117936} ));
    points1.add(primitiveFactory.createPoint( new double[]{-123.45463828850829,48.54973520267305} ));
    points1.add(primitiveFactory.createPoint( new double[]{-123.4550070827961,48.54290089070186} ));
    points1.add(primitiveFactory.createPoint( new double[]{-123.47009555832284,48.543261561072285} ));
    LineString lineString1 = geometryFactory.createLineString(points1);
        List curveSegmentList1 = Collections.singletonList(lineString1);
       
        CurveImpl curve1 = (CurveImpl) primitiveFactory.createCurve(curveSegmentList1);
       
    /* Build Ring from Curve */
    ArrayList<OrientableCurve> curveList = new ArrayList<OrientableCurve>();
    curveList.add(curve1);
   
    RingImplUnsafe ring1 = (RingImplUnsafe) primitiveFactory.createRing(curveList);
    RingImplUnsafe ring2 = (RingImplUnsafe) ring1.transform(crs2);
   
    // create expected result
    PositionFactory expectedPosF2 = new PositionFactoryImpl(crs2, new PrecisionModel());
    PrimitiveFactory expectedPrimF2 = new PrimitiveFactoryImpl(crs2, expectedPosF2);
    GeometryFactory ExpectedGeomF2 = new GeometryFactoryImpl(crs2, expectedPosF2);
   
    List<Position> expectedPoints = new ArrayList<Position>();
    expectedPoints.add(expectedPrimF2.createPoint( new double[]{1187128.000000001, 395268.0000000004} ));
View Full Code Here

        assertTrue( "object equals", surface.equals( (Object) surface2 ));
        assertTrue( "geometry equals", surface.equals( surface2 ));
  }
 
  public void testSurface() throws Exception {
    PositionFactory positionFactory = new PositionFactoryImpl(crs1, new PrecisionModel());
    PrimitiveFactory primitiveFactory = new PrimitiveFactoryImpl(crs1, positionFactory);
    GeometryFactory geometryFactory = new GeometryFactoryImpl(crs1, positionFactory);
   
    List<Position> points1 = new ArrayList<Position>();
    points1.add(primitiveFactory.createPoint( new double[]{-123.47009555832284,48.543261561072285} ));
    points1.add(primitiveFactory.createPoint( new double[]{-123.46972894676578,48.55009592117936} ));
    points1.add(primitiveFactory.createPoint( new double[]{-123.45463828850829,48.54973520267305} ));
    points1.add(primitiveFactory.createPoint( new double[]{-123.4550070827961,48.54290089070186} ));
    points1.add(primitiveFactory.createPoint( new double[]{-123.47009555832284,48.543261561072285} ));
    LineString lineString1 = geometryFactory.createLineString(points1);
        List curveSegmentList1 = Collections.singletonList(lineString1);
       
        CurveImpl curve1 = (CurveImpl) primitiveFactory.createCurve(curveSegmentList1);
       
    /* Build Ring from Curve */
    ArrayList<OrientableCurve> curveList = new ArrayList<OrientableCurve>();
    curveList.add(curve1);
   
    // Build Ring then SurfaceBoundary then Surface
    RingImpl exteriors = (RingImpl) primitiveFactory.createRing(curveList);
    List<Ring> interiors = new ArrayList<Ring>();
    SurfaceBoundary sboundary = primitiveFactory.createSurfaceBoundary(exteriors, interiors);
    Surface surface1 = primitiveFactory.createSurface(sboundary);
    Surface surface2 = (SurfaceImpl) surface1.transform(crs2);
   
    // create expected result
    PositionFactory expectedPosF2 = new PositionFactoryImpl(crs2, new PrecisionModel());
    PrimitiveFactory expectedPrimF2 = new PrimitiveFactoryImpl(crs2, expectedPosF2);
    GeometryFactory ExpectedGeomF2 = new GeometryFactoryImpl(crs2, expectedPosF2);
   
    List<Position> expectedPoints = new ArrayList<Position>();
    expectedPoints.add(expectedPrimF2.createPoint( new double[]{1187128.000000001, 395268.0000000004} ));
View Full Code Here

 
  public void testMultiPrimitive() {
   
    CoordinateReferenceSystem crs = DefaultGeographicCRS.WGS84;
    PicoContainer container = container( crs ); // normal 2D
    PositionFactoryImpl pf = (PositionFactoryImpl ) container.getComponentInstanceOfType( PositionFactory.class );
    AggregateFactoryImpl agf = (AggregateFactoryImpl) container.getComponentInstanceOfType( AggregateFactory.class );
   
    // create surfaceboundary object
   
    // build exterior ring
    DirectPosition one = pf.createDirectPosition(new double[]{280,560});
    DirectPosition two = pf.createDirectPosition(new double[]{60,180});
    DirectPosition three = pf.createDirectPosition(new double[]{720,80});
    LineSegment edge1 = new LineSegmentImpl( one, two, 0.0 );
    LineSegment edge2 = new LineSegmentImpl( two, three, 0.0 );
    LineSegment edge3 = new LineSegmentImpl( three, one, 0.0 );
   
    // build interior ring
    DirectPosition one2 = pf.createDirectPosition(new double[]{420,360});
    DirectPosition two2 = pf.createDirectPosition(new double[]{200,360});
    DirectPosition three2 = pf.createDirectPosition(new double[]{320,180});
    LineSegment edge1_1 = new LineSegmentImpl( one2, two2, 0.0 );
    LineSegment edge2_1 = new LineSegmentImpl( two2, three2, 0.0 );
    LineSegment edge3_1 = new LineSegmentImpl( three2, one2, 0.0 );
   
    // create multiprimitive object
View Full Code Here

   
  public GeometryImpl(CoordinateReferenceSystem crs, Precision pm ){
    this.crs = crs;
    this.percision = pm;
    this.positionFactory = new PositionFactoryImpl(crs, pm);
  }
View Full Code Here

  }

  protected PositionFactory getPositionFactory() {
    if( positionFactory == null ){
      // we must of been transfered over a wire?
      positionFactory = new PositionFactoryImpl(crs, percision );
    }
    return positionFactory;
  }
View Full Code Here

   *      org.opengis.referencing.operation.MathTransform)
   */
  public Geometry transform(CoordinateReferenceSystem newCRS,
      MathTransform transform) throws MismatchedDimensionException, TransformException {

    PositionFactory newPositionFactory = new PositionFactoryImpl(newCRS, getPositionFactory().getPrecision());
    PrimitiveFactory newPrimitiveFactory = new PrimitiveFactoryImpl(newCRS, newPositionFactory);
    DirectPosition dp1 = new DirectPositionImpl(newCRS);
    dp1 = transform.transform(((PointImpl)this).getPosition(), dp1);
    return newPrimitiveFactory.createPoint( dp1 );
     
View Full Code Here

    private CoordinateReferenceSystem crs;

  private StreamTokenizer tokenizer;

    public WKTReader(CoordinateReferenceSystem crs){
        this( crs, new PositionFactoryImpl(crs) );
    }
View Full Code Here

TOP

Related Classes of org.geotools.geometry.iso.PositionFactoryImpl

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.