Пример #1
0
 /**
  * Replies the new GPX and marker layers corresponding to the specified GPX data.
  *
  * @param data The GPX data
  * @param parsedProperly True if GPX data has been properly parsed by {@link GpxReader#parse}
  * @param gpxLayerName The GPX layer name
  * @param markerLayerName The marker layer name
  * @return the new GPX and marker layers corresponding to the specified GPX data, to be used with
  *     {@link #addLayers}
  * @see #addLayers
  */
 public static GpxImporterData loadLayers(
     final GpxData data,
     final boolean parsedProperly,
     final String gpxLayerName,
     String markerLayerName) {
   GpxLayer gpxLayer = null;
   MarkerLayer markerLayer = null;
   if (data.hasRoutePoints() || data.hasTrackPoints()) {
     gpxLayer = new GpxLayer(data, gpxLayerName, data.storageFile != null);
   }
   if (Main.pref.getBoolean("marker.makeautomarkers", true) && !data.waypoints.isEmpty()) {
     markerLayer = new MarkerLayer(data, markerLayerName, data.storageFile, gpxLayer);
     if (markerLayer.data.isEmpty()) {
       markerLayer = null;
     }
   }
   Runnable postLayerTask =
       () -> {
         if (!parsedProperly) {
           String msg;
           if (data.storageFile == null) {
             msg =
                 tr(
                     "Error occurred while parsing gpx data for layer ''{0}''. Only a part of the file will be available.",
                     gpxLayerName);
           } else {
             msg =
                 tr(
                     "Error occurred while parsing gpx file ''{0}''. Only a part of the file will be available.",
                     data.storageFile.getPath());
           }
           JOptionPane.showMessageDialog(null, msg);
         }
       };
   return new GpxImporterData(gpxLayer, markerLayer, postLayerTask);
 }