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
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to