Hey Thomas,

I'm having more or less the same experience when searching GeoTools' code base 
for state information. But you did find some builder/factory classes I didn't 
know about. :-)

First: It's my observation too. It's confusing to know which one to use for 
base geotries. But I have the impression the geoapi is coming up at the expense 
of the geotools primitives. But I might be wrong though...

Second: I don't know about the feature type builder, but I've found another way 
that allows for super types - multiple inheritance ? - but it's really trying 
until it does compile and run without errors: SimpleFeature's constructor. See 
the code extract. Probably you'll get a natural subclassing just by subclassing 
the java classes. 

Finally: I don't have an answer myself just yet to that, but the symbolizers 
seem to be able to cope with these classes already... So I guess we're looking 
to a transition phase in the product to delegate state modeling to the geoapi 
instead of maintaining it's own solution.

But as I'm doing my first steps too, I'm mainly guessing how to make it work. 
I'm currently trying to find out how to maintain a dynamic collection of 
features in memory - for simulation purposes.

******* some clunky code trial to start learning the state modeling in geotools 
************

import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Point;
import com.vividsolutions.jts.geom.PrecisionModel;

import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;

import org.geotools.factory.BasicFactories;
import org.geotools.feature.GeometryAttributeType;
import org.geotools.feature.SchemaException;
import org.geotools.feature.SimpleFeatureType;
import org.geotools.feature.type.GeometricAttributeType;
import org.geotools.feature.type.TextualAttributeType;
import org.geotools.referencing.crs.DefaultGeographicCRS;
import org.opengis.feature.type.AttributeType;

/**
 * Feature describing a Person somewhere on the planet
 * 
 * @author Jan Goyvaerts
 * @since Now
 */
public class PersonType extends SimpleFeatureType {

  private static final Collection ATTRIBUTE_TYPES = new HashSet();

  private static final GeometryAttributeType GEO_ATTR_TYPE;

  static {
    // just guessing about the nillable, min, max and filter
    ATTRIBUTE_TYPES.add( new TextualAttributeType("Name", false, 0, 0, "", null 
) );
    // just guessing about the default value, filter and precision model
    GEO_ATTR_TYPE = new GeometricAttributeType( "Location", Point.class, false, 
new Point( new Coordinate( 0.0, 0.0, 0.0 ), new PrecisionModel( 0.0001 ), 0 ), 
DefaultGeographicCRS.WGS84, null );
  }

  public PersonType() throws SchemaException, NullPointerException {
    // type = Person
    // namespace = org.jan
    // attributes = ATTRIBUTE_TYPES
    // super types = none (Collections.EMPTY_SET) but might have been the super 
types
    // geometry = Point
    super( "Person", "org.jan", ATTRIBUTE_TYPES, Collections.EMPTY_SET, 
GEO_ATTR_TYPE );
  }

  public static void main( String[] args ) throws Exception {
    PersonType type = new PersonType();
    System.out.println( "We managed to create: " + type );
  }

}



On Thu, 10 Apr 2008 16:48:40 +0200
"Anaxa Gore" <[EMAIL PROTECTED]> wrote:

> Sorry...This is the end of my message... :-(
> 
> 
>    - second, it does not allow to extend a type from another one :
>    FeatureTypeBuilder does not seems to provide a "FeatureType[] superTypes"
>    field.
>    - Finally, all types used in shapefiles hanlding (for examples) are
>    types from geoapi and not gt ... so how can I pass from one to another ????
> 
> If you have any advice on my code or on the api to prefer (gt or geoapi),
> please give it !
> Thomas
> 
> 2008/4/10, Anaxa Gore <[EMAIL PROTECTED]>:
> >
> > 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
> > > > >
> > > >
> > > >
> > > >
> > >
> >
> 


-- 
Jan Goyvaerts <[EMAIL PROTECTED]>

-------------------------------------------------------------------------
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