I want to know the true type of Geometry using GeoTools (point, polygon, multipolygon). GeoTools always returns me as a MultiPolygon, and my object has this format for example:
"geometry": {"type": "polygon", "coordinates": [-86.577085000372449, 34.793410999917739], [-86.57692100000412, 34.793837999823893], [-86.576509999936491, 34.794884000396337]
Currently I have the following code:
Map <String, Object> map = new HashMap <> ();
map.put ("url", file.toURI (). toURL ());
DataStore dataStore = DataStoreFinder.getDataStore (map);
String typeName = dataStore.getTypeNames () [0];
FeatureSource <SimpleFeatureType, SimpleFeature> source = dataStore
.getFeatureSource (typeName);
FeatureCollection <SimpleFeatureType, SimpleFeature> collection = source.getFeatures ();
try (FeatureIterator <SimpleFeature> features = collection.features ()) {
while (features.hasNext ()) {
SimpleFeature feature = features.next ();
feature.getAttribute ("the_geom"). toString ();
}