Ignore:
Timestamp:
2017-09-07T23:41:42+02:00 (2 years ago)
Author:
bastiK
Message:

see #15229 - remove dependency of NTV2GridShiftFileWrapper on Main.platform

  • PlatformHook bundles all application-wide platform dependent code, which is

convenient, but problematic for separating modules

  • introduces lightweight tools.Platform for adding platform dependent code more locally
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2GridShiftFileWrapper.java

    r11642 r12776  
    55import java.io.IOException;
    66import java.io.InputStream;
     7import java.util.Arrays;
     8import java.util.Collections;
     9import java.util.List;
    710
    811import org.openstreetmap.josm.Main;
    912import org.openstreetmap.josm.io.CachedFile;
     13import org.openstreetmap.josm.tools.Platform;
     14import org.openstreetmap.josm.tools.PlatformVisitor;
    1015
    1116/**
     
    2934
    3035    /**
     36     * Lists default directories where the ntv2 shift files (NAD) for the proj4
     37     * library would be located on different platforms.
     38     */
     39    public static final PlatformVisitor<List<File>> DEFAULT_PROJ4_NTV2_SHIFT_DIRS =
     40            new PlatformVisitor<List<File>>() {
     41        @Override
     42        public List<File> visitUnixoid() {
     43            return Arrays.asList(new File("/usr/local/share/proj"), new File("/usr/share/proj"));
     44        }
     45
     46        @Override
     47        public List<File> visitWindows() {
     48            return Arrays.asList(new File("C:\\PROJ\\NAD"));
     49        }
     50
     51        @Override
     52        public List<File> visitOsx() {
     53            return Collections.emptyList();
     54        }
     55    };
     56
     57    /**
    3158     * Returns the actual {@link NTV2GridShiftFile} behind this wrapper.
    3259     * The grid file is only loaded once, when first accessed.
     
    3865            File grid = null;
    3966            // Check is the grid is installed in default PROJ.4 directories
    40             for (File dir : Main.platform.getDefaultProj4NadshiftDirectories()) {
     67            for (File dir : Platform.determinePlatform().accept(DEFAULT_PROJ4_NTV2_SHIFT_DIRS)) {
    4168                File file = new File(dir, gridFileName);
    4269                if (file.exists() && file.isFile()) {
Note: See TracChangeset for help on using the changeset viewer.