Verified Commit 205de724 authored by Johannes Visintini's avatar Johannes Visintini
Browse files

Reformat code

parent 62e997b5
......@@ -12,6 +12,7 @@ import org.heigit.ohsome.oshdb.util.time.TimestampFormatter;
@SuppressWarnings("java:S106")
public class DistinctContributors {
public static void main(String[] args) throws Exception {
SortedMap<OSHDBTimestamp, Integer> result;
try (
......@@ -25,7 +26,8 @@ public class DistinctContributors {
// query
result = OSMContributionView.on(oshdb)
.keytables(oshdbKeytables)
.areaOfInterest(OSHDBBoundingBox.bboxWgs84Coordinates(71.45, -1.16, 74.7, 7.47)) // maldives
.areaOfInterest(
OSHDBBoundingBox.bboxWgs84Coordinates(71.45, -1.16, 74.7, 7.47)) // maldives
.timestamps("2007-01-01", "2017-12-01", Interval.MONTHLY)
.filter("type:way and highway=*")
.map(OSMContribution::getContributorUserId)
......
......@@ -13,6 +13,7 @@ import org.heigit.ohsome.oshdb.util.time.TimestampFormatter;
@SuppressWarnings("java:S106")
public class RoadLength {
static final List<String> other = List.of("unclassified", "road", "service", "track", "path",
"pedestrian", "footway", "cycleway", "steps", "platform", "bridleway");
static final List<String> highway_motorway = List.of(
......@@ -36,7 +37,8 @@ public class RoadLength {
// query
result = OSMEntitySnapshotView.on(oshdb)
.keytables(oshdbKeytables)
.areaOfInterest(OSHDBBoundingBox.bboxWgs84Coordinates(71.45, -1.16, 74.7, 7.47)) // maldives
.areaOfInterest(
OSHDBBoundingBox.bboxWgs84Coordinates(71.45, -1.16, 74.7, 7.47)) // maldives
.timestamps("2007-01-01", "2017-12-01", Interval.MONTHLY)
.filter("type:way and highway in (" + String.join(",", highway_motorway) + ")")
.aggregateByTimestamp()
......
......@@ -18,15 +18,16 @@ import org.heigit.ohsome.oshdb.util.time.OSHDBTimestamps;
import org.jfree.ui.RefineryUtilities;
public class AdvancedExample {
public static void main(String[] args) throws Exception {
//Declare Database
SortedMap<OSHDBTimestamp, Map<ContributionType, Integer>> reduce;
try (OSHDBDatabase oshdb = new OSHDBH2(AdvancedExample.class.getResource("/test.oshdb.mv.db")
.getFile()
.replace(".mv.db", ""));
OSHDBJdbc keytables = new OSHDBH2(Tutorial.class.getResource("/test.oshdb.keytables.mv.db")
.getFile()
.replace(".mv.db", ""))) {
OSHDBJdbc keytables = new OSHDBH2(Tutorial.class.getResource("/test.oshdb.keytables.mv.db")
.getFile()
.replace(".mv.db", ""))) {
//Define MapReducer
reduce = OSMContributionView.on(oshdb)
.keytables(keytables)
......@@ -46,6 +47,7 @@ public class AdvancedExample {
private static class Mapper implements
SerializableFunction<OSMContribution, Map<ContributionType, Integer>> {
@Override
public Map<ContributionType, Integer> apply(OSMContribution contribution) {
//get an empty result-map
......@@ -59,6 +61,7 @@ public class AdvancedExample {
private static class IdentitySupplier implements
SerializableSupplier<Map<ContributionType, Integer>> {
@Override
public Map<ContributionType, Integer> get() {
//create an empty result-map
......@@ -67,7 +70,7 @@ public class AdvancedExample {
Arrays.asList(ContributionType.values())
.forEach(
(ContributionType type) ->
result.put(type, 0)
result.put(type, 0)
);
return result;
}
......@@ -75,6 +78,7 @@ public class AdvancedExample {
private static class Combiner implements
SerializableBinaryOperator<Map<ContributionType, Integer>> {
@Override
public Map<ContributionType, Integer> apply(
Map<ContributionType, Integer> mapResultA,
......
......@@ -14,6 +14,7 @@ import org.heigit.ohsome.oshdb.util.time.OSHDBTimestamps.Interval;
@SuppressWarnings("java:S106")
public class Tutorial {
public static void main(String[] args) throws Exception {
// -- PREPARATION --
// Start writing the OSHDB query
......@@ -40,7 +41,8 @@ public class Tutorial {
// Setting spatial extent
// create BoundingBox
OSHDBBoundingBox boundingBox = OSHDBBoundingBox.bboxWgs84Coordinates(71.45, -1.16, 74.7, 7.47); //Maldives
OSHDBBoundingBox boundingBox = OSHDBBoundingBox
.bboxWgs84Coordinates(71.45, -1.16, 74.7, 7.47); //Maldives
// add hte boundingBox to the MapReducer
mapReducer = mapReducer.areaOfInterest(boundingBox);
......@@ -71,6 +73,7 @@ public class Tutorial {
}
private static class Mapper implements SerializableFunction<OSMEntitySnapshot, Double> {
@Override
public Double apply(OSMEntitySnapshot snapshot) {
return Geo.areaOf(snapshot.getGeometry());
......@@ -78,6 +81,7 @@ public class Tutorial {
}
private static class ResultFilter implements SerializablePredicate<Double> {
@Override
public boolean test(Double area) {
return area < 1000.0;
......
......@@ -15,6 +15,7 @@ import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.ui.ApplicationFrame;
public class TutorialChart extends ApplicationFrame {
private SortedMap<OSHDBTimestamp, Map<ContributionType, Integer>> dataset;
public TutorialChart(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment