[geotk] java.lang.IllegalStateException: Can not handle this instance of ‘Geometry’ because arbitrary implementations are not yet supported.

Stephane Fellah stephanef at imagemattersllc.com
Fri Jun 22 10:42:22 PDT 2018


I have tried to read GeoJSON from Geotk 5.0 snapshot and I get the
following error

java.lang.IllegalStateException: Can not handle this instance of ‘Geometry’
because arbitrary implementations are not yet supported.

I had a similar issue trying to read from a shapefile.

Here the code

import org.geotoolkit.data.FeatureCollection;
import org.geotoolkit.data.FeatureStore;
import org.geotoolkit.data.geojson.GeoJSONFeatureStoreFactory;
import org.geotoolkit.data.query.QueryBuilder;
import org.geotoolkit.data.session.Session;
import org.geotoolkit.storage.DataStores;
import org.opengis.feature.FeatureType;
import org.opengis.parameter.ParameterDescriptor;
import org.opengis.parameter.ParameterDescriptorGroup;
import org.opengis.parameter.ParameterValueGroup;
import org.opengis.util.GenericName;

import java.io.File;

public class GeoJSONReader {

    public static final ParameterDescriptorGroup PARAMETERS_DESCRIPTOR
= GeoJSONFeatureStoreFactory.PARAMETERS_DESCRIPTOR;
    public static final ParameterDescriptor PATH =
GeoJSONFeatureStoreFactory.PATH;

    public static FeatureCollection getFeatureCollection(File file)
throws DataStoreException {
        ParameterValueGroup param = PARAMETERS_DESCRIPTOR.createValue();
        param.parameter("path").setValue(file.toURI());
        FeatureStore store = (FeatureStore) DataStores.open(param);

        GenericName name = store.getNames().iterator().next();
        FeatureType ft = store.getFeatureType(name.toString());
        Session session = store.createSession(false);
        return session.getFeatureCollection(QueryBuilder.all(name));
    }

    public static void main(String[] args) throws DataStoreException {

        File file = new File(args[0]);
        FeatureCollection fc = getFeatureCollection(file);
        System.out.println(fc);

    }
}


Gradle configuration is:

group 'com.imagemattersllc'
version '1.0-SNAPSHOT'

apply plugin: 'java'

sourceCompatibility = 1.8

repositories {
    maven { url "http://maven.geotoolkit.org/"}
    mavenCentral()
}

dependencies {
    compile (group: 'org.geotoolkit', name: 'geotk-feature-geojson',
version: '5.0-SNAPSHOT')
    testCompile group: 'junit', name: 'junit', version: '4.12'
}


I attached the geojson file I used. Right now I am unable to use GeoToolkit
FeatureStore with Apache 1.0-SNAPSHOT.  Any solutions?




-- 
Stephane Fellah
Chief  Knowledge Scientist
Image Matters LLC
Office: +(703) 669 5510
Cell: 703 431 9420
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/geotoolkit/attachments/20180622/8c8ff0a5/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: countries.geojson
Type: application/octet-stream
Size: 257134 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/geotoolkit/attachments/20180622/8c8ff0a5/attachment-0001.obj>


More information about the Geotoolkit mailing list