Note that we do store the CoordinateReferenceSystem object in the FeatureType (and not the geometry).

See the diagram below for GeometryType and FeatureType - both provide a getCoordinateReferenceSystem() method.

- http://docs.geotools.org/latest/userguide/guide/library/opengis/model.html

-- 
Jody Garnett

On Thursday, 31 March 2011 at 11:22 AM, Oleksandr Huziy wrote:

Hello,

I solved the problem with null crs of the feature adding 1 line

Hints hints = new Hints();
        hints.put(Hints.CRS, re.getCoordinateReferenceSystem());
        geometryFactory = JTSFactoryFinder.getGeometryFactory(hints);
        simpleFeatureTypeBuilder.add("geometry", Polygon.class);
        simpleFeatureTypeBuilder.setCRS(re.getCoordinateReferenceSystem());
        simpleFeatureTypeBuilder.setName("polygon");
        SimpleFeatureType type = simpleFeatureTypeBuilder.buildFeatureType();
       
        type = DataUtilities.createSubType(type, null, DefaultGeographicCRS.WGS84);

then created the feature as earlier. So now the purpose of hints is not clear.


--
Oleksandr Huziy

2011/3/30 Oleksandr Huziy <guziy.sasha@gmail.com>
Hello again,

another method I am trying to use to create a polygon is:

     Hints hints = new Hints();
        hints.put(Hints.CRS, DefaultGeographicCRS.WGS84);
        geometryFactory = JTSFactoryFinder.getGeometryFactory(hints);
        simpleFeatureTypeBuilder.add("geometry", Polygon.class);
        simpleFeatureTypeBuilder.setName("polygon");
        SimpleFeatureType type = simpleFeatureTypeBuilder.buildFeatureType();

        Coordinate[] coords = new Coordinate[5];
        double x0, y0, dx, dy;
        x0 = re.getMinX();
        y0 = re.getMinY();
        dx = re.getWidth();
        dy = re.getHeight();

        coords[0] = new Coordinate(x0, y0);
        coords[1] = new Coordinate(x0, y0 + dy);
        coords[2] = new Coordinate(x0 + dx, y0 + dy);
        coords[3] = new Coordinate(x0 + dx, y0);
        coords[4] = coords[0];


        Polygon polygon = geometryFactory.createPolygon(geometryFactory.createLinearRing(coords), null);
        SimpleFeature feature = SimpleFeatureBuilder.build( type, new Object[]{ polygon }, null);
 

but when I try to access crs of the feature it gives me null (i.e. feature.getFeatureType().getCoordinateReferenceSystem()),
and as a consequence I get the following error while trying to draw it:

Mar 30, 2011 2:08:16 PM org.geotools.map.MapContext getLayerBounds
SEVERE: It was not possible to get a projected bounds estimate

But it is drawn ok.

And while we are at this, how can I specify bounds of MapContext in coordinates, for example, if I want it to have an extent
-180, 180; -90, 90 ?

thank you very much
--
Oleksandr Huziy





------------------------------------------------------------------------------
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself;
WebMatrix provides all the features you need to develop and
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
_______________________________________________
Geotools-gt2-users mailing list
Geotools-gt2-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users