|
From: Alessandro F. <ale...@gm...> - 2011-03-18 22:31:36
|
Testing pre-built 2.7.RC2 binaries to compile simple shapefile reading
program.
Using 2.7.RC2 I get
Exception in thread "Thread-5" Exception in thread "Thread-2"
java.lang.RuntimeException: Unable to find function Length
at
org.geotools.filter.FunctionFinder.findFunction(FunctionFinder.java:103)
at
org.geotools.filter.FunctionFinder.findFunction(FunctionFinder.java:69)
at
org.geotools.filter.FilterFactoryImpl.function(FilterFactoryImpl.java:469)
at
org.geotools.feature.AttributeTypeBuilder.lengthRestriction(AttributeTypeBuilder.java:624)
at
org.geotools.feature.AttributeTypeBuilder.buildType(AttributeTypeBuilder.java:455)
at
org.geotools.feature.AttributeTypeBuilder.buildDescriptor(AttributeTypeBuilder.java:516)
at
org.geotools.data.shapefile.ShapefileDataStore.readAttributes(ShapefileDataStore.java:811)
at
org.geotools.data.shapefile.ShapefileDataStore.getSchema(ShapefileDataStore.java:714)
at
org.geotools.data.shapefile.ShapefileDataStore.getSchema(ShapefileDataStore.java:708)
at
org.geotools.data.shapefile.ShapefileDataStore.getFeatureSource(ShapefileDataStore.java:1040)
at geom_reader.run(geom_reader.java:57)
at java.lang.Thread.run(Thread.java:619)
If I swap out 2.7.RC2 geotools with 2.6.5 geotools it works fine.
I've found lots of postings about people having this exact same issue but
they were all using maven plugin voodoo and creating these service functions
at build time... I am not using maven but pre-built bin jars downloaded from
http://sourceforge.net/projects/geotools/files/GeoTools%202.7%20Releases/2.7-RC2/
and a simple.sh file to invoke java, keepin' it old school.
I unjarred the gt-main and did find a lot of SPI files, with many functions
inside
grep -r "Length" *
org.opengis.filter.expression.Function:org.geotools.filter.LengthFunction
org.opengis.filter.expression.Function:org.geotools.filter.function.FilterFunction_geomLength
org.opengis.filter.expression.Function:org.geotools.filter.function.FilterFunction_strLength
The following are the jars I'm including in classpath:
gt-api-2.7-RC2.jar
gt-main-2.7-RC2.jar
gt-opengis-2.7-RC2.jar
gt-shapefile-2.7-RC2.jar
jts-1.11.jar
gt-data-2.7-RC2.jar
gt-metadata-2.7-RC2.jar
gt-referencing-2.7-RC2.jar
jsr-275-1.0-beta-2.jar
code is straight forward:
Map map = new HashMap();
map.put("url", shpfile.toURI().toURL());
DataStore store = DataStoreFinder.getDataStore(map);
String[] typeNames = store.getTypeNames();
String typeName = typeNames[0];
logger.info("typeName: " + typeName);
FeatureSource<SimpleFeatureType, SimpleFeature>
featureSource = store.getFeatureSource(typeName);
SimpleFeatureType ft = featureSource.getSchema();
Map<String, Integer> attributemap = new HashMap<String,
Integer>();
List<AttributeDescriptor> attrdescripts =
ft.getAttributeDescriptors();
for (int x = 0; x < attrdescripts.size(); x++) {
attributemap.put(attrdescripts.get(x).getLocalName(), x);
}
FeatureCollection<SimpleFeatureType, SimpleFeature>
collection = featureSource.getFeatures();
FeatureIterator<SimpleFeature> iterator =
collection.features();
while (iterator.hasNext()) {
}
Any ideas?
Thank you,
--
Signed,
Alessandro Ferrucci
|