Package org.opengis.geometry

Examples of org.opengis.geometry.DirectPosition


   
    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));
View Full Code Here


    assertEquals(segments.get(3).getEndConstructiveParam() , 1.0);


    // ***** LineSegment.forParam(double)
    // Parameter for forParam() is 0.0 (startparam)
    DirectPosition resultPos = seg1.forParam(0.0);
    //System.outprintln(resultPos);
    assertEquals(resultPos.getOrdinate(0) , -50.0);
    assertEquals(resultPos.getOrdinate(1) , 0.0);

    // Parameter for forParam() is endparam
    resultPos = seg1.forParam(seg1.getEndParam());
    //System.outprintln(resultPos);
    assertEquals(resultPos.getOrdinate(0) , -30.0);
    assertEquals(resultPos.getOrdinate(1) , 30.0);

    // Parameter for startParam out of param range
    resultPos = null;
    try {
      resultPos = seg1.forParam(180);
View Full Code Here

    assertEquals(segments.get(3).getEndConstructiveParam() , 1.0);


    // ***** LineSegment.forParam(double)
    // Parameter for forParam() is 0.0 (startparam)
    DirectPosition resultPos = seg1.forParam(0.0);
    //System.out.println(resultPos);
    assertEquals(resultPos.getOrdinate(0) , -50.0);
    assertEquals(resultPos.getOrdinate(1) , 0.0);

    // Parameter for forParam() is endparam
    resultPos = seg1.forParam(seg1.getEndParam());
    //System.out.println(resultPos);
    assertEquals(resultPos.getOrdinate(0) , -30.0);
    assertEquals(resultPos.getOrdinate(1) , 30.0);

    // Parameter for startParam out of param range
    resultPos = null;
    try {
      resultPos = seg1.forParam(180);
View Full Code Here

    assertTrue(pa.size() == 5);
    // PointArray.positions()
    assertTrue(pa.size() == 5);

    // get-method creates new DP instance
    DirectPosition directPosition = pa.getDirectPosition(0, null);
    ////System.out.println(dp);
    assertTrue(directPosition.getOrdinate(0) == -50);
    assertTrue(directPosition.getOrdinate(1) == 0);
   
    DirectPosition directPositionAt4 = pa.getDirectPosition(4, directPosition);
    ////System.out.println(dp);
    assertTrue(directPosition.getOrdinate(0) == 50);
    assertTrue(directPosition.getOrdinate(1) == 0);
    // get-method uses the same DirectPosition without creating new instance
    assertTrue(directPositionAt4 == directPosition);
   
    DirectPosition directPositionAddition = tCoordFactory.createDirectPosition(new double[]{5, 5});
    pa.setDirectPosition(4, directPositionAddition); // test to see of object or values is stored       
       
        DirectPosition directPositionAt4mk2 = pa.getDirectPosition(4, directPosition); // retrive
        assertEquals( "Same values as we put into 4", directPositionAt4mk2, directPositionAddition );
        assertNotSame( "Not the same object we put into 4", directPositionAt4mk2, directPositionAddition );
       
        assertEquals( directPositionAt4mk2, directPositionAddition );
       
        // BEFORE
    assertEquals( 5.0, directPosition.getOrdinate(0) );
    assertEquals( 5.0, directPosition.getOrdinate(1) );
       
    // Check if the values were copied and not referenced (by modifying the ordinates)
        // Modify values set into position 4
    directPositionAddition.setOrdinate( 0, 2);
   
        // retrive values from position 4 again
        DirectPosition directPositionAt4mk3 = pa.getDirectPosition(4, directPosition);   
    assertEquals( "check if position is independent", 5.0, directPositionAt4mk3.getOrdinate(0) );
   
    double[] coord = ((PointArrayImpl)pa).getCoordinate(0);
    //System.out.print(coord[0] + "|" + coord[1]);
   
    // .isEmpty() and remove(int)
View Full Code Here

    CoordinateReferenceSystem crs = DefaultGeographicCRS.WGS84;
    PicoContainer container = container( crs ); // normal 2D
    PrimitiveFactoryImpl factory = (PrimitiveFactoryImpl) container.getComponentInstanceOfType( PrimitiveFactoryImpl.class );
    PositionFactory positionFactory = (PositionFactory ) container.getComponentInstanceOfType( PositionFactory.class );
   
    DirectPosition positionA = positionFactory.createDirectPosition(new double[]{10, 10});
    DirectPosition positionB = positionFactory.createDirectPosition(new double[]{70, 30});
    Envelope bounds = new EnvelopeImpl( positionA, positionB );
   
    LineSegmentImpl expected = new LineSegmentImpl( crs, new double[]{10,Double.NaN}, new double[]{70,Double.NaN}, 0.0 );   
   
    LineSegment actual =  factory.processBoundsToSegment( bounds );
View Full Code Here

    CoordinateReferenceSystem crs = DefaultGeographicCRS.WGS84;
    PicoContainer container = container( crs ); // normal 2D
    PrimitiveFactoryImpl factory = (PrimitiveFactoryImpl) container.getComponentInstanceOfType( PrimitiveFactoryImpl.class );
    PositionFactory positionFactory = (PositionFactory ) container.getComponentInstanceOfType( PositionFactory.class );
   
    DirectPosition positionA = positionFactory.createDirectPosition(new double[]{10, 10});
    DirectPosition positionB = positionFactory.createDirectPosition(new double[]{70, 30});
    Envelope bounds = new EnvelopeImpl( positionA, positionB );
   
    LineSegmentImpl segment = new LineSegmentImpl( crs, new double[]{10,Double.NaN}, new double[]{70,Double.NaN}, 0.0 );
   
    // create expected ring
    DirectPosition one = new DirectPositionImpl( segment.getStartPoint() );
    one.setOrdinate( 1, bounds.getMinimum(1) );
   
    DirectPosition two = new DirectPositionImpl( segment.getEndPoint() );
    two.setOrdinate( 1, bounds.getMinimum(1) );
   
    DirectPosition three = new DirectPositionImpl( two );
    three.setOrdinate( 1, bounds.getMaximum(1) );
   
    DirectPosition four = new DirectPositionImpl( one );
    four.setOrdinate( 1, bounds.getMaximum(1) );
   
    LineSegment edge1 = new LineSegmentImpl( one, two, 0.0 );
    LineSegment edge2 = new LineSegmentImpl( two, three, 0.0 );
    LineSegment edge3 = new LineSegmentImpl( three, four, 0.0 );
    LineSegment edge4 = new LineSegmentImpl( four, one, 0.0 );
View Full Code Here

    CoordinateReferenceSystem crs = DefaultGeographicCRS.WGS84;
    PicoContainer container = container( crs ); // normal 2D
    PrimitiveFactoryImpl factory = (PrimitiveFactoryImpl) container.getComponentInstanceOfType( PrimitiveFactoryImpl.class );
    PositionFactory positionFactory = (PositionFactory ) container.getComponentInstanceOfType( PositionFactory.class );
   
    DirectPosition positionA = positionFactory.createDirectPosition(new double[]{10, 10});
    DirectPosition positionB = positionFactory.createDirectPosition(new double[]{70, 30});
    Envelope bounds = new EnvelopeImpl( positionA, positionB );
   
    // create expected ring
    DirectPosition one = new DirectPositionImpl( positionA );
    one.setOrdinate( 1, bounds.getMinimum(1) );
   
    DirectPosition two = new DirectPositionImpl( positionB );
    two.setOrdinate( 1, bounds.getMinimum(1) );
   
    DirectPosition three = new DirectPositionImpl( two );
    three.setOrdinate( 1, bounds.getMaximum(1) );
   
    DirectPosition four = new DirectPositionImpl( one );
    four.setOrdinate( 1, bounds.getMaximum(1) );
   
    LineSegment edge1 = new LineSegmentImpl( one, two, 0.0 );
    LineSegment edge2 = new LineSegmentImpl( two, three, 0.0 );
    LineSegment edge3 = new LineSegmentImpl( three, four, 0.0 );
    LineSegment edge4 = new LineSegmentImpl( four, one, 0.0 );
View Full Code Here

    PrimitiveFactoryImpl prf = (PrimitiveFactoryImpl) container.getComponentInstanceOfType( PrimitiveFactory.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 );
   
    List<OrientableCurve> edges = new ArrayList<OrientableCurve>();
    edges.add( new CurveImpl( edge1 ));
    edges.add( new CurveImpl( edge2 ));
    edges.add( new CurveImpl( edge3 ));
    Ring exterior = new RingImpl( edges );
   
    // 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 );
   
    edges = new ArrayList<OrientableCurve>();
View Full Code Here

    CoordinateReferenceSystem crs = DefaultGeographicCRS.WGS84;
    PicoContainer container = container( crs ); // normal 2D
    PrimitiveFactoryImpl factory = (PrimitiveFactoryImpl) container.getComponentInstanceOfType( PrimitiveFactoryImpl.class );
    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

    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);
View Full Code Here

TOP

Related Classes of org.opengis.geometry.DirectPosition

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.