Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,12 @@
import static reactor.core.scheduler.Schedulers.parallel;

@CommandLine.Command(name = "contributions", aliases = {"contribs"},
mixinStandardHelpOptions = true,
version = "ohsome-planet contribution 1.0.1", //TODO version should be automatically set see picocli.CommandLine.IVersionProvider
description = "generates parquet files")
public class Contributions2Parquet implements Callable<Integer> {

@Option(names = {"-h", "--help"}, usageHelp = true, description = "Show this help message and exit.")
boolean usageHelpRequested;

@Option(names = {"--pbf"}, required = true)
private Path pbfPath;

Expand Down Expand Up @@ -92,6 +93,10 @@ public class Contributions2Parquet implements Callable<Integer> {

@Override
public Integer call() throws Exception {
if (usageHelpRequested) {
CommandLine.usage(this, System.out);
return 0;
}
var pbf = OSMPbf.open(pbfPath);
if (debug) {
FileInfo.printInfo(pbf);
Expand Down Expand Up @@ -289,10 +294,4 @@ private void printBlobInfo(Map<OSMType, List<BlobHeader>> blobTypes) {
);
}

public static void main(String[] args) {
var main = new Contributions2Parquet();
var exit = new CommandLine(main).execute(args);
System.exit(exit);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.google.common.collect.Streams;
import org.heigit.ohsome.osm.pbf.OSMPbf;
import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;

Expand All @@ -12,11 +13,20 @@
@Command(name = "fileinfo",
description = "print header for osm pbf file")
public class FileInfo implements Callable<Integer> {

@Option(names = {"-h", "--help"}, usageHelp = true, description = "Show this help message and exit.")
boolean usageHelpRequested;

@Option(names = {"--pbf"}, required = true)
private Path path;

@Override
public Integer call() throws Exception {
if (usageHelpRequested) {
CommandLine.usage(this, System.out);
return 0;
}

var pbf = OSMPbf.open(path);
printInfo(pbf);
return 0;
Expand Down
38 changes: 36 additions & 2 deletions ohsome-planet-cli/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.heigit.ohsome</groupId>
Expand Down Expand Up @@ -30,6 +31,38 @@

<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
<configuration>
<shortRevisionLength>7</shortRevisionLength>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
<manifestEntries>
<application>${project.parent.artifactId}</application>
<version>${project.version}</version>
<buildnumber>${buildNumber}</buildnumber>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
Expand All @@ -42,7 +75,8 @@
<finalName>ohsome-planet</finalName>
<minimizeJar>true</minimizeJar>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>${main.class}</Main-Class>
<Multi-Release>true</Multi-Release>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
import org.heigit.ohsome.contributions.FileInfo;
import picocli.CommandLine;

import java.util.Properties;
import java.util.concurrent.Callable;

import static picocli.CommandLine.Command;

@Command(name = "ohsome-planet",
mixinStandardHelpOptions = true,
version = "ohsome-planet 1.0.0",
versionProvider = OhsomePlanet.ManifestVersionProvider.class,
description = "Transform OSM (history) PBF files into GeoParquet. Enrich with OSM changeset metadata and country information.%n",
subcommands = {
FileInfo.class,
Expand All @@ -29,4 +30,19 @@ public static void main(String[] args) {
var exit = new CommandLine(main).execute(args);
System.exit(exit);
}


static class ManifestVersionProvider implements CommandLine.IVersionProvider {
public String[] getVersion() throws Exception {
var url = CommandLine.class.getClassLoader().getResource("META-INF/MANIFEST.MF");
if (url == null) {
return new String[] {"ohsome-planet"};
}
try (var stream = url.openStream()){
var props = new Properties();
props.load(stream);
return new String[]{"%s %s (rev: %s)".formatted(props.getProperty("application"), props.getProperty("version"), props.getProperty("buildnumber"))};
}
}
}
}