--- /dev/null
+argeo.osgi.start=\
+org.springframework.osgi.extender,\
+org.argeo.slc.gis.position.gpsbabel,\
+org.argeo.slc.gis.position.ui
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.argeo.slc.gis.position.gpsbabel</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <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>
+ </natures>
+</projectDescription>
--- /dev/null
+#Fri May 07 11:03:14 CEST 2010
+eclipse.preferences.version=1
+pluginProject.extensions=false
+resolve.requirebundle=false
--- /dev/null
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: SLC GIS Position GpsBabel
+Bundle-SymbolicName: org.argeo.slc.gis.position.gpsbabel
+Bundle-Version: 1.0.0.qualifier
+Import-Package: org.argeo.slc.gpsbabel;version="0.12.2.SNAPSHOT-r3562",
+ org.argeo.slc.jts;version="0.12.2.SNAPSHOT-r3562"
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans:beans xmlns="http://www.springframework.org/schema/osgi"\r
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"\r
+ xsi:schemaLocation="http://www.springframework.org/schema/osgi \r
+ http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
+ http://www.springframework.org/schema/beans \r
+ http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
+\r
+ <service ref="gpsBabelPositionProvider" interface="org.argeo.slc.jts.PositionProvider" />\r
+\r
+</beans:beans>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
+ xsi:schemaLocation="\r
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
+\r
+ <bean id="gpsBabelPositionProvider" class="org.argeo.slc.gpsbabel.GpsBabelPositionProvider">\r
+ <property name="inputFormat" value="garmin,get_posn" />\r
+ </bean>\r
+</beans>
\ No newline at end of file
--- /dev/null
+bin.includes = META-INF/
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.argeo.slc.gis.position.ui</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <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>
+ </natures>
+</projectDescription>
--- /dev/null
+#Fri May 07 16:28:04 CEST 2010
+eclipse.preferences.version=1
+pluginProject.extensions=false
+resolve.requirebundle=false
--- /dev/null
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Ui
+Bundle-SymbolicName: org.argeo.slc.gis.position.ui
+Bundle-Version: 1.0.0.qualifier
+Import-Package: org.argeo.slc.geotools;version="0.12.2.SNAPSHOT-r3562",
+ org.argeo.slc.jts;version="0.12.2.SNAPSHOT-r3562",
+ org.springframework.osgi.util;version="1.2.1"
--- /dev/null
+#
+# The registry file for Geotools Grid Coverage implementation. This file should be automatically
+# parsed by JAI under initialization. If it is not, then Registry.registerServices(...) can parse
+# it. This may happen if this file is unreachable from the JAI class loader.
+#
+# If this file is updated, remember to update Registry.registerServices(...) accordingly.
+#
+# Version: $Id: registryFile.jai 34781 2010-01-13 11:56:07Z simonegiannecchini $
+#
+##################################################################################################
+#
+# Each line can be in one of the formats described below. Space or tab characters separate
+# keywords in each line. The comment character is '#'; on each line all characters following
+# the first comment character are ignored. The file must be encoded in UTF-8.
+#
+# 1. To register descriptors :
+#
+# descriptor <descriptor-class-name>
+#
+# 2. To register factory objects under a product against a specific mode :
+#
+# <registry-mode-name> <factory-class-name> <product-name> <descriptor-name> <local-name>
+#
+# The <local-name> is (only) used later on in this file to set preferences
+# between factory objects, if wanted.
+#
+##################################################################################################
+#
+# Image operation descriptors :
+#
+descriptor org.geotools.image.jai.CombineDescriptor
+descriptor org.geotools.image.jai.HysteresisDescriptor
+descriptor org.geotools.image.jai.NodataFilterDescriptor
+descriptor org.geotools.image.palette.ColorReductionDescriptor
+descriptor org.geotools.image.palette.ColorInversionDescriptor
+
+
+#
+# "rendered" factory objects
+#
+rendered org.geotools.image.jai.CombineCRIF org.geotools org.geotools.Combine Combine
+rendered org.geotools.image.jai.HysteresisCRIF org.geotools org.geotools.Hysteresis Hysteresis
+rendered org.geotools.image.jai.NodataFilterCRIF org.geotools org.geotools.NodataFilter NodataFilter
+rendered org.geotools.image.palette.ColorReductionCRIF org.geotools org.geotools.ColorReduction ColorReduction
+rendered org.geotools.image.palette.ColorInversionCRIF org.geotools org.geotools.ColorInversion ColorInversion
+#
+# The registry file for Geotools Grid Coverage implementation. This file should be automatically
+# parsed by JAI under initialization. If it is not, then Registry.registerServices(...) can parse
+# it. This may happen if this file is unreachable from the JAI class loader.
+#
+# If this file is updated, remember to update Registry.registerServices(...) accordingly.
+#
+# Version: $Id: registryFile.jai 34781 2010-01-13 11:56:07Z simonegiannecchini $
+#
+##################################################################################################
+#
+# Each line can be in one of the formats described below. Space or tab characters separate
+# keywords in each line. The comment character is '#'; on each line all characters following
+# the first comment character are ignored. The file must be encoded in UTF-8.
+#
+# 1. To register descriptors :
+#
+# descriptor <descriptor-class-name>
+#
+# 2. To register factory objects under a product against a specific mode :
+#
+# <registry-mode-name> <factory-class-name> <product-name> <descriptor-name> <local-name>
+#
+# The <local-name> is (only) used later on in this file to set preferences
+# between factory objects, if wanted.
+#
+##################################################################################################
+#
+# Image operation descriptors :
+#
+descriptor org.geotools.image.jai.CombineDescriptor
+descriptor org.geotools.image.jai.HysteresisDescriptor
+descriptor org.geotools.image.jai.NodataFilterDescriptor
+descriptor org.geotools.image.palette.ColorReductionDescriptor
+descriptor org.geotools.image.palette.ColorInversionDescriptor
+
+
+#
+# "rendered" factory objects
+#
+rendered org.geotools.image.jai.CombineCRIF org.geotools org.geotools.Combine Combine
+rendered org.geotools.image.jai.HysteresisCRIF org.geotools org.geotools.Hysteresis Hysteresis
+rendered org.geotools.image.jai.NodataFilterCRIF org.geotools org.geotools.NodataFilter NodataFilter
+rendered org.geotools.image.palette.ColorReductionCRIF org.geotools org.geotools.ColorReduction ColorReduction
+rendered org.geotools.image.palette.ColorInversionCRIF org.geotools org.geotools.ColorInversion ColorInversion
+#
+# The registry file for Geotools Grid Coverage implementation. This file should be automatically
+# parsed by JAI under initialization. If it is not, then Registry.registerServices(...) can parse
+# it. This may happen if this file is unreachable from the JAI class loader.
+#
+# If this file is updated, remember to update Registry.registerServices(...) accordingly.
+#
+# Version: $Id: registryFile.jai 34781 2010-01-13 11:56:07Z simonegiannecchini $
+#
+##################################################################################################
+#
+# Each line can be in one of the formats described below. Space or tab characters separate
+# keywords in each line. The comment character is '#'; on each line all characters following
+# the first comment character are ignored. The file must be encoded in UTF-8.
+#
+# 1. To register descriptors :
+#
+# descriptor <descriptor-class-name>
+#
+# 2. To register factory objects under a product against a specific mode :
+#
+# <registry-mode-name> <factory-class-name> <product-name> <descriptor-name> <local-name>
+#
+# The <local-name> is (only) used later on in this file to set preferences
+# between factory objects, if wanted.
+#
+##################################################################################################
+#
+# Image operation descriptors :
+#
+descriptor org.geotools.image.jai.CombineDescriptor
+descriptor org.geotools.image.jai.HysteresisDescriptor
+descriptor org.geotools.image.jai.NodataFilterDescriptor
+descriptor org.geotools.image.palette.ColorReductionDescriptor
+descriptor org.geotools.image.palette.ColorInversionDescriptor
+
+
+#
+# "rendered" factory objects
+#
+rendered org.geotools.image.jai.CombineCRIF org.geotools org.geotools.Combine Combine
+rendered org.geotools.image.jai.HysteresisCRIF org.geotools org.geotools.Hysteresis Hysteresis
+rendered org.geotools.image.jai.NodataFilterCRIF org.geotools org.geotools.NodataFilter NodataFilter
+rendered org.geotools.image.palette.ColorReductionCRIF org.geotools org.geotools.ColorReduction ColorReduction
+rendered org.geotools.image.palette.ColorInversionCRIF org.geotools org.geotools.ColorInversion ColorInversion
+#
+# The registry file for Geotools Grid Coverage implementation. This file should be automatically
+# parsed by JAI under initialization. If it is not, then Registry.registerServices(...) can parse
+# it. This may happen if this file is unreachable from the JAI class loader.
+#
+# If this file is updated, remember to update Registry.registerServices(...) accordingly.
+#
+# Version: $Id: registryFile.jai 34781 2010-01-13 11:56:07Z simonegiannecchini $
+#
+##################################################################################################
+#
+# Each line can be in one of the formats described below. Space or tab characters separate
+# keywords in each line. The comment character is '#'; on each line all characters following
+# the first comment character are ignored. The file must be encoded in UTF-8.
+#
+# 1. To register descriptors :
+#
+# descriptor <descriptor-class-name>
+#
+# 2. To register factory objects under a product against a specific mode :
+#
+# <registry-mode-name> <factory-class-name> <product-name> <descriptor-name> <local-name>
+#
+# The <local-name> is (only) used later on in this file to set preferences
+# between factory objects, if wanted.
+#
+##################################################################################################
+#
+# Image operation descriptors :
+#
+descriptor org.geotools.image.jai.CombineDescriptor
+descriptor org.geotools.image.jai.HysteresisDescriptor
+descriptor org.geotools.image.jai.NodataFilterDescriptor
+descriptor org.geotools.image.palette.ColorReductionDescriptor
+descriptor org.geotools.image.palette.ColorInversionDescriptor
+
+
+#
+# "rendered" factory objects
+#
+rendered org.geotools.image.jai.CombineCRIF org.geotools org.geotools.Combine Combine
+rendered org.geotools.image.jai.HysteresisCRIF org.geotools org.geotools.Hysteresis Hysteresis
+rendered org.geotools.image.jai.NodataFilterCRIF org.geotools org.geotools.NodataFilter NodataFilter
+rendered org.geotools.image.palette.ColorReductionCRIF org.geotools org.geotools.ColorReduction ColorReduction
+rendered org.geotools.image.palette.ColorInversionCRIF org.geotools org.geotools.ColorInversion ColorInversion
+#
+# The registry file for Geotools Grid Coverage implementation. This file should be automatically
+# parsed by JAI under initialization. If it is not, then Registry.registerServices(...) can parse
+# it. This may happen if this file is unreachable from the JAI class loader.
+#
+# If this file is updated, remember to update Registry.registerServices(...) accordingly.
+#
+# Version: $Id: registryFile.jai 34781 2010-01-13 11:56:07Z simonegiannecchini $
+#
+##################################################################################################
+#
+# Each line can be in one of the formats described below. Space or tab characters separate
+# keywords in each line. The comment character is '#'; on each line all characters following
+# the first comment character are ignored. The file must be encoded in UTF-8.
+#
+# 1. To register descriptors :
+#
+# descriptor <descriptor-class-name>
+#
+# 2. To register factory objects under a product against a specific mode :
+#
+# <registry-mode-name> <factory-class-name> <product-name> <descriptor-name> <local-name>
+#
+# The <local-name> is (only) used later on in this file to set preferences
+# between factory objects, if wanted.
+#
+##################################################################################################
+#
+# Image operation descriptors :
+#
+descriptor org.geotools.image.jai.CombineDescriptor
+descriptor org.geotools.image.jai.HysteresisDescriptor
+descriptor org.geotools.image.jai.NodataFilterDescriptor
+descriptor org.geotools.image.palette.ColorReductionDescriptor
+descriptor org.geotools.image.palette.ColorInversionDescriptor
+
+
+#
+# "rendered" factory objects
+#
+rendered org.geotools.image.jai.CombineCRIF org.geotools org.geotools.Combine Combine
+rendered org.geotools.image.jai.HysteresisCRIF org.geotools org.geotools.Hysteresis Hysteresis
+rendered org.geotools.image.jai.NodataFilterCRIF org.geotools org.geotools.NodataFilter NodataFilter
+rendered org.geotools.image.palette.ColorReductionCRIF org.geotools org.geotools.ColorReduction ColorReduction
+rendered org.geotools.image.palette.ColorInversionCRIF org.geotools org.geotools.ColorInversion ColorInversion
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans:beans xmlns="http://www.springframework.org/schema/osgi"\r
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"\r
+ xsi:schemaLocation="http://www.springframework.org/schema/osgi \r
+ http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
+ http://www.springframework.org/schema/beans \r
+ http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
+\r
+ <reference id="positionProvider" interface="org.argeo.slc.jts.PositionProvider" />\r
+\r
+ <bundle id="geotools" symbolic-name="org.argeo.dep.osgi.geotools" />\r
+ <bundle id="jai.imageio" symbolic-name="org.argeo.dep.osgi.jai.imageio" />\r
+</beans:beans>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
+ xsi:schemaLocation="\r
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
+\r
+ <bean id="ui" class="org.argeo.slc.geotools.SimpleGisFieldViewer"\r
+ init-method="run">\r
+ <property name="positionProvider" ref="positionProvider" />\r
+ <property name="jaiImageIoClassLoader">\r
+ <bean class="org.springframework.osgi.util.BundleDelegatingClassLoader"\r
+ factory-method="createBundleClassLoaderFor">\r
+ <constructor-arg>\r
+ <ref bean="jai.imageio" />\r
+ <!--\r
+ <bean factory-bean="bundleContext" factory-method="getBundle" />\r
+ -->\r
+ </constructor-arg>\r
+ </bean>\r
+ </property>\r
+ </bean>\r
+</beans>
\ No newline at end of file
--- /dev/null
+bin.includes = META-INF/
-#Thu May 06 12:24:28 CEST 2010
+#Fri May 07 21:03:36 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.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.5
org.argeo.dep.osgi.jsr275,\
org.argeo.dep.osgi.java3d,\
org.argeo.dep.osgi.jts,\
- com.springsource.org.apache.commons.beanutils
+ com.springsource.org.apache.commons.beanutils,\
+ com.springsource.javax.media.jai.codec,\
+ com.springsource.javax.media.jai.core,\
+ org.argeo.dep.osgi.jai.imageio
<groupId>org.apache.commons</groupId>
<artifactId>com.springsource.org.apache.commons.beanutils</artifactId>
</dependency>
+ <!-- JAI -->
+ <dependency>
+ <groupId>javax.media.jai</groupId>
+ <artifactId>com.springsource.javax.media.jai.core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.media.jai</groupId>
+ <artifactId>com.springsource.javax.media.jai.codec</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.argeo.dep.osgi</groupId>
+ <artifactId>org.argeo.dep.osgi.jai.imageio</artifactId>
+ </dependency>
+
</dependencies>
<repositories>
<repository>
+++ /dev/null
-/*
- * 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.Color;
-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.argeo.slc.gpsbabel.GpsBabelPositionProvider;
-import org.argeo.slc.jts.PositionProvider;
-import org.geotools.data.FileDataStoreFactorySpi;
-import org.geotools.data.FileDataStoreFinder;
-import org.geotools.feature.DefaultFeatureCollection;
-import org.geotools.feature.FeatureCollection;
-import org.geotools.feature.simple.SimpleFeatureBuilder;
-import org.geotools.feature.simple.SimpleFeatureTypeBuilder;
-import org.geotools.geometry.jts.ReferencedEnvelope;
-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.DefaultGeographicCRS;
-import org.geotools.styling.SLD;
-import org.geotools.styling.Style;
-import org.geotools.swing.JMapFrame;
-import org.geotools.swing.JMapPane;
-import org.opengis.feature.simple.SimpleFeature;
-import org.opengis.feature.simple.SimpleFeatureType;
-
-import com.vividsolutions.jts.geom.Point;
-
-/**
- * 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 mapContext = new DefaultMapContext();
- mapContext.setTitle("Quickstart");
-
- // Now display the map
- // UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
-
- final JMapFrame frame = new JMapFrame(mapContext);
- 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);
- }
- });
-
- // Create position type
- SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
- builder.setName("Position");
- builder.setNamespaceURI("http://localhost/");
- builder.setCRS(DefaultGeographicCRS.WGS84);
-
- // add attributes in order
- builder.add("Location", Point.class);
- builder.add("ID", Integer.class);
- builder.add("Name", String.class);
-
- // build the type
- final SimpleFeatureType POSITION = builder.buildFeatureType();
-
- PositionProvider positionProvider = new GpsBabelPositionProvider();
-
- // FeatureSource<SimpleFeatureType, SimpleFeature> fs =
- // FileDataStoreFinder
- // .getDataStore(new File(dir, "countries-EuroMed-NEarth.shp"))
- // .getFeatureSource();
-
- // mapContext.addLayer(FileDataStoreFinder.getDataStore(
- // new File(dir, "cities-EuroMed-NEarth.shp")).getFeatureSource(),
- // null);
- mapContext.addLayer(FileDataStoreFinder.getDataStore(
- new File(dir, "countries-EuroMed-NEarth.shp"))
- .getFeatureSource(), null);
- mapContext.addLayer(FileDataStoreFinder.getDataStore(
- new File(dir, "highways-EastBalkan-OSM.shp"))
- .getFeatureSource(), null);
-
- MapLayer mapLayer = null;
- while (true) {
- SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(
- POSITION);
-
- // add the attributes
- featureBuilder.add(positionProvider.currentPosition());
- featureBuilder.add(12);
- featureBuilder.add("My Name");
-
- // build the feature
- SimpleFeature feature = featureBuilder.buildFeature("Flag.12");
- FeatureCollection<SimpleFeatureType, SimpleFeature> collection = new DefaultFeatureCollection(
- "testCollection", POSITION);
- collection.add(feature);
- if (mapLayer != null)
- mapContext.removeLayer(mapLayer);
- Style style = SLD.createSimpleStyle(POSITION, Color.RED);
- mapLayer = new DefaultMapLayer(collection, style, "");
- mapContext.addLayer(mapLayer);
- // mapContext.addLayer(collection,null);
-
- Thread.sleep(1000);
- }
- }
-
-}
\ No newline at end of file
--- /dev/null
+/*
+ * 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.Color;
+import java.io.File;
+import java.io.IOException;
+import java.util.Iterator;
+
+import javax.media.jai.JAI;
+import javax.swing.SwingUtilities;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.geotools.swing.VersatileZoomTool;
+import org.argeo.slc.jts.PositionProvider;
+import org.geotools.data.FileDataStoreFactorySpi;
+import org.geotools.data.FileDataStoreFinder;
+import org.geotools.data.WorldFileReader;
+import org.geotools.feature.DefaultFeatureCollection;
+import org.geotools.feature.FeatureCollection;
+import org.geotools.feature.simple.SimpleFeatureBuilder;
+import org.geotools.feature.simple.SimpleFeatureTypeBuilder;
+import org.geotools.gce.image.WorldImageFormat;
+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.DefaultGeographicCRS;
+import org.geotools.styling.RasterSymbolizer;
+import org.geotools.styling.SLD;
+import org.geotools.styling.Style;
+import org.geotools.styling.StyleBuilder;
+import org.geotools.swing.JMapFrame;
+import org.geotools.swing.JMapPane;
+import org.opengis.feature.simple.SimpleFeature;
+import org.opengis.feature.simple.SimpleFeatureType;
+
+import com.vividsolutions.jts.geom.Point;
+
+/**
+ * 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 SimpleGisFieldViewer implements Runnable {
+ private final static Log log = LogFactory
+ .getLog(SimpleGisFieldViewer.class);
+
+ private PositionProvider positionProvider;
+
+ private ClassLoader jaiImageIoClassLoader;
+
+ public static void main(String[] args) throws Exception {
+ new SimpleGisFieldViewer().run();
+ }
+
+ public void run() {
+ 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 mapContext = new DefaultMapContext();
+ mapContext.setTitle("Quickstart");
+
+ // Now display the map
+ // UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+
+ final JMapFrame frame = new JMapFrame(mapContext);
+ frame.enableStatusBar(true);
+ frame.enableToolBar(false);
+ frame.enableLayerTable(false);
+ frame.initComponents();
+
+ frame.setSize(800, 600);
+
+ final JMapPane mapPane = frame.getMapPane();
+ mapPane.setCursorTool(new VersatileZoomTool());
+
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ frame.setVisible(true);
+ }
+ });
+
+ // Create position type
+ SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
+ builder.setName("Position");
+ builder.setNamespaceURI("http://localhost/");
+ builder.setCRS(DefaultGeographicCRS.WGS84);
+
+ // add attributes in order
+ builder.add("Location", Point.class);
+ builder.add("ID", Integer.class);
+ builder.add("Name", String.class);
+
+ // build the type
+ final SimpleFeatureType POSITION = builder.buildFeatureType();
+
+ // PositionProvider positionProvider = new GpsBabelPositionProvider();
+
+ try {
+ // FeatureSource<SimpleFeatureType, SimpleFeature> fs =
+ // FileDataStoreFinder
+ // .getDataStore(new File(dir, "countries-EuroMed-NEarth.shp"))
+ // .getFeatureSource();
+
+ // mapContext.addLayer(FileDataStoreFinder.getDataStore(
+ // new File(dir, "cities-EuroMed-NEarth.shp")).getFeatureSource(),
+ // null);
+
+ // Raster
+ if (jaiImageIoClassLoader != null) {
+ Thread.currentThread().setContextClassLoader(
+ jaiImageIoClassLoader);
+ JAI.getDefaultInstance().getOperationRegistry()
+ .registerServices(
+ WorldFileReader.class.getClassLoader());
+// OperationDescriptor odesc = (OperationDescriptor) JAI
+// .getDefaultInstance().getOperationRegistry()
+// .getDescriptor("rendered", "ImageRead");
+ }
+
+ // Raster style
+ StyleBuilder styleBuilder = new StyleBuilder();
+ RasterSymbolizer rasterSymbolizer = styleBuilder
+ .createRasterSymbolizer();
+ rasterSymbolizer.setGeometryPropertyName("geom");
+ Style rasterStyle = styleBuilder.createStyle(rasterSymbolizer);
+ WorldImageFormat worldImageFormat = new WorldImageFormat();
+
+ File rasterDir = new File("/home/mbaudier/gis/data/100501-Poehali");
+ mapContext.addLayer(worldImageFormat.getReader(
+ new File(rasterDir, "500k--l36-1--(1984).gif")).read(null),
+ rasterStyle);
+ mapContext.addLayer(worldImageFormat.getReader(
+ new File(rasterDir, "500k--l35-4--(1978).gif")).read(null),
+ rasterStyle);
+ mapContext.addLayer(worldImageFormat.getReader(
+ new File(rasterDir, "500k--l35-2--(1980).gif")).read(null),
+ rasterStyle);
+ mapContext.addLayer(worldImageFormat.getReader(
+ new File(rasterDir, "100k--l36-050--(1982).gif")).read(null),
+ rasterStyle);
+
+ mapContext.addLayer(FileDataStoreFinder.getDataStore(
+ new File(dir, "countries-EuroMed-NEarth.shp"))
+ .getFeatureSource(), null);
+ // mapContext.addLayer(FileDataStoreFinder.getDataStore(
+ // new File(dir, "highways-EastBalkan-OSM.shp"))
+ // .getFeatureSource(), null);
+ } catch (IOException e1) {
+ throw new SlcException("Cannot load sta stores", e1);
+ }
+
+ MapLayer mapLayer = null;
+ while (true) {
+ SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(
+ POSITION);
+
+ // add the attributes
+ featureBuilder.add(positionProvider.currentPosition());
+ featureBuilder.add(12);
+ featureBuilder.add("My Name");
+
+ // build the feature
+ SimpleFeature feature = featureBuilder.buildFeature("Flag.12");
+ FeatureCollection<SimpleFeatureType, SimpleFeature> collection = new DefaultFeatureCollection(
+ "testCollection", POSITION);
+ collection.add(feature);
+ if (mapLayer != null)
+ mapContext.removeLayer(mapLayer);
+ Style style = SLD.createSimpleStyle(POSITION, Color.RED);
+ mapLayer = new DefaultMapLayer(collection, style, "");
+ mapContext.addLayer(mapLayer);
+ // mapContext.addLayer(collection,null);
+
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public void setPositionProvider(PositionProvider positionProvider) {
+ this.positionProvider = positionProvider;
+ }
+
+ public void setJaiImageIoClassLoader(ClassLoader classLoader) {
+ this.jaiImageIoClassLoader = classLoader;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+package org.argeo.slc.geotools;
+
+import java.io.File;
+
+import org.geotools.coverage.grid.GridCoverage2D;
+import org.geotools.gce.image.WorldImageFormat;
+import org.geotools.gce.image.WorldImageReader;
+
+public class WorldFileTest {
+
+ @SuppressWarnings("restriction")
+ public static void main(String[] args) throws Exception {
+ File dir = new File("/home/mbaudier/gis/data/100501-Poehali");
+ WorldImageFormat worldImageFormat = new WorldImageFormat();
+ WorldImageReader worldImageReader = worldImageFormat
+ .getReader(new File(dir, "500k--l36-1--(1984).gif"));
+ GridCoverage2D gridCoverage2D = worldImageReader.read(null);
+ gridCoverage2D.show();
+ }
+
+}
--- /dev/null
+package org.argeo.slc.geotools.swing;
+
+import java.awt.Color;
+import java.awt.Cursor;
+import java.awt.Graphics2D;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseWheelEvent;
+import java.awt.event.MouseWheelListener;
+import java.awt.geom.Point2D;
+
+import javax.swing.SwingUtilities;
+import javax.swing.event.MouseInputAdapter;
+
+import org.geotools.geometry.DirectPosition2D;
+import org.geotools.geometry.Envelope2D;
+import org.geotools.geometry.jts.ReferencedEnvelope;
+import org.geotools.swing.JMapPane;
+import org.geotools.swing.event.MapMouseEvent;
+import org.geotools.swing.tool.AbstractZoomTool;
+
+public class VersatileZoomTool extends AbstractZoomTool {
+ // private Log log = LogFactory.getLog(VersatileZoomTool.class);
+
+ // private static final ResourceBundle stringRes = ResourceBundle
+ // .getBundle("org/geotools/swing/Text");
+
+ // Cursors
+ private Cursor zoomInCursor;
+ private Cursor panCursor;
+ private Cursor defaultCursor;
+
+ // Variable values
+ private Point2D startDragPos;
+ private Point panePos;
+ private boolean computingZoomBox;
+ private boolean panning;
+
+ /**
+ * Constructor
+ */
+ public VersatileZoomTool() {
+ // Toolkit tk = Toolkit.getDefaultToolkit();
+ // zoomInCursor = tk.createCustomCursor(new ImageIcon(getClass()
+ // .getResource("/org/geotools/swing/icons/mActionZoomIn.png"))
+ // .getImage(), new Point(14, 9), stringRes
+ // .getString("tool_name_zoom_in"));
+ zoomInCursor = new Cursor(Cursor.SE_RESIZE_CURSOR);
+ // panCursor = tk.createCustomCursor(new
+ // ImageIcon(getClass().getResource(
+ // "/org/geotools/swing/icons/mActionPan.png")).getImage(),
+ // new Point(15, 15), stringRes.getString("tool_name_pan"));
+ panCursor = new Cursor(Cursor.HAND_CURSOR);
+ defaultCursor = new Cursor(Cursor.CROSSHAIR_CURSOR);
+
+ startDragPos = new DirectPosition2D();
+ computingZoomBox = false;
+ panning = false;
+
+ }
+
+ /**
+ * Zoom in by the currently set increment, with the map centred at the
+ * location (in world coords) of the mouse click
+ *
+ * @param e
+ * map mapPane mouse event
+ */
+ @Override
+ public void onMouseClicked(MapMouseEvent e) {
+ centerMapToEvent(e);
+ }
+
+ protected void centerMapToEvent(MapMouseEvent e) {
+ Rectangle paneArea = getMapPane().getVisibleRect();
+ DirectPosition2D mapPos = e.getMapPosition();
+
+ double scale = getMapPane().getWorldToScreenTransform().getScaleX();
+ // double newScale = scale * zoom;
+ //
+ DirectPosition2D corner = new DirectPosition2D(mapPos.getX() - 0.5d
+ * paneArea.getWidth() / scale, mapPos.getY() + 0.5d
+ * paneArea.getHeight() / scale);
+
+ Envelope2D newMapArea = new Envelope2D();
+ newMapArea.setFrameFromCenter(mapPos, corner);
+ getMapPane().setDisplayArea(newMapArea);
+ }
+
+ /**
+ * Records the map position of the mouse event in case this button press is
+ * the beginning of a mouse drag
+ *
+ * @param ev
+ * the mouse event
+ */
+ @Override
+ public void onMousePressed(MapMouseEvent ev) {
+ if (SwingUtilities.isLeftMouseButton(ev)) {
+ startDragPos = new DirectPosition2D();
+ startDragPos.setLocation(ev.getMapPosition());
+ } else if (SwingUtilities.isMiddleMouseButton(ev)) {
+ panePos = ev.getPoint();
+ panning = true;
+ }
+ }
+
+ /**
+ * Records that the mouse is being dragged
+ *
+ * @param ev
+ * the mouse event
+ */
+ @Override
+ public void onMouseDragged(MapMouseEvent ev) {
+ if (SwingUtilities.isLeftMouseButton(ev)) {
+ computingZoomBox = true;
+ } else if (panning) {
+ Point pos = ev.getPoint();
+ if (!pos.equals(panePos)) {
+ getMapPane().moveImage(pos.x - panePos.x, pos.y - panePos.y);
+ panePos = pos;
+ }
+ }
+ getMapPane().setCursor(getCursor());
+ }
+
+ /**
+ * If the mouse was dragged, determines the bounds of the box that the user
+ * defined and passes this to the mapPane's
+ * {@link org.geotools.swing.JMapPane#setDisplayArea(org.opengis.geometry.Envelope) }
+ * method
+ *
+ * @param ev
+ * the mouse event
+ */
+ @Override
+ public void onMouseReleased(MapMouseEvent ev) {
+ if (computingZoomBox && !ev.getPoint().equals(startDragPos)) {
+ Envelope2D env = new Envelope2D();
+ env.setFrameFromDiagonal(startDragPos, ev.getMapPosition());
+ computingZoomBox = false;
+ getMapPane().setDisplayArea(env);
+ } else if (panning) {
+ panning = false;
+ getMapPane().repaint();
+ }
+ getMapPane().setCursor(getCursor());
+ }
+
+ /**
+ * Get the mouse cursor for this tool
+ */
+ @Override
+ public Cursor getCursor() {
+ if (computingZoomBox)
+ return zoomInCursor;
+ else if (panning)
+ return panCursor;
+ else
+ return defaultCursor;
+ }
+
+ /**
+ * We use a custom drag box
+ */
+ @Override
+ public boolean drawDragBox() {
+ return false;
+ }
+
+ @Override
+ public void setMapPane(JMapPane pane) {
+ super.setMapPane(pane);
+ VariableDragBox dragBox = new VariableDragBox();
+ getMapPane().addMouseListener(dragBox);
+ getMapPane().addMouseMotionListener(dragBox);
+ getMapPane().addMouseWheelListener(new MouseWheelListener() {
+ private double clickToZoom = 0.1; // 1 wheel click is 10% zoom
+
+ 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 = getMapPane().getDisplayArea();
+ double width = env.getWidth();
+ double delta = width * clickToZoom * sign;
+
+ env.expandBy(delta);
+ getMapPane().setDisplayArea(env);
+ getMapPane().repaint();
+ }
+ });
+ }
+
+ /**
+ * Custom drag box (hacked from JMapPane) so that we can change the behavior
+ * depending on whether we pan or zoom.
+ */
+ private class VariableDragBox extends MouseInputAdapter {
+
+ private Point startPos;
+ private Rectangle rect;
+ private boolean dragged;
+
+ VariableDragBox() {
+ rect = new Rectangle();
+ dragged = false;
+ }
+
+ @Override
+ public void mousePressed(MouseEvent e) {
+ startPos = new Point(e.getPoint());
+ }
+
+ @Override
+ public void mouseDragged(MouseEvent e) {
+ if (computingZoomBox) {
+ Graphics2D g2D = (Graphics2D) getMapPane().getGraphics();
+ g2D.setColor(Color.WHITE);
+ g2D.setXORMode(Color.RED);
+ if (dragged) {
+ g2D.drawRect(rect.x, rect.y, rect.width, rect.height);
+ }
+
+ rect.setFrameFromDiagonal(startPos, e.getPoint());
+ g2D.drawRect(rect.x, rect.y, rect.width, rect.height);
+
+ dragged = true;
+ }
+ }
+
+ @Override
+ public void mouseReleased(MouseEvent e) {
+ if (dragged) {
+ Graphics2D g2D = (Graphics2D) getMapPane().getGraphics();
+ g2D.setColor(Color.WHITE);
+ g2D.setXORMode(Color.RED);
+ g2D.drawRect(rect.x, rect.y, rect.width, rect.height);
+ dragged = false;
+ }
+ }
+ }
+
+}
return position;
}
+ public void setInputFormat(String inputFormat) {
+ this.inputFormat = inputFormat;
+ }
+
+ public void setInputFile(String inputFile) {
+ this.inputFile = inputFile;
+ }
+
}