Ignore:
Timestamp:
2017-09-08T00:42:43+02:00 (3 years ago)
Author:
bastiK
Message:

see #15229 - add registry for NTV2 grid file sources

removes dependency of NTV2GridShiftFileWrapper on Main

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/MainApplication.java

    r12770 r12777  
    8585import org.openstreetmap.josm.data.osm.UserInfo;
    8686import org.openstreetmap.josm.data.osm.search.SearchMode;
     87import org.openstreetmap.josm.data.projection.datum.NTV2GridShiftFileSource;
     88import org.openstreetmap.josm.data.projection.datum.NTV2GridShiftFileWrapper;
     89import org.openstreetmap.josm.data.projection.datum.NTV2Proj4DirGridShiftFileSource;
    8790import org.openstreetmap.josm.data.validation.OsmValidator;
    8891import org.openstreetmap.josm.gui.ProgramArguments.Option;
     
    113116import org.openstreetmap.josm.gui.util.WindowGeometry;
    114117import org.openstreetmap.josm.gui.widgets.UrlLabel;
     118import org.openstreetmap.josm.io.CachedFile;
    115119import org.openstreetmap.josm.io.CertificateAmendment;
    116120import org.openstreetmap.josm.io.DefaultProxySelector;
     
    235239            menu.redo.setEnabled(redoSize > 0);
    236240        };
     241
     242    /**
     243     * Source of NTV2 shift files: Download from JOSM website.
     244     * @since 12777
     245     */
     246    public static final NTV2GridShiftFileSource JOSM_WEBSITE_NTV2_SOURCE = gridFileName -> {
     247        String location = Main.getJOSMWebsite() + "/proj/" + gridFileName;
     248        // Try to load grid file
     249        CachedFile cf = new CachedFile(location);
     250        try {
     251            return cf.getInputStream();
     252        } catch (IOException ex) {
     253            Logging.warn(ex);
     254            return null;
     255        }
     256    };
    237257
    238258    /**
     
    902922        Main.toolbar = toolbar;
    903923        ProjectionPreference.setProjection();
     924        NTV2GridShiftFileWrapper.registerNTV2GridShiftFileSource(
     925                NTV2GridShiftFileWrapper.NTV2_SOURCE_PRIORITY_LOCAL,
     926                NTV2Proj4DirGridShiftFileSource.getInstance());
     927        NTV2GridShiftFileWrapper.registerNTV2GridShiftFileSource(
     928                NTV2GridShiftFileWrapper.NTV2_SOURCE_PRIORITY_DOWNLOAD,
     929                JOSM_WEBSITE_NTV2_SOURCE);
    904930        GuiHelper.translateJavaInternalMessages();
    905931        preConstructorInit();
Note: See TracChangeset for help on using the changeset viewer.