Hello,

I got an idea to do what I described above, from the DefaultFeature class.

First, we create a new class extending DefaultFeature :

public class _4_ExtendsFeature extends DefaultFeature{
    static DefaultFeatureType type;

    static {
        try{
            type = getTestFeatureType();
        }catch(SchemaException se){}
    }


    public _4_ExtendsFeature()throws SchemaException{
        super(
                type,
                new Object[]{null,"test",0},
                "TestFeature");
    }
}

To describe the FeatureType, we create a static method, like this :

public static DefaultFeatureType getTestFeatureType() throws
SchemaException{
        GeometryAttributeType geom =
(GeometryAttributeType)AttributeTypeFactory.newAttributeType("geom",
Point.class, true, 1, null, DefaultGeographicCRS.WGS84);
        AttributeType name = AttributeTypeFactory.newAttributeType("name",
String.class, true);
        NumericAttributeType number =
(NumericAttributeType)AttributeTypeFactory.newAttributeType("number",
Integer.class, true);

        FeatureTypeBuilder builder = FeatureTypeBuilder.newInstance("Sensor
Site");
        builder.addType(geom);
        builder.addType(name);
        builder.addType(number);

        builder.setName("Test Feature");

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

        return type;
}

But there are (I think) many problems in this idea :

   - first, there are a lot of class in gt and geoapi for doing this kind
   of things. Many are deprecated, and maybe many are going to become
   deprecated ? So I would like to know if this choice is good for the future ?
   (for instance, AttributeType - used here - is flagged deprecated, so ...?)
   - second, it does not allow to extend a type from another one :
   FeatureTypeBuilder does not contain



2008/4/10, Anaxa Gore <[EMAIL PROTECTED]>:
>
> And did you already get some information about how to do that... Because I
> could'nt find anything about that...
>
> Thomas
>
> 2008/4/10, [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
> >
> > Same for me. I'm actually investigating the way primitives and feature
> > types can be combined into real-world objects.
> >
> > >----- Oorspronkelijk bericht -----
> > >Van: Anaxa Gore [mailto:[EMAIL PROTECTED]
> > >Verzonden: donderdag, april 10, 2008 12:28 PM
> > >Aan: 'Geotools users list'
> > >Onderwerp: [Geotools-gt2-users] [GeoTools-gt2-users] Creating a
> > personal       Feature with personal FeatureType
> >
> > >
> > >Hello,
> > >
> > >My application is using a "model" (MVC architecture).
> > >This model is composed of many classes, describing the different
> > objects
> > >manipulating by the user. For example
> > >
> > >public class SensorSiteStation{
> > >    /** The height of sensors. */
> > >    private double height;
> > >    /** The x coordinate of the place. */
> > >    private double x;
> > >    /** The y coordinate of the place. */
> > >    private double y;
> > >    /** The terrain elevation of the place. */
> > >    private double tElev;
> > >    /** The name of the place */
> > >    private String name;
> > >
> > >    /** The feature associated with the [EMAIL PROTECTED] 
> > > SensorSiteStation}. */
> > >    SimpleFeature mssSensorSiteFeature;
> > >    /** The feature type assoiated with the [EMAIL PROTECTED] 
> > > SensorSiteStation}.
> > */
> > >    SimpleFeatureType mssSensorSiteType;
> > >}
> > >
> > >As you can see, each class of my model is composed of a SimpleFeature
> > and
> > >its associated SimpleFeatureType, plus its java attributes.
> > >But I think this is not a good implementation because informations are
> > >redundant in this class (we can find in the FeatureType the height, the
> > >coordinate, the tElev, the name...).
> > >
> > >So I would like to have directly a model class which is a Feature. This
> > kind
> > >of implementation seems to be more efficient and logical.
> > >
> > >I searched how to do that, but can't know what is the best way... and
> > can't
> > >find the global architecture for creating its own feature..
> > >Do I have to create a class which implements SimpleFeature ? But then,
> > there
> > >is A LOT OF work to implement all methods... What sort of Feature and
> > >FeatureType do we have to use ? SimpleFeature and SimpleFeatureType
> > from
> > >geoapi or DefaultFeature and DefaultFeatureType from gt ?
> > >
> > >If somebody already tried to do that, I would be grateful for a piece
> > of
> > >code, an idea or a link..
> > >
> > >Thanks
> > >Thomas
> > >
> >
> >
> >
>
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to