Package org.opengis.geometry

Examples of org.opengis.geometry.PositionFactory


  }
 
  public void testBuildPoint() {
   
    // test positionfactory
    PositionFactory posFactory = builder.getPositionFactory();
    DirectPosition position = posFactory.createDirectPosition(new double[] { 48.44, -123.37 });
   
    // test primitivefactory
    PrimitiveFactory primitiveFactory = builder.getPrimitiveFactory();
    System.out.println(primitiveFactory.getCoordinateReferenceSystem());
    Point point = primitiveFactory.createPoint(new double[] { 48.44, -123.37 });
   
    assertTrue(position.equals(point.getCentroid()));
   
    // change CRS and test
    builder.setCoordianteReferenceSystem(DefaultGeographicCRS.WGS84_3D);
    PrimitiveFactory primitiveFactory3D = builder.getPrimitiveFactory();
    Point point3D = primitiveFactory3D.createPoint(new double[] { 48.44, -123.37, 1.0 });
   
    assertFalse(point.getCoordinateReferenceSystem().equals(point3D.getCoordinateReferenceSystem()));
    assertFalse(point.equals(point3D));
   
    // back to 2D
    builder.setCoordianteReferenceSystem(DefaultGeographicCRS.WGS84);
    PositionFactory pf = builder.getPositionFactory();
    PrimitiveFactoryImpl primf = (PrimitiveFactoryImpl) builder.getPrimitiveFactory();
    AggregateFactory agf = builder.getAggregateFactory();
   
    List<DirectPosition> directPositionList = new ArrayList<DirectPosition>();
    directPositionList.add(pf.createDirectPosition(new double[] {20, 10}));
    directPositionList.add(pf.createDirectPosition(new double[] {40, 10}));
    directPositionList.add(pf.createDirectPosition(new double[] {50, 40}));
    directPositionList.add(pf.createDirectPosition(new double[] {30, 50}));
    directPositionList.add(pf.createDirectPosition(new double[] {10, 30}));
    directPositionList.add(pf.createDirectPosition(new double[] {20, 10}));

    Ring exteriorRing = primf.createRingByDirectPositions(directPositionList);
    List<Ring> interiors = new ArrayList<Ring>();
   
    SurfaceBoundary surfaceBoundary1 = primf.createSurfaceBoundary(exteriorRing, interiors );
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

            throw new RuntimeException("", e);
        }

        GeometryFactory geomFact = new GeometryFactoryImpl(DefaultGeographicCRS.WGS84);
        PrimitiveFactory primFact = new PrimitiveFactoryImpl(DefaultGeographicCRS.WGS84);
        PositionFactory posFact = null;
        wktFactory = new WKTParser(geomFact, primFact, posFact, null );
    }
View Full Code Here

    assertEquals(here, point.getDirectPosition());
    assertEquals(here.hashCode(), point.getDirectPosition().hashCode());
  }

  public void testNewFactoryPointHere() {
    PositionFactory gFact = new PositionFactoryImpl(
        DefaultGeographicCRS.WGS84);
    double[] ords = { 48.44, -123.37 };
    DirectPosition here = gFact.createDirectPosition(ords);

    Point point = new PointImpl(here);
    assertNotNull(point.getCoordinateReferenceSystem());
    assertEquals(here.getCoordinateReferenceSystem(), point
        .getCoordinateReferenceSystem());
View Full Code Here

    } catch (Exception expected) {
    }
    // let's provide a CRS now and confirm everything works
    container.registerComponentInstance(DefaultGeographicCRS.WGS84_3D);

    PositionFactory positionFactory =
      (PositionFactory) container.getComponentInstanceOfType(PositionFactory.class);
   
    assertSame(DefaultGeographicCRS.WGS84_3D, positionFactory.getCoordinateReferenceSystem());
  }
View Full Code Here

    PicoContainer c = container( DefaultGeographicCRS.WGS84 );
   
    // Do actually test stuff
   
    double[] ords = { 48.44, -123.37 };
    PositionFactory factory = (PositionFactory) c.getComponentInstanceOfType( PositionFactory.class );
   
    assertNotNull(factory);
    DirectPosition here = factory.createDirectPosition(ords);
    Point point = new PointImpl(here);
    assertNotNull(point.getCoordinateReferenceSystem());
    assertEquals(here.getCoordinateReferenceSystem(), point
        .getCoordinateReferenceSystem());
    assertEquals(here, point.getDirectPosition());
View Full Code Here

    PicoContainer c = container( DefaultGeographicCRS.WGS84_3D );
   
    // Do actually test stuff
   
    double[] ords = { 48.44, -123.37, 0.0 };
    PositionFactory factory = (PositionFactory) c.getComponentInstanceOfType( PositionFactory.class );
   
    assertNotNull(factory);
    DirectPosition here = factory.createDirectPosition(ords);
    Point point = new PointImpl(here);
    assertNotNull(point.getCoordinateReferenceSystem());
    assertEquals(here.getCoordinateReferenceSystem(), point
        .getCoordinateReferenceSystem());
    assertEquals(here, point.getDirectPosition());
View Full Code Here

TOP

Related Classes of org.opengis.geometry.PositionFactory

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.