private SymRef getHead(GeoGIG geogig) { final Ref currentHead = geogig.command(RefParse.class).setName(Ref.HEAD).call().get(); if (!(currentHead instanceof SymRef)) { throw new CommandFailedException("Cannot run on a dettached HEAD"); } return (SymRef) currentHead; }
final ImmutableList<Long> nodes = way.getNodes(); StagingArea index = geogig.getRepository().index(); FindTreeChild findTreeChild = geogig.command(FindTreeChild.class); ObjectId rootTreeId = geogig.command(ResolveTreeish.class).setTreeish(Ref.HEAD).call() .get(); if (!rootTreeId.isNull()) { RevTree headTree = geogig.command(RevObjectParse.class).setObjectId(rootTreeId) .call(RevTree.class).get(); findTreeChild.setParent(headTree); ObjectStore objectDatabase = geogig.getContext().objectDatabase(); for (Long nodeId : nodes) { Coordinate coord = thisChangePointCache.get(nodeId);
/** * Executes the map command using the provided options. */ @Override protected void runInternal(GeogigCLI cli) throws IOException { if (args == null || args.isEmpty() || args.size() != 1) { printUsage(cli); throw new CommandFailedException(); } checkState(cli.getGeogig().getRepository().index().isClean() && cli.getGeogig().getRepository().workingTree().isClean(), "Working tree and index are not clean"); String mappingFilepath = args.get(0); Mapping mapping = Mapping.fromFile(mappingFilepath); geogig = cli.getGeogig(); ObjectId oldTreeId = geogig.getRepository().workingTree().getTree().getId(); message = message == null ? "Applied mapping " + new File(mappingFilepath).getName() : message; ObjectId newTreeId = geogig.command(OSMMapOp.class).setMapping(mapping).setMessage(message) .call().getId(); Console console = cli.getConsole(); if (newTreeId.equals(oldTreeId)) { console.println("No features matched the specified filter, or they provided no updated data.\n" + "No changes have been made to the working tree"); } else { // print something? } }
WorkingTree workingTree = geogig.getContext().workingTree(); ObjectId afterTreeId = workingTree.getTree().getId(); DiffObjectCount diffCount = geogig.command(DiffCount.class).setOldTree(workTreeId) .setNewTree(afterTreeId).call(); geogig.command(AddOp.class).call(); console.print(String.format(" %,d actual changes.", diffCount.featureCount())); console.flush();
private long getCurrentBranchChangeset(GeoGIG geogig) throws IOException { String path = getBranchChangesetPath(geogig); BlobStore blobStore = geogig.getContext().blobStore(); Optional<String> blob = Blobs.getBlobAsString(blobStore, path); return blob.isPresent() ? Long.parseLong(blob.get()) : 0L; }
final Repository repository = geogig.getRepository(); final WorkingTree workTree = repository.workingTree();
/** * Executes the map command using the provided options. */ @Override protected void runInternal(GeogigCLI cli) throws IOException { if (args == null || args.isEmpty() || args.size() != 1) { printUsage(cli); throw new CommandFailedException(); } String path = args.get(0); geogig = cli.getGeogig(); ObjectId oldTreeId = geogig.getRepository().workingTree().getTree().getId(); ObjectId newTreeId = geogig.command(OSMUnmapOp.class).setPath(path).call().getId(); Console console = cli.getConsole(); if (newTreeId.equals(oldTreeId)) { console.println("No differences were found after unmapping.\n" + "No changes have been made to the working tree"); } else { // print something? } }
/** * @param geogig * @param id * @throws IOException */ private void updateBranchChangeset(GeoGIG geogig, long id) throws IOException { String path = getBranchChangesetPath(geogig); BlobStore blobStore = geogig.getContext().blobStore(); Blobs.putBlob(blobStore, path, String.valueOf(id)); }
if (args.size() == 2) { ref = args.get(1); Optional<ObjectId> tree = geogig.command(ResolveTreeish.class).setTreeish(ref).call(); checkParameter(tree.isPresent(), "Invalid commit or reference: %s", ref);
"Filters cannot be used when updating"); GeoGIG geogig = cli.getGeogig(); checkState(geogig.getRepository().index().isClean() && geogig.getRepository().workingTree().isClean(), "Working tree and index are not clean"); GeogigTransaction tx = geogig.command(TransactionBegin.class).call(); try { AbstractGeoGigOp<Optional<OSMReport>> cmd;
private Iterator<EntityContainer> getFeatures(String ref) { Optional<ObjectId> id = geogig.command(RevParse.class).setRefSpec(ref).call(); if (!id.isPresent()) { return Collections.emptyIterator(); LsTreeOp op = geogig.command(LsTreeOp.class).setStrategy(Strategy.DEPTHFIRST_ONLY_FEATURES) .setReference(ref); if (bbox != null) { final EntityConverter converter = new EntityConverter(); final Function<NodeRef, EntityContainer> function = (nr) -> { RevFeature revFeature = geogig.command(RevObjectParse.class) .setObjectId(nr.getObjectId()).call(RevFeature.class).get(); SimpleFeatureType featureType;
Optional<OSMReport> report = cli.getGeogig().command(OSMApplyDiffOp.class) .setDiffFile(diffFile).setProgressListener(cli.getProgressListener()).call(); if (report.isPresent()) {
/** * 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); try (AutoCloseableIterator<ChangeContainer> 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(); } }
@Test public void testSPILookup() { DeduplicationService service = geogig.command(CreateDeduplicator.class).call(); assertTrue(service instanceof BDBJEDeduplicationService); }
Optional<OSMReport> report = cli.getGeogig().command(OSMImportOp.class) .setDataSource(importFile.getAbsolutePath()).setMapping(mapping) .setMessage(message).setNoRaw(noRaw).setAdd(add)
@Test public void testCreateDeduplicator() { DeduplicationService service = geogig.command(CreateDeduplicator.class).call(); BDBJEDeduplicator deduplicator = (BDBJEDeduplicator) service.createDeduplicator(); assertNotNull(deduplicator); File dbdir = deduplicator.dbdir; try { assertTrue(dbdir.exists()); assertTrue(dbdir.getName().startsWith("geogig-deduplicator")); } finally { deduplicator.release(); assertFalse(dbdir.exists()); } } }
"Could not create feature store. Shapefile may be read only"); final SimpleFeatureStore store = (SimpleFeatureStore) source; ExportOp op = cli.getGeogig().command(ExportOp.class).setFeatureStore(store) .setPath(path).setFeatureTypeConversionFunction(function); try {
featureStore.removeFeatures(Filter.INCLUDE); ExportOp op = cli.getGeogig().command(ExportOp.class).setFeatureStore(featureStore) .setPath(path).setFeatureTypeConversionFunction(function); try {