daily pastebin goal
45%
SHARE
TWEET

Untitled

a guest Feb 22nd, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import org.opengis.feature.*;
  2. import org.geotools.feature.*;
  3. import org.geotools.data.*;
  4. import java.io.*;
  5. import java.util.*;
  6. public class GeoOpen
  7. {
  8.  
  9. public static void main(String[] args) {
  10. File file = new File("states.shp");
  11.  
  12. try {
  13.   Map<String, String> connect = new HashMap();
  14.   connect.put("url", file.toURI().toString());
  15.  
  16.   DataStore dataStore = DataStoreFinder.getDataStore(connect);
  17.   String[] typeNames = dataStore.getTypeNames();
  18.   String typeName = typeNames[0];
  19.  
  20.   System.out.println("Reading content " + typeName);
  21.  
  22.   FeatureSource featureSource = dataStore.getFeatureSource(typeName);
  23.   FeatureCollection collection = featureSource.getFeatures();
  24.   FeatureIterator iterator = collection.features();
  25.  
  26.  
  27.   try {
  28.     while (iterator.hasNext()) {
  29.       Feature feature = iterator.next();
  30.       GeometryAttribute sourceGeometry = feature.getDefaultGeometryProperty();
  31.     }
  32.   } finally {
  33.     iterator.close();
  34.   }
  35.  
  36. } catch (Throwable e) {
  37.     e.printStackTrace();}}
  38. }
  39.      
  40. java.lang.IncompatibleClassChangeError: Implementing class
  41.     at java.lang.ClassLoader.defineClass1(Native Method)
  42.     at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
  43.     at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
  44.     at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
  45.     at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
  46.     at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
  47.     at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
  48.     at java.security.AccessController.doPrivileged(Native Method)
  49.     at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
  50.     at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
  51.     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
  52.     at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
  53.     at org.geotools.data.shapefile.ShpFiles.exists(ShpFiles.java:981)
  54.     at org.geotools.data.shapefile.ShpFiles.init(ShpFiles.java:172)
  55.     at org.geotools.data.shapefile.ShpFiles.<init>(ShpFiles.java:129)
  56.     at org.geotools.data.shapefile.ShapefileDataStoreFactory.createDataStore(ShapefileDataStoreFactory.java:195)
  57.     at org.geotools.data.shapefile.ShapefileDataStoreFactory.createDataStore(ShapefileDataStoreFactory.java:63)
  58.     at org.geotools.data.DataAccessFinder.getDataStore(DataAccessFinder.java:129)
  59.     at org.geotools.data.DataStoreFinder.getDataStore(DataStoreFinder.java:87)
  60.     at GeoOpen.main(GeoOpen.java:28)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top