Package org.opengis.geometry.primitive

Examples of org.opengis.geometry.primitive.Point


    // test 2.5D point creation
    double[] da = new double[3];
    da[0] = 10.0;
    da[1] = -115000.0;
    da[2] = 0.0000000125;
    Point p1 = pf.createPoint(da);
    assertTrue(p1.getDirectPosition().getOrdinate(0) == 10.0);
    assertTrue(p1.getDirectPosition().getOrdinate(1) == -115000.0);
    assertTrue(p1.getDirectPosition().getOrdinate(2) == 0.0000000125);

    // public PointImpl createPoint(Position position);
    // public PointImpl createPoint(DirectPositionImpl dp);
    da[0] = 999999999.0;
    da[1] = 100.0;
    da[2] = -0.00000565;
    Position pos1 = new DirectPositionImpl( pf.getCoordinateReferenceSystem(),  da );
    Point p2 = pf.createPoint(pos1);
    assertTrue(p2.getDirectPosition().getOrdinate(0) == 999999999.0);
    assertTrue(p2.getDirectPosition().getOrdinate(1) == 100.0);
    assertTrue(p2.getDirectPosition().getOrdinate(2) == -0.00000565);
   
  }
View Full Code Here


    // public PointImpl createPoint(double[] coord);
    double[] da = new double[3];
    da[0] = 10.0;
    da[1] = -115000.0;
    da[2] = 0.0000000125;
    Point p1 = pf.createPoint(da);
    assertTrue(p1.getDirectPosition().getOrdinate(0) == 10.0);
    assertTrue(p1.getDirectPosition().getOrdinate(1) == -115000.0);
    assertTrue(p1.getDirectPosition().getOrdinate(2) == 0.0000000125);

    // public PointImpl createPoint(Position position);
    // public PointImpl createPoint(DirectPositionImpl dp);
    da[0] = 999999999.0;
    da[1] = 100.0;
    da[2] = -0.00000565;
    Position pos1 = new DirectPositionImpl( pf.getCoordinateReferenceSystem(),  da );
    Point p2 = pf.createPoint(pos1);
    assertTrue(p2.getDirectPosition().getOrdinate(0) == 999999999.0);
    assertTrue(p2.getDirectPosition().getOrdinate(1) == 100.0);
    assertTrue(p2.getDirectPosition().getOrdinate(2) == -0.00000565);

  }
View Full Code Here

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

    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} );
   
    assertNotNull( point );
    assertEquals( crs, point.getCoordinateReferenceSystem() );
    assertSame( crs, point.getCoordinateReferenceSystem() );   
  }
View Full Code Here

   
    GeometryFactoryImpl tCoordFactory = (GeometryFactoryImpl) builder.getGeometryFactory();
    PrimitiveFactoryImpl tPrimFactory = (PrimitiveFactoryImpl) builder.getPrimitiveFactory();
   
    double[] coord = new double[]{10, 32000};
    Point p1 = tPrimFactory.createPoint(coord);

    // ***** 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);
    assertTrue(p1.equals(p2));
   
View Full Code Here

    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 });
   
    assertFalse(point.getCoordinateReferenceSystem().equals(point3D.getCoordinateReferenceSystem()));
    assertFalse(point.equals(point3D));
  }
View Full Code Here

    private Point readPointText(StreamTokenizer tokenizer) throws IOException, ParseException {
        String nextToken = getNextEmptyOrOpener(tokenizer);
        if (nextToken.equals(EMPTY)) {
            return primitiveFactory.createPoint(new double[2]);
        }
        Point point = primitiveFactory.createPoint(getPreciseCoordinate(tokenizer));
        getNextCloser(tokenizer);
        return point;
    }
