From: Martin D. <mar...@te...> - 2003-10-01 15:22:54
|
Dale Peakall a =E9crit : > println to the rescue! >=20 > I'm finally making progress. The problem appears to be that when > I call setContext() on the StyledMapPane to add my data, the=20 > CoordinateSystem I installed is overwritten with WGS84. Right. The 'setContext(...)' method set the renderer's CS to the=20 BoundingBox's CS (not sure if it was the best idea, any feedback is=20 welcome), and the default BoundingBox's CS is WGS84. I've > searched the API docs surrounding Context, and the only thing that > seems to process a co-ordinate system is a BoundingBox, but these > methods take an org.opengis.cs.CS_CoordinateSystem not an > org.geotools.cs.CoordinateSystem and I have no idea about how to > convert between these - or why the BoundingBox needs a coord > system for that matter. Conversion from CoordinateSystem implementation to CS_CoordinateSystem=20 interface is done as below (using org.geotools.ct.Adapters): CS_CoordinateSystem ogcCS =3D Adapters.getDefault().export(cs); NOTES: - Those interfaces (org.opengis.cs.CS_CoordinateSystem) are going to change!! This is the purpose of the GeoAPI project. - OpenGIS requires that CS interface are RMI aware. Consequently, Adapters.export(...) wrap Geotool's implementation into a RMI-aware OpenGIS interface. One consequence of that is that it may open a socket connection for use with a RMI server. We wish to revisit this issue in the GeoAPI project. We will try to get ride of Adapters in a future version (Geotools=20 implementation should extends interfaces directly). > Here's the code I'm using to create the context. >=20 > // create the context > Context createContext(FeatureCollection features) > { > final ContextFactory factory =3D ContextFactory.createFactory(); > final Context context =3D factory.createContext(); > final Layer layer =3D factory.createLayer(features, style); > layer.setTitle("Boundary Line Data"); > context.getLayerList().addLayer(layer); > context.getBoundingBox().setAreaOfInterest(features.getBounds()); > context.setTitle("GT2BLineDataSourceTest"); > return context; > } Just add yours CS in the 'setAreaOfInterest' method call. Regards, Martin. |