Package org.geotools.geometry.iso.coordinate

Examples of org.geotools.geometry.iso.coordinate.GeometryFactoryImpl


 
  private void _testCompositeSurface(PicoContainer c) {
   
    ComplexFactoryImpl complf = (ComplexFactoryImpl) c.getComponentInstanceOfType(ComplexFactory.class);
    PrimitiveFactoryImpl pf = (PrimitiveFactoryImpl) c.getComponentInstanceOfType(PrimitiveFactory.class);
    GeometryFactoryImpl geomFact = (GeometryFactoryImpl) c.getComponentInstanceOfType(GeometryFactory.class);
   
    List<DirectPosition> directPositionList = new ArrayList<DirectPosition>();
    directPositionList.add(geomFact.createDirectPosition(new double[] {20, 10}));
    directPositionList.add(geomFact.createDirectPosition(new double[] {40, 10}));
    directPositionList.add(geomFact.createDirectPosition(new double[] {50, 40}));
    directPositionList.add(geomFact.createDirectPosition(new double[] {30, 50}));
    directPositionList.add(geomFact.createDirectPosition(new double[] {10, 30}));
    directPositionList.add(geomFact.createDirectPosition(new double[] {20, 10}));

   
    // test createCompositeSurface()
    Surface s1 = pf.createSurfaceByDirectPositions(directPositionList);
    List<OrientableSurface> surfaceList = new ArrayList<OrientableSurface>();
View Full Code Here


      }
    }
   
    public Surface createSurface(GeometryBuilder builder) {
     
      GeometryFactoryImpl tCoordFactory = (GeometryFactoryImpl) builder.getGeometryFactory();
      PrimitiveFactoryImpl tPrimFactory = (PrimitiveFactoryImpl) builder.getPrimitiveFactory();

      List<DirectPosition> directPositionList = new ArrayList<DirectPosition>();
      directPositionList.add(tCoordFactory.createDirectPosition(new double[] {20, 10}));
      directPositionList.add(tCoordFactory.createDirectPosition(new double[] {40, 10}));
      directPositionList.add(tCoordFactory.createDirectPosition(new double[] {50, 40}));
      directPositionList.add(tCoordFactory.createDirectPosition(new double[] {30, 50}));
      directPositionList.add(tCoordFactory.createDirectPosition(new double[] {10, 30}));
      directPositionList.add(tCoordFactory.createDirectPosition(new double[] {20, 10}));

      Ring exteriorRing = (Ring) tPrimFactory.createRingByDirectPositions(directPositionList);
      List<Ring> interiors = new ArrayList<Ring>();
     
      SurfaceBoundaryImpl surfaceBoundary1 = tPrimFactory.createSurfaceBoundary(exteriorRing, interiors );
View Full Code Here

      return surface2;
    }

    public Ring createRing(GeometryBuilder builder) {
     
      GeometryFactoryImpl tCoordFactory = (GeometryFactoryImpl) builder.getGeometryFactory();
      PrimitiveFactoryImpl tPrimFactory = (PrimitiveFactoryImpl) builder.getPrimitiveFactory();
     
      /* Defining Positions for LineStrings */
      ArrayList<Position> line1 = new ArrayList<Position>();
      line1.add(new PositionImpl(tCoordFactory.createDirectPosition(new double[]{50, 20})));
      line1.add(new PositionImpl(tCoordFactory.createDirectPosition(new double[]{30, 30})));
      line1.add(new PositionImpl(tCoordFactory.createDirectPosition(new double[]{20, 50})));
      line1.add(new PositionImpl(tCoordFactory.createDirectPosition(new double[]{20, 70})));

      ArrayList<Position> line2 = new ArrayList<Position>();
      line2.add(new PositionImpl(tCoordFactory.createDirectPosition(new double[]{20, 70})));
      line2.add(new PositionImpl(tCoordFactory.createDirectPosition(new double[]{40, 80})));
      line2.add(new PositionImpl(tCoordFactory.createDirectPosition(new double[]{70, 80})));

      ArrayList<Position> line3 = new ArrayList<Position>();
      line3.add(new PositionImpl(tCoordFactory.createDirectPosition(new double[]{70, 80})));
      line3.add(new PositionImpl(tCoordFactory.createDirectPosition(new double[]{90, 70})));
      line3.add(new PositionImpl(tCoordFactory.createDirectPosition(new double[]{100, 60})));
      line3.add(new PositionImpl(tCoordFactory.createDirectPosition(new double[]{100, 40})));

      ArrayList<Position> line4 = new ArrayList<Position>();
      line4.add(new PositionImpl(tCoordFactory.createDirectPosition(new double[]{100, 40})));
      line4.add(new PositionImpl(tCoordFactory.createDirectPosition(new double[]{80, 30})));
      line4.add(new PositionImpl(tCoordFactory.createDirectPosition(new double[]{50, 20})));
     
      /* Setting up Array of these LineStrings */
      ArrayList<CurveSegment> tLineList1 = new ArrayList<CurveSegment>();
      tLineList1.add(tCoordFactory.createLineString(line1));
      tLineList1.add(tCoordFactory.createLineString(line2));

      ArrayList<CurveSegment> tLineList2 = new ArrayList<CurveSegment>();
      tLineList2.add(tCoordFactory.createLineString(line3));
      tLineList2.add(tCoordFactory.createLineString(line4));

      /* Build Curve */
      CurveImpl curve1 = tPrimFactory.createCurve(tLineList1);
      CurveImpl curve2 = tPrimFactory.createCurve(tLineList2);

View Full Code Here

  public void testRing1() {
   
    CoordinateReferenceSystem crs = DefaultGeographicCRS.WGS84;
    PicoContainer container = container( crs ); // normal 2D
   
    GeometryFactoryImpl tGeomFactory = (GeometryFactoryImpl) container.getComponentInstanceOfType(GeometryFactory.class);
    PrimitiveFactoryImpl tPrimFactory = (PrimitiveFactoryImpl) container.getComponentInstanceOfType( PrimitiveFactoryImpl.class );
    PositionFactory positionFactory = (PositionFactory ) container.getComponentInstanceOfType( PositionFactory.class );
   
    //GeometryFactoryImpl tCoordFactory = aGeomFactory.getGeometryFactoryImpl();
    //PrimitiveFactoryImpl tPrimFactory = aGeomFactory.getPrimitiveFactory();
   
    /* Defining Positions for LineStrings */
    ArrayList<Position> line1 = new ArrayList<Position>();
    line1.add(new PositionImpl(positionFactory.createDirectPosition(new double[]{50, 20})));
    line1.add(new PositionImpl(positionFactory.createDirectPosition(new double[]{30, 30})));
    line1.add(new PositionImpl(positionFactory.createDirectPosition(new double[]{20, 50})));
    line1.add(new PositionImpl(positionFactory.createDirectPosition(new double[]{20, 70})));

    ArrayList<Position> line2 = new ArrayList<Position>();
    line2.add(new PositionImpl(positionFactory.createDirectPosition(new double[]{20, 70})));
    line2.add(new PositionImpl(positionFactory.createDirectPosition(new double[]{40, 80})));
    line2.add(new PositionImpl(positionFactory.createDirectPosition(new double[]{70, 80})));

    ArrayList<Position> line3 = new ArrayList<Position>();
    line3.add(new PositionImpl(positionFactory.createDirectPosition(new double[]{70, 80})));
    line3.add(new PositionImpl(positionFactory.createDirectPosition(new double[]{90, 70})));
    line3.add(new PositionImpl(positionFactory.createDirectPosition(new double[]{100, 60})));
    line3.add(new PositionImpl(positionFactory.createDirectPosition(new double[]{100, 40})));

    ArrayList<Position> line4 = new ArrayList<Position>();
    line4.add(new PositionImpl(positionFactory.createDirectPosition(new double[]{100, 40})));
    line4.add(new PositionImpl(positionFactory.createDirectPosition(new double[]{80, 30})));
    line4.add(new PositionImpl(positionFactory.createDirectPosition(new double[]{50, 20})));
   
    /* Setting up Array of these LineStrings */
    ArrayList<CurveSegment> tLineList1 = new ArrayList<CurveSegment>();
    tLineList1.add(tGeomFactory.createLineString(line1));
    tLineList1.add(tGeomFactory.createLineString(line2));

    ArrayList<CurveSegment> tLineList2 = new ArrayList<CurveSegment>();
    tLineList2.add(tGeomFactory.createLineString(line3));
    tLineList2.add(tGeomFactory.createLineString(line4));

    /* Build Curve */
    CurveImpl curve1 = tPrimFactory.createCurve(tLineList1);
    CurveImpl curve2 = tPrimFactory.createCurve(tLineList2);

View Full Code Here

   
 

  private void _testCoordinateObjects(GeometryBuilder builder) {
   
    GeometryFactoryImpl cf = (GeometryFactoryImpl) builder.getGeometryFactory();
   
    // public DirectPositionImpl createDirectPosition();
    DirectPosition dp1 = cf.createDirectPosition();
    assertTrue(Double.compare(dp1.getOrdinate(0), Double.NaN) == 0);
    assertTrue(Double.compare(dp1.getOrdinate(1), Double.NaN) == 0);
    assertTrue(Double.compare(dp1.getOrdinate(2), Double.NaN) == 0);
   
    // public DirectPositionImpl createDirectPosition(double[] coord);
    double[] da = new double[3];
    da[0] = 10.0;
    da[1] = -115000.0;
    da[2] = 0.0000000125;
    DirectPosition dp2 = cf.createDirectPosition(da);
    assertTrue(dp2.getOrdinate(0) == 10.0);
    assertTrue(dp2.getOrdinate(1) == -115000.0);
    assertTrue(dp2.getOrdinate(2) == 0.0000000125);

    // public Envelope createEnvelope(
    //      DirectPosition lowerCorner,
    //      DirectPosition upperCorner)
    Envelope env1 = cf.createEnvelope(dp1, dp2);
    DirectPosition lc = env1.getLowerCorner();
    assertTrue(Double.compare(lc.getOrdinate(0), Double.NaN) == 0);
    assertTrue(Double.compare(lc.getOrdinate(1), Double.NaN) == 0);
    assertTrue(Double.compare(lc.getOrdinate(2), Double.NaN) == 0);
    DirectPosition uc = env1.getUpperCorner();
    assertTrue(uc.getOrdinate(0) == 10.0);
    assertTrue(uc.getOrdinate(1) == -115000.0);
    assertTrue(uc.getOrdinate(2) == 0.0000000125);
    env1 = cf.createEnvelope(dp2, dp1);
    lc = env1.getLowerCorner();
    assertTrue(lc.getOrdinate(0) == 10.0);
    assertTrue(lc.getOrdinate(1) == -115000.0);
    assertTrue(lc.getOrdinate(2) == 0.0000000125);
    uc = env1.getUpperCorner();
    assertTrue(Double.compare(uc.getOrdinate(0), Double.NaN) == 0);
    assertTrue(Double.compare(uc.getOrdinate(1), Double.NaN) == 0);
    assertTrue(Double.compare(uc.getOrdinate(2), Double.NaN) == 0);
   
    // public Position createPosition(DirectPosition dp);
    Position pos1 = cf.createPosition(dp2);
    assertTrue(pos1.getDirectPosition().getOrdinate(0) == 10.0);
    assertTrue(pos1.getDirectPosition().getOrdinate(1) == -115000.0);
    assertTrue(pos1.getDirectPosition().getOrdinate(2) == 0.0000000125);

    // public LineSegment createLineSegment(Position startPoint, Position endPoint);
    Position pos2 = cf.createPosition(dp1);
    LineSegment seg1 = cf.createLineSegment(pos1, pos2);
    assertTrue(Double.compare(seg1.getEndPoint().getOrdinate(0), Double.NaN) == 0.0);
    assertTrue(Double.compare(seg1.getEndPoint().getOrdinate(1), Double.NaN) == 0.0);
    assertTrue(Double.compare(seg1.getEndPoint().getOrdinate(2), Double.NaN) == 0.0);
    assertTrue(seg1.getStartPoint().getOrdinate(0) == 10.0);
    assertTrue(seg1.getStartPoint().getOrdinate(1) == -115000.0);
View Full Code Here

    /** We need to create a large surface with 7000 points */
    public void testLargeSurfaceFactory(){
        DefaultGeographicCRS crs = DefaultGeographicCRS.WGS84;
        PositionFactory postitionFactory = new PositionFactoryImpl( crs );
        PrimitiveFactory primitiveFactory = new PrimitiveFactoryImpl( crs, postitionFactory );
        GeometryFactory geometryFactory = new GeometryFactoryImpl( crs, postitionFactory );
       
        int NUMBER = 100000;
         double delta = 360.0 / (double) NUMBER;
         PointArray points = postitionFactory.createPointArray();
         for( double angle = 0.0; angle < 360.0; angle += delta ){
             double ordinates[] = new double[]{
                     Math.sin( Math.toRadians(angle) ),
                     Math.cos( Math.toRadians(angle) )
             };
             DirectPosition point = postitionFactory.createDirectPosition( ordinates );
             points.add( point );
         }
         List<OrientableCurve> curves = new ArrayList<OrientableCurve>();       
         // 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
         List<CurveSegment> segmentList = new ArrayList<CurveSegment>();
         for( int i=0; i<points.size();i++){
             int start = i;
             int end = (i+1)%points.size();
             DirectPosition point1 = points.getDirectPosition( start, null );
             DirectPosition point2 = points.getDirectPosition( end, null );
             LineSegment segment = geometryFactory.createLineSegment( point1, point2 );
             segmentList.add( segment );
         }
         Curve curve = primitiveFactory.createCurve( segmentList );
         curves.add( curve);        
         Ring ring = primitiveFactory.createRing( curves );
View Full Code Here

         SurfaceBoundary boundary = builder.createSurfaceBoundary(ring );
         Surface surface = builder.createSurface(boundary);        
    }
   
  private List<Triangle> createTestTriangle1(GeometryBuilder builder) {   
    GeometryFactoryImpl tCoordFactory = (GeometryFactoryImpl) builder.getGeometryFactory();
    PrimitiveFactoryImpl tPrimFactory = (PrimitiveFactoryImpl) builder.getPrimitiveFactory();

    ArrayList<double[][]> tDoubleList = new ArrayList<double[][]>();
    tDoubleList.add(new double[][]{{0,0},{100,100},{0, 100}});
    tDoubleList.add(new double[][]{{0,100},{100,100},{50,200}});
    tDoubleList.add(new double[][]{{50,200},{100,100},{150,200}});
    ArrayList<Triangle> triangleList = tCoordFactory.createTriangles(tDoubleList);
     
    for (int i=0; i < triangleList.size(); i++) {
      Triangle triangle1 = triangleList.get(i);
      //System.out.println(triangle1);
    }
View Full Code Here

    this.testSurfaces((SurfaceImpl) surface1);
  }

  public Surface _testSurface2(GeometryBuilder builder) {
   
    GeometryFactoryImpl tCoordFactory = (GeometryFactoryImpl) builder.getGeometryFactory();
    PrimitiveFactoryImpl tPrimFactory = (PrimitiveFactoryImpl) builder.getPrimitiveFactory();

    List<DirectPosition> directPositionList = new ArrayList<DirectPosition>();
    directPositionList.add(tCoordFactory.createDirectPosition(new double[] {20, 10}));
    directPositionList.add(tCoordFactory.createDirectPosition(new double[] {40, 10}));
    directPositionList.add(tCoordFactory.createDirectPosition(new double[] {50, 40}));
    directPositionList.add(tCoordFactory.createDirectPosition(new double[] {30, 50}));
    directPositionList.add(tCoordFactory.createDirectPosition(new double[] {10, 30}));
    directPositionList.add(tCoordFactory.createDirectPosition(new double[] {20, 10}));

    Ring exteriorRing = (Ring) tPrimFactory.createRingByDirectPositions(directPositionList);
    List<Ring> interiors = new ArrayList<Ring>();
   
    SurfaceBoundaryImpl surfaceBoundary1 = tPrimFactory.createSurfaceBoundary(exteriorRing, interiors );
View Full Code Here

   
 

  private void _testEnvelope1(GeometryBuilder builder) {
   
    GeometryFactoryImpl tCoordFactory = (GeometryFactoryImpl) builder.getGeometryFactory();

   
    // CoordinateFactory.createDirectPosition(double[])
    DirectPosition dp1 = tCoordFactory.createDirectPosition(new double[] {0, 0});
    DirectPosition dp2 = tCoordFactory.createDirectPosition(new double[] {100, 100});

    DirectPosition dp0 = tCoordFactory.createDirectPosition(new double[] {100, 100});
   
    // DirectPosition.equals(DirectPosition)
    assertTrue(dp2.equals(dp0));

    // Envelope.getDimension()
    assertTrue(dp2.getDimension() == 2);
    //System.outprintln("Dimension of dp1: " + dp2.getDimension());
   
    EnvelopeImpl env1 = new EnvelopeImpl(dp1, dp2);
   
    // Envelope.getLowerCorner() + Envelope.equals(DP, tol)
    assertTrue(env1.getLowerCorner().equals(dp1));
    //System.outprintln(env1.getLowerCorner());
   
    // Envelope.getUpperCorner() + Envelope.equals(DP, tol)
    assertTrue(env1.getUpperCorner().equals(dp2));
    //System.outprintln(env1.getUpperCorner());
    //System.outprintln(env1);
   
    EnvelopeImpl env2 = new EnvelopeImpl(env1);
    //System.outprintln(env2);
   
    // Envelope.equals(Envelope)
    assertTrue(env1.equals(env2));
   
   
    DirectPosition dp3 = tCoordFactory.createDirectPosition(new double[] {0,0});
    DirectPosition dp4 = tCoordFactory.createDirectPosition(new double[] {100,50});
    DirectPosition dp5 = tCoordFactory.createDirectPosition(new double[] {100.01,50});
    DirectPosition dp6 = tCoordFactory.createDirectPosition(new double[] {50,100});
    DirectPosition dp7 = tCoordFactory.createDirectPosition(new double[] {50,100.01});
   
    // Envelope.contains(DirectPosition)
    //System.outprintln("Contains Method for " + env1);
    assertTrue(env1.contains(dp3) == true);
    //System.outprintln(dp3 + " liegt im Envelope: " + env1.contains(dp3));
    assertTrue(env1.contains(dp4) == true);
    //System.outprintln(dp4 + " liegt im Envelope: " + env1.contains(dp4));
    assertTrue(env1.contains(dp5) == false);
    //System.outprintln(dp5 + " liegt im Envelope: " + env1.contains(dp5));
    assertTrue(env1.contains(dp6) == true);
    //System.outprintln(dp6 + " liegt im Envelope: " + env1.contains(dp6));
    assertTrue(env1.contains(dp7) == false);
    //System.outprintln(dp7 + " liegt im Envelope: " + env1.contains(dp7));

//    DirectPositionImpl dp8 = tCoordFactory.createDirectPosition(new double[] {200,200});
//   
//    EnvelopeImpl env2 = new EnvelopeImpl(dp6, dp8);
//    EnvelopeImpl env3 = new EnvelopeImpl(dp7, dp8);
//   
//    //System.outprintln(env1 + " intersects with " + env2 + " : " + env1.intersects(env2));
//    //System.outprintln(env1 + " intersects with " + env3 + " : " + env1.intersects(env3));
   
    //System.outprintln("TEST EXPAND");
    env1 = tCoordFactory.createEnvelope(dp1.getCoordinate());
    //System.outprintln(env1);
    env1.expand(dp2.getCoordinate());
    //System.outprintln(env1);
    env1.expand(dp5.getCoordinate());
    //System.outprintln(env1);
View Full Code Here

  private void _testCompositeCurve(PicoContainer c) {
   
    PositionFactoryImpl positionFactory = (PositionFactoryImpl) c.getComponentInstanceOfType(PositionFactory.class);
    ComplexFactoryImpl complf = (ComplexFactoryImpl) c.getComponentInstanceOfType(ComplexFactory.class);
    PrimitiveFactoryImpl pf = (PrimitiveFactoryImpl) c.getComponentInstanceOfType(PrimitiveFactory.class);
    GeometryFactoryImpl geomFact = (GeometryFactoryImpl) c.getComponentInstanceOfType(GeometryFactory.class);
     
    // testcreateCompositeCurve()
    ArrayList<Position> line1 = new ArrayList<Position>();
    line1.add(new PositionImpl(positionFactory.createDirectPosition(new double[]{50, 20})));
    line1.add(new PositionImpl(positionFactory.createDirectPosition(new double[]{30, 30})));
    line1.add(new PositionImpl(positionFactory.createDirectPosition(new double[]{20, 50})));
    line1.add(new PositionImpl(positionFactory.createDirectPosition(new double[]{20, 70})));

    ArrayList<Position> line2 = new ArrayList<Position>();
    line2.add(new PositionImpl(positionFactory.createDirectPosition(new double[]{20, 70})));
    line2.add(new PositionImpl(positionFactory.createDirectPosition(new double[]{40, 80})));
    line2.add(new PositionImpl(positionFactory.createDirectPosition(new double[]{70, 80})));

    ArrayList<Position> line3 = new ArrayList<Position>();
    line3.add(new PositionImpl(positionFactory.createDirectPosition(new double[]{70, 80})));
    line3.add(new PositionImpl(positionFactory.createDirectPosition(new double[]{90, 70})));
    line3.add(new PositionImpl(positionFactory.createDirectPosition(new double[]{100, 60})));
    line3.add(new PositionImpl(positionFactory.createDirectPosition(new double[]{100, 40})));

    ArrayList<Position> line4 = new ArrayList<Position>();
    line4.add(new PositionImpl(positionFactory.createDirectPosition(new double[]{100, 40})));
    line4.add(new PositionImpl(positionFactory.createDirectPosition(new double[]{80, 30})));
    line4.add(new PositionImpl(positionFactory.createDirectPosition(new double[]{50, 20})));
    ArrayList<CurveSegment> tLineList1 = new ArrayList<CurveSegment>();
    tLineList1.add(geomFact.createLineString(line1));
    tLineList1.add(geomFact.createLineString(line2));

    ArrayList<CurveSegment> tLineList2 = new ArrayList<CurveSegment>();
    tLineList2.add(geomFact.createLineString(line3));
    tLineList2.add(geomFact.createLineString(line4));
    CurveImpl curve1 = pf.createCurve(tLineList1);
    CurveImpl curve2 = pf.createCurve(tLineList2);
    ArrayList<OrientableCurve> curveList = new ArrayList<OrientableCurve>();
    curveList.add(curve1);
    curveList.add(curve2);
View Full Code Here

TOP

Related Classes of org.geotools.geometry.iso.coordinate.GeometryFactoryImpl

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.