Changeset 36076 in osm for applications/editors/josm


Ignore:
Timestamp:
2023-04-20T15:14:44+02:00 (15 months ago)
Author:
taylor.smock
Message:

GeotoolsConverter: Continue parsing layers even if a previous layer could not be parsed

This is mostly useful when JTS (the underlying WKB parser) does not understand
the geometry type for a layer.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/GeotoolsConverter.java

    r36074 r36076  
    2727import org.locationtech.jts.geom.Point;
    2828import org.locationtech.jts.geom.Polygon;
     29import org.locationtech.jts.io.ParseException;
    2930import org.opengis.feature.Feature;
    3031import org.opengis.feature.GeometryAttribute;
     
    8283                FeatureSource<?, ?> featureSource = dataStore.getFeatureSource(typeName);
    8384                FeatureCollection<?, ?> collection = featureSource.getFeatures();
    84                 parseFeatures(progressMonitor != null ? progressMonitor.createSubTaskMonitor(1, false) : null, collection);
     85                try {
     86                    parseFeatures(progressMonitor != null ? progressMonitor.createSubTaskMonitor(1, false) : null, collection);
     87                    // Geotools wraps an IOException in a RuntimeException. We want to keep parsing layers, even if we could not understand
     88                    // a previous layer.
     89                } catch (RuntimeException runtimeException) {
     90                    if (runtimeException.getCause() instanceof IOException && runtimeException.getCause().getCause() instanceof ParseException) {
     91                        Logging.error(runtimeException);
     92                    } else {
     93                        throw runtimeException;
     94                    }
     95                }
    8596            }
    8697        } finally {
Note: See TracChangeset for help on using the changeset viewer.