Search in sources :

Example 1 with CreateOSMChangesetOp

use of org.locationtech.geogig.osm.internal.CreateOSMChangesetOp in project GeoGig by boundlessgeo.

the class CreateOSMChangeset method runInternal.

/**
     * Executes the command with the specified options.
     */
@Override
protected void runInternal(GeogigCLI cli) throws IOException {
    checkParameter(refSpec.size() < 3, "Commit list is too long :" + refSpec);
    GeoGIG geogig = cli.getGeogig();
    CreateOSMChangesetOp op = geogig.command(CreateOSMChangesetOp.class);
    String oldVersion = resolveOldVersion();
    String newVersion = resolveNewVersion();
    op.setOldVersion(oldVersion).setNewVersion(newVersion).setId(id);
    Iterator<ChangeContainer> entries;
    entries = op.setProgressListener(cli.getProgressListener()).call();
    if (!entries.hasNext()) {
        cli.getConsole().println("No differences found");
        return;
    }
    BufferedWriter bufWriter = new BufferedWriter(new FileWriter(new File(file)));
    XmlChangeWriter writer = new XmlChangeWriter(bufWriter);
    while (entries.hasNext()) {
        ChangeContainer change = entries.next();
        writer.process(change);
    }
    writer.complete();
    bufWriter.flush();
}
Also used : ChangeContainer(org.openstreetmap.osmosis.core.container.v0_6.ChangeContainer) FileWriter(java.io.FileWriter) XmlChangeWriter(org.openstreetmap.osmosis.xml.v0_6.XmlChangeWriter) CreateOSMChangesetOp(org.locationtech.geogig.osm.internal.CreateOSMChangesetOp) File(java.io.File) GeoGIG(org.locationtech.geogig.api.GeoGIG) BufferedWriter(java.io.BufferedWriter)

Aggregations

BufferedWriter (java.io.BufferedWriter)1 File (java.io.File)1 FileWriter (java.io.FileWriter)1 GeoGIG (org.locationtech.geogig.api.GeoGIG)1 CreateOSMChangesetOp (org.locationtech.geogig.osm.internal.CreateOSMChangesetOp)1 ChangeContainer (org.openstreetmap.osmosis.core.container.v0_6.ChangeContainer)1 XmlChangeWriter (org.openstreetmap.osmosis.xml.v0_6.XmlChangeWriter)1