Package org.openstreetmap.josm.io

Examples of org.openstreetmap.josm.io.CachedFile


                            sources.add((ExtendedSourceEntry) src);
                        }
                    }
                }

                InputStream stream = new CachedFile(url).getInputStream();
                reader = new BufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8));

                String line;
                ExtendedSourceEntry last = null;
View Full Code Here


        return !rlCache.get(ll);
    }

    private static void initialize() {
        leftHandTrafficPolygons = new ArrayList<>();
        try (InputStream is = new CachedFile("resource://data/left-right-hand-traffic.osm").getInputStream()) {
            DataSet data = OsmReader.parseDataSet(is, null);
            for (Way w : data.getWays()) {
                leftHandTrafficPolygons.add(Geometry.getAreaLatLon(w.getNodes()));
            }
        } catch (IOException | IllegalDataException ex) {
View Full Code Here

    @Override
    public void initialize() throws Exception {
        super.initialize();
        if (ENGINE != null) {
            try (Reader reader = new InputStreamReader(
                    new CachedFile("resource://data/validator/opening_hours.js").getInputStream(), StandardCharsets.UTF_8)) {
                ENGINE.eval(reader);
                // fake country/state to not get errors on holidays
                ENGINE.eval("var nominatimJSON = {address: {state: 'Bayern', country_code: 'de'}};");
                ENGINE.eval(
                        "var oh = function (value, mode) {" +
View Full Code Here

        spellCheckKeyData = new HashMap<>();

        String errorSources = "";
        for (String source : Main.pref.getCollection(PREF_SOURCES, DEFAULT_SOURCES)) {
            try (
                InputStream s = new CachedFile(source).getInputStream();
                BufferedReader reader = new BufferedReader(UTFInputStreamReader.create(s));
            ) {
                String okValue = null;
                boolean tagcheckerfile = false;
                boolean ignorefile = false;
View Full Code Here

     * @throws IOException if any I/O error occurs
     * @since 7275
     */
    public synchronized void addMapCSS(String url) throws ParseException, IOException {
        CheckParameterUtil.ensureParameterNotNull(url, "url");
        CachedFile cache = new CachedFile(url);
        try (InputStream s = cache.getInputStream()) {
            List<TagCheck> tagchecks = TagCheck.readMapCSS(new BufferedReader(UTFInputStreamReader.create(s)));
            checks.remove(url);
            checks.putAll(url, tagchecks);
            // Check assertions, useful for development of local files
            if (Main.pref.getBoolean("validator.check_assert_local_rules", false) && Utils.isLocalUrl(url)) {
View Full Code Here

        return all;
    }

    public static Collection<TaggingPreset> readAll(String source, boolean validate) throws SAXException, IOException {
        Collection<TaggingPreset> tp;
        CachedFile cf = new CachedFile(source).setHttpAccept(PRESET_MIME_TYPES);
        try (
            // zip may be null, but Java 7 allows it: https://blogs.oracle.com/darcy/entry/project_coin_null_try_with
            InputStream zip = cf.findZipEntryInputStream("xml", "preset")
        ) {
            if (zip != null) {
                zipIcons = cf.getFile();
            }
            try (InputStreamReader r = new InputStreamReader(zip == null ? cf.getInputStream() : zip, StandardCharsets.UTF_8)) {
                tp = readAll(new BufferedReader(r), validate);
            }
        }
        return tp;
    }
View Full Code Here

     * Load +init "presets" from file
     */
    private static void loadInits() {
        Pattern epsgPattern = Pattern.compile("<(\\d+)>(.*)<>");
        try (
            InputStream in = new CachedFile("resource://data/projection/epsg").getInputStream();
            BufferedReader r = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8));
        ) {
            String line, lastline = "";
            while ((line = r.readLine()) != null) {
                line = line.trim();
View Full Code Here

        }
    }

    @Override
    public InputStream getSourceInputStream() throws IOException {
        CachedFile cf = getCachedFile();
        InputStream zip = cf.findZipEntryInputStream("xml", "style");
        if (zip != null) {
            zipIcons = cf.getFile();
            return zip;
        } else {
            zipIcons = null;
            return cf.getInputStream();
        }
    }
View Full Code Here

        }
    }

    @Override
    public CachedFile getCachedFile() throws IOException {
        return new CachedFile(url).setHttpAccept(XML_STYLE_MIME_TYPES);
    }
View Full Code Here

     * The grid file is only loaded once, when first accessed.
     * @return The NTv2 grid file
     */
    public NTV2GridShiftFile getShiftFile() {
        if (instance == null) {
            try (InputStream is = new CachedFile(gridFileName).getInputStream()) {
                instance = new NTV2GridShiftFile();
                instance.loadGridShiftFile(is, false);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
View Full Code Here

TOP

Related Classes of org.openstreetmap.josm.io.CachedFile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.