Package org.opengis.geometry

Examples of org.opengis.geometry.Envelope


    public void testTransformWgs84PolarStereographic() throws Exception {
        CoordinateReferenceSystem crs = CRS.decode("EPSG:3031", true);
        Envelope2D envelope = new Envelope2D(DefaultGeographicCRS.WGS84);
        envelope.add(-180, -90);
        envelope.add(180, 0);
        Envelope transformed = CRS.transform(envelope, crs);
        // the result is a square
        assertEquals(transformed.getMaximum(0), transformed.getMaximum(1), 1d);
        assertEquals(transformed.getMinimum(0), transformed.getMinimum(1), 1d);
        assertEquals(Math.abs(transformed.getMinimum(0)), transformed.getMaximum(0), 1d);

        assertEquals(transformed.getMaximum(0), 1.236739621845986E7, 1d);
    }
View Full Code Here


        CoordinateReferenceSystem crs = CRS.decode("EPSG:3031", true);
        Envelope2D envelope = new Envelope2D(crs);
        // random bbox that does include the pole
        envelope.add(-4223632.8125, -559082.03125);
        envelope.add(5053710.9375, 3347167.96875);
        Envelope transformed = CRS.transform(envelope, DefaultGeographicCRS.WGS84);
        // check we got the whole range of longitudes, since the original bbox contains the pole
        assertEquals(-180d, transformed.getMinimum(0), 0d);
        assertEquals(180d, transformed.getMaximum(0), 0d);
        // another bbox
        envelope = new Envelope2D(crs);
        // random bbox that does not include the pole, but it's really just slightly off it
        envelope.add(-10718812.640513, -10006238.053703);
        envelope.add(12228504.561708, -344209.75803081);
        transformed = CRS.transform(envelope, DefaultGeographicCRS.WGS84);
        assertEquals(-90, transformed.getMinimum(1), 0.1d);
    }
View Full Code Here

        // this one has false origins at 6000000/6000000
        CoordinateReferenceSystem crs = CRS.decode("EPSG:3032", true);
        Envelope2D envelope = new Envelope2D(crs);
        envelope.add(5900000, 5900000);
        envelope.add(6100000, 6100000);
        Envelope transformed = CRS.transform(envelope, DefaultGeographicCRS.WGS84);
        // check we got the whole range of longitudes, since the original bbox contains the pole
        assertEquals(-180d, transformed.getMinimum(0), 0d);
        assertEquals(180d, transformed.getMaximum(0), 0d);
    }
View Full Code Here

        CoordinateReferenceSystem antarcticPs = CRS.decode("EPSG:3031", true);
        CoordinateReferenceSystem australianPs = CRS.decode("EPSG:3032", true);
        Envelope2D envelope = new Envelope2D(antarcticPs);
        envelope.add(-4223632.8125, -559082.03125);
        envelope.add(5053710.9375, 3347167.96875);
        Envelope transformed = CRS.transform(envelope, australianPs);
        // has a false easting and northing, we can only check the spans are equal
        assertEquals(transformed.getSpan(0), transformed.getSpan(1), 1d);

        assertEquals(transformed.getMaximum(0), 1.2309982175378662E7, 1d);
    }
View Full Code Here

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

    // 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

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

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

    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

    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

TOP

Related Classes of org.opengis.geometry.Envelope

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.