Package org.opengis.geometry

Examples of org.opengis.geometry.PositionFactory


  public void testCreatePrimitive() {
   
    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) );
View Full Code Here


 
  public void testCurveEquals(){
    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

 
  public void testGoodPoint() throws Exception {
    CoordinateReferenceSystem crs = CRS.decode( "EPSG:4326");   
    assertNotNull( crs );

    PositionFactory positionFactory = new PositionFactoryImpl(crs, new PrecisionModel());
    PrimitiveFactory primitiveFactory = new PrimitiveFactoryImpl(crs, positionFactory); // null;
   
    assertEquals( crs, primitiveFactory.getCoordinateReferenceSystem() );
   
    Point point = primitiveFactory.createPoint( new double[]{1,1} );
View Full Code Here

  }
 
  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();
    Point point = primitiveFactory.createPoint(new double[] { 48.44, -123.37 });
   
View Full Code Here

 
  public void testEquals(){
    CoordinateReferenceSystem crs = DefaultGeographicCRS.WGS84;
    PicoContainer container = container( crs ); // normal 2D
    GeometryFactoryImpl factory = (GeometryFactoryImpl) container.getComponentInstanceOfType( GeometryFactory.class );
    PositionFactory positionFactory = (PositionFactory ) container.getComponentInstanceOfType( PositionFactory.class );
   
    DirectPosition positionA = positionFactory.createDirectPosition(new double[]{10, 10});
    DirectPosition positionB = positionFactory.createDirectPosition(new double[]{70, 30});
   
    LineSegmentImpl expected = createLineSegment(positionA, positionB);   
    LineSegmentImpl actual = (LineSegmentImpl) factory.createLineSegment(positionA, positionB);
   
    assertEquals( expected, actual );
View Full Code Here

 
  public void testCurveEquals(){
    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

 
  public void testOtherCurveMethods() {
    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[]{20, 20});
   
    CurveImpl curve = createCurve(positionA, positionB);   

    // test split (split seems broken)
    //curve.split(5);
   
    // test getSegmentAt
    CurveSegmentImpl segmentAt = curve.getSegmentAt(1);
    assertTrue(segmentAt.equals(curve.asLineSegments().get(0)));
   
    // test getParamForPoint (not fully implemented yet)
    //ParamForPoint paramForPoint = curve.getParamForPoint(positionA);
    //System.out.println(paramForPoint);
   
    // test length
    double d = curve.length(0,1);
    assertTrue(d == 1);
    // the following length uses getParamForPoint and it's not fully implemented yet)
    //double e = curve.length(positionA, positionB);
    //System.out.println(e);
   
    // test asLineString
    LineStringImpl linestring = curve.asLineString();
    List<Position> posList = new ArrayList<Position>();
    posList.add(positionA);
    posList.add(positionB);
    assertTrue(linestring.equals(new LineStringImpl(posList)));
   
    // test getDimension
    assertEquals(curve.getDimension(positionA), 1);
   
    // test toString
    String toS = curve.toString();
    assertTrue(toS != null);
    assertTrue(toS.length() > 0);
   
    // test obj equals
    CurveImpl curve2 = null;
    try {
      curve2 = curve.clone();
    } catch (CloneNotSupportedException e) {
      e.printStackTrace();
      fail();
    }

    assertTrue(curve.equals((Object) curve2));
    assertTrue(curve.equals((Object) curve));
    assertFalse(curve.equals((Object) positionA));
    assertFalse(curve.equals((Object) null));
    DirectPosition positionC = positionFactory.createDirectPosition(new double[]{30, 30});
    CurveImpl curve3 = createCurve(positionA, positionC);
    assertFalse(curve.equals((Object) curve3));
   
  }
View Full Code Here

  }
 
  public void testCurveAgain() {

    GeometryBuilder builder = new GeometryBuilder(DefaultGeographicCRS.WGS84);
    PositionFactory posF = builder.getPositionFactory();
    PrimitiveFactory primF = builder.getPrimitiveFactory();
    GeometryFactory geomF = builder.getGeometryFactory();   

//     create directpositions
    DirectPosition start = posF.createDirectPosition(new double[]{ 48.44, -123.37 });
    DirectPosition middle = posF.createDirectPosition(new double[]{ 47, -122 });
    DirectPosition end = posF.createDirectPosition(new double[]{ 46.5, -121.5 });

//     add directpositions to a list
    ArrayList<Position> positions = new ArrayList<Position>();
    positions .add(start);
    positions.add(middle);
View Full Code Here

 
  private void _testMultiCurve(PicoContainer c) {

    AggregateFactoryImpl af = (AggregateFactoryImpl) c.getComponentInstanceOfType(AggregateFactory.class);
    GeometryFactoryImpl gf = (GeometryFactoryImpl) c.getComponentInstanceOfType( GeometryFactory.class );
    PositionFactory pf = (PositionFactory ) c.getComponentInstanceOfType( PositionFactory.class );
   
    DirectPosition dp1 = pf.createDirectPosition(new double[]{10, 30});
    DirectPosition dp2 = pf.createDirectPosition(new double[]{70, 15});
    LineSegment line1 = gf.createLineSegment(dp1, pf.createDirectPosition(new double[]{20, 40}));
    LineSegment line2 = gf.createLineSegment(dp2, pf.createDirectPosition(new double[]{45, 25}));
    Set<OrientableCurve> curves = new HashSet<OrientableCurve>();
    curves.add( new CurveImpl( line1 ) );
    curves.add( new CurveImpl( line2 ) );
    MultiCurve mc = af.createMultiCurve(curves);
   
View Full Code Here

  }
 
  private void _testMultiCurve(PicoContainer c) {

    AggregateFactoryImpl af = (AggregateFactoryImpl) c.getComponentInstanceOfType(AggregateFactory.class);
    PositionFactory pf = (PositionFactory ) c.getComponentInstanceOfType( PositionFactory.class );
   
    DirectPosition dp1 = pf.createDirectPosition(new double[]{10, 30});
    DirectPosition dp2 = pf.createDirectPosition(new double[]{70, 15});
    DirectPosition dp3 = pf.createDirectPosition(new double[]{45, 5});
    DirectPosition dp4 = pf.createDirectPosition(new double[]{10, 35});
    Set<Point> points = new HashSet<Point>();
    points.add( new PointImpl(dp1) );
    points.add( new PointImpl(dp2) );
    points.add( new PointImpl(dp3) );
    points.add( new PointImpl(dp4) );
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.