예제 #1
0
  public static final boolean acceptsXmlNeptuneFile(File file, URL schemaURL) {

    if (schemaURL == null) {
      schemaURL = schemas.get(0);
    }

    try (FileInputStream in = new FileInputStream(file)) {
      Source xmlFile = new StreamSource(in);
      try {
        SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        Schema schema = schemaFactory.newSchema(schemaURL);
        Validator validator = schema.newValidator();
        validator.validate(xmlFile);
        Main.info(xmlFile.getSystemId() + " is valid");
        return true;
      } catch (SAXException e) {
        Main.error(xmlFile.getSystemId() + " is NOT valid");
        Main.error("Reason: " + e.getLocalizedMessage());
      } catch (IOException e) {
        Main.error(xmlFile.getSystemId() + " is NOT valid");
        Main.error("Reason: " + e.getLocalizedMessage());
      }
    } catch (IOException e) {
      Main.error(e.getMessage());
    }

    return false;
  }
예제 #2
0
 @Override
 public void realRun() throws IOException, SAXException, OsmTransferException {
   try {
     if (isCanceled()) {
       return;
     }
     dataSet = parseDataSet();
   } catch (Exception e) {
     if (isCanceled()) {
       Main.info(
           tr(
               "Ignoring exception because download has been canceled. Exception was: {0}",
               e.toString()));
       return;
     }
     if (e instanceof OsmTransferCanceledException) {
       setCanceled(true);
       return;
     } else if (e instanceof OsmTransferException) {
       rememberException(e);
     } else {
       rememberException(new OsmTransferException(e));
     }
     DownloadOsmTask.this.setFailed(true);
   }
 }
  private void setGeometry(ArrayList<GeomType> selectedTypes, String typename) {
    Main.info("Passed type is" + typename);
    if (typename.compareTo("duplicate_ways") == 0) {
      geometryType = GeomType.LINE;
    } else geometryType = GeomType.POINT;

    selectedTypes.add(geometryType);
  }
예제 #4
0
 public void cancel() {
   clearImagesToGrab();
   if (cacheControl != null) {
     while (!cacheControl.isCachePipeEmpty()) {
       Main.info("Try to close a WMSLayer which is currently saving in cache : wait 1 sec.");
       CadastrePlugin.safeSleep(1000);
     }
   }
 }
  public void selectFeatures(int x, int y) {
    int pixelDelta = 2;
    LatLon clickUL = Main.map.mapView.getLatLon(x - pixelDelta, y - pixelDelta);
    LatLon clickLR = Main.map.mapView.getLatLon(x + pixelDelta, y + pixelDelta);

    Envelope envelope =
        new Envelope(
            Math.min(clickUL.lon(), clickLR.lon()),
            Math.max(clickUL.lon(), clickLR.lon()),
            Math.min(clickUL.lat(), clickLR.lat()),
            Math.max(clickUL.lat(), clickLR.lat()));

    ReferencedEnvelope mapArea = new ReferencedEnvelope(envelope, crsOSMI);

    Intersects filter = ff.intersects(ff.property("msGeometry"), ff.literal(mapArea));
    //
    // Select features in all layers
    //
    content.layers().clear();

    // Iterate through features and build a list that intersects the above
    // envelope
    for (int idx = 0; idx < arrFeatures.size(); ++idx) {
      OSMIFeatureTracker tracker = arrFeatures.get(idx);
      FeatureCollection<SimpleFeatureType, SimpleFeature> features = tracker.getFeatures();

      SimpleFeatureSource tempfs = DataUtilities.source(features);
      FeatureCollection<SimpleFeatureType, SimpleFeature> selectedFeatures;

      try {
        selectedFeatures = tempfs.getFeatures(filter);
        Set<FeatureId> IDs = new HashSet<>();

        try (FeatureIterator<SimpleFeature> iter = selectedFeatures.features()) {

          Main.info("Selected features " + selectedFeatures.size());

          while (iter.hasNext()) {
            SimpleFeature feature = iter.next();
            IDs.add(feature.getIdentifier());
          }
        }

        geometryType = selectGeomType.get(idx + layerOffset);
        Style style = createDefaultStyle(idx + layerOffset, IDs);
        content.addLayer(new FeatureLayer(features, style));
      } catch (IOException e) {
        Main.error(e);
      }
    }

    bIsChanged = true;
  }
