src/main/java/de/blau/android/osm/StorageDelegator.java
/**
     * Upload created, modified and deleted data in diff format
     * 
     * @param server Server to upload changes to.
     * @param comment Changeset comment tag
     * @param source Changeset source tag
     * @param closeOpenChangeset if true close any open Changeset first
     * @param closeChangeset if true close the Changeset
     * @param extraTags Additional tags to add
     * @param elements List of OsmElement to upload if null all changed elements will be uploaded
     * @throws IOException if the upload doesn't work
     */
Upload created, modified and deleted data in diff format

@param server Server to upload changes to.
Upload created modified and deleted data in diff format @param server Server to upload changes to .
public synchronized void uploadToServer(@NonNull final Server server, @Nullable final String comment, @Nullable String source, boolean closeOpenChangeset,
            boolean closeChangeset, @Nullable Map<String, String> extraTags, @Nullable List<OsmElement> elements) throws IOException {
        dirty = true; 
        removeUnchanged();
        boolean fullUpload = elements == null;
        int uploadElementCount = fullUpload ? getApiElementCount() : elements.size();
        int notUploadedElementCount = getApiElementCount() - uploadElementCount; 
        boolean split = uploadElementCount > server.getCapabilities().getMaxElementsInChangeset();
        int part = 1;
        int elementCount = uploadElementCount;
        while (elementCount > 0) {
            String tmpSource = source;
            if (split) {
                tmpSource = source + " [" + part + "]";
            }
            server.openChangeset(closeOpenChangeset, comment, tmpSource, Util.toOsmList(imagery), extraTags);
            try {
                lock();
                if (fullUpload) {
                    server.diffUpload(this, getApiStorage());
                } else {
                    Storage storage = new Storage();
                    storage.addChangedElements(elements);
                    server.diffUpload(this, storage);
                }
            } finally {
                unlock();
            }
            if (closeChangeset || split) { 
                server.closeChangeset();
            }
            part++;
            int currentElementCount = getApiElementCount();
            if (currentElementCount < notUploadedElementCount + elementCount) {
                elementCount = currentElementCount - notUploadedElementCount;
            } else {
                Log.e(DEBUG_TAG, "Upload had no effect, API element count " + elementCount);
                throw new ProtocolException("Upload had no effect");
            }
        }
        dirty = true;
        imagery = new ArrayList<>();
        if (fullUpload) {
            setImageryRecorded(false);
        }
    }
public synchronized void uploadToServer ( @ NonNull final Server server , @ Nullable final String comment , @ Nullable String source , boolean closeOpenChangeset , boolean closeChangeset , @ Nullable Map < String , String > extraTags , @ Nullable List < OsmElement > elements ) throws IOException { dirty = true ; removeUnchanged ( ) ; boolean fullUpload = elements == null ; int uploadElementCount = fullUpload ? getApiElementCount ( ) : elements . size ( ) ; int notUploadedElementCount = getApiElementCount ( ) - uploadElementCount ; boolean split = uploadElementCount > server . getCapabilities ( ) . getMaxElementsInChangeset ( ) ; int part = 1 ; int elementCount = uploadElementCount ; while ( elementCount > 0 ) { String tmpSource = source ; if ( split ) { tmpSource = source + " [" + part + "]" ; } server . openChangeset ( closeOpenChangeset , comment , tmpSource , Util . toOsmList ( imagery ) , extraTags ) ; try { lock ( ) ; if ( fullUpload ) { server . diffUpload ( this , getApiStorage ( ) ) ; } else { Storage storage = new Storage ( ) ; storage . addChangedElements ( elements ) ; server . diffUpload ( this , storage ) ; } } finally { unlock ( ) ; } if ( closeChangeset || split ) { server . closeChangeset ( ) ; } part ++ ; int currentElementCount = getApiElementCount ( ) ; if ( currentElementCount < notUploadedElementCount + elementCount ) { elementCount = currentElementCount - notUploadedElementCount ; } else { Log . e ( DEBUG_TAG , "Upload had no effect, API element count " + elementCount ) ; throw new ProtocolException ( "Upload had no effect" ) ; } } dirty = true ; imagery = new ArrayList < > ( ) ; if ( fullUpload ) { setImageryRecorded ( false ) ; } }
Upload created, modified and deleted data in diff format
Upload created modified and deleted data in diff format
// storages will get modified as data is uploaded, these changes need to be saved to file // upload methods set dirty flag too, in case the file is saved during an upload // will be zero for normal uploads // if we are uploading more than the limit elements // this will work as uploaded elements will have // unmodified status // always close when splitting // element count didn't do anything, that should cause an exception to be // thrown in diffUpload, but it is conceivable that that doesn't happen // yes, again, just to be sure // reset imagery recording for next upload