Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.GeometryCollection


        assertTrue( gc.getGeometryN(2) instanceof Polygon );
    }
   
    public void testEncodeMultiGeometry() throws Exception {
        GeometryFactory gf = new GeometryFactory();
        GeometryCollection gc = gf.createGeometryCollection(
            new Geometry[]{
                gf.createPoint( new Coordinate(0,0)),
                gf.createLineString( new Coordinate[]{new Coordinate(0,0), new Coordinate(1,1)}),
                gf.createPolygon(
                    gf.createLinearRing( new Coordinate[] {
View Full Code Here


            }

            list.add(geom);
        }

        GeometryCollection geoms = gf.createGeometryCollection(toGeometryArray(
                    list));
        geoms.setSRID(SRID);

        return geoms;
    }
View Full Code Here

    private void validateOGCUnitUsage(double distance, String unit) throws Exception {
        Coordinate coordinate = new Coordinate(3.031, 2.754);
        GeometryFactory factory = new GeometryFactory();
        Point point = factory.createPoint(coordinate);
        Geometry[] geometries = {point};
        GeometryCollection geometry = new GeometryCollection(geometries, factory );

        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);

        PropertyName geomName = ff.property(aname("geom"));
        Literal lit = ff.literal(geometry);
View Full Code Here

            if (cnode.getValue() instanceof Geometry) {
                geoms.add(cnode.getValue());
            }
        }

        GeometryCollection gc = null;
       
        if (MultiPoint.class.isAssignableFrom(clazz)) {
            gc = gFactory.createMultiPoint((Point[]) geoms.toArray(new Point[geoms.size()]));
        }
        else if (MultiLineString.class.isAssignableFrom(clazz)) {
            gc = gFactory.createMultiLineString(
                (LineString[]) geoms.toArray(new LineString[geoms.size()]));
        }
        else if (MultiPolygon.class.isAssignableFrom(clazz)) {
            gc = gFactory.createMultiPolygon((Polygon[]) geoms.toArray(new Polygon[geoms.size()]));
        }
       
        else {
            gc = gFactory.createGeometryCollection((Geometry[]) geoms.toArray(
                new Geometry[geoms.size()]));
        }
       
        //set an srs if there is one
        CoordinateReferenceSystem crs = crs(node);

        if (crs != null) {
            gc.setUserData(crs);

            // since we're setting the CRS on the UserData object, might as well set the SRID for the geom
            // collection
            try {
                gc.setSRID(CRS.lookupEpsgCode(crs, true));
            } catch (FactoryException e) {
                // as long as the provided CRS is valid, this block will be unreachable
            }
        }
       
View Full Code Here

            crs = coverage.getCoordinateReferenceSystem();
        }
        GeneralEnvelope bounds = new GeneralEnvelope(new ReferencedEnvelope(cropShape.getEnvelopeInternal(), crs));

        // force it to a collection if necessary
        GeometryCollection roi;
        if (!(cropShape instanceof GeometryCollection)) {
            roi = cropShape.getFactory().createGeometryCollection(new Geometry[] { cropShape });
        } else {
            roi = (GeometryCollection) cropShape;
        }
View Full Code Here

                }, null, null);

        GMLGeometryCollectionTypeBinding s = (GMLGeometryCollectionTypeBinding) container
            .getComponentInstanceOfType(GMLGeometryCollectionTypeBinding.class);

        GeometryCollection gc = (GeometryCollection) s.parse(gcol, node, null);
        assertNotNull(gc);
        assertEquals(gc.getNumGeometries(), 2);
        assertTrue(gc.getGeometryN(0) instanceof Point);
        assertTrue(gc.getGeometryN(1) instanceof Point);
        assertEquals(((Point) gc.getGeometryN(0)).getX(), 0d, 0d);
        assertEquals(((Point) gc.getGeometryN(0)).getY(), 0d, 0d);
        assertEquals(((Point) gc.getGeometryN(1)).getX(), 1d, 0d);
        assertEquals(((Point) gc.getGeometryN(1)).getY(), 1d, 0d);
    }
View Full Code Here

                }, null, null);

        GMLGeometryCollectionTypeBinding s = (GMLGeometryCollectionTypeBinding) container
            .getComponentInstanceOfType(GMLGeometryCollectionTypeBinding.class);

        GeometryCollection gc = (GeometryCollection) s.parse(gcol, node, null);
        assertNotNull(gc);
        assertEquals(gc.getNumGeometries(), 5);
        assertTrue(gc.getGeometryN(0) instanceof Point);
        assertTrue(gc.getGeometryN(1) instanceof Point);
        assertTrue(gc.getGeometryN(2) instanceof LineString);
        assertTrue(gc.getGeometryN(3) instanceof LinearRing);
        assertTrue(gc.getGeometryN(4) instanceof Polygon);
    }
View Full Code Here

      builder.add("centerline", line.getClass());
    builder.add("name", String.class);
    SimpleFeatureType lrType = builder.buildFeatureType();
    SimpleFeature ringFeature = SimpleFeatureBuilder.build(lrType, new Object[] { ring, "centerline" }, null);

    GeometryCollection coll = makeSampleGeometryCollection(geomFac);
    builder.setName(COLLECTION);
    if (crs != null)
      builder.add("collection", coll.getClass(), crs);
    else
      builder.add("collection", coll.getClass());
    builder.add("name", String.class);
    SimpleFeatureType collType = builder.buildFeatureType();
    SimpleFeature collFeature = SimpleFeatureBuilder.build(collType, new Object[] { coll, "collection" }, null);

    MemoryDataStore data = new MemoryDataStore();
View Full Code Here

                }, null, null);

        GMLGeometryAssociationTypeBinding s = (GMLGeometryAssociationTypeBinding) getBinding(GML.GEOMETRYASSOCIATIONTYPE);
        GMLMultiGeometryPropertyTypeBinding s1 = (GMLMultiGeometryPropertyTypeBinding) getBinding(GML.MULTIGEOMETRYPROPERTYTYPE);

        GeometryCollection p = (GeometryCollection) s1.parse(association, node,
                s.parse(association, node, null));
        assertNotNull(p);
    }
View Full Code Here

   
    void drawGeometry(Geometry g, Graphics2D g2, int series, int item, Rectangle2D dataArea,
            XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis) {
       
        if (g instanceof GeometryCollection) {
            GeometryCollection gc = (GeometryCollection) g;
            for (int i = 0; i < gc.getNumGeometries(); i++) {
                drawGeometry(
                    gc.getGeometryN(i), g2, series, item, dataArea, plot, domainAxis, rangeAxis);
            }
        }
        else if (g instanceof Point) {
            drawCoordinate(((Point)g).getCoordinate(), g2, series, item, dataArea, plot, domainAxis,
                rangeAxis);
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.