예제 #6
0
 /** Call directly grabber for raster images or prepare thread for vector images */
 public void addImages(ArrayList<EastNorthBound> moreImages) {
   lockImagesToGrag.lock();
   imagesToGrab.addAll(moreImages);
   lockImagesToGrag.unlock();
   synchronized (this) {
     this.notify();
   }
   Main.info("Added " + moreImages.size() + " to the grab thread");
   if (wmsLayer.isRaster()) {
     waitNotification();
   }
 }
예제 #7
0
  public void removeCurrentPhotoFromDisk() {
    ImageEntry toDelete;
    if (data != null && !data.isEmpty() && currentPhoto >= 0 && currentPhoto < data.size()) {
      toDelete = data.get(currentPhoto);

      int result =
          new ExtendedDialog(
                  Main.parent,
                  tr("Delete image file from disk"),
                  new String[] {tr("Cancel"), tr("Delete")})
              .setButtonIcons(new String[] {"cancel", "dialogs/delete"})
              .setContent(
                  new JLabel(
                      tr(
                          "<html><h3>Delete the file {0} from disk?<p>The image file will be permanently lost!</h3></html>",
                          toDelete.getFile().getName()),
                      ImageProvider.get("dialogs/geoimage/deletefromdisk"),
                      SwingConstants.LEFT))
              .toggleEnable("geoimage.deleteimagefromdisk")
              .setCancelButton(1)
              .setDefaultButton(2)
              .showDialog()
              .getValue();

      if (result == 2) {
        data.remove(currentPhoto);
        if (currentPhoto >= data.size()) {
          currentPhoto = data.size() - 1;
        }
        if (currentPhoto >= 0) {
          ImageViewerDialog.showImage(this, data.get(currentPhoto));
        } else {
          ImageViewerDialog.showImage(this, null);
        }

        if (Utils.deleteFile(toDelete.getFile())) {
          Main.info("File " + toDelete.getFile() + " deleted. ");
        } else {
          JOptionPane.showMessageDialog(
              Main.parent,
              tr("Image file could not be deleted."),
              tr("Error"),
              JOptionPane.ERROR_MESSAGE);
        }

        updateOffscreenBuffer = true;
        Main.map.repaint();
      }
    }
  }
  /**
   * @param wfsClient
   * @throws NoSuchAuthorityCodeException
   * @throws FactoryException
   * @throws IOException
   * @throws IndexOutOfBoundsException
   * @throws ParseException
   */
  public OsmInspectorLayer(GeoFabrikWFSClient wfsClient, ProgressMonitor monitor)
      throws NoSuchAuthorityCodeException, FactoryException, IOException, IndexOutOfBoundsException,
          ParseException {
    super("OsmInspector");

    arrFeatures = new ArrayList<>();
    osmiBugInfo = new LinkedHashMap<>();
    selectGeomType = new ArrayList<>();

    // Step 3 - discovery; enhance to iterate over all types with bounds

    String typeNames[] = wfsClient.getTypeNames();
    renderer = new StreamingRenderer();
    CRS.decode(Main.getProjection().toCode());
    crsOSMI = CRS.decode("EPSG:4326");
    content = new MapContent(crsOSMI);

    selectGeomType.add(GeomType.POINT);
    for (int idx = 1; idx < typeNames.length; ++idx) {
      String typeName = typeNames[idx];
      Set<FeatureId> selectedFeatures = new HashSet<>();

      FeatureCollection<SimpleFeatureType, SimpleFeature> features =
          wfsClient.getFeatures(typeName, monitor);
      setGeometry(selectGeomType, typeName);

      Main.info("Osm Inspector Features size: " + features.size());
      Style style = createDefaultStyle(idx, selectedFeatures);

      OSMIFeatureTracker tracker = new OSMIFeatureTracker(features);
      arrFeatures.add(tracker);
      FeatureIterator<SimpleFeature> it = tracker.getFeatures().features();

      while (it.hasNext()) {
        BugInfo theInfo = new BugInfo(it.next(), osmiBugInfo.size());
        osmiBugInfo.put(theInfo, theInfo.bugId);
      }

      content.addLayer(new FeatureLayer(tracker.getFeatures(), style));
    }

    osmiIndex = new BugIndex(osmiBugInfo);
    content.setTitle("Osm Inspector Errors");
    renderer.setMapContent(content);
    bIsChanged = true;

    // finally initialize the dialog
    dialog = new OsmInspectorDialog(this);
    this.updateView();
  }
  /**
   * @param wfsClient
   * @throws NoSuchAuthorityCodeException
   * @throws FactoryException
   * @throws IOException
   * @throws ParseException
   * @throws NoSuchElementException
   * @throws IndexOutOfBoundsException
   */
  public void loadFeatures(GeoFabrikWFSClient wfsClient)
      throws NoSuchAuthorityCodeException, FactoryException, IOException, IndexOutOfBoundsException,
          NoSuchElementException, ParseException {
    String typeNames[] = wfsClient.getTypeNames();

    content.layers().clear();
    selectGeomType.clear();
    selectGeomType.add(GeomType.POINT);

    ProgressMonitor monitor = new ProgressMonitor(Main.map.mapView, "Loading features", "", 0, 100);

    for (int idx = 1; idx < typeNames.length; ++idx) {
      String typeName = typeNames[idx];
      Set<FeatureId> selectedFeatures = new HashSet<>();

      monitor.setProgress(100 / typeNames.length * idx);
      FeatureCollection<SimpleFeatureType, SimpleFeature> features =
          wfsClient.getFeatures(typeName, monitor);
      setGeometry(selectGeomType, typeName);

      Main.info("Osm Inspector Features size: " + features.size());

      OSMIFeatureTracker tracker = arrFeatures.get(idx - layerOffset);
      tracker.mergeFeatures(features);

      FeatureIterator<SimpleFeature> it = tracker.getFeatures().features();

      while (it.hasNext()) {
        BugInfo theInfo = new BugInfo(it.next(), osmiBugInfo.size());
        if (!osmiBugInfo.keySet().contains(theInfo)) {
          osmiBugInfo.put(theInfo, theInfo.bugId);
        }
      }

      Style style = createDefaultStyle(idx, selectedFeatures);
      content.addLayer(new FeatureLayer(tracker.getFeatures(), style));
    }

    osmiIndex.append(osmiBugInfo);

    monitor.setProgress(100);
    monitor.close();
    bIsChanged = true;
    // dialog.updateDialog(this);
    dialog.refreshModel();
    // dialog.updateNextPrevAction(this);

    this.updateView();
  }
