Package org.opengis.geometry.coordinate

Examples of org.opengis.geometry.coordinate.GeometryFactory


                          PointImpl point = (PointImpl) op.getExpectedResult();
                          op.setExpectedResult( point );
                        }
                        else { // try parsing this thing as WKT
                          GeometryBuilder builder = new GeometryBuilder(DefaultGeographicCRS.WGS84);
                            GeometryFactory geomFact = builder.getGeometryFactory();
                            PrimitiveFactory primFact = builder.getPrimitiveFactory();
                            WKTParser wktFactory = new WKTParser(geomFact, primFact, null, builder.getAggregateFactory());
                            try {
                                Object expectedResult = wktFactory.parse(operationValue);
                                op.setExpectedResult(expectedResult);
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);
    positions.add(end);

//     create linestring from directpositions
    LineString line = geomF.createLineString(positions);

//     create curvesegments from line
    ArrayList<CurveSegment> segs = new ArrayList<CurveSegment>();
    segs.add(line);
View Full Code Here

      MathTransform transform) throws MismatchedDimensionException, TransformException {

    // loop through each point in this curve and transform it to the new CRS, then
    // use the new points to build a new curve and return that.
    PrimitiveFactory primitiveFactory = new PrimitiveFactoryImpl(newCRS, getPositionFactory());
    GeometryFactory geometryFactory = new GeometryFactoryImpl(newCRS, getPositionFactory());
   
    DirectPositionImpl dp1 = null;
    List<DirectPosition> currentpositions = asDirectPositions();
    Iterator<DirectPosition> iter = currentpositions.iterator();
    List<Position> newpositions = new ArrayList<Position>();
    while (iter.hasNext()) {
      DirectPosition thispos = (DirectPosition) iter.next();
      dp1 = new DirectPositionImpl(newCRS);
      dp1 = (DirectPositionImpl) transform.transform(thispos, dp1);
      newpositions.add(dp1);
    }
   
    // use the new positions list to build a new curve and return it
    LineString lineString = geometryFactory.createLineString(newpositions);
    List curveSegmentList = Collections.singletonList(lineString);
    CurveImpl newCurve = (CurveImpl) primitiveFactory.createCurve(curveSegmentList);
    return newCurve;
     
  }
View Full Code Here

            documentBuilder = documentBuilderFactory.newDocumentBuilder();
        } catch (ParserConfigurationException e) {
            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

      MathTransform transform) throws MismatchedDimensionException, TransformException {

    // loop through each point in this Ring and transform it to the new CRS, then
    // use the new points to build a new Ring and return that.
    PrimitiveFactory primitiveFactory = new PrimitiveFactoryImpl(newCRS, getPositionFactory());
    GeometryFactory geometryFactory = new GeometryFactoryImpl(newCRS, getPositionFactory());
   
    DirectPositionImpl dp1 = null;
    List<DirectPosition> currentpositions = this.asDirectPositions();
    Iterator<DirectPosition> iter = currentpositions.iterator();
    List<Position> newpositions = new ArrayList<Position>();
    while (iter.hasNext()) {
      DirectPosition thispos = (DirectPosition) iter.next();
     
      dp1 = new DirectPositionImpl(newCRS);
      dp1 = (DirectPositionImpl) transform.transform( thispos, dp1);
      newpositions.add(dp1);
    }
   
    // use the new positions list to build a new Ring and return it
    LineString lineString = geometryFactory.createLineString(newpositions);
    List curveSegmentList = Collections.singletonList(lineString);
    CurveImpl newCurve = (CurveImpl) primitiveFactory.createCurve(curveSegmentList);
    ArrayList<OrientableCurve> curveList = new ArrayList<OrientableCurve>();
    curveList.add(newCurve);
    Ring newRing = primitiveFactory.createRing(curveList);
View Full Code Here

            final com.vividsolutions.jts.geom.Geometry jtsGeom,
            final CoordinateReferenceSystem crs) {

        Hints hints = new Hints( Hints.CRS, crs );
        PrimitiveFactory pf = GeometryFactoryFinder.getPrimitiveFactory(hints);
        GeometryFactory gf = GeometryFactoryFinder.getGeometryFactory(hints);

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

    public static DirectPosition coordinateToDirectPosition(
            com.vividsolutions.jts.geom.Coordinate c,
            CoordinateReferenceSystem crs) {
       
        Hints hints = new Hints( Hints.CRS, crs );
        GeometryFactory gf = GeometryFactoryFinder.getGeometryFactory(hints);       
        
        double [] vertices;
        if (crs == null)
            vertices = new double[3];
        else
            vertices = new double[crs.getCoordinateSystem().getDimension()];
        DirectPosition result = gf.createDirectPosition(vertices);
        coordinateToDirectPosition(c, result);
        return result;
    }
View Full Code Here

        if (! jtsLinearRing.getCoordinateN(0).equals(jtsLinearRing.getCoordinateN(numPoints-1))) {
            throw new IllegalArgumentException("LineString must be a ring");
        }
        Hints hints = new Hints( Hints.CRS, crs );
        PrimitiveFactory pf = GeometryFactoryFinder.getPrimitiveFactory(hints);
        GeometryFactory gf = GeometryFactoryFinder.getGeometryFactory(hints);
       
        LineString ls = gf.createLineString(new ArrayList());
        List pointList = ls.getControlPoints();
        for (int i=0; i<numPoints; i++) {
            pointList.add(coordinateToDirectPosition(jtsLinearRing.getCoordinateN(i), crs));
        }
        Curve curve = pf.createCurve(new ArrayList());
View Full Code Here

            } catch (Exception nsace){
                getLog().warn("could not get crs for EPSG:4326");
            }
           
            final BasicFactories commonFactory = BasicFactories.getDefault();
            final GeometryFactory geometryFactory = commonFactory.getGeometryFactory(crs);
           
            final DirectPosition lowerCorner = geometryFactory.createDirectPosition(new double[] { -90, -180 });
            final DirectPosition upperCorner = geometryFactory.createDirectPosition(new double[] { 90, 180 });
           
            WHOLE_WORLD = geometryFactory.createEnvelope(lowerCorner, upperCorner);
        }
        return WHOLE_WORLD;
    }
View Full Code Here

            final double minx,
            final double miny,
            final double maxx,
            final double maxy) {
        final BasicFactories commonFactory = BasicFactories.getDefault();
        final GeometryFactory geometryFactory = commonFactory.getGeometryFactory(crs);
       
        final DirectPosition lowerCorner = geometryFactory.createDirectPosition();
        lowerCorner.setOrdinate(0, minx);
        lowerCorner.setOrdinate(1, miny);
       
        final DirectPosition upperCorner = geometryFactory.createDirectPosition();
        upperCorner.setOrdinate(0, maxx);
        upperCorner.setOrdinate(1, maxy);
       
        return geometryFactory.createEnvelope(lowerCorner, upperCorner);
    }
View Full Code Here

TOP

Related Classes of org.opengis.geometry.coordinate.GeometryFactory

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.