Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.GeometryCollection


       * @throws IOException if an error occurs during encoding
       */
      protected void writeFeature(SimpleFeature ft,Style style,FeatureTypeStyle[] fts) throws IOException {
        reset(ft);
       
        GeometryCollection geomCollection = (GeometryCollection) ft.getDefaultGeometry();
       
        for (int i = 0; i < geomCollection.getNumGeometries(); i++) {
          Geometry geom=geomCollection.getGeometryN(i);
         
                Class<?> gtype = geom.getClass();

                // retrieves the right feature writer (based on the current geometry type)
                delegateWriter = (HTMLImageMapFeatureWriter) writers.get(gtype);
View Full Code Here


     * @param geom
     * @throws IOException
     */
    private void writeGeometry(String layer, String ownerHandle, Geometry geom) throws IOException {
        if (geom instanceof GeometryCollection) {
            GeometryCollection coll = (GeometryCollection) geom;
            for (int count = 0; count < coll.getNumGeometries(); count++)
                writeGeometry(layer, ownerHandle, coll.getGeometryN(count));
        } else if (geom instanceof Polygon) {
            Polygon p = (Polygon) geom;
            writeGeometry(layer, ownerHandle, p.getExteriorRing());
            for (int count = 0; count < p.getNumInteriorRing(); count++)
                writeGeometry(layer, ownerHandle, p.getInteriorRingN(count));
View Full Code Here

    final double x2 = this.defaultViewEnvelope.getMinX() + (2 * expectedScreenX2);
    final double y2 = this.defaultViewEnvelope.getMinY() + (2 * expectedScreenY2);
    Point point = this.geometryFactory.createPoint( new Coordinate( x1, y1 ) );
    LineString line = this.geometryFactory.createLineString( LimbGeneratorTest.Utils.createCoords( "" + x1 + " " + y1 +", " + x2 + " " + y2 ) );
    MultiLineString multiLine = this.geometryFactory.createMultiLineString( new LineString[]{ line, line } );
    GeometryCollection innerCollection = this.geometryFactory.createGeometryCollection( new Geometry[]{ point, line } );
    GeometryCollection outerCollection = this.geometryFactory.createGeometryCollection( new Geometry[]{ multiLine, innerCollection } );
    // It's important to re-use the same line object multiple times.
    // We're then able to verify that the cloning process takes a deep copy of the geometry collection.
    // A shallow copy will result in the transform being applied several times to the same line object.
    // (Interestingly, outerCollection.clone() takes a deep copy
    //  but GeometryFactory::createGeometry( outerCollection ) takes a shallow copy.)
   
    Limb limb = new Limb();
    limb.setIntersection( outerCollection );
   
    Options options = new Options();
    options.setScreenSize( this.halfScreenSize );
   
    PositionAssignmentLimbRefiner testObj = new PositionAssignmentLimbRefiner();
    testObj.refine( limb, this.defaultView, options );
   
    assertTrue( limb.getPosition() instanceof GeometryCollection );
    GeometryCollection position = (GeometryCollection)limb.getPosition();
    assertTrue( position.getGeometryN( 0 ) instanceof MultiLineString );
    MultiLineString position1 = (MultiLineString)position.getGeometryN( 0 );
    assertTrue( position1.getGeometryN( 0 ) instanceof LineString );
    LineString multiLine1 = (LineString)position1.getGeometryN( 0 );
    assertEquals( expectedScreenX1, multiLine1.getCoordinateN( 0 ).x, DOUBLE_TOLERANCE );
    assertEquals( expectedScreenY1, multiLine1.getCoordinateN( 0 ).y, DOUBLE_TOLERANCE );
    assertEquals( expectedScreenX2, multiLine1.getCoordinateN( 1 ).x, DOUBLE_TOLERANCE );
    assertEquals( expectedScreenY2, multiLine1.getCoordinateN( 1 ).y, DOUBLE_TOLERANCE );
    assertTrue( position1.getGeometryN( 1 ) instanceof LineString );
    LineString multiLine2 = (LineString)position1.getGeometryN( 1 );
    assertEquals( expectedScreenX1, multiLine2.getCoordinateN( 0 ).x, DOUBLE_TOLERANCE );
    assertEquals( expectedScreenY1, multiLine2.getCoordinateN( 0 ).y, DOUBLE_TOLERANCE );
    assertEquals( expectedScreenX2, multiLine2.getCoordinateN( 1 ).x, DOUBLE_TOLERANCE );
    assertEquals( expectedScreenY2, multiLine2.getCoordinateN( 1 ).y, DOUBLE_TOLERANCE );
    assertTrue( position.getGeometryN( 1 ) instanceof GeometryCollection );
    GeometryCollection position2 = (GeometryCollection)position.getGeometryN( 1 );
    assertTrue( position2.getGeometryN( 0 ) instanceof Point );
    Point point1 = (Point)position2.getGeometryN( 0 );
    assertEquals( expectedScreenX1, point1.getX(), DOUBLE_TOLERANCE );
    assertEquals( expectedScreenY1, point1.getY(), DOUBLE_TOLERANCE );
    assertTrue( position2.getGeometryN( 1 ) instanceof LineString );
    LineString line1 = (LineString)position2.getGeometryN( 1 );
    assertEquals( expectedScreenX1, line1.getCoordinateN( 0 ).x, DOUBLE_TOLERANCE );
    assertEquals( expectedScreenY1, line1.getCoordinateN( 0 ).y, DOUBLE_TOLERANCE );
    assertEquals( expectedScreenX2, line1.getCoordinateN( 1 ).x, DOUBLE_TOLERANCE );
    assertEquals( expectedScreenY2, line1.getCoordinateN( 1 ).y, DOUBLE_TOLERANCE );
  }
View Full Code Here

   
    Geometry line = this.geometryFactory.createLineString( new Coordinate[]{ new Coordinate( 34.474, 843.487 ),
                                                                             new Coordinate( 942.42, 4.47452 ),
                                                                             new Coordinate( 3562.4, 95633.1 ) } );
   
    GeometryCollection geometryCollection = this.geometryFactory.createGeometryCollection( new Geometry[]{ polygon, point, line } );
    this.geoJsonWriter.value( geometryCollection );
   
    assertEquals( "{\"type\":\"GeometryCollection\",\"geometries\":[{\"type\":\"Polygon\",\"coordinates\":[[[0,0],[0,5],[5,5],[5,0],[0,0]],[[1,1],[1,2],[2,2],[2,1],[1,1]],[[3,3],[3,4],[4,4],[4,3],[3,3]]]},{\"type\":\"Point\",\"coordinates\":[50.6,124.59]},{\"type\":\"LineString\",\"coordinates\":[[34.474,843.487],[942.42,4.47452],[3562.4,95633.1]]}]}", this.geoJsonBuffer.toString() );
  }
View Full Code Here

        // Handle union
        if (unionResults) {
          GeometryFactory geoFactory = new GeometryFactory();
          Geometry[] geos = new Geometry[resultGeometries.size()];
          resultGeometries.toArray(geos);
          GeometryCollection geoCollection = geoFactory
              .createGeometryCollection(geos);
          resultGeometries = new ArrayList<Geometry>();
          resultGeometries.add(geoCollection.union());
        }
      }

      // Various out format
      if ("json".equals(f)) {
View Full Code Here

 
  @Override
  public void write(Object[] input){
    logger.debug("writing "+this.fileName+" ...");
    Geometry[] geometries = (Geometry[])input;
    GeometryCollection coll = new GeometryCollection(geometries, new GeometryFactory(new PrecisionModel(PrecisionModel.FLOATING),4030));
   
    //write geometries
    try{
      shpWriter.skipHeaders();
      shpWriter.write(coll,ShapeType.POLYGON);
View Full Code Here

        ArrayList<Point> pList = new ArrayList<>(commands.size());
        for (GCodeCommand c : commands) {
            if(c.type == GCodeCommand.Type.MOVE)
                pList.add(JTSUtils.createPoint2D(c.x, c.y));
        }
        GeometryCollection g = new GeometryCollection(pList.toArray(new Point[pList.size()]), JTSUtils.getFactory());
        return g.convexHull();
    }
View Full Code Here

            if(s != null){
                polys[i] = JTSUtils.createMultiPolygon(s);
            }
        }
       
        GeometryCollection gc;
        gc = JTSUtils.getFactory().createGeometryCollection(polys);
       
        Geometry union = gc.buffer(0);
        return JTSUtils.toShape(union);
    }
View Full Code Here

                        geomsArray = new Geometry[walkShedEdges.size()];
                        int k = 0;
                        for (LineString ls : walkShedEdges.values())
                            geomsArray[k++] = ls;
                    } // end if-else: maxTime condition
                    GeometryCollection gc = gf.createGeometryCollection(geomsArray);
                    // create the concave hull, but in case it fails we just return the convex hull
                    Geometry outputHull = null;
                    LOG.debug(
                            "create concave hull from {} geoms with edge length limit of about {} m (distance on meridian)",
                            geomsArray.length, concaveHullAlpha * 111132);
                    // 1deg at Latitude phi = 45deg is about 111.132km
                    // (see wikipedia: http://en.wikipedia.org/wiki/Latitude#The_length_of_a_degree_of_latitude)
                    try {
                        ConcaveHull hull = new ConcaveHull(gc, concaveHullAlpha);
                        outputHull = hull.getConcaveHull();
                    } catch (Exception e) {
                        outputHull = gc.convexHull();
                        LOG.debug("Could not generate ConcaveHull for WalkShed, using ConvexHull instead.");
                    }
                    LOG.debug("write shed geom");
                    geometryJSON.write(outputHull, sw);
                    LOG.debug("done");
View Full Code Here

      Coordinate[] c = new Coordinate[] { coord[i] };
      CoordinateArraySequence cs = new CoordinateArraySequence(c);
      geometries[i] = new Point(cs, geom.getFactory());
    }
   
    return new GeometryCollection(geometries, geom.getFactory());
  }
View Full Code Here

TOP

Related Classes of com.vividsolutions.jts.geom.GeometryCollection

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.