예제 #10
0
파일: Shortcut.java 프로젝트: uazure/josm
 private static Shortcut reassignShortcut(
     String shortText,
     String longText,
     int requestedKey,
     Shortcut conflict,
     int m,
     int k,
     int newmodifier) {
   Shortcut newsc =
       new Shortcut(shortText, longText, requestedKey, m, k, newmodifier, false, false);
   Main.info(
       tr(
           "Silent shortcut conflict: ''{0}'' moved by ''{1}'' to ''{2}''.",
           shortText, conflict.getShortText(), newsc.getKeyText()));
   newsc.saveDefault();
   shortcuts.put(shortText, newsc);
   return newsc;
 }
예제 #11
0
  /**
   * Open a connection to the given url and return a reader on the input stream from that
   * connection. In case of user cancel, return <code>null</code>.
   *
   * @param urlStr The exact url to connect to.
   * @param progressMonitor progress monitoring and abort handler
   * @return An reader reading the input stream (servers answer) or <code>null</code>.
   * @throws OsmTransferException thrown if data transfer errors occur
   */
  protected InputStream getInputStreamRaw(String urlStr, ProgressMonitor progressMonitor)
      throws OsmTransferException {
    try {
      URL url = null;
      try {
        url = new URL(urlStr.replace(" ", "%20"));
      } catch (MalformedURLException e) {
        throw new OsmTransferException(e);
      }
      try {
        // fix #7640, see http://www.tikalk.com/java/forums/httpurlconnection-disable-keep-alive
        activeConnection = Utils.openHttpConnection(url, false);
      } catch (Exception e) {
        throw new OsmTransferException(
            tr("Failed to open connection to API {0}.", url.toExternalForm()), e);
      }
      if (cancel) {
        activeConnection.disconnect();
        return null;
      }

      if (doAuthenticate) {
        addAuth(activeConnection);
      }
      if (cancel) throw new OsmTransferCanceledException();
      if (Main.pref.getBoolean("osm-server.use-compression", true)) {
        activeConnection.setRequestProperty("Accept-Encoding", "gzip, deflate");
      }

      activeConnection.setConnectTimeout(Main.pref.getInteger("socket.timeout.connect", 15) * 1000);

      try {
        Main.info("GET " + url);
        activeConnection.connect();
      } catch (Exception e) {
        e.printStackTrace();
        OsmTransferException ote =
            new OsmTransferException(
                tr("Could not connect to the OSM server. Please check your internet connection."),
                e);
        ote.setUrl(url.toString());
        throw ote;
      }
      try {
        if (activeConnection.getResponseCode() == HttpURLConnection.HTTP_UNAUTHORIZED)
          throw new OsmApiException(HttpURLConnection.HTTP_UNAUTHORIZED, null, null);

        if (activeConnection.getResponseCode() == HttpURLConnection.HTTP_PROXY_AUTH)
          throw new OsmTransferCanceledException();

        String encoding = activeConnection.getContentEncoding();
        if (activeConnection.getResponseCode() != HttpURLConnection.HTTP_OK) {
          String errorHeader = activeConnection.getHeaderField("Error");
          StringBuilder errorBody = new StringBuilder();
          try {
            InputStream i = FixEncoding(activeConnection.getErrorStream(), encoding);
            if (i != null) {
              BufferedReader in = new BufferedReader(new InputStreamReader(i));
              String s;
              while ((s = in.readLine()) != null) {
                errorBody.append(s);
                errorBody.append("\n");
              }
            }
          } catch (Exception e) {
            errorBody.append(tr("Reading error text failed."));
          }

          throw new OsmApiException(
              activeConnection.getResponseCode(),
              errorHeader,
              errorBody.toString(),
              url.toString());
        }

        return FixEncoding(new ProgressInputStream(activeConnection, progressMonitor), encoding);
      } catch (OsmTransferException e) {
        throw e;
      } catch (Exception e) {
        throw new OsmTransferException(e);
      }
    } finally {
      progressMonitor.invalidate();
    }
  }
예제 #12
0
파일: Shortcut.java 프로젝트: uazure/josm
  // and now the workhorse. same parameters as above, just one more
  private static Shortcut registerShortcut(
      String shortText, String longText, int requestedKey, int requestedGroup, Integer modifier) {
    doInit();
    if (shortcuts.containsKey(
        shortText)) { // a re-register? maybe a sc already read from the preferences?
      Shortcut sc = shortcuts.get(shortText);
      sc.setLongText(
          longText); // or set by the platformHook, in this case the original longText doesn't match
      // the real action
      sc.saveDefault();
      return sc;
    }
    Integer defaultModifier = findModifier(requestedGroup, modifier);
    Shortcut conflict = findShortcut(requestedKey, defaultModifier);
    if (conflict != null) {
      if (Main.isPlatformOsx()) {
        // Try to reassign Meta to Ctrl
        int newmodifier = findNewOsxModifier(requestedGroup);
        if (findShortcut(requestedKey, newmodifier) == null) {
          Main.info(
              "Reassigning OSX shortcut '"
                  + shortText
                  + "' from Meta to Ctrl because of conflict with "
                  + conflict);
          return reassignShortcut(
              shortText,
              longText,
              requestedKey,
              conflict,
              requestedGroup,
              requestedKey,
              newmodifier);
        }
      }
      for (int m : mods) {
        for (int k : keys) {
          int newmodifier = getGroupModifier(m);
          if (findShortcut(k, newmodifier) == null) {
            Main.info(
                "Reassigning shortcut '"
                    + shortText
                    + "' from "
                    + modifier
                    + " to "
                    + newmodifier
                    + " because of conflict with "
                    + conflict);
            return reassignShortcut(shortText, longText, requestedKey, conflict, m, k, newmodifier);
          }
        }
      }
    } else {
      Shortcut newsc =
          new Shortcut(
              shortText,
              longText,
              requestedKey,
              requestedGroup,
              requestedKey,
              defaultModifier,
              true,
              false);
      newsc.saveDefault();
      shortcuts.put(shortText, newsc);
      return newsc;
    }

    return null;
  }
예제 #13
0
  private DataSet parse(InputStream in, ProgressMonitor instance) throws JAXBException {
    root = unmarshal(ChouettePTNetworkType.class, in);

    Relation network = createNetwork(root.getPTNetwork());

    // Parsing Stop areas
    for (StopArea sa : root.getChouetteArea().getStopArea()) {
      if (sa.getStopAreaExtension().getAreaType().equals(ChouetteAreaType.COMMERCIAL_STOP_POINT)) {
        Relation stopArea = createStopArea(sa);
        stopArea.put("name", sa.getName());
        for (String childId : sa.getContains()) {
          if (childId.contains("StopArea")) {
            StopArea child = findStopArea(childId);
            if (child == null) {
              Main.warn("Cannot find StopArea: " + childId);
            } else {
              if (child
                  .getStopAreaExtension()
                  .getAreaType()
                  .equals(ChouetteAreaType.BOARDING_POSITION)) {
                for (String grandchildId : child.getContains()) {
                  if (grandchildId.contains("StopPoint")) {
                    StopPoint grandchild = findStopPoint(grandchildId);
                    if (grandchild == null) {
                      Main.warn("Cannot find StopPoint: " + grandchildId);
                    } else {
                      if (grandchild.getLongLatType().equals(LongLatTypeType.WGS_84)) {
                        Node platform = createPlatform(grandchild);
                        stopArea.addMember(new RelationMember(OSM_PLATFORM, platform));
                      } else {
                        Main.warn("Unsupported long/lat type: " + grandchild.getLongLatType());
                      }
                    }
                  } else {
                    Main.warn("Unsupported grandchild: " + grandchildId);
                  }
                }
                String centroidId = child.getCentroidOfArea();
                AreaCentroid areaCentroid = findAreaCentroid(centroidId);
                if (areaCentroid == null) {
                  Main.warn("Cannot find AreaCentroid: " + centroidId);
                } else if (!areaCentroid.getLongLatType().equals(LongLatTypeType.WGS_84)) {
                  Main.warn("Unsupported long/lat type: " + areaCentroid.getLongLatType());
                } else {
                  for (RelationMember member : stopArea.getMembers()) {
                    // Fix stop coordinates if needed
                    if (member.getRole().equals(OSM_PLATFORM)
                        && isNullLatLon(member.getNode().getCoor())) {
                      member.getNode().setCoor(createLatLon(areaCentroid));
                    }
                  }
                }
              } else {
                Main.warn("Unsupported child type: " + child.getStopAreaExtension().getAreaType());
              }
            }

          } else if (childId.contains("StopPoint")) {
            StopPoint child = findStopPoint(childId);
            if (child == null) {
              Main.warn("Cannot find StopPoint: " + childId);
            } else {
              // TODO
              Main.info("TODO: handle StopPoint " + childId);
            }

          } else {
            Main.warn("Unsupported child: " + childId);
          }
        }
      } else if (sa.getStopAreaExtension()
          .getAreaType()
          .equals(ChouetteAreaType.BOARDING_POSITION)) {
        // Main.info("skipping StopArea with type "+sa.getStopAreaExtension().getAreaType()+":
        // "+sa.getObjectId());
      } else {
        Main.warn("Unsupported StopArea type: " + sa.getStopAreaExtension().getAreaType());
      }
    }

    Relation routeMaster = createRouteMaster(root.getChouetteLineDescription().getLine());
    network.addMember(new RelationMember(null, routeMaster));

    for (ChouetteRoute cr : root.getChouetteLineDescription().getChouetteRoute()) {
      Relation route = createRoute(cr);
      routeMaster.addMember(new RelationMember(null, route));
      for (String id : cr.getPtLinkId()) {
        PTLinkType ptlink = findPtLink(id);
        if (ptlink == null) {
          Main.warn("Cannot find PTLinkType: " + id);
        } else {
          /*StopPoint start = findStopPoint(ptlink.getStartOfLink());
          StopPoint end = findStopPoint(ptlink.getEndOfLink());*/
          OsmPrimitive start = tridentObjects.get(ptlink.getStartOfLink());
          OsmPrimitive end = tridentObjects.get(ptlink.getEndOfLink());
          if (start == null) {
            Main.warn("Cannot find start StopPoint: " + ptlink.getStartOfLink());
          } else if (start.get(OSM_PUBLIC_TRANSPORT).equals(OSM_STOP)
              || start.get(OSM_PUBLIC_TRANSPORT).equals(OSM_PLATFORM)) {
            addStopToRoute(route, start);
          }

          if (end == null) {
            Main.warn("Cannot find end StopPoint: " + ptlink.getEndOfLink());
          } else if (end.get(OSM_PUBLIC_TRANSPORT).equals(OSM_STOP)
              || end.get(OSM_PUBLIC_TRANSPORT).equals(OSM_PLATFORM)) {
            addStopToRoute(route, end);
          }
        }
      }
    }

    return ds;
  }
예제 #14
0
 @Override
 public void run() {
   for (; ; ) {
     while (getImagesToGrabSize() > 0) {
       lockImagesToGrag.lock();
       lockCurrentGrabImage.lock();
       currentGrabImage = imagesToGrab.get(0);
       lockCurrentGrabImage.unlock();
       imagesToGrab.remove(0);
       lockImagesToGrag.unlock();
       if (canceled) {
         break;
       } else {
         GeorefImage newImage;
         try {
           Main.map.repaint(); // paint the current grab box
           newImage = grabber.grab(wmsLayer, currentGrabImage.min, currentGrabImage.max);
         } catch (IOException e) {
           Main.warn("Download action canceled by user or server did not respond");
           setCanceled(true);
           break;
         } catch (OsmTransferException e) {
           Main.error("OSM transfer failed");
           setCanceled(true);
           break;
         }
         if (grabber.getWmsInterface().downloadCanceled) {
           Main.info("Download action canceled by user");
           setCanceled(true);
           break;
         }
         try {
           if (CadastrePlugin.backgroundTransparent) {
             wmsLayer.imagesLock.lock();
             for (GeorefImage img : wmsLayer.getImages()) {
               if (img.overlap(newImage))
                 // mask overlapping zone in already grabbed image
                 img.withdraw(newImage);
               else
                 // mask overlapping zone in new image only when new image covers completely the
                 // existing image
                 newImage.withdraw(img);
             }
             wmsLayer.imagesLock.unlock();
           }
           wmsLayer.addImage(newImage);
           Main.map.mapView.repaint();
           saveToCache(newImage);
         } catch (NullPointerException e) {
           Main.info("Layer destroyed. Cancel grab thread");
           setCanceled(true);
         }
       }
     }
     Main.info("grab thread list empty");
     lockCurrentGrabImage.lock();
     currentGrabImage = null;
     lockCurrentGrabImage.unlock();
     if (canceled) {
       clearImagesToGrab();
       canceled = false;
     }
     if (wmsLayer.isRaster()) {
       notifyWaiter();
     }
     waitNotification();
   }
 }
예제 #15
0
  @Override
  protected void realRun() {
    try {
      uploadloop:
      while (true) {
        try {
          getProgressMonitor()
              .subTask(
                  trn(
                      "Uploading {0} object...",
                      "Uploading {0} objects...", toUpload.getSize(), toUpload.getSize()));
          synchronized (this) {
            writer = new OsmServerWriter();
          }
          writer.uploadOsm(
              strategy,
              toUpload.getPrimitives(),
              changeset,
              getProgressMonitor().createSubTaskMonitor(1, false));

          // if we get here we've successfully uploaded the data. Exit the loop.
          //
          break;
        } catch (OsmTransferCanceledException e) {
          Main.error(e);
          uploadCanceled = true;
          break uploadloop;
        } catch (OsmApiPrimitiveGoneException e) {
          // try to recover from  410 Gone
          //
          recoverFromGoneOnServer(e, getProgressMonitor());
        } catch (ChangesetClosedException e) {
          if (writer != null) {
            processedPrimitives.addAll(
                writer.getProcessedPrimitives()); // OsmPrimitive in => OsmPrimitive out
          }
          changeset.setOpen(false);
          switch (e.getSource()) {
            case UNSPECIFIED:
              throw e;
            case UPDATE_CHANGESET:
              // The changeset was closed when we tried to update it. Probably, our
              // local list of open changesets got out of sync with the server state.
              // The user will have to select another open changeset.
              // Rethrow exception - this will be handled later.
              //
              throw e;
            case UPLOAD_DATA:
              // Most likely the changeset is full. Try to recover and continue
              // with a new changeset, but let the user decide first (see
              // recoverFromChangesetFullException)
              //
              if (recoverFromChangesetFullException()) {
                continue;
              }
              lastException = e;
              break uploadloop;
          }
        } finally {
          if (writer != null) {
            processedPrimitives.addAll(writer.getProcessedPrimitives());
          }
          synchronized (this) {
            writer = null;
          }
        }
      }
      // if required close the changeset
      //
      if (strategy.isCloseChangesetAfterUpload()
          && changeset != null
          && !changeset.isNew()
          && changeset.isOpen()) {
        OsmApi.getOsmApi()
            .closeChangeset(changeset, progressMonitor.createSubTaskMonitor(0, false));
      }
    } catch (OsmTransferException e) {
      if (uploadCanceled) {
        Main.info(
            tr(
                "Ignoring caught exception because upload is canceled. Exception is: {0}",
                e.toString()));
      } else {
        lastException = e;
      }
    }
    if (uploadCanceled && processedPrimitives.isEmpty()) return;
    cleanupAfterUpload();
  }