]> git.argeo.org Git - lgpl/argeo-commons.git/commitdiff
Start working on change CRS
authorMathieu Baudier <mbaudier@argeo.org>
Thu, 7 Jul 2011 20:20:04 +0000 (20:20 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Thu, 7 Jul 2011 20:20:04 +0000 (20:20 +0000)
git-svn-id: https://svn.argeo.org/commons/trunk@4675 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

gis/plugins/org.argeo.gis.ui.rcp.swing/META-INF/MANIFEST.MF
gis/plugins/org.argeo.gis.ui.rcp.swing/pom.xml [new file with mode: 0644]
gis/plugins/org.argeo.gis.ui.rcp.swing/src/main/java/org/argeo/gis/ui/rcp/swing/SwingMapViewer.java

index 2a6511c884b8b85e69197763bf319fb54623e00d..d010b1df62077fd24ab53f53a01f15756ebe323d 100644 (file)
@@ -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 (file)
index 0000000..9bac13e
--- /dev/null
@@ -0,0 +1,48 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+       <modelVersion>4.0.0</modelVersion>
+       <parent>
+               <groupId>org.argeo.commons.gis</groupId>
+               <version>0.3.4-SNAPSHOT</version>
+               <artifactId>plugins</artifactId>
+               <relativePath>..</relativePath>
+       </parent>
+       <artifactId>org.argeo.gis.ui.rcp.swing</artifactId>
+       <name>Commons GIS RCP Swing</name>
+       <packaging>jar</packaging>
+       <build>
+               <plugins>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-compiler-plugin</artifactId>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-source-plugin</artifactId>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-jar-plugin</artifactId>
+                       </plugin>
+               </plugins>
+       </build>
+       <dependencies>
+               <!-- Commons -->
+               <dependency>
+                       <groupId>org.argeo.commons.basic</groupId>
+                       <artifactId>org.argeo.basic.nodeps</artifactId>
+                       <version>0.3.4-SNAPSHOT</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.commons.gis</groupId>
+                       <artifactId>org.argeo.gis.ui</artifactId>
+                       <version>0.3.4-SNAPSHOT</version>
+               </dependency>
+
+               <!-- RCP only dependency, needed at compile time -->
+               <dependency>
+                       <groupId>org.argeo.commons.eclipse</groupId>
+                       <artifactId>org.argeo.eclipse.dep.rcp</artifactId>
+                       <version>0.3.4-SNAPSHOT</version>
+               </dependency>
+       </dependencies>
+</project>
index b2f21489a06a028574144b321f417a328de9d445..32d03c19285d656e6b99a0a3fa9c119c83ed87fa 100644 (file)
@@ -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);
+               }
+
        }
 
 }