thanks, geometries are read from oracle and converted by OraReader to
JTS geometry.
anyway I solved it with MemoryFeatureCollection class

this is currently my class, just one feature is created ... problem is
that resulting svg file is without this feature. what did I forgot ?

public class SvgExport {

    public static class MyFeature extends DefaultFeature {
        public MyFeature(Object[] attributes, String featureId,
DefaultFeatureType ftType) throws IllegalAttributeException {
          super(
            ftType,
            attributes,
            featureId);
        }
      }

    public Feature createFeature (Geometry geom, DefaultFeatureType
ftType) throws IllegalAttributeException {
        return new MyFeature( new Object[] { geom }, "1", ftType);
    }

    public void build(Vector ifeatures) {

        try {
            FeatureTypeBuilder builder = FeatureTypeFactory
            .newInstance("test");

            builder.addType(
                    AttributeTypeFactory.newAttributeType("the_geom",
LineString.class /*MultiPolygon.class*/, true));

            DefaultFeatureType ftType = (DefaultFeatureType)
builder.getFeatureType();

            MemoryFeatureCollection features = new
MemoryFeatureCollection(ftType);

            // vlozime geometrie
            /*
            Iterator it = ifeatures.iterator();
            while(it.hasNext()) {
                features.add(it.next());
            }
            */
            WKTReader wktReader = new WKTReader();
            LineString geometry = (LineString) wktReader
            .read("LINESTRING (0 0, 10 10)");
            features.add(createFeature(geometry, ftType));

            GenerateSVG genSVG = new GenerateSVG();

            MapLayer[] layers = new DefaultMapLayer[1];
            layers[0] = new DefaultMapLayer(features, new
BasicPolygonStyle());

            MapContext mapContext = new DefaultMapContext(layers);
            Envelope envelope = new Envelope(100, -100, 100, -100);

            FileOutputStream fout = new FileOutputStream("c:/pokus6.svg");
            genSVG.go(mapContext, envelope, fout);


        } catch (FactoryRegistryException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (NullPointerException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IllegalArgumentException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (SchemaException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (ParserConfigurationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (ParseException e) {
            e.printStackTrace();
        } catch (IllegalAttributeException e) {
            e.printStackTrace();
        }

    }

}

On 10/11/06, Gabriel Roldán <[EMAIL PROTECTED]> wrote:
> Where your geometries come from? Are they in some kind of spatial storage like
> a shapefile, Oracle Spatial, PostGIS, etc?
>
> The way to obtain the featurecollection from your storage medium is to use a
> DataStore (think of it as the JDBC driver for your database, but in GIS)
> So, depending on where your features are, you have to use one or another.
> There are plenty of them on geotools and hopefully you'll find one
> appropriate.
>
> Read the following section on the user guide on how to use DataStores:
> http://docs.codehaus.org/display/GEOTOOLS/Data+Reading
>
> You may find a couple API differencies depending on if you're using version
> 2.2 or 2.3+
>
> I can't remember if DefaultMapLayer expects a FeatureResults or a
> FeatureCollection, but anyways you can get the FeatureCollection from the
> FeatureResults.getFeatures()
>
> regards,
>
> Gabriel
>
> PS: I could have written something wrong, since I'm writing from the top of my
> head, but I guess you'll easily find the way through the user docs pointed
> out above.
>
> On Wednesday 11 October 2006 10:51, Jan Gregor wrote:
> > Hi,
> >
> >  I want to export my geometries that are located outside datasource to
> > svg format.
> > In geotools is class org.geotools.svg.GenerateSVG and method go to do
> > that, but i don't know how to put features in DefaultMapLayer.
> >
> > this link could help, but i can't find class PFeatureCollection :
> > http://docs.codehaus.org/display/GEOTOOLS/How+to+create+a+simple+FeatureCol
> >lection+from+Scratch?showComments=false
> >
> > my target is to put polygons in svg, each with different color. so
> > just geometries. any help would be welcomed.
> >
> > thanks,
> > Jan
> >
> >
> >         GenerateSVG genSVG = new GenerateSVG();
> >
> >         MapLayer[] layers = new DefaultMapLayer[1];
> >         layers[0] = new DefaultMapLayer(features, new BasicPolygonStyle());
> >
> >         MapContext mapContext = new DefaultMapContext(layers);
> >         Envelope envelope = new Envelope();
> >
> >         FileOutputStream fout = new FileOutputStream("c:/pokus.svg");
> >         genSVG.go(mapContext, envelope, fout);
> >
> > -------------------------------------------------------------------------
> > Using Tomcat but need to do more? Need to support web services, security?
> > Get stuff done quickly with pre-integrated technology to make your job
> > easier Download IBM WebSphere Application Server v.1.0.1 based on Apache
> > Geronimo
> > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> > _______________________________________________
> > Geotools-gt2-users mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>
> --
> Gabriel Roldán ([EMAIL PROTECTED])
> Axios Engineering (http://www.axios.es)
> Tel. +34 944 41 63 84
> Fax. +34 944 41 64 90
>
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to