use of org.locationtech.geogig.osm.internal.Mapping in project GeoGig by boundlessgeo.
the class OSMExportShp method runInternal.
/**
* Executes the export command using the provided options.
*/
@Override
protected void runInternal(GeogigCLI cli) throws IOException {
Preconditions.checkNotNull(mappingFile != null, "A data mapping file must be specified");
if (args == null || args.isEmpty() || args.size() != 1) {
printUsage(cli);
throw new CommandFailedException();
}
String shapefile = args.get(0);
final File file = new File(shapefile);
final Mapping mapping = Mapping.fromFile(mappingFile);
List<MappingRule> rules = mapping.getRules();
checkParameter(!rules.isEmpty(), "No rules are defined in the specified mapping");
for (MappingRule rule : rules) {
File targetFile = file;
if (rules.size() > 1) {
String name = getNameWithoutExtension(file.getName()) + "_" + rule.getName() + ".shp";
targetFile = new File(file.getParentFile(), name);
}
exportRule(rule, cli, targetFile);
}
}
use of org.locationtech.geogig.osm.internal.Mapping in project GeoGig by boundlessgeo.
the class OSMMap method runInternal.
/**
* 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();
ConsoleReader 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?
}
}
Aggregations