Introduce SLC GIS support
authorMathieu Baudier <mbaudier@argeo.org>
Thu, 6 May 2010 15:39:43 +0000 (15:39 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Thu, 6 May 2010 15:39:43 +0000 (15:39 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@3562 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

runtime/org.argeo.slc.support.gis/.classpath [new file with mode: 0644]
runtime/org.argeo.slc.support.gis/.project [new file with mode: 0644]
runtime/org.argeo.slc.support.gis/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
runtime/org.argeo.slc.support.gis/.settings/org.eclipse.pde.core.prefs [new file with mode: 0644]
runtime/org.argeo.slc.support.gis/build.properties [new file with mode: 0644]
runtime/org.argeo.slc.support.gis/pom.xml [new file with mode: 0644]
runtime/org.argeo.slc.support.gis/src/main/java/org/argeo/slc/geotools/Quickstart.java [new file with mode: 0644]
runtime/org.argeo.slc.support.gis/src/test/resources/log4j.properties [new file with mode: 0644]

diff --git a/runtime/org.argeo.slc.support.gis/.classpath b/runtime/org.argeo.slc.support.gis/.classpath
new file mode 100644 (file)
index 0000000..dff8aa6
--- /dev/null
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="src" path="src/main/java"/>
+       <classpathentry kind="src" path="src/main/resources"/>
+       <classpathentry kind="src" path="src/test/resources"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+       <classpathentry kind="output" path="target/classes"/>
+</classpath>
diff --git a/runtime/org.argeo.slc.support.gis/.project b/runtime/org.argeo.slc.support.gis/.project
new file mode 100644 (file)
index 0000000..5acae6a
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.argeo.slc.support.gis</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/runtime/org.argeo.slc.support.gis/.settings/org.eclipse.jdt.core.prefs b/runtime/org.argeo.slc.support.gis/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..4e4b533
--- /dev/null
@@ -0,0 +1,8 @@
+#Thu May 06 12:24:28 CEST 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/runtime/org.argeo.slc.support.gis/.settings/org.eclipse.pde.core.prefs b/runtime/org.argeo.slc.support.gis/.settings/org.eclipse.pde.core.prefs
new file mode 100644 (file)
index 0000000..612d947
--- /dev/null
@@ -0,0 +1,4 @@
+#Thu May 06 11:09:21 CEST 2010
+eclipse.preferences.version=1
+pluginProject.extensions=false
+resolve.requirebundle=false
diff --git a/runtime/org.argeo.slc.support.gis/build.properties b/runtime/org.argeo.slc.support.gis/build.properties
new file mode 100644 (file)
index 0000000..a4e488c
--- /dev/null
@@ -0,0 +1,12 @@
+source.. = src/main/java/
+output.. = target/classes/
+bin.includes = META-INF/,\
+               .
+additional.bundles = com.springsource.slf4j.api,\
+                     com.springsource.slf4j.log4j,\
+                     com.springsource.org.apache.log4j,\
+                     com.springsource.org.hsqldb,\
+                     org.argeo.dep.osgi.jsr275,\
+                     org.argeo.dep.osgi.java3d,\
+                     org.argeo.dep.osgi.jts,\
+                     com.springsource.org.apache.commons.beanutils
diff --git a/runtime/org.argeo.slc.support.gis/pom.xml b/runtime/org.argeo.slc.support.gis/pom.xml
new file mode 100644 (file)
index 0000000..efa20ea
--- /dev/null
@@ -0,0 +1,103 @@
+<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.slc</groupId>
+               <artifactId>runtime</artifactId>
+               <version>0.12.2-SNAPSHOT</version>
+               <relativePath>..</relativePath>
+       </parent>
+       <groupId>org.argeo.slc.runtime</groupId>
+       <artifactId>org.argeo.slc.support.gis</artifactId>
+       <name>SLC Support GIS</name>
+       <build>
+               <plugins>
+                       <plugin>
+                               <groupId>org.apache.felix</groupId>
+                               <artifactId>maven-bundle-plugin</artifactId>
+                               <version>${version.maven-bundle-plugin}</version>
+                               <configuration>
+                                       <instructions>
+                                               <Export-Package>
+                                                       org.argeo.slc.*
+                                               </Export-Package>
+                                               <Import-Package>*,
+                                                       org.opengis.feature.simple,
+                                               </Import-Package>
+                                       </instructions>
+                               </configuration>
+                       </plugin>
+               </plugins>
+       </build>
+       <dependencies>
+               <dependency>
+                       <groupId>org.slf4j</groupId>
+                       <artifactId>com.springsource.slf4j.org.apache.commons.logging</artifactId>
+               </dependency>
+
+               <dependency>
+                       <groupId>org.argeo.dep.osgi</groupId>
+                       <artifactId>org.argeo.dep.osgi.jts</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.dep.osgi</groupId>
+                       <artifactId>org.argeo.dep.osgi.postgis.jdbc</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.dep.osgi</groupId>
+                       <artifactId>org.argeo.dep.osgi.hibernatespatial</artifactId>
+               </dependency>
+               <!-- GeoTools -->
+               <dependency>
+                       <groupId>org.argeo.dep.osgi</groupId>
+                       <artifactId>org.argeo.dep.osgi.geotools</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.jdom</groupId>
+                       <artifactId>com.springsource.org.jdom</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.jaxen</groupId>
+                       <artifactId>com.springsource.org.jaxen</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.dep.osgi</groupId>
+                       <artifactId>org.argeo.dep.osgi.jsr275</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.dep.osgi</groupId>
+                       <artifactId>org.argeo.dep.osgi.java3d</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.dep.osgi</groupId>
+                       <artifactId>org.argeo.dep.osgi.geoapi</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.apache.commons</groupId>
+                       <artifactId>com.springsource.org.apache.commons.beanutils</artifactId>
+               </dependency>
+       </dependencies>
+       <repositories>
+               <repository>
+                       <id>com.springsource.repository.bundles.external</id>
+                       <name>
+                               SpringSource Enterprise Bundle Repository - External
+                               Bundle
+                               Releases
+                       </name>
+                       <url>
+                               http://repository.springsource.com/maven/bundles/external
+                       </url>
+                       <releases>
+                               <enabled>true</enabled>
+                               <updatePolicy>daily</updatePolicy>
+                               <checksumPolicy>fail</checksumPolicy>
+                       </releases>
+                       <snapshots>
+                               <enabled>false</enabled>
+                               <updatePolicy>never</updatePolicy>
+                               <checksumPolicy>fail</checksumPolicy>
+                       </snapshots>
+               </repository>
+       </repositories>
+</project>
\ No newline at end of file
diff --git a/runtime/org.argeo.slc.support.gis/src/main/java/org/argeo/slc/geotools/Quickstart.java b/runtime/org.argeo.slc.support.gis/src/main/java/org/argeo/slc/geotools/Quickstart.java
new file mode 100644 (file)
index 0000000..25c6244
--- /dev/null
@@ -0,0 +1,136 @@
+/*
+ *    GeoTools - The Open Source Java GIS Tookit
+ *    http://geotools.org
+ *
+ *    (C) 2006-2008, Open Source Geospatial Foundation (OSGeo)
+ *
+ *    This file is hereby placed into the Public Domain. This means anyone is
+ *    free to do whatever they wish with this file. Use it well and enjoy!
+ */
+package org.argeo.slc.geotools;
+
+import java.awt.event.MouseWheelEvent;
+import java.awt.event.MouseWheelListener;
+import java.io.File;
+import java.util.Iterator;
+
+import javax.swing.SwingUtilities;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.geotools.data.FeatureSource;
+import org.geotools.data.FileDataStore;
+import org.geotools.data.FileDataStoreFactorySpi;
+import org.geotools.data.FileDataStoreFinder;
+import org.geotools.geometry.jts.ReferencedEnvelope;
+import org.geotools.map.DefaultMapContext;
+import org.geotools.map.MapContext;
+import org.geotools.swing.JMapFrame;
+import org.geotools.swing.JMapPane;
+import org.geotools.swing.event.MapMouseAdapter;
+import org.opengis.feature.simple.SimpleFeature;
+import org.opengis.feature.simple.SimpleFeatureType;
+
+/**
+ * GeoTools Quickstart demo application. Prompts the user for a shapefile and
+ * displays its contents on the screen in a map frame
+ * 
+ * @source $URL:
+ *         http://svn.osgeo.org/geotools/trunk/demo/example/src/main/java/org
+ *         /geotools/demo/Quickstart.java $
+ */
+public class Quickstart {
+       private final static Log log = LogFactory.getLog(Quickstart.class);
+
+       /**
+        * GeoTools Quickstart demo application. Prompts the user for a shapefile
+        * and displays its contents on the screen in a map frame
+        */
+       public static void main(String[] args) throws Exception {
+               Iterator<FileDataStoreFactorySpi> ps = FileDataStoreFinder
+                               .getAvailableDataStores();
+               log.debug("Available datastores:");
+               while (ps.hasNext()) {
+                       log.debug(ps.next());
+               }
+
+               // display a data store file chooser dialog for shapefiles
+               // File file = JFileDataStoreChooser.showOpenFile("shp", null);
+               // if (file == null) {
+               // return;
+               // }
+               File dir = new File(
+                               "/home/mbaudier/gis/projects/100122-EasternBalkans2010/data");
+
+               FeatureSource<SimpleFeatureType, SimpleFeature> featureSource = FileDataStoreFinder
+                               .getDataStore(new File(dir, "countries-EuroMed-NEarth.shp"))
+                               .getFeatureSource();
+
+               // Create a map context and add our shapefile to it
+               MapContext map = new DefaultMapContext();
+               map.setTitle("Quickstart");
+
+               // Now display the map
+               // UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+
+               final JMapFrame frame = new JMapFrame(map);
+               frame.enableStatusBar(true);
+               frame.enableToolBar(true);
+               frame.enableLayerTable(true);
+               frame.initComponents();
+
+               frame.setSize(800, 600);
+
+               final double clickToZoom = 0.1; // 1 wheel click is 10% zoom
+               final JMapPane mapPane = frame.getMapPane();
+               mapPane.addMouseWheelListener(new MouseWheelListener() {
+
+                       public void mouseWheelMoved(MouseWheelEvent ev) {
+                               int clicks = ev.getWheelRotation();
+                               // -ve means wheel moved up, +ve means down
+                               int sign = (clicks < 0 ? -1 : 1);
+
+                               ReferencedEnvelope env = mapPane.getDisplayArea();
+                               double width = env.getWidth();
+                               double delta = width * clickToZoom * sign;
+
+                               env.expandBy(delta);
+                               mapPane.setDisplayArea(env);
+                               mapPane.repaint();
+                       }
+               });
+               // mapPane.addMouseListener(new MapMouseAdapter() {
+               // // wheel event handler
+               // public void handleMouseWheelEvent(MouseWheelEvent ev) {
+               // int clicks = ev.getWheelRotation();
+               // // -ve means wheel moved up, +ve means down
+               // int sign = (clicks < 0 ? -1 : 1);
+               //
+               // ReferencedEnvelope env = mapPane.getDisplayArea();
+               // double width = env.getWidth();
+               // double delta = width * clickToZoom * sign;
+               //
+               // env.expandBy(delta);
+               // mapPane.setDisplayArea(env);
+               // mapPane.repaint();
+               // }
+               // });
+
+               SwingUtilities.invokeLater(new Runnable() {
+                       public void run() {
+                               frame.setVisible(true);
+                       }
+               });
+
+               map.addLayer(FileDataStoreFinder.getDataStore(
+                               new File(dir, "cities-EuroMed-NEarth.shp")).getFeatureSource(),
+                               null);
+               map.addLayer(FileDataStoreFinder.getDataStore(
+                               new File(dir, "countries-EuroMed-NEarth.shp"))
+                               .getFeatureSource(), null);
+               map.addLayer(FileDataStoreFinder.getDataStore(
+                               new File(dir, "highways-EastBalkan-OSM.shp"))
+                               .getFeatureSource(), null);
+
+       }
+}
\ No newline at end of file
diff --git a/runtime/org.argeo.slc.support.gis/src/test/resources/log4j.properties b/runtime/org.argeo.slc.support.gis/src/test/resources/log4j.properties
new file mode 100644 (file)
index 0000000..0133bab
--- /dev/null
@@ -0,0 +1,22 @@
+# Set root logger level to DEBUG and its only appender to A1.\r
+log4j.rootLogger=WARN, console\r
+\r
+## Levels\r
+# Slc\r
+log4j.logger.org.argeo=DEBUG\r
+\r
+# Castor\r
+log4j.logger.org.exolab.castor=WARN\r
+\r
+# Spring\r
+log4j.logger.org.springframework=WARN\r
+\r
+\r
+## Appenders\r
+# A1 is set to be a ConsoleAppender.\r
+log4j.appender.console=org.apache.log4j.ConsoleAppender\r
+\r
+# A1 uses PatternLayout.\r
+log4j.appender.console.layout=org.apache.log4j.PatternLayout\r
+log4j.appender.console.layout.ConversionPattern= %-5p %d{ISO8601} %m - %c%n\r
+\r