Package org.opengis.geometry

Examples of org.opengis.geometry.DirectPosition


     */
    public void testMathTransform() throws FactoryException, TransformException {
        final MathTransformFactory mtFactory = ReferencingFactoryFinder.getMathTransformFactory(null);
        final ParameterValueGroup p = mtFactory.getDefaultParameters("Earth gravitational model");
        final MathTransform mt = mtFactory.createParameterizedTransform(p);
        DirectPosition pos = new GeneralDirectPosition(new double[] {45, 45, 1000});
        pos = mt.transform(pos, pos);
        assertEquals45.000, pos.getOrdinate(0), 0.001);
        assertEquals45.000, pos.getOrdinate(1), 0.001);
        assertEquals(1001.515, pos.getOrdinate(2), 0.001);
    }
View Full Code Here


        // 2 points with SRS
        Function function = ff.function("toDirectPosition", ToDirectPositionFunction.SRS_NAME,
                ff.literal("EPSG:4326"), pointOne, pointTwo);
        Object value = function.evaluate(feature);
        assertTrue(value instanceof DirectPosition);
        DirectPosition pos = (DirectPosition) value;
        assertEquals(CRS.toSRS(pos.getCoordinateReferenceSystem()), "EPSG:4326");
        assertEquals(pos.getDimension(), 2);
        assertEquals(pos.getOrdinate(0), 5.0, 0);
        assertEquals(pos.getOrdinate(1), 2.5, 0);

        // 1 point, no SRS
        function = ff.function("toDirectPosition", pointOne);
        value = function.evaluate(feature);
        assertTrue(value instanceof DirectPosition);
        pos = (DirectPosition) value;
        assertNull(pos.getCoordinateReferenceSystem());
        assertEquals(pos.getDimension(), 1);
        assertEquals(pos.getOrdinate(0), 5.0, 0);
        // invalid CRS
        try {
            function = ff.function("toDirectPosition", ToDirectPositionFunction.SRS_NAME,
                    ff.literal("1"), pointOne, pointTwo);
            function.evaluate(feature);
View Full Code Here

    GeometryFactoryImpl cf = (GeometryFactoryImpl) c.getComponentInstanceOfType(GeometryFactory.class);
    PrimitiveFactoryImpl tPrimFactory = (PrimitiveFactoryImpl) c.getComponentInstanceOfType( PrimitiveFactoryImpl.class );
    PositionFactory positionFactory = (PositionFactory ) c.getComponentInstanceOfType( PositionFactory.class );
   
    // 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);
View Full Code Here

 
  // make it and test it's serialization
  public void testPointFactory() throws IOException, ClassNotFoundException {
   
    // create object, serialize, deserialize and compare results
    DirectPosition dp = new DirectPositionImpl(DefaultGeographicCRS.WGS84, new double[]{1,2});
    PointImpl point = new PointImpl(dp);
    PointImpl copy = (PointImpl) serializeAndDeSerialize(point);
    assertTrue(point.equals(copy));
  }
View Full Code Here

    // public PrimitiveImpl createPrimitive(Envelope envelope);
    // indirect: public SurfaceImpl createSurface(SurfaceBoundary boundary);
    // indirect: public SurfaceImpl createSurfaceByDirectPositions(List<DirectPosition> positions);
    // indirect: public SurfaceBoundaryImpl createSurfaceBoundary(Ring exterior, List<Ring> interiors);
    // indirect: public Ring createRingByDirectPositions(List<DirectPosition> directPositions);
    DirectPosition dp1 = posf.createDirectPosition(new double[]{10, 10});
    DirectPosition dp2 = posf.createDirectPosition(new double[]{70, 30});
    Envelope env1 = cf.createEnvelope(dp1, dp2);
    PrimitiveImpl prim1 = (PrimitiveImpl) pf.createPrimitive(env1);
    assertNotNull(prim1);
   
  }
View Full Code Here

    assertSame( positionFactory.getCoordinateReferenceSystem(), primitiveFactory.getCoordinateReferenceSystem() );
    assertNotNull(positionFactory);
    assertNotNull(primitiveFactory);
   
    // create position and point
    DirectPosition here = positionFactory.createDirectPosition(ords);
    Point point = primitiveFactory.createPoint(here);
    assertNotNull(here.getCoordinateReferenceSystem());
    assertNotNull(point.getCoordinateReferenceSystem());
    assertEquals(here.getCoordinateReferenceSystem(), point.getCoordinateReferenceSystem());
    assertEquals(here, point.getDirectPosition());
    assertEquals(here.hashCode(), point.getDirectPosition().hashCode());
    assertEquals(point.getCentroid(), here);
   
    // get ordinates out of point
    double[] ords2 = point.getCentroid().getCoordinate();
  }
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);
View Full Code Here

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

    public void testLargeSurfaceBuilder(){
         int NUMBER = 100000;
         double delta = 360.0 / (double) NUMBER;
         PointArray points = builder.createPointArray();
         for( double angle = 0.0; angle < 360.0; angle += delta ){
             DirectPosition point = builder.createDirectPosition();
             point.setOrdinate( 0, Math.sin( Math.toRadians(angle) ) );
             point.setOrdinate( 1, Math.cos( Math.toRadians(angle) ) );  

             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<LineSegment> segmentList = new ArrayList<LineSegment>();
         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 = builder.createLineSegment( point1, point2 );
             segmentList.add( segment );
         }
         Curve curve = builder.createCurve( segmentList );
         curves.add( curve);        
View Full Code Here

        assertEquals( "close array", openSurface, closedSurface );
       
        Surface surface = transmit(closedSurface);
        assertEquals( closedSurface, surface );
       
        DirectPosition aPoint = surface.getRepresentativePoint();
        DirectPosition point = transmit( aPoint );
        assertEquals( aPoint, point );
    }
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.