View Full Code Here

        String nextToken = getNextEmptyOrOpener(tokenizer);       
        if (nextToken.equals(EMPTY)) {
          return null;
        }
        MultiPrimitive multi = geometryFactory.createMultiPrimitive();       
        Point point = primitiveFactory.createPoint(getPreciseCoordinate(tokenizer));
        //multi.getElements().add(point);
        Set elements = multi.getElements();
        elements.add(point);
        nextToken = getNextCloserOrComma(tokenizer);
        while (nextToken.equals(COMMA)) {
View Full Code Here

      }
      cs0 = cs1;
    }
    Position p1 = cs0.getEndPosition();

    Point pt0 = toPoint( p0 );
    Point pt1 = toPoint( p1 );
    if (pt0 == null) {
      DirectPositionImpl copy = new DirectPositionImpl(p0.getDirectPosition());
      pt0 = new PointImpl(copy);
      //pt0 = this.getFeatGeometryFactory().getPrimitiveFactory().createPoint(p0);
    }
View Full Code Here

        String geomType = jtsGeom.getGeometryType();
        if (geomType.equalsIgnoreCase("Point")) {
            com.vividsolutions.jts.geom.Point jtsPoint =
                (com.vividsolutions.jts.geom.Point) jtsGeom;
            DirectPosition dp = pointToDirectPosition(jtsPoint, crs);
            Point result = pf.createPoint(dp);
            return result;
       
        } else if (geomType.equalsIgnoreCase("LineString")) {
            com.vividsolutions.jts.geom.LineString jtsLineString =
                (com.vividsolutions.jts.geom.LineString) jtsGeom;
            int numPoints = jtsLineString.getNumPoints();
            LineString ls = gf.createLineString(new ArrayList());
            List pointList = ls.getControlPoints();
            for (int i=0; i<numPoints; i++) {
                pointList.add(coordinateToDirectPosition(jtsLineString.getCoordinateN(i), crs));
            }
            ArrayList segments = new ArrayList();
            segments.add(ls);
            Curve result = pf.createCurve(segments);
            return result;
       
        } else if (geomType.equalsIgnoreCase("LinearRing")) {
            Ring result = linearRingToRing(
                    (com.vividsolutions.jts.geom.LinearRing) jtsGeom, crs);
            return result;
       
        } else if (geomType.equalsIgnoreCase("Polygon")) {
            com.vividsolutions.jts.geom.Polygon jtsPolygon =
                (com.vividsolutions.jts.geom.Polygon) jtsGeom;
            Ring externalRing = linearRingToRing(
                    (com.vividsolutions.jts.geom.LinearRing) jtsPolygon.getExteriorRing(),
                    crs);
            int n = jtsPolygon.getNumInteriorRing();
            ArrayList internalRings = new ArrayList();
            for (int i=0; i<n; i++) {
                internalRings.add(linearRingToRing(
                    (com.vividsolutions.jts.geom.LinearRing) jtsPolygon.getInteriorRingN(i),
                    crs));
            }
            SurfaceBoundary boundary = pf.createSurfaceBoundary(externalRing,
                    internalRings);
            Polygon polygon = gf.createPolygon(boundary);
            ArrayList patches = new ArrayList();
            patches.add(polygon);
            PolyhedralSurface result = gf.createPolyhedralSurface(patches);
            return result;
       
        } else if (geomType.equalsIgnoreCase("GeometryCollection") ||
                geomType.equalsIgnoreCase("MultiPoint") ||
                geomType.equalsIgnoreCase("MultiLineString") ||
                geomType.equalsIgnoreCase("MultiPolygon")) {
            com.vividsolutions.jts.geom.GeometryCollection jtsCollection =
                (com.vividsolutions.jts.geom.GeometryCollection) jtsGeom;
            int n = jtsCollection.getNumGeometries();
            MultiPrimitive result = gf.createMultiPrimitive();
            Set elements = result.getElements();
            for (int i=0; i<n; i++) {
                //result.getElements().add(jtsToGo1(jtsCollection.getGeometryN(i), crs));
                elements.add(jtsToGo1(jtsCollection.getGeometryN(i), crs));
            }
            return result;
View Full Code Here

TOP

Related Classes of org.opengis.geometry.primitive.Point

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.