On Friday, June 15, 2012 05:16:31 AM George Schole wrote:
> By the way how can i progamatically change the projection of a map?
You could use the ChangeCRSCommand
...
getMap().sendCommandSync(new ChangeCRSCommand(result));
...
> Or
> change the projection ofa layer if the first is not possible
To reproyect a layer you should transform each geometry. I have extracted the following idea from http://docs.geotools.org/stable/userguide/examples/crslab.html#exporting-reprojected-data-to-a-shapefile
SimpleFeatureIterator iterator = featureCollection.features();
try {
while( iterator.hasNext() ){
// copy the contents of each feature and transform the geometry
SimpleFeature feature = iterator.next();
SimpleFeature copy = writer.next();
copy.setAttributes( feature.getAttributes() );
Geometry geometry = (Geometry) feature.getDefaultGeometry();
Geometry geometry2 = JTS.transform(geometry, transform);
copy.setDefaultGeometry( geometry2 );
writer.write();
}
transaction.commit();
>
> Thanks
cheers
--
Mauricio Pazos |