Package slash.navigation.base

Examples of slash.navigation.base.NavigationFormatParser


        System.exit(0);
    }

    private void convert(File source, NavigationFormat format, File target) throws IOException {
        NavigationFormatParser parser = new NavigationFormatParser();
        ParserResult result = parser.read(source);
        if (!result.isSuccessful()) {
            log.severe("Could not read source '" + source.getAbsolutePath() + "'");
            logFormatNames(getReadFormatsSortedByName());
            System.exit(20);
        }

        if (format.isSupportsMultipleRoutes()) {
            parser.write(result.getAllRoutes(), (MultipleRoutesFormat) format, target);
        } else {
            int fileCount = getNumberOfFilesToWriteFor(result.getTheRoute(), format, false);
            File[] targets = createTargetFiles(target, fileCount, format.getExtension(), format.getMaximumFileNameLength());
            for (File t : targets) {
                if (t.exists()) {
                    log.severe("Target '" + t.getAbsolutePath() + "' already exists; stopping.");
                    System.exit(13);
                }
            }
            parser.write(result.getTheRoute(), format, false, false, null, targets);
        }
    }
View Full Code Here


public class GoogleMapsUrlFormatIT {

    private void checkBookmark(String name) throws IOException {
        File source = new File(SAMPLE_PATH + name);
        NavigationFormatParser parser = new NavigationFormatParser();
        ParserResult result = parser.read(source);
        assertNotNull(result);
        assertEquals(GoogleMapsUrlFormat.class, result.getFormat().getClass());
        assertEquals(1, result.getAllRoutes().size());
        BaseRoute<BaseNavigationPosition, BaseNavigationFormat> route = result.getTheRoute();
        assertEquals(9, route.getPositionCount());
View Full Code Here

        preferences.put(READ_PATH_PREFERENCE, path);

        startWaitCursor(r.getFrame().getRootPane());
        new Thread(new Runnable() {
            public void run() {
                NavigationFormatParser parser = new NavigationFormatParser();
                NavigationFormatParserListener listener = new NavigationFormatParserListener() {
                    public void reading(final NavigationFormat<BaseRoute> format) {
                        invokeLater(new Runnable() {
                            public void run() {
                                formatAndRoutesModel.setFormat(format);
                            }
                        });
                    }
                };
                parser.addNavigationFileParserListener(listener);

                try {
                    invokeAndWait(new Runnable() {
                        public void run() {
                            Gpx11Format gpxFormat = new Gpx11Format();
                            formatAndRoutesModel.setRoutes(new FormatAndRoutes(gpxFormat, new GpxRoute(gpxFormat)));
                            urlModel.clear();
                        }
                    });

                    final ParserResult result = parser.read(url, formats);
                    if (result.isSuccessful()) {
                        log.info("Opened: " + path);
                        final NavigationFormat format = result.getFormat();
                        countRead(format);
                        if (!checkReadFormat(format))
                            return;
                        invokeLater(new Runnable() {
                            public void run() {
                                formatAndRoutesModel.setRoutes(new FormatAndRoutes(format, result.getAllRoutes()));
                                comboBoxChoosePositionList.setModel(formatAndRoutesModel);
                                urlModel.setString(path);
                                recentUrlsModel.addUrl(url);

                                if (urls.size() > 1) {
                                    List<URL> append = new ArrayList<>(urls);
                                    append.remove(0);
                                    // this way the route is always marked as modified :-(
                                    appendPositionList(-1, append);
                                }
                            }
                        });

                    } else {
                        invokeLater(new Runnable() {
                            public void run() {
                                Gpx11Format gpxFormat = new Gpx11Format();
                                formatAndRoutesModel.setRoutes(new FormatAndRoutes(gpxFormat, new GpxRoute(gpxFormat)));
                            }
                        });
                        r.handleUnsupportedFormat(path);
                    }
                } catch (BabelException e) {
                    r.handleBabelError(e);
                } catch (OutOfMemoryError e) {
                    r.handleOutOfMemoryError();
                } catch (FileNotFoundException e) {
                    r.handleFileNotFound(path);
                } catch (Throwable t) {
                    r.handleOpenError(t, path);
                } finally {
                    parser.removeNavigationFileParserListener(listener);
                    invokeLater(new Runnable() {
                        public void run() {
                            stopWaitCursor(r.getFrame().getRootPane());
                        }
                    });
View Full Code Here

            public void run() {
                try {
                    for (URL url : urls) {
                        String path = createReadablePath(url);

                        NavigationFormatParser parser = new NavigationFormatParser();
                        final ParserResult result = parser.read(url, getReadFormats());
                        if (result.isSuccessful()) {
                            log.info("Appended: " + path);
                            countRead(result.getFormat());

                            final String finalPath = path;
View Full Code Here

        try {
            if (!checkWriteFormat(format))
                return;
            if (format.isSupportsMultipleRoutes()) {
                List<BaseRoute> routes = exportSelectedRoute ? asList(route) : formatAndRoutesModel.getRoutes();
                new NavigationFormatParser().write(routes, (MultipleRoutesFormat) format, files[0]);
            } else {
                boolean duplicateFirstPosition = preferences.getBoolean(DUPLICATE_FIRST_POSITION_PREFERENCE, true);
                ParserCallback parserCallback = new ParserCallback() {
                    public void preprocess(BaseRoute route, NavigationFormat format) {
                        if (format instanceof GarminFlightPlanFormat) {
                            GarminFlightPlanRoute garminFlightPlanRoute = (GarminFlightPlanRoute) route;
                            completeGarminFlightPlan(garminFlightPlanRoute);
                        }
                    }
                };
                new NavigationFormatParser().write(route, format, duplicateFirstPosition, true, parserCallback, files);
            }
            formatAndRoutesModel.setModified(false);
            recentFormatsModel.addFormat(format);
            countWrite(format);
            log.info(String.format("Saved: %s", targetsAsString));
View Full Code Here

        RouteConverter r = RouteConverter.getInstance();
        String path = Files.createReadablePath(file);
        String description = null;
        Double length = null;
        try {
            NavigationFormatParser parser = new NavigationFormatParser();
            ParserResult result = parser.read(file);
            if (result.isSuccessful()) {
                BaseRoute<BaseNavigationPosition, BaseNavigationFormat> route = result.getTheRoute();
                if (route != null) {
                    description = createRouteDescription(route);
                    length = route.getDistance();
View Full Code Here

        });
    }

    @SuppressWarnings("unchecked")
    private void paste(String string) {
        NavigationFormatParser parser = new NavigationFormatParser();
        try {
            ParserResult result = parser.read(string);
            if (result.isSuccessful()) {
                BaseRoute route = result.getTheRoute();
                paste(route.getPositions());
            }
        } catch (IOException e) {
View Full Code Here

TOP

Related Classes of slash.navigation.base.NavigationFormatParser

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.