Hello Amador, I'm moving your question to the user list.
Just in case... Rob's answer will guide you to storing multiple geometries in individual features. Is this what you were asking about or did you want to know how to create separate feature types and map layers for different types of geometries ? Michael On 30 April 2010 10:16, Rob Atkinson <[email protected]> wrote: > you need the application-schema support > > see http://docs.geoserver.org/2.0.0/user/data/app-schema/index.html > > Rob Atkinson > > On Fri, Apr 30, 2010 at 12:15 AM, Amador Antonio Cuenca > <[email protected]> wrote: >> I've the follow code, but I can't add multiple geometries because my >> SimpleFeatureType is "hard coded", how do I to load the type of feature >> dinamyc? >> >> package demo.geometry01; >> >> import com.vividsolutions.jts.geom.Coordinate; >> import com.vividsolutions.jts.geom.Geometry; >> import com.vividsolutions.jts.geom.GeometryFactory; >> import com.vividsolutions.jts.geom.LinearRing; >> import com.vividsolutions.jts.geom.Polygon; >> import org.geotools.data.DataUtilities; >> import org.geotools.feature.FeatureCollection; >> import org.geotools.feature.FeatureCollections; >> import org.geotools.feature.simple.SimpleFeatureBuilder; >> >> import org.geotools.geometry.jts.JTSFactoryFinder; >> import org.geotools.map.DefaultMapContext; >> import org.geotools.map.MapContext; >> import org.geotools.swing.JMapFrame; >> import org.opengis.feature.simple.SimpleFeature; >> import org.opengis.feature.simple.SimpleFeatureType; >> >> public class SimpleGeometryLab { >> >> GeometryFactory gf = JTSFactoryFinder.getGeometryFactory(null); >> FeatureCollection col = FeatureCollections.newCollection(); >> SimpleFeatureBuilder sfb; >> FeatureCollection<SimpleFeatureType, SimpleFeature> miCol = >> FeatureCollections.newCollection(); >> MapContext map; >> JMapFrame frame; >> >> public static void main(String[] args) throws Exception { >> SimpleGeometryLab me = new SimpleGeometryLab(); >> } >> >> public SimpleGeometryLab() throws Exception { >> map = new DefaultMapContext(); >> frame = new JMapFrame(map); >> map.setTitle("Geometrias simples"); >> >> //Here my problem... ¬¬ >> SimpleFeatureType TYPE = DataUtilities.createType( >> "Location", >> "location:Point:srid=4326," >> + "name:String"); >> sfb = new SimpleFeatureBuilder(TYPE); >> >> sfb.add(crearPunto(10, 30)); >> sfb.add(crearLinea()); >> SimpleFeature feat = sfb.buildFeature(null); >> miCol.add(feat); >> >> map.addLayer(miCol, null); >> frame.setSize(800, 600); >> frame.setVisible(true); >> } >> >> private Geometry crearPunto(int x, int y) { >> Coordinate c = new Coordinate(x, y); >> return gf.createPoint(c); >> } >> >> //Not in use >> private Geometry crearLinea() { >> Coordinate[] c = new Coordinate[]{ >> new Coordinate(100, 112), >> new Coordinate(200, 100), >> new Coordinate(85, 46) >> }; >> return gf.createLineString(c); >> } >> >> //Not in use >> private Geometry createCircle(double x, double y, final double r) { >> final int l = 32; >> Coordinate coords[] = new Coordinate[l + 1]; >> for (int i = 0; i < l; i++) { >> double angle = ((double) i / (double) l) * Math.PI * 2.0; >> double dx = Math.cos(angle) * r; >> double dy = Math.sin(angle) * r; >> coords[i] = new Coordinate((double) x + dx, (double) y + dy); >> } >> coords[l] = coords[0]; >> >> LinearRing ring = gf.createLinearRing(coords); >> Polygon polygon = gf.createPolygon(ring, null); >> >> return polygon; >> } >> >> } >> >> -- >> TSU. Amador Cuenca >> >> ------------------------------------------------------------------------------ >> >> _______________________________________________ >> Geotools-devel mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/geotools-devel >> >> > > ------------------------------------------------------------------------------ > _______________________________________________ > Geotools-devel mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/geotools-devel > ------------------------------------------------------------------------------ _______________________________________________ Geotools-gt2-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
