Package org.opengis.geometry

Examples of org.opengis.geometry.DirectPosition


     
        int xCoordsOut[] = new int[dps.size()];
        int yCoordsOut[] = new int[dps.size()];

        for (int j=0; j<dps.size(); j++) {
            DirectPosition pos = dps.get(j);
            xCoordsOut[j] = (int) pos.getOrdinate(0);
            yCoordsOut[j] = (int) pos.getOrdinate(1);
        }
       
        return new Coords(xCoordsOut, yCoordsOut);
    }
View Full Code Here


    // ***** getRepresentativePoint()
    double[] dp = p1.getRepresentativePoint().getCoordinate();
    assertTrue(dp[0] == 10);
    assertTrue(dp[1] == 32000);
   
    DirectPosition dp1 = tCoordFactory.createDirectPosition(coord);
   
    Point p2 = tPrimFactory.createPoint(dp1);
   
    //System.out.println("P1: " + p1);
    //System.out.println("P2: " + p2);
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 });
   
    assertTrue(position.equals(point.getCentroid()));
   
    // change CRS and test
    builder.setCoordianteReferenceSystem(DefaultGeographicCRS.WGS84_3D);
    primitiveFactory = builder.getPrimitiveFactory();
    Point point3D = primitiveFactory.createPoint(new double[] { 48.44, -123.37, 1.0 });
View Full Code Here

        public void addRingToCoords(RingImplUnsafe ring) {
         
          List<DirectPosition> dps = ring.asDirectPositions();
         
            for (int j=0; j<dps.size()-1; j++) {
                DirectPosition pos = dps.get(j);
                DirectPosition nextpos = dps.get(j+1);
                this.add( pos, nextpos );
            }           
            return;
        }
View Full Code Here

    double coords1[] = new double[]{x1, y1, z1};
    double coords2[] = new double[]{x1, y1};
    double resultCoords[];
   
    // Creating a DP
    DirectPosition dp1 = gf3D.createDirectPosition(coords1);
   
    // getCoordinate()
    resultCoords = dp1.getCoordinate();
    assertTrue(coords1[0] == resultCoords[0]);
    assertTrue(coords1[1] == resultCoords[1]);
    assertTrue(coords1[2] == resultCoords[2]);
   
    // getOrdinate(dim)
    assertTrue(coords1[0] == dp1.getOrdinate(0));
    assertTrue(coords1[1] == dp1.getOrdinate(1));
    assertTrue(coords1[2] == dp1.getOrdinate(2));
   
    // Cloning a DP
    DirectPosition dp2 = (DirectPosition) ((Cloneable) dp1).clone();
   
    // setOrdinate(dim, value)
    dp1.setOrdinate(0, 10.5);
    dp1.setOrdinate(1, 20.7);
    dp1.setOrdinate(2, -30.666);
    resultCoords = dp1.getCoordinate();
    assertTrue(resultCoords[0] == 10.5);
    assertTrue(resultCoords[1] == 20.7);
    assertTrue(resultCoords[2] == -30.666);
   
    // Test if clone() returned a copy, and not a reference
    // The values of dp2 should not be modified by the previous setOrdinate call in dp1
    resultCoords = dp2.getCoordinate();
    assertTrue(x1 == resultCoords[0]);
    assertTrue(y1 == resultCoords[1]);
    assertTrue(z1 == resultCoords[2]);

    //DirectPosition dp3 = aCoordFactory.createDirectPosition(coords2);
View Full Code Here

    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

   
    GeometryFactoryImpl gf = (GeometryFactoryImpl) c.getComponentInstanceOfType(GeometryFactory.class);

   
    // CoordinateFactory.createDirectPosition(double[])
    DirectPosition dp1 = gf.createDirectPosition(new double[] {0, 0});
    DirectPosition dp2 = gf.createDirectPosition(new double[] {100, 100});

    DirectPosition dp0 = gf.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 = gf.createDirectPosition(new double[] {0,0});
    DirectPosition dp4 = gf.createDirectPosition(new double[] {100,50});
    DirectPosition dp5 = gf.createDirectPosition(new double[] {100.01,50});
    DirectPosition dp6 = gf.createDirectPosition(new double[] {50,100});
    DirectPosition dp7 = gf.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

            }
        }
       
      protected boolean compareDirectPositionResult(DirectPosition result) {
            if (expectedResult instanceof DirectPosition) {
              DirectPosition expect = (DirectPosition)expectedResult;
                return result.equals(expect);
            } else {
                return false;
            }
      }
View Full Code Here

        int i = 1;
        for (int y = 0; y < gridDim.height; y++) {
            for (int x = 0; x < gridDim.width; x++) {
                if (rand.nextDouble() < PROB_POINT) {
                    gridPos.setLocation(x, y);
                    DirectPosition worldPos = gridGeom.gridToWorld(gridPos);
                   
                    String wkt = String.format(Locale.US, "MULTIPOINT((%f %f))",
                            worldPos.getOrdinate(0), worldPos.getOrdinate(1));
                    fc.add( buildFeature(builder, reader, wkt, "p" + i, i ) );
                    i++ ;
                }
            }
        }
View Full Code Here

    double coords2[] = new double[]{x1, y1};
    double resultCoords[];
   
    // Creating a DP
    GeometryFactoryImpl gf = (GeometryFactoryImpl) c.getComponentInstanceOfType(GeometryFactory.class);
    DirectPosition dp1 = gf.createDirectPosition(coords1);
   
    // getCoordinate()
    resultCoords = dp1.getCoordinate();
    assertTrue(coords1[0] == resultCoords[0]);
    assertTrue(coords1[1] == resultCoords[1]);
    assertTrue(coords1[2] == resultCoords[2]);
   
    // getOrdinate(dim)
    assertTrue(coords1[0] == dp1.getOrdinate(0));
    assertTrue(coords1[1] == dp1.getOrdinate(1));
    assertTrue(coords1[2] == dp1.getOrdinate(2));
   
    // Cloning a DP
    DirectPosition dp2 = (DirectPosition) ((Cloneable) dp1).clone();
   
    // setOrdinate(dim, value)
    dp1.setOrdinate(0, 10.5);
    dp1.setOrdinate(1, 20.7);
    dp1.setOrdinate(2, -30.666);
    resultCoords = dp1.getCoordinate();
    assertTrue(resultCoords[0] == 10.5);
    assertTrue(resultCoords[1] == 20.7);
    assertTrue(resultCoords[2] == -30.666);
   
    // Test if clone() returned a copy, and not a reference
    // The values of dp2 should not be modified by the previous setOrdinate call in dp1
    resultCoords = dp2.getCoordinate();
    assertTrue(x1 == resultCoords[0]);
    assertTrue(y1 == resultCoords[1]);
    assertTrue(z1 == resultCoords[2]);

    //DirectPosition dp3 = aCoordFactory.createDirectPosition(coords2);
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.