Package org.openstreetmap.josm.io

Examples of org.openstreetmap.josm.io.IllegalDataException


     *
     * @param e the exception
     * @return The HTML formatted error message to display
     */
    public static String explainNestedIllegalDataException(OsmTransferException e) {
        IllegalDataException ide = getNestedException(e, IllegalDataException.class);
        Main.error(e);
        return tr("<html>Failed to download data. "
                + "Its format is either unsupported, ill-formed, and/or inconsistent.<br>"
                + "<br>Details (untranslated): {0}</html>", ide.getMessage());
    }
View Full Code Here


            return layer;
        }
    }

    private static void error(String msg) throws IllegalDataException {
        throw new IllegalDataException(msg);
    }
View Full Code Here

            builderFactory.setNamespaceAware(true);
            DocumentBuilder builder = builderFactory.newDocumentBuilder();
            Document document = builder.parse(josIS);
            parseJos(document, progressMonitor);
        } catch (SAXException e) {
            throw new IllegalDataException(e);
        } catch (ParserConfigurationException e) {
            throw new IOException(e);
        }
    }
View Full Code Here

    @Override
    public Layer load(Element elem, ImportSupport support, ProgressMonitor progressMonitor) throws IOException, IllegalDataException {
        String version = elem.getAttribute("version");
        if (!"0.1".equals(version)) {
            throw new IllegalDataException(tr("Version ''{0}'' of meta data for marker layer is not supported. Expected: 0.1", version));
        }
        try {
            XPathFactory xPathFactory = XPathFactory.newInstance();
            XPath xpath = xPathFactory.newXPath();
            XPathExpression fileExp = xpath.compile("file/text()");
            String fileStr = (String) fileExp.evaluate(elem, XPathConstants.STRING);
            if (fileStr == null || fileStr.isEmpty()) {
                throw new IllegalDataException(tr("File name expected for layer no. {0}", support.getLayerIndex()));
            }

            try (InputStream in = support.getInputStream(fileStr)) {
                GpxImporter.GpxImporterData importData = GpxImporter.loadLayers(in, support.getFile(fileStr), support.getLayerName(), null, progressMonitor);

                support.addPostLayersTask(importData.getPostLayerTask());

                GpxLayer gpxLayer = null;
                List<SessionReader.LayerDependency> deps = support.getLayerDependencies();
                if (!deps.isEmpty()) {
                    Layer layer = deps.iterator().next().getLayer();
                    if (layer instanceof GpxLayer) {
                        gpxLayer = (GpxLayer) layer;
                    }
                }

                MarkerLayer markerLayer = importData.getMarkerLayer();
                if (markerLayer != null) {
                    markerLayer.fromLayer = gpxLayer;
                }

                return markerLayer;
            }
        } catch (XPathExpressionException e) {
            throw new IllegalDataException(e);
        }
    }
View Full Code Here

    @Override
    public Layer load(Element elem, SessionReader.ImportSupport support, ProgressMonitor progressMonitor) throws IOException, IllegalDataException {
        String version = elem.getAttribute("version");
        if (!"0.1".equals(version)) {
            throw new IllegalDataException(tr("Version ''{0}'' of meta data for geoimage layer is not supported. Expected: 0.1", version));
        }

        List<ImageEntry> entries = new ArrayList<>();
        NodeList imgNodes = elem.getChildNodes();
        boolean useThumbs = false;
View Full Code Here

    @Override
    public Layer load(Element elem, SessionReader.ImportSupport support, ProgressMonitor progressMonitor) throws IOException, IllegalDataException {
        String version = elem.getAttribute("version");
        if (!"0.1".equals(version)) {
            throw new IllegalDataException(tr("Version ''{0}'' of meta data for gpx track layer is not supported. Expected: 0.1", version));
        }
        try {
            XPathFactory xPathFactory = XPathFactory.newInstance();
            XPath xpath = xPathFactory.newXPath();
            XPathExpression fileExp = xpath.compile("file/text()");
            String fileStr = (String) fileExp.evaluate(elem, XPathConstants.STRING);
            if (fileStr == null || fileStr.isEmpty()) {
                throw new IllegalDataException(tr("File name expected for layer no. {0}", support.getLayerIndex()));
            }

            try (InputStream in = support.getInputStream(fileStr)) {
                GpxImporter.GpxImporterData importData = null;

                if (NMEAImporter.FILE_FILTER.acceptName(fileStr)) {
                    importData = NMEAImporter.loadLayers(in, support.getFile(fileStr), support.getLayerName(), null);
                } else {
                    importData = GpxImporter.loadLayers(in, support.getFile(fileStr), support.getLayerName(), null, progressMonitor);
                }

                support.addPostLayersTask(importData.getPostLayerTask());
                return importData.getGpxLayer();
            }

        } catch (XPathExpressionException e) {
            throw new IllegalDataException(e);
        }
    }
View Full Code Here

    @Override
    public Layer load(Element elem, ImportSupport support, ProgressMonitor progressMonitor) throws IOException, IllegalDataException {
        String version = elem.getAttribute("version");
        if (!"0.1".equals(version)) {
            throw new IllegalDataException(tr("Version ''{0}'' of meta data for osm data layer is not supported. Expected: 0.1", version));
        }
        try {
            XPathFactory xPathFactory = XPathFactory.newInstance();
            XPath xpath = xPathFactory.newXPath();
            XPathExpression fileExp = xpath.compile("file/text()");
            String fileStr = (String) fileExp.evaluate(elem, XPathConstants.STRING);
            if (fileStr == null || fileStr.isEmpty()) {
                throw new IllegalDataException(tr("File name expected for layer no. {0}", support.getLayerIndex()));
            }

            OsmImporter importer = new OsmImporter();
            try (InputStream in = support.getInputStream(fileStr)) {
                OsmImporter.OsmImporterData importData = importer.loadLayer(in, support.getFile(fileStr), support.getLayerName(), progressMonitor);

                support.addPostLayersTask(importData.getPostLayerTask());
                return importData.getLayer();
            }
        } catch (XPathExpressionException e) {
            throw new IllegalDataException(e);
        }
    }
View Full Code Here

    @Override
    public Layer load(Element elem, ImportSupport support, ProgressMonitor progressMonitor) throws IOException, IllegalDataException {
        String version = elem.getAttribute("version");
        if (!"0.1".equals(version)) {
            throw new IllegalDataException(tr("Version ''{0}'' of meta data for imagery layer is not supported. Expected: 0.1", version));
        }
        Map<String, String> attributes = new HashMap<>();

        NodeList nodes = elem.getChildNodes();
View Full Code Here

TOP

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

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.