문제

I just want to know how to create an instance of a Multipoint from a PostGIS database.

I do the query, then get a ResultSet named area. The column with MultiPolygon attributes is named geom, so I do the following:

MultiPolygon m = (MultiPolygon)area.getObject("geom");

Forced cast doesn't work though!

도움이 되었습니까?

해결책

You shouldn't be referencing the ResultSet directly but should work through the datastore interface which takes care of the conversion for you. See the Query Tutorial for an example of searching a dataset and retrieving geometries.

You'll need something like:

 SimpleFeatureSource source = dataStore.getFeatureSource(typeName);

    FeatureType schema = source.getSchema();
    String name = schema.getGeometryDescriptor().getLocalName();

    Filter filter = CQL.toFilter(text.getText());

    Query query = new Query(typeName, filter, new String[] { name });

    SimpleFeatureCollection features = source.getFeatures(query);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top