I think the hint applies to the ISO Geometry classes.

Yep that is what the javadocs say:

/**
 * The {@link org.opengis.referencing.crs.CoordinateReferenceSystem} to use in
 * ISO geometry factories.
 *
 * @see #JTS_SRID
 * @since 2.5
 */
public static final Key CRS = new 
Key("org.opengis.referencing.crs.CoordinateReferenceSystem");

The JTSFactoryFinder does list the respected hints:

/**
 * Returns the first implementation of {@link GeometryFactory} matching the 
specified hints.
 * If no implementation matches, a new one is created if possible or an 
exception is thrown
 * otherwise.
 * <p>
 * Hints that may be understood includes
 * {@link Hints#JTS_COORDINATE_SEQUENCE_FACTORY 
JTS_COORDINATE_SEQUENCE_FACTORY},
 * {@link Hints#JTS_PRECISION_MODEL  JTS_PRECISION_MODEL} and
 * {@link Hints#JTS_SRID JTS_SRID}.
 *
 * @param hints An optional map of hints, or {@code null} if none.
 * @return The first geometry factory that matches the supplied hints.
 * @throws FactoryRegistryException if no implementation was found or can be 
created for the
 *  {@link GeometryFactory} category and the given hints.
 */


For background:

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

Still the idea of asking the JTSFactoryFinder to respect the hint is 
interesting; however we do not provide the GeometryFactory class ourselves (so 
we cannot modify it to accept a default user data value).

-- 
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 <[email protected]>
> > 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
> 
------------------------------------------------------------------------------
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