From: Mathieu Baudier Date: Thu, 7 Jul 2011 20:20:04 +0000 (+0000) Subject: Start working on change CRS X-Git-Tag: argeo-commons-2.1.30~1195 X-Git-Url: http://git.argeo.org/?a=commitdiff_plain;h=52c95e6e2ebfd85602abeaa739fa1afcc43e8fc9;p=lgpl%2Fargeo-commons.git Start working on change CRS git-svn-id: https://svn.argeo.org/commons/trunk@4675 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- diff --git a/gis/plugins/org.argeo.gis.ui.rcp.swing/META-INF/MANIFEST.MF b/gis/plugins/org.argeo.gis.ui.rcp.swing/META-INF/MANIFEST.MF index 2a6511c88..d010b1df6 100644 --- a/gis/plugins/org.argeo.gis.ui.rcp.swing/META-INF/MANIFEST.MF +++ b/gis/plugins/org.argeo.gis.ui.rcp.swing/META-INF/MANIFEST.MF @@ -6,6 +6,10 @@ Bundle-Version: 0.3.4.SNAPSHOT Bundle-RequiredExecutionEnvironment: J2SE-1.5 Import-Package: com.vividsolutions.jts.geom;version="1.10.0", javax.jcr;version="2.0.0", + javax.measure.converter, + javax.media.jai;version="1.1.3";resolution:=optional, + javax.vecmath, + org.argeo, org.argeo.geotools.jcr, org.argeo.geotools.styling, org.argeo.gis.ui, @@ -16,6 +20,8 @@ Import-Package: com.vividsolutions.jts.geom;version="1.10.0", org.geotools.geometry, org.geotools.geometry.jts, org.geotools.map, + org.geotools.referencing, + org.geotools.referencing.crs, org.geotools.renderer, org.geotools.renderer.lite, org.geotools.styling, @@ -24,4 +30,5 @@ Import-Package: com.vividsolutions.jts.geom;version="1.10.0", org.geotools.swing.tool, org.opengis.feature, org.opengis.feature.simple, - org.opengis.geometry + org.opengis.geometry, + org.opengis.referencing.crs diff --git a/gis/plugins/org.argeo.gis.ui.rcp.swing/pom.xml b/gis/plugins/org.argeo.gis.ui.rcp.swing/pom.xml new file mode 100644 index 000000000..9bac13eb1 --- /dev/null +++ b/gis/plugins/org.argeo.gis.ui.rcp.swing/pom.xml @@ -0,0 +1,48 @@ + + 4.0.0 + + org.argeo.commons.gis + 0.3.4-SNAPSHOT + plugins + .. + + org.argeo.gis.ui.rcp.swing + Commons GIS RCP Swing + jar + + + + org.apache.maven.plugins + maven-compiler-plugin + + + org.apache.maven.plugins + maven-source-plugin + + + org.apache.maven.plugins + maven-jar-plugin + + + + + + + org.argeo.commons.basic + org.argeo.basic.nodeps + 0.3.4-SNAPSHOT + + + org.argeo.commons.gis + org.argeo.gis.ui + 0.3.4-SNAPSHOT + + + + + org.argeo.commons.eclipse + org.argeo.eclipse.dep.rcp + 0.3.4-SNAPSHOT + + + diff --git a/gis/plugins/org.argeo.gis.ui.rcp.swing/src/main/java/org/argeo/gis/ui/rcp/swing/SwingMapViewer.java b/gis/plugins/org.argeo.gis.ui.rcp.swing/src/main/java/org/argeo/gis/ui/rcp/swing/SwingMapViewer.java index b2f21489a..32d03c192 100644 --- a/gis/plugins/org.argeo.gis.ui.rcp.swing/src/main/java/org/argeo/gis/ui/rcp/swing/SwingMapViewer.java +++ b/gis/plugins/org.argeo.gis.ui.rcp.swing/src/main/java/org/argeo/gis/ui/rcp/swing/SwingMapViewer.java @@ -9,6 +9,7 @@ import java.util.Map; import javax.jcr.Node; +import org.argeo.ArgeoException; import org.argeo.geotools.jcr.GeoJcrMapper; import org.argeo.geotools.styling.StylingUtils; import org.argeo.gis.ui.AbstractMapViewer; @@ -21,11 +22,13 @@ import org.geotools.map.DefaultMapContext; import org.geotools.map.DefaultMapLayer; import org.geotools.map.MapContext; import org.geotools.map.MapLayer; +import org.geotools.referencing.CRS; import org.geotools.renderer.lite.StreamingRenderer; import org.geotools.styling.Style; import org.geotools.swing.JMapPane; import org.opengis.feature.simple.SimpleFeature; import org.opengis.feature.simple.SimpleFeatureType; +import org.opengis.referencing.crs.CoordinateReferenceSystem; /** Map viewer implementation based on GeoTools Swing components. */ public class SwingMapViewer extends AbstractMapViewer { @@ -50,7 +53,6 @@ public class SwingMapViewer extends AbstractMapViewer { versatileZoomTool = new VersatileZoomTool(); mapPane.setCursorTool(versatileZoomTool); mapPane.setBackground(Color.WHITE); - frame.add(mapPane); setControl(embedded); @@ -85,7 +87,31 @@ public class SwingMapViewer extends AbstractMapViewer { public void setAreaOfInterest(ReferencedEnvelope areaOfInterest) { // mapPane.getMapContext().setAreaOfInterest(areaOfInterest); - mapPane.setDisplayArea(areaOfInterest); + CoordinateReferenceSystem crs = mapPane.getMapContext() + .getCoordinateReferenceSystem(); + + ReferencedEnvelope toDisplay; + if (crs != null) + try { + toDisplay = areaOfInterest.transform(crs, true); + } catch (Exception e) { + throw new ArgeoException("Cannot reproject " + areaOfInterest, + e); + } + else + toDisplay = areaOfInterest; + mapPane.setDisplayArea(toDisplay); + } + + public void setCoordinateReferenceSystem(String crs) { + try { + CoordinateReferenceSystem crsObj = CRS.decode(crs); + mapPane.getMapContext().setCoordinateReferenceSystem(crsObj); + mapPane.repaint(); + } catch (Exception e) { + throw new ArgeoException("Cannot set CRS '" + crs + "'", e); + } + } }