Changeset 29497 in osm


Ignore:
Timestamp:
2013-04-14T16:34:48+02:00 (11 years ago)
Author:
donvip
Message:

[josm_opendata] fix #josm8309 - Fallback to EPSG:4326 when no projection found for shapefiles

File:
1 edited

Legend:

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

    r28191 r29497  
    2626import java.util.Map;
    2727import java.util.Set;
     28
     29import javax.swing.JOptionPane;
    2830
    2931import org.geotools.data.DataStore;
     
    4850import org.openstreetmap.josm.data.osm.Way;
    4951import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     52import org.openstreetmap.josm.gui.util.GuiHelper;
    5053import org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler;
    5154import org.openstreetmap.josm.plugins.opendata.core.datasets.NationalHandlers;
     
    8184        }
    8285       
    83         private void parseFeature(Feature feature, Component parent)
     86        private void parseFeature(Feature feature, final Component parent)
    8487                        throws UserCancelException, GeoMathTransformException, FactoryException, GeoCrsException, MismatchedDimensionException, TransformException {
    8588                featurePrimitives.clear();
     
    8992                        GeometryDescriptor desc = geometry.getDescriptor();
    9093                       
    91                         if (crs == null && desc != null && desc.getCoordinateReferenceSystem() != null) {
    92                                 crs = desc.getCoordinateReferenceSystem();
    93                                 findMathTransform(parent, true);
    94                         } else if (crs == null) {
    95                                 throw new GeoCrsException("Unable to detect CRS !");
     94                        if (crs == null) {
     95                        if (desc != null && desc.getCoordinateReferenceSystem() != null) {
     96                                crs = desc.getCoordinateReferenceSystem();
     97                        } else {
     98                            GuiHelper.runInEDTAndWait(new Runnable() {
     99                        @Override
     100                        public void run() {
     101                            if (0 == JOptionPane.showConfirmDialog(
     102                                    parent,
     103                                    tr("Unable to detect Coordinate Reference System.\nWould you like to fallback to ESPG:4326 (WGS 84) ?"),
     104                                    tr("Warning: CRS not found"),
     105                                    JOptionPane.YES_NO_CANCEL_OPTION
     106                            )) {
     107                                crs = wgs84;
     108                            }
     109                        }
     110                    });
     111                        }
     112                if (crs != null) {
     113                    findMathTransform(parent, true);
     114                } else {
     115                    throw new GeoCrsException(tr("Unable to detect CRS !"));
     116                }
    96117                        }
    97118                       
Note: See TracChangeset for help on using the changeset viewer.