private NavigationFormat determineFormat( List<BaseRoute> routes, NavigationFormat preferredFormat) { NavigationFormat result = preferredFormat; for (BaseRoute route : routes) { // more than one route: the same result if (result.equals(route.getFormat())) continue; // result is capable of storing multiple routes if (result.isSupportsMultipleRoutes()) continue; // result from GPSBabel-based format which allows only one route but is represented by GPX 1.0 if (result instanceof BabelFormat) continue; // default for multiple routes is GPX 1.1 result = new Gpx11Format(); } return result; }