diff --git a/CHANGELOG.md b/CHANGELOG.md index bfb273343..953053446 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,13 +5,11 @@ Changelog ### breaking changes -* reorganizing java packages, moving them from `org/heigit/bigspatialdata` to `org/heigit/ohsome` +* reorganize java packages, moving them from `org/heigit/bigspatialdata` to `org/heigit/ohsome` +* integrate [ohsome-filter](https://gitlab.gistools.geog.uni-heidelberg.de/giscience/big-data/ohsome/libs/ohsome-filter) module fully into this repository, renaming it to `oshdb-filter` ([#306]) +* rename methods and move classes/interfaces ([#369]) -When switching to the OSHDB version 0.7 you need to change your imports to the new path, e.g.: -```java -import org.heigit.ohsome.oshdb.api.db.OSHDBDatabase; -import org.heigit.ohsome.oshdb.api.db.OSHDBH2; -``` +> See the _upgrading from 0.6_ section below for instructions how to update your code according to these breaking changes. ### performance improvements @@ -19,10 +17,10 @@ import org.heigit.ohsome.oshdb.api.db.OSHDBH2; ### other changes -* integrate [ohsome-filter](https://gitlab.gistools.geog.uni-heidelberg.de/giscience/big-data/ohsome/libs/ohsome-filter) module fully into this repository, renaming it to `oshdb-filter`. ([#306]) -* make sure predicate-filters are always serializable. ([#353]) -* improve maintainability of parts of important central processing algorithms for determining entity modification history: refactoring improves code structure, adds inline documentation and enhances test coverage. ([#327]) +* make sure predicate-filters are always serializable ([#353]) +* improve maintainability of parts of important central processing algorithms for determining entity modification history: refactoring improves code structure, adds inline documentation and enhances test coverage ([#327]) * reorganize and update ohsome parent module ([#360]) +* add new interfaces `OSHDBTemporal` and `OSHDBBoundable` ([#369]) ### bugfixes @@ -30,7 +28,23 @@ import org.heigit.ohsome.oshdb.api.db.OSHDBH2; ### upgrading from 0.6 -* If you already used the “ohsome filter” functionality from OSHDB version 0.6 and imported one or more classes from the ohsome filter module, you would need to adjust the package names from `org.heigit.ohsome.filter` to `org.heigit.ohsome.oshdb.filter`. +* Since the java package namespace was updated, you need to change your imports to the new path, e.g.: + ```java + import org.heigit.ohsome.oshdb.api.db.OSHDBDatabase; + import org.heigit.ohsome.oshdb.api.db.OSHDBH2; + ``` +* If you used the “ohsome filter” functionality from OSHDB version 0.6 and imported one or more classes from the ohsome filter module, you would need to adjust the package names from `org.heigit.ohsome.filter` to `org.heigit.ohsome.oshdb.filter`. +* the following methods, classes and packages were renamed or moved: + | | old | new | + | --- | --- | --- | + | renamed method | `OSMWay.getRef()` | `OSMWay.getMember()` | + | renamed method | `OSHDBTimestamp.getRawUnixTimestamp()` | `OSHDBTimestamp.getEpochSecond()` | + | moved class | `oshdb.util.OSHDBTimestamp` | `oshdb.OSHDBTimestamp` | + | moved class | `oshdb.util.OSHDBTag` | `oshdb.OSHDBTag` | + | moved class | `CellIterator.OSHEntityFilter` | `oshdb-util/oshdb.osh.OSHEntityFilter` | + | moved class | `CellIterator.OSMEntityFilter` | `oshdb-util/oshdb.osm.OSMEntityFilter` | + | moved class | `oshdb-api.generic.function` | `oshdb-util/oshdb.util.function` | + [#306]: https://github.com/GIScience/oshdb/pull/306 [#327]: https://github.com/GIScience/oshdb/issues/327 @@ -38,6 +52,7 @@ import org.heigit.ohsome.oshdb.api.db.OSHDBH2; [#352]: https://github.com/GIScience/oshdb/pull/352 [#353]: https://github.com/GIScience/oshdb/pull/353 [#360]: https://github.com/GIScience/oshdb/pull/360 +[#369]: https://github.com/GIScience/oshdb/pull/369 ## 0.6.4 diff --git a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/GeometrySplitter.java b/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/GeometrySplitter.java index ac7741688..181664d58 100644 --- a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/GeometrySplitter.java +++ b/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/GeometrySplitter.java @@ -12,15 +12,17 @@ import java.util.TreeMap; import java.util.stream.Collectors; import java.util.stream.Stream; +import org.heigit.ohsome.oshdb.OSHDBBoundable; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.api.object.OSMContribution; import org.heigit.ohsome.oshdb.api.object.OSMEntitySnapshot; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.util.celliterator.ContributionType; import org.heigit.ohsome.oshdb.util.celliterator.LazyEvaluatedObject; import org.heigit.ohsome.oshdb.util.geometry.OSHDBGeometryBuilder; import org.heigit.ohsome.oshdb.util.geometry.fip.FastBboxInPolygon; import org.heigit.ohsome.oshdb.util.geometry.fip.FastBboxOutsidePolygon; import org.heigit.ohsome.oshdb.util.geometry.fip.FastPolygonOperations; +import org.locationtech.jts.geom.Envelope; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.GeometryFactory; import org.locationtech.jts.geom.Polygonal; @@ -85,9 +87,9 @@ D getData() { * @return a list of OSMEntitySnapshot objects */ public Map splitOSMEntitySnapshot(OSMEntitySnapshot data) { - OSHDBBoundingBox oshBoundingBox = data.getOSHEntity().getBoundingBox(); + OSHDBBoundable oshBoundingBox = data.getOSHEntity(); @SuppressWarnings("unchecked") // STRtree works with raw types unfortunately - List candidates = (List) spatialIndex.query( + List candidates = spatialIndex.query( OSHDBGeometryBuilder.getGeometry(oshBoundingBox).getEnvelopeInternal() ); return candidates.stream() @@ -149,9 +151,9 @@ public Map splitOSMEntitySnapshot(OSMEntitySnapshot data) * @return a list of OSMContribution objects */ public Map splitOSMContribution(OSMContribution data) { - OSHDBBoundingBox oshBoundingBox = data.getOSHEntity().getBoundingBox(); + OSHDBBoundable oshBoundingBox = data.getOSHEntity(); @SuppressWarnings("unchecked") // STRtree works with raw types unfortunately - List candidates = (List) spatialIndex.query( + List candidates = spatialIndex.query( OSHDBGeometryBuilder.getGeometry(oshBoundingBox).getEnvelopeInternal() ); return candidates.stream() @@ -176,12 +178,9 @@ public Map splitOSMContribution(OSMContribution data) { contributionGeometryBefore.getEnvelopeInternal() ); } else { - contributionGeometryBbox = OSHDBGeometryBuilder.boundingBoxOf( - contributionGeometryBefore.getEnvelopeInternal() - ); - contributionGeometryBbox.add(OSHDBGeometryBuilder.boundingBoxOf( - contributionGeometryAfter.getEnvelopeInternal() - )); + Envelope env = contributionGeometryBefore.getEnvelopeInternal(); + env.expandToInclude(contributionGeometryAfter.getEnvelopeInternal()); + contributionGeometryBbox = OSHDBGeometryBuilder.boundingBoxOf(env); } if (bops.get(index).test(contributionGeometryBbox)) { diff --git a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/MapAggregatable.java b/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/MapAggregatable.java index 9b0b0716c..cb45737ea 100644 --- a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/MapAggregatable.java +++ b/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/MapAggregatable.java @@ -1,7 +1,7 @@ package org.heigit.ohsome.oshdb.api.mapreducer; import java.io.Serializable; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableFunction; +import org.heigit.ohsome.oshdb.util.function.SerializableFunction; /** * Interface for MapReducers or MapAggregators that can be aggregated by an arbitrary index. diff --git a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/MapAggregator.java b/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/MapAggregator.java index 9a21e8cea..fc6051cc8 100644 --- a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/MapAggregator.java +++ b/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/MapAggregator.java @@ -4,6 +4,7 @@ import com.google.common.collect.Streams; import com.tdunning.math.stats.TDigest; import java.io.Serializable; +import java.util.AbstractMap.SimpleImmutableEntry; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -19,30 +20,28 @@ import java.util.TreeSet; import java.util.function.DoubleUnaryOperator; import java.util.function.Function; -import java.util.function.Predicate; import java.util.regex.Pattern; import java.util.stream.Collectors; import java.util.stream.Stream; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; import org.heigit.ohsome.oshdb.api.generic.NumberUtils; import org.heigit.ohsome.oshdb.api.generic.OSHDBCombinedIndex; import org.heigit.ohsome.oshdb.api.generic.WeightedValue; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableBiConsumer; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableBiFunction; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableBinaryOperator; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableFunction; -import org.heigit.ohsome.oshdb.api.generic.function.SerializablePredicate; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableSupplier; import org.heigit.ohsome.oshdb.api.mapreducer.MapReducer.Grouping; import org.heigit.ohsome.oshdb.api.object.OSHDBMapReducible; import org.heigit.ohsome.oshdb.api.object.OSMContribution; import org.heigit.ohsome.oshdb.api.object.OSMEntitySnapshot; -import org.heigit.ohsome.oshdb.filter.Filter; import org.heigit.ohsome.oshdb.filter.FilterExpression; -import org.heigit.ohsome.oshdb.osm.OSMEntity; import org.heigit.ohsome.oshdb.osm.OSMType; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.heigit.ohsome.oshdb.util.exceptions.OSHDBInvalidTimestampException; +import org.heigit.ohsome.oshdb.util.function.OSMEntityFilter; +import org.heigit.ohsome.oshdb.util.function.SerializableBiConsumer; +import org.heigit.ohsome.oshdb.util.function.SerializableBiFunction; +import org.heigit.ohsome.oshdb.util.function.SerializableBinaryOperator; +import org.heigit.ohsome.oshdb.util.function.SerializableFunction; +import org.heigit.ohsome.oshdb.util.function.SerializablePredicate; +import org.heigit.ohsome.oshdb.util.function.SerializableSupplier; import org.heigit.ohsome.oshdb.util.tagtranslator.OSMTagInterface; import org.jetbrains.annotations.Contract; import org.locationtech.jts.geom.Geometry; @@ -86,7 +85,7 @@ public class MapAggregator & Serializable, X> implements SerializableFunction indexer, Collection zerofill ) { - this.mapReducer = mapReducer.map(data -> new IndexValuePair( + this.mapReducer = mapReducer.map(data -> new IndexValuePair<>( indexer.apply(data), data )); @@ -121,7 +120,7 @@ private MapAggregator copyTransform(MapReducer> m copyTransformKey(MapReducer> mapReducer) { @SuppressWarnings("unchecked") // we convert the mapAggregator to a new key type "V" MapAggregator transformedMapAggregator = (MapAggregator) this; - return new MapAggregator(transformedMapAggregator, mapReducer); + return new MapAggregator<>(transformedMapAggregator, mapReducer); } // ----------------------------------------------------------------------------------------------- @@ -139,7 +138,7 @@ private MapAggregator copyTransform(MapReducer> m public & Serializable> MapAggregator, X> aggregateBy(SerializableFunction indexer, Collection zerofill) { MapAggregator, X> res = this - .mapIndex((existingIndex, data) -> new OSHDBCombinedIndex( + .mapIndex((existingIndex, data) -> new OSHDBCombinedIndex<>( existingIndex, indexer.apply(data) )); @@ -254,6 +253,7 @@ MapAggregator, X> aggregateByGeometry(Map geometr * @param bboxFilter the bounding box to query the data in * @return a modified copy of this object (can be used to chain multiple commands together) */ + @Override @Contract(pure = true) public MapAggregator areaOfInterest(OSHDBBoundingBox bboxFilter) { return this.copyTransform(this.mapReducer.areaOfInterest(bboxFilter)); @@ -267,6 +267,7 @@ public MapAggregator areaOfInterest(OSHDBBoundingBox bboxFilter) { * @param polygonFilter the bounding box to query the data in * @return a modified copy of this object (can be used to chain multiple commands together) */ + @Override @Contract(pure = true) public

MapAggregator areaOfInterest(P polygonFilter) { return this.copyTransform(this.mapReducer.areaOfInterest(polygonFilter)); @@ -279,6 +280,7 @@ public

MapAggregator areaOfInterest(P pol * @return a modified copy of this object (can be used to chain multiple commands together) * @deprecated use oshdb-filter {@link #filter(String)} instead */ + @Override @Deprecated @Contract(pure = true) public MapAggregator osmType(Set typeFilter) { @@ -292,12 +294,13 @@ public MapAggregator osmType(Set typeFilter) { * @param f the filter function to call for each osm entity * @return a modified copy of this object (can be used to chain multiple commands together) * @deprecated use oshdb-filter {@link #filter(FilterExpression)} with {@link - * org.heigit.ohsome.oshdb.filter.Filter#byOSMEntity(Filter.SerializablePredicate)} + * org.heigit.ohsome.oshdb.filter.Filter#byOSMEntity(OSMEntityFilter)} * instead */ + @Override @Deprecated @Contract(pure = true) - public MapAggregator osmEntityFilter(SerializablePredicate f) { + public MapAggregator osmEntityFilter(OSMEntityFilter f) { return this.copyTransform(this.mapReducer.osmEntityFilter(f)); } @@ -310,6 +313,7 @@ public MapAggregator osmEntityFilter(SerializablePredicate f) { * @return a modified copy of this mapReducer (can be used to chain multiple commands together) * @deprecated use oshdb-filter {@link #filter(String)} instead */ + @Override @Deprecated @Contract(pure = true) public MapAggregator osmTag(OSMTagInterface tag) { @@ -324,6 +328,7 @@ public MapAggregator osmTag(OSMTagInterface tag) { * @return a modified copy of this object (can be used to chain multiple commands together) * @deprecated use oshdb-filter {@link #filter(String)} instead */ + @Override @Deprecated @Contract(pure = true) public MapAggregator osmTag(String key) { @@ -339,6 +344,7 @@ public MapAggregator osmTag(String key) { * @return a modified copy of this object (can be used to chain multiple commands together) * @deprecated use oshdb-filter {@link #filter(String)} instead */ + @Override @Deprecated @Contract(pure = true) public MapAggregator osmTag(String key, String value) { @@ -355,6 +361,7 @@ public MapAggregator osmTag(String key, String value) { * @return a modified copy of this object (can be used to chain multiple commands together) * @deprecated use oshdb-filter {@link #filter(String)} instead */ + @Override @Deprecated @Contract(pure = true) public MapAggregator osmTag(String key, Collection values) { @@ -369,6 +376,7 @@ public MapAggregator osmTag(String key, Collection values) { * @param valuePattern a regular expression which the tag value of the osm entity must match * @return a modified copy of this object (can be used to chain multiple commands together) */ + @Override @Contract(pure = true) public MapAggregator osmTag(String key, Pattern valuePattern) { return this.copyTransform(this.mapReducer.osmTag(key, valuePattern)); @@ -382,6 +390,7 @@ public MapAggregator osmTag(String key, Pattern valuePattern) { * @return a modified copy of this object (can be used to chain multiple commands together) * @deprecated use oshdb-filter {@link #filter(String)} instead */ + @Override @Deprecated @Contract(pure = true) public MapAggregator osmTag(Collection tags) { @@ -405,6 +414,7 @@ public MapAggregator osmTag(Collection tags) { * @return the sum of the current data * @throws UnsupportedOperationException if the data cannot be cast to numbers */ + @Override @Contract(pure = true) public SortedMap sum() throws Exception { return this @@ -425,6 +435,7 @@ public SortedMap sum() throws Exception { * @param the numeric type that is returned by the `mapper` function * @return the summed up results of the `mapper` function */ + @Override @Contract(pure = true) public SortedMap sum(SerializableFunction mapper) throws Exception { @@ -441,6 +452,7 @@ public SortedMap sum(SerializableFunction mapper) * * @return the total count of features or modifications, summed up over all timestamps */ + @Override @Contract(pure = true) public SortedMap count() throws Exception { return this.sum(ignored -> 1); @@ -454,6 +466,7 @@ public SortedMap count() throws Exception { * * @return the set of distinct values */ + @Override @Contract(pure = true) public SortedMap> uniq() throws Exception { return this.reduce( @@ -472,6 +485,7 @@ public SortedMap> uniq() throws Exception { * @param the type that is returned by the `mapper` function * @return a set of distinct values returned by the `mapper` function */ + @Override @Contract(pure = true) public SortedMap> uniq(SerializableFunction mapper) throws Exception { return this.map(mapper).uniq(); @@ -485,6 +499,7 @@ public SortedMap> uniq(SerializableFunction mapper) throws E * * @return the set of distinct values */ + @Override @Contract(pure = true) public SortedMap countUniq() throws Exception { return transformSortedMap(this.uniq(), Set::size); @@ -499,6 +514,7 @@ public SortedMap countUniq() throws Exception { * @return the average of the current data * @throws UnsupportedOperationException if the data cannot be cast to numbers */ + @Override @Contract(pure = true) public SortedMap average() throws Exception { return this @@ -513,6 +529,7 @@ public SortedMap average() throws Exception { * @param the numeric type that is returned by the `mapper` function * @return the average of the numbers returned by the `mapper` function */ + @Override @Contract(pure = true) public SortedMap average(SerializableFunction mapper) throws Exception { @@ -529,6 +546,7 @@ public SortedMap average(SerializableFunction weightedAverage(SerializableFunction mapper) throws Exception { @@ -552,6 +570,7 @@ public SortedMap weightedAverage(SerializableFunction estimatedMedian() throws Exception { return this.estimatedQuantile(0.5); @@ -568,6 +587,7 @@ public SortedMap estimatedMedian() throws Exception { * @param mapper function that returns the numbers to generate the mean for * @return estimated median */ + @Override @Contract(pure = true) public SortedMap estimatedMedian(SerializableFunction mapper) throws Exception { @@ -585,6 +605,7 @@ public SortedMap estimatedMedian(SerializableFunct * @param q the desired quantile to calculate (as a number between 0 and 1) * @return estimated quantile boundary */ + @Override @Contract(pure = true) public SortedMap estimatedQuantile(double q) throws Exception { return this.makeNumeric().estimatedQuantile(n -> n, q); @@ -603,6 +624,7 @@ public SortedMap estimatedQuantile(double q) throws Exception { * @param q the desired quantile to calculate (as a number between 0 and 1) * @return estimated quantile boundary */ + @Override @Contract(pure = true) public SortedMap estimatedQuantile( SerializableFunction mapper, @@ -625,6 +647,7 @@ public SortedMap estimatedQuantile( * @param q the desired quantiles to calculate (as a collection of numbers between 0 and 1) * @return estimated quantile boundaries */ + @Override @Contract(pure = true) public SortedMap> estimatedQuantiles(Iterable q) throws Exception { return this.makeNumeric().estimatedQuantiles(n -> n, q); @@ -642,6 +665,7 @@ public SortedMap> estimatedQuantiles(Iterable q) throws * @param q the desired quantiles to calculate (as a collection of numbers between 0 and 1) * @return estimated quantile boundaries */ + @Override @Contract(pure = true) public SortedMap> estimatedQuantiles( SerializableFunction mapper, @@ -667,6 +691,7 @@ public SortedMap> estimatedQuantiles( * * @return a function that computes estimated quantile boundaries */ + @Override @Contract(pure = true) public SortedMap estimatedQuantiles() throws Exception { return this.makeNumeric().estimatedQuantiles(n -> n); @@ -684,6 +709,7 @@ public SortedMap estimatedQuantiles() throws Exception { * @param mapper function that returns the numbers to generate the quantiles for * @return a function that computes estimated quantile boundaries */ + @Override @Contract(pure = true) public SortedMap estimatedQuantiles( SerializableFunction mapper @@ -732,6 +758,7 @@ public void forEach(SerializableBiConsumer> action) throws Exception * * @return an aggregated map of lists with all results */ + @Override @Contract(pure = true) public SortedMap> collect() throws Exception { return this.reduce( @@ -746,24 +773,11 @@ public SortedMap> collect() throws Exception { * * @return a stream with all results returned by the `mapper` function */ + @Override @Contract(pure = true) public Stream> stream() throws Exception { - return this.mapReducer.stream().map(d -> new Entry() { - @Override - public U getKey() { - return d.getKey(); - } - - @Override - public X getValue() { - return d.getValue(); - } - - @Override - public X setValue(X value) { - throw new RuntimeException("cannot modify the value of this entry"); - } - }); + return this.mapReducer.stream().map(d -> + new SimpleImmutableEntry<>(d.getKey(),d.getValue())); } // ----------------------------------------------------------------------------------------------- @@ -778,6 +792,7 @@ public X setValue(X value) { * @param an arbitrary data type which is the return type of the transformation `map` function * @return a modified copy of this MapAggregator object operating on the transformed type R */ + @Override @Contract(pure = true) public MapAggregator map(SerializableFunction mapper) { return this.copyTransform(this.mapReducer.map(inData -> { @@ -801,12 +816,13 @@ public MapAggregator map(SerializableFunction mapper) { * @param an arbitrary data type which is the return type of the transformation `map` function * @return a modified copy of this MapAggregator object operating on the transformed type R */ + @Override @Contract(pure = true) public MapAggregator flatMap(SerializableFunction> flatMapper) { return this.copyTransform(this.mapReducer.flatMap(inData -> { List> outData = new LinkedList<>(); flatMapper.apply(inData.getValue()).forEach(flatMappedData -> - outData.add(new IndexValuePair( + outData.add(new IndexValuePair<>( inData.getKey(), flatMappedData )) @@ -822,6 +838,7 @@ public MapAggregator flatMap(SerializableFunction> flat * (when f returns true) or discarded (when f returns false) * @return a modified copy of this object (can be used to chain multiple commands together) */ + @Override @Contract(pure = true) public MapAggregator filter(SerializablePredicate f) { return this.copyTransform(this.mapReducer.filter(data -> @@ -839,6 +856,7 @@ public MapAggregator filter(SerializablePredicate f) { * @param f the {@link org.heigit.ohsome.oshdb.filter.FilterExpression} to apply * @return a modified copy of this object (can be used to chain multiple commands together) */ + @Override @Contract(pure = true) public MapAggregator filter(FilterExpression f) { return this.copyTransform(this.mapReducer.filter(f)); @@ -853,6 +871,7 @@ public MapAggregator filter(FilterExpression f) { * @param f the filter string to apply * @return a modified copy of this object (can be used to chain multiple commands together) */ + @Override @Contract(pure = true) public MapAggregator filter(String f) { return this.copyTransform(this.mapReducer.filter(f)); @@ -905,6 +924,7 @@ public MapAggregator filter(String f) { * `combiner` function, after all `mapper` results have been aggregated (in the * `accumulator` and `combiner` steps) */ + @Override @Contract(pure = true) public SortedMap reduce( SerializableSupplier identitySupplier, @@ -921,7 +941,7 @@ public SortedMap reduce( return m; }, (a, b) -> { - TreeMap combined = new TreeMap(a); + TreeMap combined = new TreeMap<>(a); for (SortedMap.Entry entry : b.entrySet()) { combined.merge(entry.getKey(), entry.getValue(), combiner); } @@ -985,6 +1005,7 @@ public SortedMap reduce( * `combiner` function, after all `mapper` results have been aggregated (in the * `accumulator` and `combiner` steps) */ + @Override @Contract(pure = true) public SortedMap reduce( SerializableSupplier identitySupplier, diff --git a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/MapFunction.java b/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/MapFunction.java index 1cae1a30b..97a3f5f0b 100644 --- a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/MapFunction.java +++ b/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/MapFunction.java @@ -1,6 +1,6 @@ package org.heigit.ohsome.oshdb.api.mapreducer; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableFunction; +import org.heigit.ohsome.oshdb.util.function.SerializableFunction; /** * A function that has a flag: isFlatMapper. diff --git a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/MapReducer.java b/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/MapReducer.java index 727f6e7ed..93c352d12 100644 --- a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/MapReducer.java +++ b/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/MapReducer.java @@ -26,16 +26,13 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import org.heigit.ohsome.oshdb.OSHDB; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; +import org.heigit.ohsome.oshdb.OSHDBTag; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; import org.heigit.ohsome.oshdb.api.db.OSHDBDatabase; import org.heigit.ohsome.oshdb.api.db.OSHDBJdbc; import org.heigit.ohsome.oshdb.api.generic.NumberUtils; import org.heigit.ohsome.oshdb.api.generic.WeightedValue; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableBiFunction; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableBinaryOperator; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableConsumer; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableFunction; -import org.heigit.ohsome.oshdb.api.generic.function.SerializablePredicate; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableSupplier; import org.heigit.ohsome.oshdb.api.object.OSHDBMapReducible; import org.heigit.ohsome.oshdb.api.object.OSMContribution; import org.heigit.ohsome.oshdb.api.object.OSMEntitySnapshot; @@ -52,14 +49,18 @@ import org.heigit.ohsome.oshdb.osh.OSHEntity; import org.heigit.ohsome.oshdb.osm.OSMEntity; import org.heigit.ohsome.oshdb.osm.OSMType; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; -import org.heigit.ohsome.oshdb.util.OSHDBTag; import org.heigit.ohsome.oshdb.util.OSHDBTagKey; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; -import org.heigit.ohsome.oshdb.util.celliterator.CellIterator; import org.heigit.ohsome.oshdb.util.celliterator.ContributionType; import org.heigit.ohsome.oshdb.util.exceptions.OSHDBInvalidTimestampException; import org.heigit.ohsome.oshdb.util.exceptions.OSHDBKeytablesNotFoundException; +import org.heigit.ohsome.oshdb.util.function.OSHEntityFilter; +import org.heigit.ohsome.oshdb.util.function.OSMEntityFilter; +import org.heigit.ohsome.oshdb.util.function.SerializableBiFunction; +import org.heigit.ohsome.oshdb.util.function.SerializableBinaryOperator; +import org.heigit.ohsome.oshdb.util.function.SerializableConsumer; +import org.heigit.ohsome.oshdb.util.function.SerializableFunction; +import org.heigit.ohsome.oshdb.util.function.SerializablePredicate; +import org.heigit.ohsome.oshdb.util.function.SerializableSupplier; import org.heigit.ohsome.oshdb.util.geometry.Geo; import org.heigit.ohsome.oshdb.util.geometry.OSHDBGeometryBuilder; import org.heigit.ohsome.oshdb.util.taginterpreter.DefaultTagInterpreter; @@ -118,8 +119,8 @@ * mapper function will be called with a parameter of this type as input */ public abstract class MapReducer implements - MapReducerSettings>, Mappable, MapReducerAggregations, - MapAggregatable, X>, X>, Serializable { +MapReducerSettings>, Mappable, MapReducerAggregations, +MapAggregatable, X>, X>, Serializable { private static final Logger LOG = LoggerFactory.getLogger(MapReducer.class); protected OSHDBDatabase oshdb; @@ -152,7 +153,7 @@ public boolean isCancelable() { "2008-01-01", TimestampFormatter.getInstance().date(new Date()), OSHDBTimestamps.Interval.MONTHLY - ); + ); protected OSHDBBoundingBox bboxFilter = new OSHDBBoundingBox(-180, -90, 180, 90); private Geometry polyFilter = null; protected EnumSet typeFilter = EnumSet.of(OSMType.NODE, OSMType.WAY, OSMType.RELATION); @@ -255,11 +256,12 @@ public MapReducer tagInterpreter(TagInterpreter tagInterpreter) { * @param bboxFilter the bounding box to query the data in * @return a modified copy of this mapReducer (can be used to chain multiple commands together) */ + @Override @Contract(pure = true) public MapReducer areaOfInterest(@NotNull OSHDBBoundingBox bboxFilter) { MapReducer ret = this.copy(); if (this.polyFilter == null) { - ret.bboxFilter = OSHDBBoundingBox.intersect(bboxFilter, ret.bboxFilter); + ret.bboxFilter = bboxFilter.intersection(bboxFilter); } else { ret.polyFilter = Geo.clip(ret.polyFilter, bboxFilter); ret.bboxFilter = OSHDBGeometryBuilder.boundingBoxOf(ret.polyFilter.getEnvelopeInternal()); @@ -274,6 +276,7 @@ public MapReducer areaOfInterest(@NotNull OSHDBBoundingBox bboxFilter) { * @param polygonFilter the bounding box to query the data in * @return a modified copy of this mapReducer (can be used to chain multiple commands together) */ + @Override @Contract(pure = true) public

MapReducer areaOfInterest(@NotNull P polygonFilter) { MapReducer ret = this.copy(); @@ -325,7 +328,7 @@ public MapReducer timestamps(OSHDBTimestampList tstamps) { @Contract(pure = true) public MapReducer timestamps( String isoDateStart, String isoDateEnd, OSHDBTimestamps.Interval interval - ) { + ) { return this.timestamps(new OSHDBTimestamps(isoDateStart, isoDateEnd, interval)); } @@ -389,14 +392,14 @@ public MapReducer timestamps( try { timestamps.add( new OSHDBTimestamp(IsoDateTimeParser.parseIsoDateTime(isoDateFirst).toEpochSecond()) - ); + ); timestamps.add( new OSHDBTimestamp(IsoDateTimeParser.parseIsoDateTime(isoDateSecond).toEpochSecond()) - ); + ); for (String isoDate : isoDateMore) { timestamps.add( new OSHDBTimestamp(IsoDateTimeParser.parseIsoDateTime(isoDate).toEpochSecond()) - ); + ); } } catch (Exception e) { LOG.error("unable to parse ISO date string: " + e.getMessage()); @@ -411,6 +414,7 @@ public MapReducer timestamps( * @return a modified copy of this mapReducer (can be used to chain multiple commands together) * @deprecated use oshdb-filter {@link #filter(String)} instead */ + @Override @Deprecated @Contract(pure = true) public MapReducer osmType(Set typeFilter) { @@ -436,12 +440,13 @@ private MapReducer osmTypeInternal(Set typeFilter) { * @param f the filter function to call for each osm entity * @return a modified copy of this mapReducer (can be used to chain multiple commands together) * @deprecated use oshdb-filter {@link #filter(FilterExpression)} with {@link - * org.heigit.ohsome.oshdb.filter.Filter#byOSMEntity(Filter.SerializablePredicate)} + * org.heigit.ohsome.oshdb.filter.Filter#byOSMEntity(OSMEntityFilter)} * instead */ + @Override @Deprecated @Contract(pure = true) - public MapReducer osmEntityFilter(SerializablePredicate f) { + public MapReducer osmEntityFilter(OSMEntityFilter f) { MapReducer ret = this.copy(); ret.filters.add(f); return ret; @@ -455,6 +460,7 @@ public MapReducer osmEntityFilter(SerializablePredicate f) { * @return a modified copy of this mapReducer (can be used to chain multiple commands together) * @deprecated use oshdb-filter {@link #filter(String)} instead */ + @Override @Deprecated @Contract(pure = true) public MapReducer osmTag(String key) { @@ -469,6 +475,7 @@ public MapReducer osmTag(String key) { * @return a modified copy of this mapReducer (can be used to chain multiple commands together) * @deprecated use oshdb-filter {@link #filter(String)} instead */ + @Override @Deprecated @Contract(pure = true) public MapReducer osmTag(OSMTagInterface tag) { @@ -509,6 +516,7 @@ private MapReducer osmTag(OSMTagKey key) { * @return a modified copy of this mapReducer (can be used to chain multiple commands together) * @deprecated use oshdb-filter {@link #filter(String)} instead */ + @Override @Deprecated @Contract(pure = true) public MapReducer osmTag(String key, String value) { @@ -544,6 +552,7 @@ private MapReducer osmTag(OSMTag tag) { * @return a modified copy of this mapReducer (can be used to chain multiple commands together) * @deprecated use oshdb-filter {@link #filter(String)} instead */ + @Override @Deprecated @Contract(pure = true) public MapReducer osmTag(String key, Collection values) { @@ -553,9 +562,9 @@ public MapReducer osmTag(String key, Collection values) { LOG.warn( (values.isEmpty() ? "Empty tag value list. No data will match this filter." - : "Tag key {} not found. No data will match this filter."), + : "Tag key {} not found. No data will match this filter."), key - ); + ); return osmTagEmptyResult(); } Set valueIds = new HashSet<>(); @@ -592,6 +601,7 @@ public MapReducer osmTag(String key, Collection values) { * @param valuePattern a regular expression which the tag value of the osm entity must match * @return a modified copy of this mapReducer (can be used to chain multiple commands together) */ + @Override @Contract(pure = true) public MapReducer osmTag(String key, Pattern valuePattern) { OSHDBTagKey oshdbKey = this.getTagTranslator().getOSHDBTagKeyOf(key); @@ -626,6 +636,7 @@ public MapReducer osmTag(String key, Pattern valuePattern) { * @return a modified copy of this mapReducer (can be used to chain multiple commands together) * @deprecated use oshdb-filter {@link #filter(String)} instead */ + @Override @Deprecated @Contract(pure = true) public MapReducer osmTag(Collection tags) { @@ -712,6 +723,7 @@ private MapReducer osmTagEmptyResult() { * @param an arbitrary data type which is the return type of the transformation `map` function * @return a modified copy of this MapReducer object operating on the transformed type (<R>) */ + @Override @Contract(pure = true) public MapReducer map(SerializableFunction mapper) { MapReducer ret = this.copy(); @@ -731,6 +743,7 @@ public MapReducer map(SerializableFunction mapper) { * @param an arbitrary data type which is the return type of the transformation `map` function * @return a modified copy of this MapReducer object operating on the transformed type (<R>) */ + @Override @Contract(pure = true) public MapReducer flatMap(SerializableFunction> flatMapper) { MapReducer ret = this.copy(); @@ -747,6 +760,7 @@ public MapReducer flatMap(SerializableFunction> flatMapper * returns true) or discarded (when f returns false) * @return a modified copy of this mapReducer (can be used to chain multiple commands together) */ + @Override @Contract(pure = true) public MapReducer filter(SerializablePredicate f) { return this @@ -763,6 +777,7 @@ public MapReducer filter(SerializablePredicate f) { * @param f the {@link org.heigit.ohsome.oshdb.filter.FilterExpression} to apply * @return a modified copy of this mapReducer (can be used to chain multiple commands together) */ + @Override @Contract(pure = true) public MapReducer filter(FilterExpression f) { MapReducer ret = this.copy(); @@ -796,27 +811,27 @@ public MapReducer filter(FilterExpression f) { if (ret.forClass.equals(OSMEntitySnapshot.class)) { @SuppressWarnings("unchecked") MapReducer filteredListMapper = (MapReducer) ret.map(x -> (Collection) x) - .map(snapshots -> snapshots.stream() - .filter(s -> f.applyOSMGeometry(s.getEntity(), s::getGeometry)) - .collect(Collectors.toCollection(ArrayList::new))) - .filter(snapshots -> !snapshots.isEmpty()); + .map(snapshots -> snapshots.stream() + .filter(s -> f.applyOSMGeometry(s.getEntity(), s::getGeometry)) + .collect(Collectors.toCollection(ArrayList::new))) + .filter(snapshots -> !snapshots.isEmpty()); ret = filteredListMapper; } else if (ret.forClass.equals(OSMContribution.class)) { @SuppressWarnings("unchecked") MapReducer filteredListMapper = (MapReducer) ret.map(x -> (Collection) x) - .map(contributions -> contributions.stream() - .filter(c -> { - if (c.is(ContributionType.CREATION)) { - return f.applyOSMGeometry(c.getEntityAfter(), c::getGeometryAfter); - } else if (c.is(ContributionType.DELETION)) { - return f.applyOSMGeometry(c.getEntityBefore(), c::getGeometryBefore); - } else { - return f.applyOSMGeometry(c.getEntityBefore(), c::getGeometryBefore) - || f.applyOSMGeometry(c.getEntityAfter(), c::getGeometryAfter); - } - }) - .collect(Collectors.toCollection(ArrayList::new))) - .filter(contributions -> !contributions.isEmpty()); + .map(contributions -> contributions.stream() + .filter(c -> { + if (c.is(ContributionType.CREATION)) { + return f.applyOSMGeometry(c.getEntityAfter(), c::getGeometryAfter); + } else if (c.is(ContributionType.DELETION)) { + return f.applyOSMGeometry(c.getEntityBefore(), c::getGeometryBefore); + } else { + return f.applyOSMGeometry(c.getEntityBefore(), c::getGeometryBefore) + || f.applyOSMGeometry(c.getEntityAfter(), c::getGeometryAfter); + } + }) + .collect(Collectors.toCollection(ArrayList::new))) + .filter(contributions -> !contributions.isEmpty()); ret = filteredListMapper; } } else { @@ -836,6 +851,7 @@ public MapReducer filter(FilterExpression f) { * @param f the filter string to apply * @return a modified copy of this mapReducer (can be used to chain multiple commands together) */ + @Override @Contract(pure = true) public MapReducer filter(String f) { return this.filter(new FilterParser(this.getTagTranslator()).parse(f)); @@ -872,7 +888,7 @@ public MapReducer> groupByEntity() throws UnsupportedOperationException throw new UnsupportedOperationException( "groupByEntity() must be called before any `map` or `flatMap` " + "transformation functions have been set" - ); + ); } if (this.grouping != Grouping.NONE) { throw new UnsupportedOperationException("A grouping is already active on this MapReducer"); @@ -899,7 +915,7 @@ public MapReducer> groupByEntity() throws UnsupportedOperationException public & Serializable> MapAggregator aggregateBy( SerializableFunction indexer, Collection zerofill - ) { + ) { return new MapAggregator<>(this, indexer, zerofill); } @@ -913,10 +929,11 @@ public & Serializable> MapAggregator aggregateBy( * @return a MapAggregator object with the equivalent state (settings, filters, map function, * etc.) of the current MapReducer object */ + @Override @Contract(pure = true) public & Serializable> MapAggregator aggregateBy( SerializableFunction indexer - ) { + ) { return this.aggregateBy(indexer, Collections.emptyList()); } @@ -942,7 +959,7 @@ public MapAggregator aggregateByTimestamp() throw new UnsupportedOperationException( "automatic aggregateByTimestamp() cannot be used together with the groupByEntity() " + "functionality -> try using aggregateByTimestamp(customTimestampIndex) instead" - ); + ); } // by timestamp indexing function -> for some views we need to match the input data to the list @@ -956,7 +973,7 @@ public MapAggregator aggregateByTimestamp() throw new UnsupportedOperationException( "automatic aggregateByTimestamp() only implemented for OSMContribution and " + "OSMEntitySnapshot -> try using aggregateByTimestamp(customTimestampIndex) instead" - ); + ); } if (this.mappers.size() > 0) { @@ -1002,11 +1019,11 @@ public MapAggregator aggregateByTimestamp() */ public MapAggregator aggregateByTimestamp( SerializableFunction indexer - ) throws UnsupportedOperationException { + ) throws UnsupportedOperationException { final TreeSet timestamps = new TreeSet<>(this.tstamps.get()); final OSHDBTimestamp minTime = timestamps.first(); final OSHDBTimestamp maxTime = timestamps.last(); - return new MapAggregator(this, data -> { + return new MapAggregator<>(this, data -> { // match timestamps to the given timestamp list OSHDBTimestamp aggregationTimestamp = indexer.apply(data); if (aggregationTimestamp == null @@ -1014,7 +1031,7 @@ public MapAggregator aggregateByTimestamp( || aggregationTimestamp.compareTo(maxTime) > 0) { throw new OSHDBInvalidTimestampException( "Aggregation timestamp outside of time query interval." - ); + ); } return timestamps.floor(aggregationTimestamp); }, getZerofillTimestamps()); @@ -1033,19 +1050,19 @@ public MapAggregator aggregateByTimestamp( */ @Contract(pure = true) public & Serializable, P extends Geometry & Polygonal> - MapAggregator aggregateByGeometry(Map geometries) throws - UnsupportedOperationException { + MapAggregator aggregateByGeometry(Map geometries) throws + UnsupportedOperationException { if (this.grouping != Grouping.NONE) { throw new UnsupportedOperationException( "aggregateByGeometry() cannot be used together with the groupByEntity() functionality" - ); + ); } GeometrySplitter gs = new GeometrySplitter<>(geometries); if (this.mappers.size() > 0) { throw new UnsupportedOperationException( "please call aggregateByGeometry before setting any map or flatMap functions" - ); + ); } else { MapAggregator ret; if (this.forClass.equals(OSMContribution.class)) { @@ -1057,7 +1074,7 @@ MapAggregator aggregateByGeometry(Map geometries) throws } else { throw new UnsupportedOperationException( "aggregateByGeometry not implemented for objects of type: " + this.forClass.toString() - ); + ); } @SuppressWarnings("unchecked") // no mapper functions have been applied so the type is still X MapAggregator result = (MapAggregator) ret; @@ -1111,12 +1128,13 @@ MapAggregator aggregateByGeometry(Map geometries) throws * @throws Exception if during the reducing operation an exception happens (see the respective * implementations for details). */ + @Override @Contract(pure = true) public S reduce( SerializableSupplier identitySupplier, SerializableBiFunction accumulator, SerializableBinaryOperator combiner) - throws Exception { + throws Exception { checkTimeout(); switch (this.grouping) { case NONE: @@ -1126,24 +1144,24 @@ public S reduce( @SuppressWarnings("Convert2MethodRef") // having just `mapper::apply` here is problematic, see https://github.com/GIScience/oshdb/pull/37 final SerializableFunction contributionMapper = - data -> mapper.apply(data); + data -> mapper.apply(data); return this.mapReduceCellsOSMContribution( contributionMapper, identitySupplier, accumulator, combiner - ); + ); } else if (this.forClass.equals(OSMEntitySnapshot.class)) { @SuppressWarnings("Convert2MethodRef") // having just `mapper::apply` here is problematic, see https://github.com/GIScience/oshdb/pull/37 final SerializableFunction snapshotMapper = - data -> mapper.apply(data); + data -> mapper.apply(data); return this.mapReduceCellsOSMEntitySnapshot( snapshotMapper, identitySupplier, accumulator, combiner - ); + ); } else { throw new UnsupportedOperationException( "Unimplemented data view: " + this.forClass.toString()); @@ -1155,8 +1173,8 @@ public S reduce( (List inputList) -> { List outputList = new LinkedList<>(); inputList.stream() - .map((SerializableFunction>) flatMapper::apply) - .forEach(data -> Iterables.addAll(outputList, data)); + .map((SerializableFunction>) flatMapper::apply) + .forEach(data -> Iterables.addAll(outputList, data)); return outputList; }, identitySupplier, accumulator, combiner); } else if (this.forClass.equals(OSMEntitySnapshot.class)) { @@ -1164,8 +1182,8 @@ public S reduce( (List inputList) -> { List outputList = new LinkedList<>(); inputList.stream() - .map((SerializableFunction>) flatMapper::apply) - .forEach(data -> Iterables.addAll(outputList, data)); + .map((SerializableFunction>) flatMapper::apply) + .forEach(data -> Iterables.addAll(outputList, data)); return outputList; }, identitySupplier, accumulator, combiner); } else { @@ -1187,24 +1205,24 @@ public S reduce( @SuppressWarnings("Convert2MethodRef") // having just `flatMapper::apply` here is problematic, see https://github.com/GIScience/oshdb/pull/37 final SerializableFunction, Iterable> contributionFlatMapper = - data -> flatMapper.apply(data); + data -> flatMapper.apply(data); return this.flatMapReduceCellsOSMContributionGroupedById( contributionFlatMapper, identitySupplier, accumulator, combiner - ); + ); } else if (this.forClass.equals(OSMEntitySnapshot.class)) { @SuppressWarnings("Convert2MethodRef") // having just `flatMapper::apply` here is problematic, see https://github.com/GIScience/oshdb/pull/37 final SerializableFunction, Iterable> snapshotFlatMapper = - data -> flatMapper.apply(data); + data -> flatMapper.apply(data); return this.flatMapReduceCellsOSMEntitySnapshotGroupedById( snapshotFlatMapper, identitySupplier, accumulator, combiner - ); + ); } else { throw new UnsupportedOperationException( "Unimplemented data view: " + this.forClass.toString()); @@ -1252,6 +1270,7 @@ public S reduce( * `combiner` function, after all `mapper` results have been aggregated (in the * `accumulator` and `combiner` steps) */ + @Override @Contract(pure = true) public X reduce(SerializableSupplier identitySupplier, SerializableBinaryOperator accumulator) throws Exception { @@ -1275,6 +1294,7 @@ public X reduce(SerializableSupplier identitySupplier, * @return the sum of the current data * @throws UnsupportedOperationException if the data cannot be cast to numbers */ + @Override @Contract(pure = true) public Number sum() throws Exception { return this.makeNumeric().reduce(() -> 0, NumberUtils::add); @@ -1290,6 +1310,7 @@ public Number sum() throws Exception { * @param the numeric type that is returned by the `mapper` function * @return the summed up results of the `mapper` function */ + @Override @Contract(pure = true) public R sum(SerializableFunction mapper) throws Exception { return this.map(mapper).reduce(() -> (R) (Integer) 0, NumberUtils::add); @@ -1300,6 +1321,7 @@ public R sum(SerializableFunction mapper) throws Except * * @return the total count of features or modifications, summed up over all timestamps */ + @Override @Contract(pure = true) public Integer count() throws Exception { return this.sum(ignored -> 1); @@ -1313,13 +1335,14 @@ public Integer count() throws Exception { * * @return the set of distinct values */ + @Override @Contract(pure = true) public Set uniq() throws Exception { return this.reduce( MapReducer::uniqIdentitySupplier, MapReducer::uniqAccumulator, MapReducer::uniqCombiner - ); + ); } /** @@ -1331,6 +1354,7 @@ public Set uniq() throws Exception { * @param the type that is returned by the `mapper` function * @return a set of distinct values returned by the `mapper` function */ + @Override @Contract(pure = true) public Set uniq(SerializableFunction mapper) throws Exception { return this.map(mapper).uniq(); @@ -1344,6 +1368,7 @@ public Set uniq(SerializableFunction mapper) throws Exception { * * @return the set of distinct values */ + @Override @Contract(pure = true) public Integer countUniq() throws Exception { return this.uniq().size(); @@ -1358,6 +1383,7 @@ public Integer countUniq() throws Exception { * @return the average of the current data * @throws UnsupportedOperationException if the data cannot be cast to numbers */ + @Override @Contract(pure = true) public Double average() throws Exception { return this.makeNumeric().average(n -> n); @@ -1370,6 +1396,7 @@ public Double average() throws Exception { * @param the numeric type that is returned by the `mapper` function * @return the average of the numbers returned by the `mapper` function */ + @Override @Contract(pure = true) public Double average(SerializableFunction mapper) throws Exception { return this.weightedAverage(data -> new WeightedValue(mapper.apply(data), 1.0)); @@ -1385,6 +1412,7 @@ public Double average(SerializableFunction mapper) thro * return the value and weight combination of numbers to average * @return the weighted average of the numbers returned by the `mapper` function */ + @Override @Contract(pure = true) public Double weightedAverage(SerializableFunction mapper) throws Exception { MutableWeightedDouble runningSums = @@ -1392,7 +1420,7 @@ public Double weightedAverage(SerializableFunction mapper) thr MutableWeightedDouble::identitySupplier, MutableWeightedDouble::accumulator, MutableWeightedDouble::combiner - ); + ); return runningSums.num / runningSums.weight; } @@ -1406,6 +1434,7 @@ public Double weightedAverage(SerializableFunction mapper) thr * * @return estimated median */ + @Override @Contract(pure = true) public Double estimatedMedian() throws Exception { return this.estimatedQuantile(0.5); @@ -1422,6 +1451,7 @@ public Double estimatedMedian() throws Exception { * @param mapper function that returns the numbers to generate the mean for * @return estimated median */ + @Override @Contract(pure = true) public Double estimatedMedian(SerializableFunction mapper) throws Exception { @@ -1439,6 +1469,7 @@ public Double estimatedMedian(SerializableFunction mapp * @param q the desired quantile to calculate (as a number between 0 and 1) * @return estimated quantile boundary */ + @Override @Contract(pure = true) public Double estimatedQuantile(double q) throws Exception { return this.makeNumeric().estimatedQuantile(n -> n, q); @@ -1457,6 +1488,7 @@ public Double estimatedQuantile(double q) throws Exception { * @param q the desired quantile to calculate (as a number between 0 and 1) * @return estimated quantile boundary */ + @Override @Contract(pure = true) public Double estimatedQuantile(SerializableFunction mapper, double q) throws Exception { @@ -1474,6 +1506,7 @@ public Double estimatedQuantile(SerializableFunction ma * @param q the desired quantiles to calculate (as a collection of numbers between 0 and 1) * @return estimated quantile boundaries */ + @Override @Contract(pure = true) public List estimatedQuantiles(Iterable q) throws Exception { return this.makeNumeric().estimatedQuantiles(n -> n, q); @@ -1491,11 +1524,12 @@ public List estimatedQuantiles(Iterable q) throws Exception { * @param q the desired quantiles to calculate (as a collection of numbers between 0 and 1) * @return estimated quantile boundaries */ + @Override @Contract(pure = true) public List estimatedQuantiles( SerializableFunction mapper, Iterable q - ) throws Exception { + ) throws Exception { return Streams.stream(q) .mapToDouble(Double::doubleValue) .map(this.estimatedQuantiles(mapper)) @@ -1513,6 +1547,7 @@ public List estimatedQuantiles( * * @return a function that computes estimated quantile boundaries */ + @Override @Contract(pure = true) public DoubleUnaryOperator estimatedQuantiles() throws Exception { return this.makeNumeric().estimatedQuantiles(n -> n); @@ -1530,10 +1565,11 @@ public DoubleUnaryOperator estimatedQuantiles() throws Exception { * @param mapper function that returns the numbers to generate the quantiles for * @return a function that computes estimated quantile boundaries */ + @Override @Contract(pure = true) public DoubleUnaryOperator estimatedQuantiles( SerializableFunction mapper - ) throws Exception { + ) throws Exception { TDigest digest = this.digest(mapper); return digest::quantile; } @@ -1548,7 +1584,7 @@ private TDigest digest(SerializableFunction mapper) thr TdigestReducer::identitySupplier, TdigestReducer::accumulator, TdigestReducer::combiner - ); + ); } // ----------------------------------------------------------------------------------------------- @@ -1582,13 +1618,14 @@ public void forEach(SerializableConsumer action) throws Exception { * * @return a list with all results returned by the `mapper` function */ + @Override @Contract(pure = true) public List collect() throws Exception { return this.reduce( MapReducer::collectIdentitySupplier, MapReducer::collectAccumulator, MapReducer::collectCombiner - ); + ); } /** @@ -1600,6 +1637,7 @@ public List collect() throws Exception { * * @return a stream with all results returned by the `mapper` function */ + @Override @Contract(pure = true) public Stream stream() throws Exception { try { @@ -1607,7 +1645,7 @@ public Stream stream() throws Exception { } catch (UnsupportedOperationException e) { LOG.info("stream not directly supported by chosen backend, falling back to " + ".collect().stream()" - ); + ); return this.collect().stream(); } } @@ -1623,13 +1661,13 @@ private Stream streamInternal() throws Exception { @SuppressWarnings("Convert2MethodRef") // having just `mapper::apply` here is problematic, see https://github.com/GIScience/oshdb/pull/37 final SerializableFunction contributionMapper = - data -> mapper.apply(data); + data -> mapper.apply(data); return this.mapStreamCellsOSMContribution(contributionMapper); } else if (this.forClass.equals(OSMEntitySnapshot.class)) { @SuppressWarnings("Convert2MethodRef") // having just `mapper::apply` here is problematic, see https://github.com/GIScience/oshdb/pull/37 final SerializableFunction snapshotMapper = - data -> mapper.apply(data); + data -> mapper.apply(data); return this.mapStreamCellsOSMEntitySnapshot(snapshotMapper); } else { throw new UnsupportedOperationException( @@ -1642,8 +1680,8 @@ private Stream streamInternal() throws Exception { (List inputList) -> { List outputList = new LinkedList<>(); inputList.stream() - .map((SerializableFunction>) flatMapper::apply) - .forEach(data -> Iterables.addAll(outputList, data)); + .map((SerializableFunction>) flatMapper::apply) + .forEach(data -> Iterables.addAll(outputList, data)); return outputList; }); } else if (this.forClass.equals(OSMEntitySnapshot.class)) { @@ -1651,8 +1689,8 @@ private Stream streamInternal() throws Exception { (List inputList) -> { List outputList = new LinkedList<>(); inputList.stream() - .map((SerializableFunction>) flatMapper::apply) - .forEach(data -> Iterables.addAll(outputList, data)); + .map((SerializableFunction>) flatMapper::apply) + .forEach(data -> Iterables.addAll(outputList, data)); return outputList; }); } else { @@ -1674,13 +1712,13 @@ private Stream streamInternal() throws Exception { @SuppressWarnings("Convert2MethodRef") // having just `mapper::apply` here is problematic, see https://github.com/GIScience/oshdb/pull/37 final SerializableFunction, Iterable> contributionFlatMapper = - data -> flatMapper.apply(data); + data -> flatMapper.apply(data); return this.flatMapStreamCellsOSMContributionGroupedById(contributionFlatMapper); } else if (this.forClass.equals(OSMEntitySnapshot.class)) { @SuppressWarnings("Convert2MethodRef") // having just `mapper::apply` here is problematic, see https://github.com/GIScience/oshdb/pull/37 final SerializableFunction, Iterable> snapshotFlatMapper = - data -> flatMapper.apply(data); + data -> flatMapper.apply(data); return this.flatMapStreamCellsOSMEntitySnapshotGroupedById(snapshotFlatMapper); } else { throw new UnsupportedOperationException( @@ -1699,19 +1737,19 @@ private Stream streamInternal() throws Exception { protected abstract Stream mapStreamCellsOSMContribution( SerializableFunction mapper - ) throws Exception; + ) throws Exception; protected abstract Stream flatMapStreamCellsOSMContributionGroupedById( SerializableFunction, Iterable> mapper - ) throws Exception; + ) throws Exception; protected abstract Stream mapStreamCellsOSMEntitySnapshot( SerializableFunction mapper - ) throws Exception; + ) throws Exception; protected abstract Stream flatMapStreamCellsOSMEntitySnapshotGroupedById( SerializableFunction, Iterable> mapper - ) throws Exception; + ) throws Exception; // ----------------------------------------------------------------------------------------------- // Generic map-reduce functions (internal). @@ -1761,7 +1799,7 @@ protected abstract S mapReduceCellsOSMContribution( SerializableSupplier identitySupplier, SerializableBiFunction accumulator, SerializableBinaryOperator combiner - ) throws Exception; + ) throws Exception; /** * Generic "flat" version of the map-reduce used by the `OSMContributionView`, with by-osm-id @@ -1816,7 +1854,7 @@ protected abstract S flatMapReduceCellsOSMContributionGroupedById( SerializableSupplier identitySupplier, SerializableBiFunction accumulator, SerializableBinaryOperator combiner - ) throws Exception; + ) throws Exception; /** * Generic map-reduce used by the `OSMEntitySnapshotView`. @@ -1861,7 +1899,7 @@ protected abstract S mapReduceCellsOSMEntitySnapshot( SerializableSupplier identitySupplier, SerializableBiFunction accumulator, SerializableBinaryOperator combiner - ) throws Exception; + ) throws Exception; /** * Generic "flat" version of the map-reduce used by the `OSMEntitySnapshotView`, with by-osm-id @@ -1916,7 +1954,7 @@ protected abstract S flatMapReduceCellsOSMEntitySnapshotGroupedById( SerializableSupplier identitySupplier, SerializableBiFunction accumulator, SerializableBinaryOperator combiner - ) throws Exception; + ) throws Exception; // ----------------------------------------------------------------------------------------------- // Some helper methods for internal use in the mapReduce functions @@ -1945,31 +1983,31 @@ protected TagTranslator getTagTranslator() { } // Helper that chains multiple oshEntity filters together - protected CellIterator.OSHEntityFilter getPreFilter() { + protected OSHEntityFilter getPreFilter() { return this.preFilters.isEmpty() ? oshEntity -> true - : oshEntity -> { - for (SerializablePredicate filter : this.preFilters) { - if (!filter.test(oshEntity)) { - return false; - } - } - return true; - }; + : oshEntity -> { + for (SerializablePredicate filter : this.preFilters) { + if (!filter.test(oshEntity)) { + return false; + } + } + return true; + }; } // Helper that chains multiple osmEntity filters together - protected CellIterator.OSMEntityFilter getFilter() { + protected OSMEntityFilter getFilter() { return this.filters.isEmpty() ? osmEntity -> true - : osmEntity -> { - for (SerializablePredicate filter : this.filters) { - if (!filter.test(osmEntity)) { - return false; - } - } - return true; - }; + : osmEntity -> { + for (SerializablePredicate filter : this.filters) { + if (!filter.test(osmEntity)) { + return false; + } + } + return true; + }; } // get all cell ids covered by the current area of interest's bounding box @@ -2026,8 +2064,8 @@ private SerializableFunction> getFlatMapper() { List newResults = new LinkedList<>(); if (mapper.isFlatMapper()) { results.forEach(result -> - Iterables.addAll(newResults, (Iterable) mapper.apply(result)) - ); + Iterables.addAll(newResults, (Iterable) mapper.apply(result)) + ); } else { results.forEach(result -> newResults.add(mapper.apply(result))); } @@ -2077,7 +2115,7 @@ static Number checkAndMapToNumeric(Object x) { /** * Checks if the current request should be run on a cancelable backend. * Produces a log message if not. - */ + */ private void checkTimeout() { if (this.oshdb.timeoutInMilliseconds().isPresent()) { if (!this.isCancelable()) { @@ -2101,7 +2139,7 @@ static List collectAccumulator(List acc, T cur) { @Contract(pure = true) static List collectCombiner(List a, List b) { - ArrayList combinedLists = new ArrayList(a.size() + b.size()); + ArrayList combinedLists = new ArrayList<>(a.size() + b.size()); combinedLists.addAll(a); combinedLists.addAll(b); return combinedLists; diff --git a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/MapReducerAggregations.java b/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/MapReducerAggregations.java index f517452b7..afa708c42 100644 --- a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/MapReducerAggregations.java +++ b/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/MapReducerAggregations.java @@ -1,10 +1,10 @@ package org.heigit.ohsome.oshdb.api.mapreducer; import org.heigit.ohsome.oshdb.api.generic.WeightedValue; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableBiFunction; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableBinaryOperator; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableFunction; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableSupplier; +import org.heigit.ohsome.oshdb.util.function.SerializableBiFunction; +import org.heigit.ohsome.oshdb.util.function.SerializableBinaryOperator; +import org.heigit.ohsome.oshdb.util.function.SerializableFunction; +import org.heigit.ohsome.oshdb.util.function.SerializableSupplier; /** * Interface defining the common aggregation methods found on MapReducer or MapAggregator objects. diff --git a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/MapReducerSettings.java b/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/MapReducerSettings.java index 5308aac33..9fd26bee5 100644 --- a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/MapReducerSettings.java +++ b/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/MapReducerSettings.java @@ -4,12 +4,11 @@ import java.util.EnumSet; import java.util.Set; import java.util.regex.Pattern; -import org.heigit.ohsome.oshdb.api.generic.function.SerializablePredicate; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.filter.Filter; import org.heigit.ohsome.oshdb.filter.FilterExpression; -import org.heigit.ohsome.oshdb.osm.OSMEntity; import org.heigit.ohsome.oshdb.osm.OSMType; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; +import org.heigit.ohsome.oshdb.util.function.OSMEntityFilter; import org.heigit.ohsome.oshdb.util.tagtranslator.OSMTag; import org.heigit.ohsome.oshdb.util.tagtranslator.OSMTagInterface; import org.heigit.ohsome.oshdb.util.tagtranslator.OSMTagKey; @@ -103,7 +102,7 @@ default M osmType(OSMType type1, OSMType... otherTypes) { * instead */ @Deprecated - M osmEntityFilter(SerializablePredicate f); + M osmEntityFilter(OSMEntityFilter f); /** * Adds an osm tag filter: The analysis will be restricted to osm entities that have @@ -192,7 +191,7 @@ default M osmTypes(OSMType type1, OSMType... otherTypes) { * @deprecated replaced by {@link #osmEntityFilter} */ @Deprecated - default M where(SerializablePredicate f) { + default M where(OSMEntityFilter f) { return this.osmEntityFilter(f); } diff --git a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/Mappable.java b/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/Mappable.java index 668f15e00..a6d4befb2 100644 --- a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/Mappable.java +++ b/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/Mappable.java @@ -1,7 +1,7 @@ package org.heigit.ohsome.oshdb.api.mapreducer; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableFunction; -import org.heigit.ohsome.oshdb.api.generic.function.SerializablePredicate; +import org.heigit.ohsome.oshdb.util.function.SerializableFunction; +import org.heigit.ohsome.oshdb.util.function.SerializablePredicate; import org.jetbrains.annotations.Contract; public interface Mappable { diff --git a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/backend/Kernels.java b/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/backend/Kernels.java index 2fa15352e..dc2bce770 100644 --- a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/backend/Kernels.java +++ b/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/backend/Kernels.java @@ -8,13 +8,13 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Stream; import javax.annotation.Nonnull; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableBiFunction; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableFunction; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableSupplier; import org.heigit.ohsome.oshdb.api.object.OSMContribution; import org.heigit.ohsome.oshdb.api.object.OSMEntitySnapshot; import org.heigit.ohsome.oshdb.grid.GridOSHEntity; import org.heigit.ohsome.oshdb.util.celliterator.CellIterator; +import org.heigit.ohsome.oshdb.util.function.SerializableBiFunction; +import org.heigit.ohsome.oshdb.util.function.SerializableFunction; +import org.heigit.ohsome.oshdb.util.function.SerializableSupplier; class Kernels implements Serializable { interface CellProcessor extends SerializableBiFunction {} diff --git a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/backend/MapReducerIgniteAffinityCall.java b/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/backend/MapReducerIgniteAffinityCall.java index 97ede9e62..785f5f515 100644 --- a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/backend/MapReducerIgniteAffinityCall.java +++ b/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/backend/MapReducerIgniteAffinityCall.java @@ -31,10 +31,6 @@ import org.apache.ignite.resources.IgniteInstanceResource; import org.heigit.ohsome.oshdb.api.db.OSHDBDatabase; import org.heigit.ohsome.oshdb.api.db.OSHDBIgnite; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableBiFunction; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableBinaryOperator; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableFunction; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableSupplier; import org.heigit.ohsome.oshdb.api.mapreducer.MapReducer; import org.heigit.ohsome.oshdb.api.mapreducer.backend.Kernels.CancelableProcessStatus; import org.heigit.ohsome.oshdb.api.mapreducer.backend.Kernels.CellProcessor; @@ -48,6 +44,10 @@ import org.heigit.ohsome.oshdb.util.TableNames; import org.heigit.ohsome.oshdb.util.celliterator.CellIterator; import org.heigit.ohsome.oshdb.util.exceptions.OSHDBTimeoutException; +import org.heigit.ohsome.oshdb.util.function.SerializableBiFunction; +import org.heigit.ohsome.oshdb.util.function.SerializableBinaryOperator; +import org.heigit.ohsome.oshdb.util.function.SerializableFunction; +import org.heigit.ohsome.oshdb.util.function.SerializableSupplier; import org.jetbrains.annotations.NotNull; import org.json.simple.parser.ParseException; diff --git a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/backend/MapReducerIgniteLocalPeek.java b/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/backend/MapReducerIgniteLocalPeek.java index 0db8b513c..e61ad1643 100644 --- a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/backend/MapReducerIgniteLocalPeek.java +++ b/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/backend/MapReducerIgniteLocalPeek.java @@ -19,12 +19,10 @@ import org.apache.ignite.compute.ComputeTaskFuture; import org.apache.ignite.compute.ComputeTaskTimeoutException; import org.apache.ignite.lang.IgniteFutureTimeoutException; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; import org.heigit.ohsome.oshdb.api.db.OSHDBDatabase; import org.heigit.ohsome.oshdb.api.db.OSHDBIgnite; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableBiFunction; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableBinaryOperator; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableFunction; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableSupplier; import org.heigit.ohsome.oshdb.api.mapreducer.MapReducer; import org.heigit.ohsome.oshdb.api.mapreducer.backend.Kernels.CellProcessor; import org.heigit.ohsome.oshdb.api.mapreducer.backend.OSHDBIgniteMapReduceComputeTask.CancelableIgniteMapReduceJob; @@ -34,11 +32,15 @@ import org.heigit.ohsome.oshdb.grid.GridOSHEntity; import org.heigit.ohsome.oshdb.index.XYGridTree.CellIdRange; import org.heigit.ohsome.oshdb.util.CellId; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.heigit.ohsome.oshdb.util.TableNames; import org.heigit.ohsome.oshdb.util.celliterator.CellIterator; import org.heigit.ohsome.oshdb.util.exceptions.OSHDBTimeoutException; +import org.heigit.ohsome.oshdb.util.function.OSHEntityFilter; +import org.heigit.ohsome.oshdb.util.function.OSMEntityFilter; +import org.heigit.ohsome.oshdb.util.function.SerializableBiFunction; +import org.heigit.ohsome.oshdb.util.function.SerializableBinaryOperator; +import org.heigit.ohsome.oshdb.util.function.SerializableFunction; +import org.heigit.ohsome.oshdb.util.function.SerializableSupplier; import org.heigit.ohsome.oshdb.util.taginterpreter.TagInterpreter; import org.jetbrains.annotations.NotNull; import org.locationtech.jts.geom.Geometry; @@ -69,7 +71,7 @@ private MapReducerIgniteLocalPeek(MapReducerIgniteLocalPeek obj) { @NotNull @Override protected MapReducer copy() { - return new MapReducerIgniteLocalPeek(this); + return new MapReducerIgniteLocalPeek<>(this); } @Override @@ -181,7 +183,7 @@ private abstract static class MapReduceCellsOnIgniteCacheComputeJob MapReduceCellsOnIgniteCacheComputeJob(TagInterpreter tagInterpreter, List cacheNames, Iterable cellIdRanges, SortedSet tstamps, OSHDBBoundingBox bbox, P poly, - CellIterator.OSHEntityFilter preFilter, CellIterator.OSMEntityFilter filter, + OSHEntityFilter preFilter, OSMEntityFilter filter, SerializableFunction mapper, SerializableSupplier identitySupplier, SerializableBiFunction accumulator, SerializableBinaryOperator combiner) { @@ -286,7 +288,7 @@ private static class MapReduceCellsOSMContributionOnIgniteCacheComputeJob MapReduceCellsOSMContributionOnIgniteCacheComputeJob(TagInterpreter tagInterpreter, List cacheNames, Iterable cellIdRanges, SortedSet tstamps, OSHDBBoundingBox bbox, P poly, - CellIterator.OSHEntityFilter preFilter, CellIterator.OSMEntityFilter filter, + OSHEntityFilter preFilter, OSMEntityFilter filter, SerializableFunction mapper, SerializableSupplier identitySupplier, SerializableBiFunction accumulator, SerializableBinaryOperator combiner) { super(tagInterpreter, cacheNames, cellIdRanges, tstamps, bbox, poly, preFilter, filter, @@ -310,7 +312,7 @@ private static class FlatMapReduceCellsOSMContributionOnIgniteCacheComputeJob FlatMapReduceCellsOSMContributionOnIgniteCacheComputeJob(TagInterpreter tagInterpreter, List cacheNames, Iterable cellIdRanges, SortedSet tstamps, OSHDBBoundingBox bbox, P poly, - CellIterator.OSHEntityFilter preFilter, CellIterator.OSMEntityFilter filter, + OSHEntityFilter preFilter, OSMEntityFilter filter, SerializableFunction, Iterable> mapper, SerializableSupplier identitySupplier, SerializableBiFunction accumulator, SerializableBinaryOperator combiner) { @@ -335,7 +337,7 @@ private static class MapReduceCellsOSMEntitySnapshotOnIgniteCacheComputeJob MapReduceCellsOSMEntitySnapshotOnIgniteCacheComputeJob(TagInterpreter tagInterpreter, List cacheNames, Iterable cellIdRanges, SortedSet tstamps, OSHDBBoundingBox bbox, P poly, - CellIterator.OSHEntityFilter preFilter, CellIterator.OSMEntityFilter filter, + OSHEntityFilter preFilter, OSMEntityFilter filter, SerializableFunction mapper, SerializableSupplier identitySupplier, SerializableBiFunction accumulator, SerializableBinaryOperator combiner) { super(tagInterpreter, cacheNames, cellIdRanges, tstamps, bbox, poly, preFilter, filter, @@ -359,7 +361,7 @@ private static class FlatMapReduceCellsOSMEntitySnapshotOnIgniteCacheComputeJob FlatMapReduceCellsOSMEntitySnapshotOnIgniteCacheComputeJob(TagInterpreter tagInterpreter, List cacheNames, Iterable cellIdRanges, SortedSet tstamps, OSHDBBoundingBox bbox, P poly, - CellIterator.OSHEntityFilter preFilter, CellIterator.OSMEntityFilter filter, + OSHEntityFilter preFilter, OSMEntityFilter filter, SerializableFunction, Iterable> mapper, SerializableSupplier identitySupplier, SerializableBiFunction accumulator, SerializableBinaryOperator combiner) { @@ -391,7 +393,7 @@ private static S mapReduceOnIgniteC IgniteCompute compute = ignite.compute(); ComputeTaskFuture asyncResult = compute.executeAsync( - new OSHDBIgniteMapReduceComputeTask( + new OSHDBIgniteMapReduceComputeTask<>( computeJob, identitySupplier, combiner, diff --git a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/backend/MapReducerIgniteScanQuery.java b/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/backend/MapReducerIgniteScanQuery.java index a6fb6f17b..2e03bba1b 100644 --- a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/backend/MapReducerIgniteScanQuery.java +++ b/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/backend/MapReducerIgniteScanQuery.java @@ -26,12 +26,10 @@ import org.apache.ignite.compute.ComputeTaskFuture; import org.apache.ignite.lang.IgniteFutureTimeoutException; import org.apache.ignite.lang.IgniteRunnable; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; import org.heigit.ohsome.oshdb.api.db.OSHDBDatabase; import org.heigit.ohsome.oshdb.api.db.OSHDBIgnite; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableBiFunction; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableBinaryOperator; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableFunction; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableSupplier; import org.heigit.ohsome.oshdb.api.mapreducer.MapReducer; import org.heigit.ohsome.oshdb.api.mapreducer.backend.Kernels.CellProcessor; import org.heigit.ohsome.oshdb.api.mapreducer.backend.OSHDBIgniteMapReduceComputeTask.CancelableIgniteMapReduceJob; @@ -42,11 +40,15 @@ import org.heigit.ohsome.oshdb.index.XYGridTree.CellIdRange; import org.heigit.ohsome.oshdb.osm.OSMType; import org.heigit.ohsome.oshdb.util.CellId; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.heigit.ohsome.oshdb.util.TableNames; import org.heigit.ohsome.oshdb.util.celliterator.CellIterator; import org.heigit.ohsome.oshdb.util.exceptions.OSHDBTimeoutException; +import org.heigit.ohsome.oshdb.util.function.OSHEntityFilter; +import org.heigit.ohsome.oshdb.util.function.OSMEntityFilter; +import org.heigit.ohsome.oshdb.util.function.SerializableBiFunction; +import org.heigit.ohsome.oshdb.util.function.SerializableBinaryOperator; +import org.heigit.ohsome.oshdb.util.function.SerializableFunction; +import org.heigit.ohsome.oshdb.util.function.SerializableSupplier; import org.heigit.ohsome.oshdb.util.taginterpreter.TagInterpreter; import org.jetbrains.annotations.NotNull; import org.locationtech.jts.geom.Geometry; @@ -97,7 +99,7 @@ static boolean cellKeyInRange( @NotNull @Override protected MapReducer copy() { - return new MapReducerIgniteScanQuery(this); + return new MapReducerIgniteScanQuery<>(this); } @Override @@ -299,7 +301,7 @@ public boolean isActive() { MapReduceCellsOnIgniteCacheComputeJob(TagInterpreter tagInterpreter, String cacheName, Map> cellIdRangesByLevel, SortedSet tstamps, OSHDBBoundingBox bbox, P poly, - CellIterator.OSHEntityFilter preFilter, CellIterator.OSMEntityFilter filter, + OSHEntityFilter preFilter, OSMEntityFilter filter, SerializableFunction mapper, SerializableSupplier identitySupplier, SerializableBiFunction accumulator, SerializableBinaryOperator combiner) { this.cacheName = cacheName; @@ -368,7 +370,7 @@ private static class MapReduceCellsOSMContributionOnIgniteCacheComputeJob MapReduceCellsOSMContributionOnIgniteCacheComputeJob(TagInterpreter tagInterpreter, String cacheName, Map> cellIdRangesByLevel, SortedSet tstamps, OSHDBBoundingBox bbox, P poly, - CellIterator.OSHEntityFilter preFilter, CellIterator.OSMEntityFilter filter, + OSHEntityFilter preFilter, OSMEntityFilter filter, SerializableFunction mapper, SerializableSupplier identitySupplier, SerializableBiFunction accumulator, SerializableBinaryOperator combiner) { @@ -393,7 +395,7 @@ private static class FlatMapReduceCellsOSMContributionOnIgniteCacheComputeJob FlatMapReduceCellsOSMContributionOnIgniteCacheComputeJob(TagInterpreter tagInterpreter, String cacheName, Map> cellIdRangesByLevel, SortedSet tstamps, OSHDBBoundingBox bbox, P poly, - CellIterator.OSHEntityFilter preFilter, CellIterator.OSMEntityFilter filter, + OSHEntityFilter preFilter, OSMEntityFilter filter, SerializableFunction, Iterable> mapper, SerializableSupplier identitySupplier, SerializableBiFunction accumulator, SerializableBinaryOperator combiner) { @@ -418,7 +420,7 @@ private static class MapReduceCellsOSMEntitySnapshotOnIgniteCacheComputeJob MapReduceCellsOSMEntitySnapshotOnIgniteCacheComputeJob(TagInterpreter tagInterpreter, String cacheName, Map> cellIdRangesByLevel, SortedSet tstamps, OSHDBBoundingBox bbox, P poly, - CellIterator.OSHEntityFilter preFilter, CellIterator.OSMEntityFilter filter, + OSHEntityFilter preFilter, OSMEntityFilter filter, SerializableFunction mapper, SerializableSupplier identitySupplier, SerializableBiFunction accumulator, SerializableBinaryOperator combiner) { @@ -443,7 +445,7 @@ private static class FlatMapReduceCellsOSMEntitySnapshotOnIgniteCacheComputeJob FlatMapReduceCellsOSMEntitySnapshotOnIgniteCacheComputeJob(TagInterpreter tagInterpreter, String cacheName, Map> cellIdRangesByLevel, SortedSet tstamps, OSHDBBoundingBox bbox, P poly, - CellIterator.OSHEntityFilter preFilter, CellIterator.OSMEntityFilter filter, + OSHEntityFilter preFilter, OSMEntityFilter filter, SerializableFunction, Iterable> mapper, SerializableSupplier identitySupplier, SerializableBiFunction accumulator, SerializableBinaryOperator combiner) { @@ -492,7 +494,7 @@ private static S mapReduceOnIgniteC computeJob.setNodesToPart(nodesToPart); IgniteRunnable onClose = oshdb.onClose().orElse(() -> { }); ComputeTaskFuture result = compute.executeAsync( - new OSHDBIgniteMapReduceComputeTask( + new OSHDBIgniteMapReduceComputeTask<>( computeJob, identitySupplier, combiner, diff --git a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/backend/MapReducerJdbcMultithread.java b/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/backend/MapReducerJdbcMultithread.java index 393314cee..312fac0de 100644 --- a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/backend/MapReducerJdbcMultithread.java +++ b/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/backend/MapReducerJdbcMultithread.java @@ -6,10 +6,6 @@ import java.util.List; import java.util.stream.Stream; import org.heigit.ohsome.oshdb.api.db.OSHDBDatabase; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableBiFunction; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableBinaryOperator; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableFunction; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableSupplier; import org.heigit.ohsome.oshdb.api.mapreducer.MapReducer; import org.heigit.ohsome.oshdb.api.mapreducer.backend.Kernels.CellProcessor; import org.heigit.ohsome.oshdb.api.object.OSHDBMapReducible; @@ -17,6 +13,10 @@ import org.heigit.ohsome.oshdb.api.object.OSMEntitySnapshot; import org.heigit.ohsome.oshdb.index.XYGridTree.CellIdRange; import org.heigit.ohsome.oshdb.util.celliterator.CellIterator; +import org.heigit.ohsome.oshdb.util.function.SerializableBiFunction; +import org.heigit.ohsome.oshdb.util.function.SerializableBinaryOperator; +import org.heigit.ohsome.oshdb.util.function.SerializableFunction; +import org.heigit.ohsome.oshdb.util.function.SerializableSupplier; import org.jetbrains.annotations.NotNull; import org.json.simple.parser.ParseException; diff --git a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/backend/MapReducerJdbcSinglethread.java b/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/backend/MapReducerJdbcSinglethread.java index 960b0b0fd..883960549 100644 --- a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/backend/MapReducerJdbcSinglethread.java +++ b/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/backend/MapReducerJdbcSinglethread.java @@ -7,10 +7,6 @@ import java.util.List; import java.util.stream.Stream; import org.heigit.ohsome.oshdb.api.db.OSHDBDatabase; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableBiFunction; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableBinaryOperator; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableFunction; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableSupplier; import org.heigit.ohsome.oshdb.api.mapreducer.MapReducer; import org.heigit.ohsome.oshdb.api.mapreducer.backend.Kernels.CellProcessor; import org.heigit.ohsome.oshdb.api.object.OSHDBMapReducible; @@ -19,6 +15,10 @@ import org.heigit.ohsome.oshdb.grid.GridOSHEntity; import org.heigit.ohsome.oshdb.index.XYGridTree.CellIdRange; import org.heigit.ohsome.oshdb.util.celliterator.CellIterator; +import org.heigit.ohsome.oshdb.util.function.SerializableBiFunction; +import org.heigit.ohsome.oshdb.util.function.SerializableBinaryOperator; +import org.heigit.ohsome.oshdb.util.function.SerializableFunction; +import org.heigit.ohsome.oshdb.util.function.SerializableSupplier; import org.jetbrains.annotations.NotNull; import org.json.simple.parser.ParseException; diff --git a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/backend/OSHDBIgniteMapReduceComputeTask.java b/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/backend/OSHDBIgniteMapReduceComputeTask.java index d05888c57..a7d91871f 100644 --- a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/backend/OSHDBIgniteMapReduceComputeTask.java +++ b/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/mapreducer/backend/OSHDBIgniteMapReduceComputeTask.java @@ -14,9 +14,9 @@ import org.apache.ignite.compute.ComputeTaskAdapter; import org.apache.ignite.lang.IgniteRunnable; import org.apache.ignite.resources.IgniteInstanceResource; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableBinaryOperator; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableSupplier; import org.heigit.ohsome.oshdb.api.mapreducer.backend.Kernels.CancelableProcessStatus; +import org.heigit.ohsome.oshdb.util.function.SerializableBinaryOperator; +import org.heigit.ohsome.oshdb.util.function.SerializableSupplier; /** * A cancelable ignite broadcast task. diff --git a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/object/OSMContribution.java b/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/object/OSMContribution.java index 6a70c6733..5f87eb72c 100644 --- a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/object/OSMContribution.java +++ b/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/object/OSMContribution.java @@ -4,11 +4,11 @@ import java.util.EnumSet; import java.util.Objects; import javax.annotation.Nonnull; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; import org.heigit.ohsome.oshdb.osh.OSHEntity; import org.heigit.ohsome.oshdb.osm.OSMEntity; import org.heigit.ohsome.oshdb.osm.OSMRelation; import org.heigit.ohsome.oshdb.osm.OSMWay; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.heigit.ohsome.oshdb.util.celliterator.CellIterator.IterateAllEntry; import org.heigit.ohsome.oshdb.util.celliterator.ContributionType; import org.heigit.ohsome.oshdb.util.celliterator.LazyEvaluatedObject; @@ -230,7 +230,7 @@ public int getContributorUserId() { OSHDBTimestamp contributionTimestamp = this.getTimestamp(); // if the entity itself was modified at this exact timestamp, or we know from the contribution // type that the entity must also have been modified, we can just return the uid directly - if (contributionTimestamp.equals(entity.getTimestamp()) + if (contributionTimestamp.getEpochSecond() == entity.getEpochSecond() || this.getEntityBefore() == null || this.getEntityBefore().getVersion() != this.getEntityAfter().getVersion() ) { @@ -241,7 +241,7 @@ public int getContributorUserId() { if (entity instanceof OSMWay) { userId = ((OSMWay) entity).getRefEntities(contributionTimestamp) .filter(Objects::nonNull) - .filter(n -> n.getTimestamp().equals(contributionTimestamp)) + .filter(n -> n.getEpochSecond() == contributionTimestamp.getEpochSecond()) .findFirst() .map(OSMEntity::getUserId) // "rare" race condition, caused by not properly ordered timestamps (t_x > t_{x+1}) @@ -250,7 +250,7 @@ public int getContributorUserId() { } else if (entity instanceof OSMRelation) { userId = ((OSMRelation) entity).getMemberEntities(contributionTimestamp) .filter(Objects::nonNull) - .filter(e -> e.getTimestamp().equals(contributionTimestamp)) + .filter(e -> e.getEpochSecond() == contributionTimestamp.getEpochSecond()) .findFirst() .map(OSMEntity::getUserId) .orElseGet(() -> @@ -261,7 +261,7 @@ public int getContributorUserId() { .map(e -> (OSMWay) e) .flatMap(w -> w.getRefEntities(contributionTimestamp)) .filter(Objects::nonNull) - .filter(n -> n.getTimestamp().equals(contributionTimestamp)) + .filter(n -> n.getEpochSecond() == contributionTimestamp.getEpochSecond()) .findFirst() .map(OSMEntity::getUserId) // possible "rare" race condition, caused by not properly ordered timestamps diff --git a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/object/OSMEntitySnapshot.java b/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/object/OSMEntitySnapshot.java index 52b1afbb8..7f78f8b9f 100644 --- a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/object/OSMEntitySnapshot.java +++ b/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/object/OSMEntitySnapshot.java @@ -2,9 +2,9 @@ import com.google.common.collect.ComparisonChain; import javax.annotation.Nonnull; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; import org.heigit.ohsome.oshdb.osh.OSHEntity; import org.heigit.ohsome.oshdb.osm.OSMEntity; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.heigit.ohsome.oshdb.util.celliterator.CellIterator.IterateByTimestampEntry; import org.heigit.ohsome.oshdb.util.celliterator.LazyEvaluatedObject; import org.locationtech.jts.geom.Geometry; diff --git a/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestCollect.java b/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestCollect.java index 9bc38779a..dd4712593 100644 --- a/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestCollect.java +++ b/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestCollect.java @@ -7,14 +7,14 @@ import java.util.List; import java.util.SortedMap; import java.util.stream.Collectors; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; import org.heigit.ohsome.oshdb.api.db.OSHDBDatabase; import org.heigit.ohsome.oshdb.api.db.OSHDBH2; import org.heigit.ohsome.oshdb.api.mapreducer.MapReducer; import org.heigit.ohsome.oshdb.api.mapreducer.OSMContributionView; import org.heigit.ohsome.oshdb.api.object.OSMContribution; import org.heigit.ohsome.oshdb.osm.OSMType; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.heigit.ohsome.oshdb.util.time.OSHDBTimestamps; import org.junit.Test; diff --git a/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestFlatMapAggregate.java b/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestFlatMapAggregate.java index 573bb8e3c..cebaeca0c 100644 --- a/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestFlatMapAggregate.java +++ b/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestFlatMapAggregate.java @@ -9,13 +9,14 @@ import java.util.Map.Entry; import java.util.Set; import java.util.SortedMap; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; +import org.heigit.ohsome.oshdb.OSHDBTag; import org.heigit.ohsome.oshdb.api.db.OSHDBDatabase; import org.heigit.ohsome.oshdb.api.db.OSHDBH2; import org.heigit.ohsome.oshdb.api.mapreducer.MapReducer; import org.heigit.ohsome.oshdb.api.mapreducer.OSMContributionView; import org.heigit.ohsome.oshdb.api.object.OSMContribution; import org.heigit.ohsome.oshdb.osm.OSMType; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.util.time.OSHDBTimestamps; import org.junit.Test; @@ -53,11 +54,10 @@ public void test() throws Exception { return new ArrayList<>(); } List>> ret = new ArrayList<>(); - int[] tags = contribution.getEntityAfter().getRawTags(); - for (int i = 0; i < tags.length; i += 2) { + for (OSHDBTag tag : contribution.getEntityAfter().getTags()) { ret.add(new SimpleImmutableEntry<>( contribution.getEntityAfter().getId(), - new SimpleImmutableEntry<>(tags[i], tags[i + 1]) + new SimpleImmutableEntry<>(tag.getKey(), tag.getValue()) )); } return ret; diff --git a/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestFlatMapAggregateGroupedByEntity.java b/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestFlatMapAggregateGroupedByEntity.java index ce2facdb1..42c09ce81 100644 --- a/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestFlatMapAggregateGroupedByEntity.java +++ b/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestFlatMapAggregateGroupedByEntity.java @@ -7,13 +7,13 @@ import java.util.List; import java.util.Map.Entry; import java.util.SortedMap; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.api.db.OSHDBDatabase; import org.heigit.ohsome.oshdb.api.db.OSHDBH2; import org.heigit.ohsome.oshdb.api.mapreducer.MapReducer; import org.heigit.ohsome.oshdb.api.mapreducer.OSMContributionView; import org.heigit.ohsome.oshdb.api.object.OSMContribution; import org.heigit.ohsome.oshdb.osm.OSMType; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.util.celliterator.ContributionType; import org.heigit.ohsome.oshdb.util.time.OSHDBTimestamps; import org.junit.Test; diff --git a/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestFlatMapReduce.java b/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestFlatMapReduce.java index 1851a86e8..7a050bb92 100644 --- a/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestFlatMapReduce.java +++ b/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestFlatMapReduce.java @@ -9,13 +9,14 @@ import java.util.Map.Entry; import java.util.Set; import java.util.TreeSet; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; +import org.heigit.ohsome.oshdb.OSHDBTag; import org.heigit.ohsome.oshdb.api.db.OSHDBDatabase; import org.heigit.ohsome.oshdb.api.db.OSHDBH2; import org.heigit.ohsome.oshdb.api.mapreducer.MapReducer; import org.heigit.ohsome.oshdb.api.mapreducer.OSMContributionView; import org.heigit.ohsome.oshdb.api.object.OSMContribution; import org.heigit.ohsome.oshdb.osm.OSMType; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.util.time.OSHDBTimestamps; import org.junit.Test; @@ -50,9 +51,8 @@ public void test() throws Exception { return new ArrayList<>(); } List> ret = new ArrayList<>(); - int[] tags = contribution.getEntityAfter().getRawTags(); - for (int i = 0; i < tags.length; i += 2) { - ret.add(new SimpleImmutableEntry<>(tags[i], tags[i + 1])); + for (OSHDBTag tag : contribution.getEntityAfter().getTags()) { + ret.add(new SimpleImmutableEntry<>(tag.getKey(), tag.getValue())); } return ret; }) diff --git a/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestFlatMapReduceGroupedByEntity.java b/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestFlatMapReduceGroupedByEntity.java index eeb331b07..a43f497ab 100644 --- a/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestFlatMapReduceGroupedByEntity.java +++ b/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestFlatMapReduceGroupedByEntity.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.List; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.api.db.OSHDBDatabase; import org.heigit.ohsome.oshdb.api.mapreducer.MapReducer; import org.heigit.ohsome.oshdb.api.mapreducer.OSMContributionView; @@ -11,7 +12,6 @@ import org.heigit.ohsome.oshdb.api.object.OSMContribution; import org.heigit.ohsome.oshdb.api.object.OSMEntitySnapshot; import org.heigit.ohsome.oshdb.osm.OSMType; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.util.celliterator.ContributionType; import org.heigit.ohsome.oshdb.util.time.OSHDBTimestamps; import org.junit.Test; diff --git a/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestForEach.java b/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestForEach.java index 1e93b6034..fd5266d1e 100644 --- a/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestForEach.java +++ b/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestForEach.java @@ -3,13 +3,13 @@ import static org.junit.Assert.assertEquals; import java.util.concurrent.ConcurrentHashMap; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.api.db.OSHDBDatabase; import org.heigit.ohsome.oshdb.api.db.OSHDBH2; import org.heigit.ohsome.oshdb.api.mapreducer.MapReducer; import org.heigit.ohsome.oshdb.api.mapreducer.OSMContributionView; import org.heigit.ohsome.oshdb.api.object.OSMContribution; import org.heigit.ohsome.oshdb.osm.OSMType; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.util.time.OSHDBTimestamps; import org.junit.Test; diff --git a/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestHelpersOSMContributionView.java b/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestHelpersOSMContributionView.java index 77b03ae29..78b77c313 100644 --- a/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestHelpersOSMContributionView.java +++ b/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestHelpersOSMContributionView.java @@ -6,6 +6,8 @@ import java.util.HashSet; import java.util.Set; import java.util.SortedMap; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; import org.heigit.ohsome.oshdb.api.db.OSHDBDatabase; import org.heigit.ohsome.oshdb.api.db.OSHDBH2; import org.heigit.ohsome.oshdb.api.generic.WeightedValue; @@ -13,8 +15,6 @@ import org.heigit.ohsome.oshdb.api.mapreducer.OSMContributionView; import org.heigit.ohsome.oshdb.api.object.OSMContribution; import org.heigit.ohsome.oshdb.osm.OSMType; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.heigit.ohsome.oshdb.util.celliterator.ContributionType; import org.heigit.ohsome.oshdb.util.time.OSHDBTimestamps; import org.junit.Test; diff --git a/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestHelpersOSMEntitySnapshotView.java b/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestHelpersOSMEntitySnapshotView.java index 88b43953b..6904b27ff 100644 --- a/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestHelpersOSMEntitySnapshotView.java +++ b/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestHelpersOSMEntitySnapshotView.java @@ -4,6 +4,8 @@ import java.util.Set; import java.util.SortedMap; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; import org.heigit.ohsome.oshdb.api.db.OSHDBDatabase; import org.heigit.ohsome.oshdb.api.db.OSHDBH2; import org.heigit.ohsome.oshdb.api.generic.WeightedValue; @@ -11,8 +13,6 @@ import org.heigit.ohsome.oshdb.api.mapreducer.OSMEntitySnapshotView; import org.heigit.ohsome.oshdb.api.object.OSMEntitySnapshot; import org.heigit.ohsome.oshdb.osm.OSMType; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.heigit.ohsome.oshdb.util.time.OSHDBTimestamps; import org.junit.Test; diff --git a/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestLambdaFilter.java b/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestLambdaFilter.java index ee14dbea5..a83f0ca1f 100644 --- a/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestLambdaFilter.java +++ b/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestLambdaFilter.java @@ -4,13 +4,13 @@ import java.util.Set; import java.util.SortedMap; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.api.db.OSHDBDatabase; import org.heigit.ohsome.oshdb.api.db.OSHDBH2; import org.heigit.ohsome.oshdb.api.mapreducer.MapReducer; import org.heigit.ohsome.oshdb.api.mapreducer.OSMContributionView; import org.heigit.ohsome.oshdb.api.object.OSMContribution; import org.heigit.ohsome.oshdb.osm.OSMType; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.util.celliterator.ContributionType; import org.heigit.ohsome.oshdb.util.time.OSHDBTimestamps; import org.junit.Test; diff --git a/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestMapAggregateByGeometry.java b/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestMapAggregateByGeometry.java index d6d15b04c..2e1fddecd 100644 --- a/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestMapAggregateByGeometry.java +++ b/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestMapAggregateByGeometry.java @@ -9,6 +9,8 @@ import java.util.SortedMap; import java.util.TreeMap; import java.util.stream.Collectors; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; import org.heigit.ohsome.oshdb.api.db.OSHDBDatabase; import org.heigit.ohsome.oshdb.api.db.OSHDBH2; import org.heigit.ohsome.oshdb.api.generic.OSHDBCombinedIndex; @@ -18,8 +20,6 @@ import org.heigit.ohsome.oshdb.api.object.OSMContribution; import org.heigit.ohsome.oshdb.api.object.OSMEntitySnapshot; import org.heigit.ohsome.oshdb.osm.OSMType; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.heigit.ohsome.oshdb.util.geometry.Geo; import org.heigit.ohsome.oshdb.util.geometry.OSHDBGeometryBuilder; import org.heigit.ohsome.oshdb.util.time.OSHDBTimestamps; diff --git a/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestMapAggregateByIndex.java b/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestMapAggregateByIndex.java index 3af79ef7e..bced580ba 100644 --- a/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestMapAggregateByIndex.java +++ b/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestMapAggregateByIndex.java @@ -6,6 +6,7 @@ import java.util.HashSet; import java.util.Set; import java.util.SortedMap; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.api.db.OSHDBDatabase; import org.heigit.ohsome.oshdb.api.db.OSHDBH2; import org.heigit.ohsome.oshdb.api.generic.OSHDBCombinedIndex; @@ -15,7 +16,6 @@ import org.heigit.ohsome.oshdb.api.object.OSMContribution; import org.heigit.ohsome.oshdb.api.object.OSMEntitySnapshot; import org.heigit.ohsome.oshdb.osm.OSMType; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.util.time.OSHDBTimestamps; import org.junit.Test; diff --git a/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestMapAggregateByTimestamp.java b/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestMapAggregateByTimestamp.java index 247534cde..b19d3c25e 100644 --- a/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestMapAggregateByTimestamp.java +++ b/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestMapAggregateByTimestamp.java @@ -5,6 +5,8 @@ import java.util.List; import java.util.Map; import java.util.SortedMap; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; import org.heigit.ohsome.oshdb.api.db.OSHDBDatabase; import org.heigit.ohsome.oshdb.api.db.OSHDBH2; import org.heigit.ohsome.oshdb.api.generic.OSHDBCombinedIndex; @@ -14,8 +16,6 @@ import org.heigit.ohsome.oshdb.api.object.OSMContribution; import org.heigit.ohsome.oshdb.api.object.OSMEntitySnapshot; import org.heigit.ohsome.oshdb.osm.OSMType; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.heigit.ohsome.oshdb.util.exceptions.OSHDBInvalidTimestampException; import org.heigit.ohsome.oshdb.util.time.OSHDBTimestamps; import org.junit.Test; diff --git a/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestMapReduce.java b/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestMapReduce.java index 24cb39c24..b06c74de8 100644 --- a/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestMapReduce.java +++ b/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestMapReduce.java @@ -5,17 +5,17 @@ import java.util.List; import java.util.Set; import java.util.stream.Collectors; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.api.db.OSHDBDatabase; import org.heigit.ohsome.oshdb.api.db.OSHDBJdbc; -import org.heigit.ohsome.oshdb.api.generic.function.SerializableFunction; import org.heigit.ohsome.oshdb.api.mapreducer.MapReducer; import org.heigit.ohsome.oshdb.api.mapreducer.OSMContributionView; import org.heigit.ohsome.oshdb.api.mapreducer.OSMEntitySnapshotView; import org.heigit.ohsome.oshdb.api.object.OSMContribution; import org.heigit.ohsome.oshdb.api.object.OSMEntitySnapshot; import org.heigit.ohsome.oshdb.osm.OSMType; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.util.exceptions.OSHDBTimeoutException; +import org.heigit.ohsome.oshdb.util.function.SerializableFunction; import org.heigit.ohsome.oshdb.util.time.OSHDBTimestamps; import org.junit.Test; diff --git a/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestOSHDBFilter.java b/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestOSHDBFilter.java index 8e45b0886..d40e7fb58 100644 --- a/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestOSHDBFilter.java +++ b/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestOSHDBFilter.java @@ -4,6 +4,7 @@ import static org.junit.Assert.fail; import java.util.SortedMap; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.api.db.OSHDBH2; import org.heigit.ohsome.oshdb.api.db.OSHDBJdbc; import org.heigit.ohsome.oshdb.api.mapreducer.MapReducer; @@ -13,7 +14,6 @@ import org.heigit.ohsome.oshdb.api.object.OSMEntitySnapshot; import org.heigit.ohsome.oshdb.filter.FilterParser; import org.heigit.ohsome.oshdb.osm.OSMType; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.util.tagtranslator.TagTranslator; import org.junit.Test; diff --git a/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestOSMContributionGetContributorUserId.java b/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestOSMContributionGetContributorUserId.java index 09deb9d07..3b0a61a99 100644 --- a/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestOSMContributionGetContributorUserId.java +++ b/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestOSMContributionGetContributorUserId.java @@ -6,6 +6,7 @@ import java.util.Collections; import java.util.EnumSet; import java.util.List; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; import org.heigit.ohsome.oshdb.api.object.OSMContribution; import org.heigit.ohsome.oshdb.impl.osh.OSHNodeImpl; import org.heigit.ohsome.oshdb.impl.osh.OSHWayImpl; @@ -15,7 +16,6 @@ import org.heigit.ohsome.oshdb.osm.OSMRelation; import org.heigit.ohsome.oshdb.osm.OSMType; import org.heigit.ohsome.oshdb.osm.OSMWay; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.heigit.ohsome.oshdb.util.celliterator.CellIterator.IterateAllEntry; import org.heigit.ohsome.oshdb.util.celliterator.ContributionType; import org.heigit.ohsome.oshdb.util.celliterator.LazyEvaluatedContributionTypes; @@ -29,7 +29,7 @@ public TestOSMContributionGetContributorUserId() throws Exception { } private final OSHEntity dummyOshEntity = OSHNodeImpl.build(Collections.singletonList( - new OSMNode(-1L, 1, new OSHDBTimestamp(0L), 1L, 1, new int[]{}, 0, 0) + new OSMNode(-1L, 1, 0L, 1L, 1, new int[]{}, 0, 0) )); @Test @@ -37,7 +37,7 @@ public void node() throws Exception { // timestamp match OSMContribution c = new OSMContribution(new IterateAllEntry( new OSHDBTimestamp(123), - new OSMNode(1L, 1, new OSHDBTimestamp(123L), 1L, 7, new int[]{}, 0, 0), null, + new OSMNode(1L, 1, 123L, 1L, 7, new int[]{}, 0, 0), null, dummyOshEntity, null, null, null, null, new LazyEvaluatedContributionTypes(EnumSet.of(ContributionType.CREATION)), @@ -47,7 +47,7 @@ public void node() throws Exception { // contribution type match c = new OSMContribution(new IterateAllEntry( new OSHDBTimestamp(123), - new OSMNode(1L, 1, new OSHDBTimestamp(122L), 1L, 7, new int[] {}, 0, 0), null, + new OSMNode(1L, 1, 122L, 1L, 7, new int[] {}, 0, 0), null, dummyOshEntity, null, null, null, null, new LazyEvaluatedContributionTypes(EnumSet.of(ContributionType.CREATION)), @@ -56,8 +56,8 @@ public void node() throws Exception { assertEquals(7, c.getContributorUserId()); c = new OSMContribution(new IterateAllEntry( new OSHDBTimestamp(123), - new OSMNode(1L, 2, new OSHDBTimestamp(122L), 2L, 7, new int[] { 3, 4 }, 0, 0), - new OSMNode(1L, 1, new OSHDBTimestamp(121L), 1L, 6, new int[] { 1, 2 }, 0, 0), + new OSMNode(1L, 2, 122L, 2L, 7, new int[] { 3, 4 }, 0, 0), + new OSMNode(1L, 1, 121L, 1L, 6, new int[] { 1, 2 }, 0, 0), dummyOshEntity, null, null, null, null, new LazyEvaluatedContributionTypes(EnumSet.of(ContributionType.TAG_CHANGE)), @@ -67,8 +67,8 @@ public void node() throws Exception { c = new OSMContribution(new IterateAllEntry( new OSHDBTimestamp(123), // negative version == isVisible = false - new OSMNode(1L, -2, new OSHDBTimestamp(122L), 2L, 7, new int[] {}, 0, 0), - new OSMNode(1L, 1, new OSHDBTimestamp(121L), 1L, 6, new int[] {}, 0, 0), + new OSMNode(1L, -2, 122L, 2L, 7, new int[] {}, 0, 0), + new OSMNode(1L, 1, 121L, 1L, 6, new int[] {}, 0, 0), dummyOshEntity, null, null, null, null, new LazyEvaluatedContributionTypes(EnumSet.of(ContributionType.DELETION)), @@ -78,8 +78,8 @@ public void node() throws Exception { assertEquals(7, c.getContributorUserId()); c = new OSMContribution(new IterateAllEntry( new OSHDBTimestamp(123), - new OSMNode(1L, 1, new OSHDBTimestamp(122L), 1L, 7, new int[] {}, 0, 0), - new OSMNode(1L, 1, new OSHDBTimestamp(122L), 1L, 7, new int[] {}, 0, 0), + new OSMNode(1L, 1, 122L, 1L, 7, new int[] {}, 0, 0), + new OSMNode(1L, 1, 122L, 1L, 7, new int[] {}, 0, 0), dummyOshEntity, null, null, null, null, new LazyEvaluatedContributionTypes(EnumSet.noneOf(ContributionType.class)), @@ -92,7 +92,7 @@ public void node() throws Exception { public void wayDirect() throws Exception { OSMContribution c = new OSMContribution(new IterateAllEntry( new OSHDBTimestamp(123), - new OSMWay(1L, 1, new OSHDBTimestamp(123L), 1L, 7, new int[] {}, new OSMMember[] {}), null, + new OSMWay(1L, 1, 123L, 1L, 7, new int[] {}, new OSMMember[] {}), null, dummyOshEntity, null, null, null, null, new LazyEvaluatedContributionTypes(EnumSet.of(ContributionType.CREATION)), @@ -104,12 +104,12 @@ public void wayDirect() throws Exception { @Test public void wayIndirect() throws Exception { List versions = new ArrayList<>(); - versions.add(new OSMNode(3L, 3, new OSHDBTimestamp(125L), 4L, 8, new int[] {}, 0, 0)); - versions.add(new OSMNode(3L, 2, new OSHDBTimestamp(123L), 3L, 7, new int[] {}, 0, 0)); - versions.add(new OSMNode(3L, 1, new OSHDBTimestamp(121L), 2L, 6, new int[] {}, 0, 0)); + versions.add(new OSMNode(3L, 3, 125L, 4L, 8, new int[] {}, 0, 0)); + versions.add(new OSMNode(3L, 2, 123L, 3L, 7, new int[] {}, 0, 0)); + versions.add(new OSMNode(3L, 1, 121L, 2L, 6, new int[] {}, 0, 0)); OSMWay entity = new OSMWay( - 1L, 1, new OSHDBTimestamp(122L), 1L, 1, new int[] {}, new OSMMember[] { + 1L, 1, 122L, 1L, 1, new int[] {}, new OSMMember[] { new OSMMember(3, OSMType.NODE, 0, OSHNodeImpl.build(versions)) }); OSMContribution c = new OSMContribution(new IterateAllEntry( @@ -127,7 +127,7 @@ public void wayIndirect() throws Exception { public void relationDirect() throws Exception { OSMContribution c = new OSMContribution(new IterateAllEntry( new OSHDBTimestamp(123), - new OSMRelation(1L, 1, new OSHDBTimestamp(123L), 1L, 7, new int[] {}, new OSMMember[] {}), + new OSMRelation(1L, 1, 123L, 1L, 7, new int[] {}, new OSMMember[] {}), null, dummyOshEntity, null, null, null, null, @@ -141,17 +141,17 @@ public void relationDirect() throws Exception { public void relationIndirectWay() throws Exception { List versions = new ArrayList<>(); versions.add( - new OSMWay(3L, 3, new OSHDBTimestamp(125L), 4L, 8, new int[] {}, new OSMMember[] {}) + new OSMWay(3L, 3, 125L, 4L, 8, new int[] {}, new OSMMember[] {}) ); versions.add( - new OSMWay(3L, 2, new OSHDBTimestamp(123L), 3L, 7, new int[] {}, new OSMMember[] {}) + new OSMWay(3L, 2, 123L, 3L, 7, new int[] {}, new OSMMember[] {}) ); versions.add( - new OSMWay(3L, 1, new OSHDBTimestamp(121L), 2L, 6, new int[] {}, new OSMMember[] {}) + new OSMWay(3L, 1, 121L, 2L, 6, new int[] {}, new OSMMember[] {}) ); OSMRelation entity = new OSMRelation( - 1L, 1, new OSHDBTimestamp(122L), 1L, 1, new int[] {}, new OSMMember[] { + 1L, 1, 122L, 1L, 1, new int[] {}, new OSMMember[] { new OSMMember(3, OSMType.WAY, 0, OSHWayImpl.build(versions, Collections.emptyList())) }); OSMContribution c = new OSMContribution(new IterateAllEntry( @@ -168,17 +168,17 @@ public void relationIndirectWay() throws Exception { @Test public void relationIndirectWayNode() throws Exception { List nodeVersions = new ArrayList<>(); - nodeVersions.add(new OSMNode(3L, 3, new OSHDBTimestamp(125L), 4L, 8, new int[] {}, 0, 0)); - nodeVersions.add(new OSMNode(3L, 2, new OSHDBTimestamp(123L), 3L, 7, new int[] {}, 0, 0)); - nodeVersions.add(new OSMNode(3L, 1, new OSHDBTimestamp(121L), 2L, 6, new int[] {}, 0, 0)); + nodeVersions.add(new OSMNode(3L, 3, 125L, 4L, 8, new int[] {}, 0, 0)); + nodeVersions.add(new OSMNode(3L, 2, 123L, 3L, 7, new int[] {}, 0, 0)); + nodeVersions.add(new OSMNode(3L, 1, 121L, 2L, 6, new int[] {}, 0, 0)); List versions = new ArrayList<>(); - versions.add(new OSMWay(2L, 1, new OSHDBTimestamp(120L), 0L, 2, new int[] {}, new OSMMember[] { + versions.add(new OSMWay(2L, 1, 120L, 0L, 2, new int[] {}, new OSMMember[] { new OSMMember(3, OSMType.NODE, 0, OSHNodeImpl.build(nodeVersions)) })); OSMRelation entity = new OSMRelation( - 1L, 1, new OSHDBTimestamp(110L), 1L, 1, new int[] {}, new OSMMember[] { + 1L, 1, 110L, 1L, 1, new int[] {}, new OSMMember[] { new OSMMember( 2, OSMType.WAY, 0, OSHWayImpl.build(versions, Collections.singletonList(OSHNodeImpl.build(nodeVersions))) diff --git a/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestOSMDataFilters.java b/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestOSMDataFilters.java index 915c12b00..dee75f7df 100644 --- a/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestOSMDataFilters.java +++ b/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestOSMDataFilters.java @@ -11,13 +11,14 @@ import java.util.SortedMap; import java.util.regex.Pattern; import java.util.stream.Collectors; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; +import org.heigit.ohsome.oshdb.OSHDBTag; import org.heigit.ohsome.oshdb.api.db.OSHDBDatabase; import org.heigit.ohsome.oshdb.api.db.OSHDBH2; import org.heigit.ohsome.oshdb.api.mapreducer.MapReducer; import org.heigit.ohsome.oshdb.api.mapreducer.OSMEntitySnapshotView; import org.heigit.ohsome.oshdb.api.object.OSMEntitySnapshot; import org.heigit.ohsome.oshdb.osm.OSMType; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.util.geometry.OSHDBGeometryBuilder; import org.heigit.ohsome.oshdb.util.tagtranslator.OSMTag; import org.heigit.ohsome.oshdb.util.tagtranslator.OSMTagKey; @@ -209,10 +210,9 @@ public void tagMultiple() throws Exception { .areaOfInterest(bbox) .timestamps(timestamps1) .uniq(snapshot -> { - int[] tags = snapshot.getEntity().getRawTags(); - for (int i = 0; i < tags.length; i += 2) { - if (tags[i] == 6 /* name */) { - return tags[i + 1]; + for (OSHDBTag tag : snapshot.getEntity().getTags()) { + if (tag.getKey() == 6 /* name */) { + return tag.getValue(); } } // cannot actually happen (since we query only snapshots with a name, but needed to make diff --git a/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestQuantiles.java b/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestQuantiles.java index 4e1ad8811..b09b3c28c 100644 --- a/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestQuantiles.java +++ b/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestQuantiles.java @@ -7,6 +7,8 @@ import java.util.List; import java.util.SortedMap; import java.util.function.DoubleUnaryOperator; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; import org.heigit.ohsome.oshdb.api.db.OSHDBDatabase; import org.heigit.ohsome.oshdb.api.db.OSHDBH2; import org.heigit.ohsome.oshdb.api.mapreducer.MapAggregator; @@ -14,8 +16,6 @@ import org.heigit.ohsome.oshdb.api.mapreducer.OSMEntitySnapshotView; import org.heigit.ohsome.oshdb.api.object.OSMEntitySnapshot; import org.heigit.ohsome.oshdb.osm.OSMType; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.heigit.ohsome.oshdb.util.time.OSHDBTimestamps; import org.junit.Test; diff --git a/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestStream.java b/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestStream.java index 6ab56f8c8..58a444cd9 100644 --- a/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestStream.java +++ b/oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/TestStream.java @@ -3,13 +3,13 @@ import static org.junit.Assert.assertEquals; import java.util.concurrent.ConcurrentHashMap; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.api.db.OSHDBDatabase; import org.heigit.ohsome.oshdb.api.db.OSHDBH2; import org.heigit.ohsome.oshdb.api.mapreducer.MapReducer; import org.heigit.ohsome.oshdb.api.mapreducer.OSMContributionView; import org.heigit.ohsome.oshdb.api.object.OSMContribution; import org.heigit.ohsome.oshdb.osm.OSMType; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.util.time.OSHDBTimestamps; import org.junit.Test; diff --git a/oshdb-filter/src/main/java/org/heigit/ohsome/oshdb/filter/Filter.java b/oshdb-filter/src/main/java/org/heigit/ohsome/oshdb/filter/Filter.java index 621a127ed..7e0669456 100644 --- a/oshdb-filter/src/main/java/org/heigit/ohsome/oshdb/filter/Filter.java +++ b/oshdb-filter/src/main/java/org/heigit/ohsome/oshdb/filter/Filter.java @@ -1,23 +1,18 @@ package org.heigit.ohsome.oshdb.filter; -import java.io.Serializable; -import java.util.function.BiPredicate; -import java.util.function.Predicate; import java.util.function.Supplier; import org.heigit.ohsome.oshdb.filter.NegatableFilter.FilterInternal; import org.heigit.ohsome.oshdb.osh.OSHEntity; import org.heigit.ohsome.oshdb.osm.OSMEntity; +import org.heigit.ohsome.oshdb.util.function.OSHEntityFilter; +import org.heigit.ohsome.oshdb.util.function.OSMEntityFilter; +import org.heigit.ohsome.oshdb.util.function.SerializableBiPredicate; import org.locationtech.jts.geom.Geometry; /** * A filter condition which can be applied to an OSM entity. */ public interface Filter extends FilterExpression { - /** A predicate which is also serializable. */ - public interface SerializablePredicate extends Predicate, Serializable {} - - /** A bi-predicate which is also serializable. */ - interface SerializableBiPredicate extends BiPredicate, Serializable {} /** * Constructs a simple filter based on a predicate on OSH entities. @@ -30,7 +25,7 @@ interface SerializableBiPredicate extends BiPredicate, Serializable * @param oshCallback predicate which tests osh entities * @return a filter object which filters using the given predicate */ - static Filter byOSHEntity(SerializablePredicate oshCallback) { + static Filter byOSHEntity(OSHEntityFilter oshCallback) { return by(oshCallback, ignored -> true); } @@ -45,7 +40,7 @@ static Filter byOSHEntity(SerializablePredicate oshCallback) { * @param osmCallback predicate which tests osm entities * @return a filter object which filters using the given predicate */ - static Filter byOSMEntity(SerializablePredicate osmCallback) { + static Filter byOSMEntity(OSMEntityFilter osmCallback) { return new NegatableFilter(osmCallback::test); } @@ -62,8 +57,8 @@ static Filter byOSMEntity(SerializablePredicate osmCallback) { * @return a filter object which filters using the given predicates */ static Filter by( - SerializablePredicate oshCallback, - SerializablePredicate osmCallback) { + OSHEntityFilter oshCallback, + OSMEntityFilter osmCallback) { return by(oshCallback, osmCallback, (ignored, ignored2) -> true); } @@ -84,8 +79,8 @@ static Filter by( * @return a filter object which filters using the given predicates */ static Filter by( - SerializablePredicate oshCallback, - SerializablePredicate osmCallback, + OSHEntityFilter oshCallback, + OSMEntityFilter osmCallback, SerializableBiPredicate> geomCallback ) { return new NegatableFilter(new FilterInternal() { diff --git a/oshdb-filter/src/main/java/org/heigit/ohsome/oshdb/filter/FilterParser.java b/oshdb-filter/src/main/java/org/heigit/ohsome/oshdb/filter/FilterParser.java index 57406a986..7cb7de32e 100644 --- a/oshdb-filter/src/main/java/org/heigit/ohsome/oshdb/filter/FilterParser.java +++ b/oshdb-filter/src/main/java/org/heigit/ohsome/oshdb/filter/FilterParser.java @@ -2,10 +2,10 @@ import java.util.ArrayList; import java.util.List; +import org.heigit.ohsome.oshdb.OSHDBTag; import org.heigit.ohsome.oshdb.filter.GeometryFilter.ValueRange; import org.heigit.ohsome.oshdb.filter.GeometryTypeFilter.GeometryType; import org.heigit.ohsome.oshdb.osm.OSMType; -import org.heigit.ohsome.oshdb.util.OSHDBTag; import org.heigit.ohsome.oshdb.util.tagtranslator.OSMTag; import org.heigit.ohsome.oshdb.util.tagtranslator.OSMTagInterface; import org.heigit.ohsome.oshdb.util.tagtranslator.OSMTagKey; diff --git a/oshdb-filter/src/main/java/org/heigit/ohsome/oshdb/filter/GeometryTypeFilter.java b/oshdb-filter/src/main/java/org/heigit/ohsome/oshdb/filter/GeometryTypeFilter.java index a62719246..f3924f1d8 100644 --- a/oshdb-filter/src/main/java/org/heigit/ohsome/oshdb/filter/GeometryTypeFilter.java +++ b/oshdb-filter/src/main/java/org/heigit/ohsome/oshdb/filter/GeometryTypeFilter.java @@ -6,12 +6,12 @@ import java.util.Set; import java.util.function.Supplier; import javax.annotation.Nonnull; +import org.heigit.ohsome.oshdb.OSHDBTag; import org.heigit.ohsome.oshdb.osh.OSHEntity; import org.heigit.ohsome.oshdb.osm.OSMEntity; import org.heigit.ohsome.oshdb.osm.OSMMember; import org.heigit.ohsome.oshdb.osm.OSMType; import org.heigit.ohsome.oshdb.osm.OSMWay; -import org.heigit.ohsome.oshdb.util.OSHDBTag; import org.heigit.ohsome.oshdb.util.tagtranslator.OSMTag; import org.heigit.ohsome.oshdb.util.tagtranslator.TagTranslator; import org.jetbrains.annotations.Contract; @@ -139,7 +139,7 @@ public boolean applyOSM(OSMEntity entity) { // type specific checks if (geometryType == GeometryType.POLYGON) { if (osmType == OSMType.WAY) { - OSMMember[] wayNodes = ((OSMWay) entity).getRefs(); + OSMMember[] wayNodes = ((OSMWay) entity).getMembers(); return wayNodes.length >= 4 && wayNodes[0].getId() == wayNodes[wayNodes.length - 1].getId(); } else if (osmType == OSMType.RELATION) { return entity.hasTagValue(typeMultipolygon.getKey(), typeMultipolygon.getValue()) diff --git a/oshdb-filter/src/main/java/org/heigit/ohsome/oshdb/filter/TagFilterAnyOf.java b/oshdb-filter/src/main/java/org/heigit/ohsome/oshdb/filter/TagFilterAnyOf.java index 4af97fe3a..954522351 100644 --- a/oshdb-filter/src/main/java/org/heigit/ohsome/oshdb/filter/TagFilterAnyOf.java +++ b/oshdb-filter/src/main/java/org/heigit/ohsome/oshdb/filter/TagFilterAnyOf.java @@ -5,7 +5,7 @@ import java.util.Optional; import java.util.Set; import javax.annotation.Nonnull; -import org.heigit.ohsome.oshdb.util.OSHDBTag; +import org.heigit.ohsome.oshdb.OSHDBTag; /** * A tag filter which executes a "key [not] in (value1, value2, …)" check. diff --git a/oshdb-filter/src/main/java/org/heigit/ohsome/oshdb/filter/TagFilterEquals.java b/oshdb-filter/src/main/java/org/heigit/ohsome/oshdb/filter/TagFilterEquals.java index 06a5d0ab6..124cef36f 100644 --- a/oshdb-filter/src/main/java/org/heigit/ohsome/oshdb/filter/TagFilterEquals.java +++ b/oshdb-filter/src/main/java/org/heigit/ohsome/oshdb/filter/TagFilterEquals.java @@ -1,8 +1,8 @@ package org.heigit.ohsome.oshdb.filter; +import org.heigit.ohsome.oshdb.OSHDBTag; import org.heigit.ohsome.oshdb.osh.OSHEntity; import org.heigit.ohsome.oshdb.osm.OSMEntity; -import org.heigit.ohsome.oshdb.util.OSHDBTag; /** * A tag filter which executes a "key=value" check. diff --git a/oshdb-filter/src/main/java/org/heigit/ohsome/oshdb/filter/TagFilterEqualsAnyOf.java b/oshdb-filter/src/main/java/org/heigit/ohsome/oshdb/filter/TagFilterEqualsAnyOf.java index 1a785d09a..d830bf7d7 100644 --- a/oshdb-filter/src/main/java/org/heigit/ohsome/oshdb/filter/TagFilterEqualsAnyOf.java +++ b/oshdb-filter/src/main/java/org/heigit/ohsome/oshdb/filter/TagFilterEqualsAnyOf.java @@ -3,9 +3,9 @@ import java.util.Collection; import java.util.stream.Collectors; import javax.annotation.Nonnull; +import org.heigit.ohsome.oshdb.OSHDBTag; import org.heigit.ohsome.oshdb.osh.OSHEntity; import org.heigit.ohsome.oshdb.osm.OSMEntity; -import org.heigit.ohsome.oshdb.util.OSHDBTag; /** * A tag filter which executes a "key in (value1, value2, …)" check. diff --git a/oshdb-filter/src/main/java/org/heigit/ohsome/oshdb/filter/TagFilterNotEquals.java b/oshdb-filter/src/main/java/org/heigit/ohsome/oshdb/filter/TagFilterNotEquals.java index 43af194f6..7ca8335b9 100644 --- a/oshdb-filter/src/main/java/org/heigit/ohsome/oshdb/filter/TagFilterNotEquals.java +++ b/oshdb-filter/src/main/java/org/heigit/ohsome/oshdb/filter/TagFilterNotEquals.java @@ -1,7 +1,7 @@ package org.heigit.ohsome.oshdb.filter; +import org.heigit.ohsome.oshdb.OSHDBTag; import org.heigit.ohsome.oshdb.osm.OSMEntity; -import org.heigit.ohsome.oshdb.util.OSHDBTag; /** * A tag filter which executes a "key!=value" check. diff --git a/oshdb-filter/src/main/java/org/heigit/ohsome/oshdb/filter/TagFilterNotEqualsAnyOf.java b/oshdb-filter/src/main/java/org/heigit/ohsome/oshdb/filter/TagFilterNotEqualsAnyOf.java index 346dcad5b..5930a0448 100644 --- a/oshdb-filter/src/main/java/org/heigit/ohsome/oshdb/filter/TagFilterNotEqualsAnyOf.java +++ b/oshdb-filter/src/main/java/org/heigit/ohsome/oshdb/filter/TagFilterNotEqualsAnyOf.java @@ -3,8 +3,8 @@ import java.util.Collection; import java.util.stream.Collectors; import javax.annotation.Nonnull; +import org.heigit.ohsome.oshdb.OSHDBTag; import org.heigit.ohsome.oshdb.osm.OSMEntity; -import org.heigit.ohsome.oshdb.util.OSHDBTag; /** * A tag filter which executes a "key not in (value1, value2, …)" check. diff --git a/oshdb-filter/src/test/java/org/heigit/ohsome/oshdb/filter/ApplyOSMGeometryTest.java b/oshdb-filter/src/test/java/org/heigit/ohsome/oshdb/filter/ApplyOSMGeometryTest.java index 9bab4cb1f..1bcfc48c9 100644 --- a/oshdb-filter/src/test/java/org/heigit/ohsome/oshdb/filter/ApplyOSMGeometryTest.java +++ b/oshdb-filter/src/test/java/org/heigit/ohsome/oshdb/filter/ApplyOSMGeometryTest.java @@ -3,8 +3,8 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.osm.OSMEntity; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.util.geometry.OSHDBGeometryBuilder; import org.junit.Test; import org.locationtech.jts.geom.Coordinate; diff --git a/oshdb-filter/src/test/java/org/heigit/ohsome/oshdb/filter/FilterTest.java b/oshdb-filter/src/test/java/org/heigit/ohsome/oshdb/filter/FilterTest.java index 6131829c3..2ea12d474 100644 --- a/oshdb-filter/src/test/java/org/heigit/ohsome/oshdb/filter/FilterTest.java +++ b/oshdb-filter/src/test/java/org/heigit/ohsome/oshdb/filter/FilterTest.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; +import org.heigit.ohsome.oshdb.OSHDBTag; import org.heigit.ohsome.oshdb.impl.osh.OSHNodeImpl; import org.heigit.ohsome.oshdb.impl.osh.OSHRelationImpl; import org.heigit.ohsome.oshdb.impl.osh.OSHWayImpl; @@ -17,8 +18,6 @@ import org.heigit.ohsome.oshdb.osm.OSMRelation; import org.heigit.ohsome.oshdb.osm.OSMType; import org.heigit.ohsome.oshdb.osm.OSMWay; -import org.heigit.ohsome.oshdb.util.OSHDBTag; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.heigit.ohsome.oshdb.util.exceptions.OSHDBKeytablesNotFoundException; import org.heigit.ohsome.oshdb.util.tagtranslator.TagTranslator; import org.junit.After; @@ -57,7 +56,7 @@ protected int[] createTestTags(String... keyValues) { } protected OSMNode createTestOSMEntityNode(String... keyValues) { - return new OSMNode(1, 1, new OSHDBTimestamp(0), 1, 1, createTestTags(keyValues), 0, 0); + return new OSMNode(1, 1, 0L, 1, 1, createTestTags(keyValues), 0, 0); } protected OSMWay createTestOSMEntityWay(long[] nodeIds, String... keyValues) { @@ -65,11 +64,11 @@ protected OSMWay createTestOSMEntityWay(long[] nodeIds, String... keyValues) { for (int i = 0; i < refs.length; i++) { refs[i] = new OSMMember(nodeIds[i], OSMType.NODE, 0); } - return new OSMWay(1, 1, new OSHDBTimestamp(0), 1, 1, createTestTags(keyValues), refs); + return new OSMWay(1, 1, 0L, 1, 1, createTestTags(keyValues), refs); } protected OSMRelation createTestOSMEntityRelation(String... keyValues) { - return new OSMRelation(1, 1, new OSHDBTimestamp(0), 1, 1, createTestTags(keyValues), + return new OSMRelation(1, 1, 0L, 1, 1, createTestTags(keyValues), new OSMMember[] {}); } diff --git a/oshdb-filter/src/test/java/org/heigit/ohsome/oshdb/filter/NegateTest.java b/oshdb-filter/src/test/java/org/heigit/ohsome/oshdb/filter/NegateTest.java index 6bfa42361..4fd55bfd1 100644 --- a/oshdb-filter/src/test/java/org/heigit/ohsome/oshdb/filter/NegateTest.java +++ b/oshdb-filter/src/test/java/org/heigit/ohsome/oshdb/filter/NegateTest.java @@ -6,10 +6,10 @@ import java.util.Arrays; import java.util.Collections; +import org.heigit.ohsome.oshdb.OSHDBTag; import org.heigit.ohsome.oshdb.filter.GeometryTypeFilter.GeometryType; import org.heigit.ohsome.oshdb.osm.OSMEntity; import org.heigit.ohsome.oshdb.osm.OSMType; -import org.heigit.ohsome.oshdb.util.OSHDBTag; import org.heigit.ohsome.oshdb.util.tagtranslator.OSMTag; import org.heigit.ohsome.oshdb.util.tagtranslator.OSMTagKey; import org.junit.Test; diff --git a/oshdb-filter/src/test/java/org/heigit/ohsome/oshdb/filter/ParseTest.java b/oshdb-filter/src/test/java/org/heigit/ohsome/oshdb/filter/ParseTest.java index 08a703786..0ef31d2a9 100644 --- a/oshdb-filter/src/test/java/org/heigit/ohsome/oshdb/filter/ParseTest.java +++ b/oshdb-filter/src/test/java/org/heigit/ohsome/oshdb/filter/ParseTest.java @@ -6,9 +6,9 @@ import java.util.Arrays; import java.util.Collections; import java.util.EnumSet; +import org.heigit.ohsome.oshdb.OSHDBTag; import org.heigit.ohsome.oshdb.filter.GeometryTypeFilter.GeometryType; import org.heigit.ohsome.oshdb.osm.OSMType; -import org.heigit.ohsome.oshdb.util.OSHDBTag; import org.heigit.ohsome.oshdb.util.OSHDBTagKey; import org.junit.Test; diff --git a/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/load/handle/OSHDBHandler.java b/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/load/handle/OSHDBHandler.java index d3e8b7b9e..8c5cb0715 100644 --- a/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/load/handle/OSHDBHandler.java +++ b/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/load/handle/OSHDBHandler.java @@ -8,6 +8,7 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.grid.GridOSHNodes; import org.heigit.ohsome.oshdb.grid.GridOSHRelations; import org.heigit.ohsome.oshdb.grid.GridOSHWays; @@ -25,7 +26,6 @@ import org.heigit.ohsome.oshdb.tool.importer.transform.oshdb.TransformOSHNode; import org.heigit.ohsome.oshdb.tool.importer.transform.oshdb.TransformOSHWay; import org.heigit.ohsome.oshdb.tool.importer.util.ZGrid; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; import org.roaringbitmap.longlong.Roaring64NavigableMap; public abstract class OSHDBHandler extends LoaderHandler { diff --git a/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/Transformer.java b/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/Transformer.java index 7885f681e..e4f4eb4ea 100644 --- a/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/Transformer.java +++ b/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/Transformer.java @@ -19,6 +19,7 @@ import java.util.Set; import java.util.function.LongFunction; import java.util.stream.Collectors; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.osm.OSMType; import org.heigit.ohsome.oshdb.tool.importer.util.RoleToIdMapper; import org.heigit.ohsome.oshdb.tool.importer.util.SizeEstimator; @@ -26,7 +27,6 @@ import org.heigit.ohsome.oshdb.tool.importer.util.TagToIdMapper; import org.heigit.ohsome.oshdb.tool.importer.util.ZGrid; import org.heigit.ohsome.oshdb.tool.importer.util.long2long.SortedLong2LongMap; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; import org.heigit.ohsome.oshpbf.parser.osm.v0_6.Entity; import org.heigit.ohsome.oshpbf.parser.osm.v0_6.TagText; import org.roaringbitmap.longlong.Roaring64NavigableMap; diff --git a/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/TransformerNode.java b/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/TransformerNode.java index 0224b87ad..c0d9f8f89 100644 --- a/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/TransformerNode.java +++ b/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/TransformerNode.java @@ -7,12 +7,11 @@ import java.util.Set; import java.util.TreeSet; import java.util.function.LongFunction; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.osm.OSMNode; import org.heigit.ohsome.oshdb.osm.OSMType; import org.heigit.ohsome.oshdb.tool.importer.transform.oshdb.TransformOSHNode; import org.heigit.ohsome.oshdb.tool.importer.util.TagToIdMapper; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.heigit.ohsome.oshdb.util.bytearray.ByteArrayOutputWrapper; import org.heigit.ohsome.oshpbf.parser.osm.v0_6.Entity; import org.heigit.ohsome.oshpbf.parser.osm.v0_6.Node; @@ -28,12 +27,14 @@ public TransformerNode(long maxMemory,int maxZoom, Path workDirectory, TagToIdMa super(maxMemory,maxZoom, workDirectory, tagToIdMapper,workerId); } + @Override public OSMType type() { return OSMType.NODE; } private final long[] lastDataSize = new long[2]; + @Override public void transform(long id, List versions) { final List nodes = new ArrayList<>(versions.size()); @@ -87,7 +88,7 @@ public void transform(long id, List versions) { private OSMNode getNode(Node entity) { return new OSMNode(entity.getId(), // modifiedVersion(entity), // - new OSHDBTimestamp(entity.getTimestamp()), // + entity.getTimestamp(), // entity.getChangeset(), // entity.getUserId(), // getKeyValue(entity.getTags()), // diff --git a/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/TransformerRelation.java b/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/TransformerRelation.java index 0ba5abbba..46cb17b7b 100644 --- a/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/TransformerRelation.java +++ b/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/TransformerRelation.java @@ -17,7 +17,6 @@ import org.heigit.ohsome.oshdb.tool.importer.util.RoleToIdMapper; import org.heigit.ohsome.oshdb.tool.importer.util.TagToIdMapper; import org.heigit.ohsome.oshdb.tool.importer.util.long2long.SortedLong2LongMap; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.heigit.ohsome.oshdb.util.bytearray.ByteArrayOutputWrapper; import org.heigit.ohsome.oshpbf.parser.osm.v0_6.Entity; import org.heigit.ohsome.oshpbf.parser.osm.v0_6.Relation; @@ -40,6 +39,7 @@ public TransformerRelation(long maxMemory,int maxZoom, Path workDirectory, TagTo } + @Override public OSMType type() { return OSMType.RELATION; } @@ -48,6 +48,7 @@ public OSMType type() { private Roaring64NavigableMap bitmapRefWay = new Roaring64NavigableMap(); + @Override public void transform(long id, List versions) { List entities = new ArrayList<>(versions.size()); LongSortedSet nodeIds = new LongAVLTreeSet(); @@ -124,7 +125,7 @@ public void complete() { private OSMRelation getOSM(Relation entity) { return new OSMRelation(entity.getId() // , modifiedVersion(entity) // - , new OSHDBTimestamp(entity.getTimestamp()) // + , entity.getTimestamp() // , entity.getChangeset() // , entity.getUserId() // , getKeyValue(entity.getTags()) // diff --git a/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/TransformerWay.java b/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/TransformerWay.java index 8a0ae9f9c..1122df8b5 100644 --- a/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/TransformerWay.java +++ b/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/TransformerWay.java @@ -14,7 +14,6 @@ import org.heigit.ohsome.oshdb.tool.importer.transform.oshdb.TransformOSHWay; import org.heigit.ohsome.oshdb.tool.importer.util.TagToIdMapper; import org.heigit.ohsome.oshdb.tool.importer.util.long2long.SortedLong2LongMap; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.heigit.ohsome.oshdb.util.bytearray.ByteArrayOutputWrapper; import org.heigit.ohsome.oshpbf.parser.osm.v0_6.Entity; import org.heigit.ohsome.oshpbf.parser.osm.v0_6.Way; @@ -31,12 +30,14 @@ public TransformerWay(long maxMemory,int maxZoom,Path workDirectory,TagToIdMappe super(maxMemory,maxZoom, workDirectory,tagToIdMapper,workerId); this.nodeToCell = nodeToCell; } + @Override public OSMType type(){ return OSMType.WAY; } private final long[] lastDataSize = new long[2]; + @Override public void transform(long id, List versions) { List ways = new ArrayList<>(versions.size()); LongSortedSet nodeIds = new LongAVLTreeSet(); @@ -77,7 +78,7 @@ public void transform(long id, List versions) { private OSMWay getOSM(Way entity) { return new OSMWay(entity.getId() // , modifiedVersion(entity) // - , new OSHDBTimestamp(entity.getTimestamp()) // + , entity.getTimestamp() // , entity.getChangeset() // , entity.getUserId() // , getKeyValue(entity.getTags()) // diff --git a/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/MutableOSMEntity.java b/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/MutableOSMEntity.java index a23f366ff..95a1a573b 100644 --- a/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/MutableOSMEntity.java +++ b/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/MutableOSMEntity.java @@ -1,6 +1,6 @@ package org.heigit.ohsome.oshdb.tool.importer.transform.oshdb; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; public class MutableOSMEntity implements OSMEntity { @@ -8,7 +8,7 @@ public class MutableOSMEntity implements OSMEntity { private int version; private boolean visible; - private OSHDBTimestamp timestamp = new OSHDBTimestamp(0L); + private long timestamp; private long changeset; private int userId; private int[] tags; @@ -17,13 +17,14 @@ public void setEntity(long id, int version, boolean visible, long timestamp, lon this.id = id; this.version = version; this.visible = visible; - this.timestamp.setTimestamp(timestamp); + this.timestamp = timestamp; this.changeset = changeset; this.userId = userId; this.tags = tags; } + @Override public long getId() { return id; } @@ -32,6 +33,7 @@ public void setId(long id) { this.id = id; } + @Override public int getVersion() { return version; } @@ -49,19 +51,21 @@ public void isVisible(boolean visible) { public void setVersion(int version) { this.version = version; } - - public OSHDBTimestamp getTimestamp() { + + @Override + public long getEpochSecond() { return timestamp; } public void setTimestamp(OSHDBTimestamp timestamp) { - this.timestamp = timestamp; + this.timestamp = timestamp.getEpochSecond(); } public void setTimestamp(long timestamp) { - this.timestamp.setTimestamp(timestamp); + this.timestamp = timestamp; } + @Override public long getChangeset() { return changeset; } @@ -70,6 +74,7 @@ public void setChangeset(long changeset) { this.changeset = changeset; } + @Override public int getUserId() { return userId; } @@ -78,6 +83,7 @@ public void setUserId(int userId) { this.userId = userId; } + @Override public int[] getTags() { return tags; } diff --git a/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/OSHEntity.java b/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/OSHEntity.java index 126179521..de0ed04af 100644 --- a/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/OSHEntity.java +++ b/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/OSHEntity.java @@ -2,8 +2,8 @@ import java.util.Iterator; import java.util.stream.Stream; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.osm.OSMType; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; public interface OSHEntity { diff --git a/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/OSHEntity2.java b/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/OSHEntity2.java index 2fb90537a..1176cc5ef 100644 --- a/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/OSHEntity2.java +++ b/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/OSHEntity2.java @@ -7,8 +7,8 @@ import java.util.Map; import java.util.Set; import java.util.TreeSet; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.osm.OSMEntity; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.util.bytearray.ByteArrayOutputWrapper; import org.heigit.ohsome.oshdb.util.bytearray.ByteArrayWrapper; @@ -64,33 +64,35 @@ public long getBaseLatitude() { } public abstract OSHBuilder builder(); - + private static final int CHANGED_USER_ID = 1 << 0; private static final int CHANGED_TAGS = 1 << 1; private static final int CHANGED_EXTENSION = 1 << 2; - + private static final int CHANGED_FREE_BIT4 = 1 << 3; private static final int CHANGED_FREE_BIT5 = 1 << 4; private static final int CHANGED_FREE_BIT6 = 1 << 5; private static final int CHANGED_FREE_BIT7 = 1 << 6; private static final int CHANGED_FREE_BIT8 = 1 << 7; - + protected static abstract class OSHBuilder { private Set keySet = new TreeSet<>(); - - public void build(ByteArrayOutputWrapper out,List versions, - long baseTimestamp,long baseLongitude,long baseLatitude, - Map nodeOffsets,Map wayOffsets,Map relationOffsets) throws IOException { + + public void build(ByteArrayOutputWrapper out, List versions, long baseTimestamp, + long baseLongitude, long baseLatitude, Map nodeOffsets, + Map wayOffsets, Map relationOffsets) throws IOException { ByteArrayOutputWrapper aux = new ByteArrayOutputWrapper(); - build(out, aux, versions, baseTimestamp,baseLongitude,baseLatitude, nodeOffsets, wayOffsets, relationOffsets); + build(out, aux, versions, baseTimestamp, baseLongitude, baseLatitude, nodeOffsets, wayOffsets, + relationOffsets); } - - - public void build(ByteArrayOutputWrapper out,ByteArrayOutputWrapper aux,List versions, - long baseTimestamp,long baseLongitude,long baseLatitude, - Map nodeOffsets,Map wayOffsets,Map relationOffsets) throws IOException { + + + public void build(ByteArrayOutputWrapper out, ByteArrayOutputWrapper aux, + List versions, long baseTimestamp, long baseLongitude, + long baseLatitude, Map nodeOffsets, Map wayOffsets, + Map relationOffsets) throws IOException { int versionNumber = 0; long timestamp = 0; long changeset = 0; @@ -98,12 +100,12 @@ public void build(ByteArrayOutputWrapper out,ByteArrayOutputWrapper aux,List getKeySet() { return keySet; } - protected abstract boolean extension(ByteArrayOutputWrapper out, OSMEntity version, - long baseLongitude,long baseLatitude, - Map nodeOffsets,Map wayOffsets,Map relationOffsets) throws IOException; - + protected abstract boolean extension(ByteArrayOutputWrapper out, OSMEntity version, + long baseLongitude, long baseLatitude, Map nodeOffsets, + Map wayOffsets, Map relationOffsets) throws IOException; } - protected static abstract class OSMIterator implements Iterator { + protected abstract static class OSMIterator implements Iterator { protected final ByteArrayWrapper in; protected final OSHEntity2 entity; @@ -199,7 +201,4 @@ protected boolean changedExtension() { protected abstract T extension(); } - - - } diff --git a/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/OSHNode2.java b/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/OSHNode2.java index 210398e0a..4b8c49c4d 100644 --- a/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/OSHNode2.java +++ b/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/OSHNode2.java @@ -3,11 +3,10 @@ import java.io.IOException; import java.util.Iterator; import java.util.Map; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.osm.OSMEntity; import org.heigit.ohsome.oshdb.osm.OSMNode; import org.heigit.ohsome.oshdb.osm.OSMType; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.heigit.ohsome.oshdb.util.bytearray.ByteArrayOutputWrapper; public class OSHNode2 extends OSHEntity2 implements OSH { @@ -91,7 +90,7 @@ protected OSMNode extension() { longitude = in.readSInt64Delta(longitude); latitude = in.readSInt64Delta(latitude); } - return new OSMNode(entity.id, version, new OSHDBTimestamp(entity.baseTimestamp + timestamp), changeset, userId, keyValues, // + return new OSMNode(entity.id, version, (entity.baseTimestamp + timestamp), changeset, userId, keyValues, // entity.baseLongitude + longitude, entity.baseLatitude + latitude); } catch (IOException e) { throw new RuntimeException(e); diff --git a/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/OSHRelation2.java b/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/OSHRelation2.java index eee232bb3..27c553b3d 100644 --- a/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/OSHRelation2.java +++ b/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/OSHRelation2.java @@ -3,13 +3,11 @@ import java.io.IOException; import java.util.Iterator; import java.util.Map; - +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.osm.OSMEntity; import org.heigit.ohsome.oshdb.osm.OSMMember; import org.heigit.ohsome.oshdb.osm.OSMRelation; import org.heigit.ohsome.oshdb.osm.OSMType; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.heigit.ohsome.oshdb.util.bytearray.ByteArrayOutputWrapper; public abstract class OSHRelation2 extends OSHEntity2 implements OSH { @@ -125,7 +123,7 @@ protected OSMRelation extension() { } } - return new OSMRelation(entity.id, version, new OSHDBTimestamp(entity.baseTimestamp + timestamp), changeset, userId, keyValues, + return new OSMRelation(entity.id, version, (entity.baseTimestamp + timestamp), changeset, userId, keyValues, members); } catch (IOException e) { throw new RuntimeException(e); diff --git a/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/OSHWay2.java b/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/OSHWay2.java index 2d8c4939e..f0f512204 100644 --- a/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/OSHWay2.java +++ b/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/OSHWay2.java @@ -3,12 +3,11 @@ import java.io.IOException; import java.util.Iterator; import java.util.Map; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.osm.OSMEntity; import org.heigit.ohsome.oshdb.osm.OSMMember; import org.heigit.ohsome.oshdb.osm.OSMType; import org.heigit.ohsome.oshdb.osm.OSMWay; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.heigit.ohsome.oshdb.util.bytearray.ByteArrayOutputWrapper; public abstract class OSHWay2 extends OSHEntity2 implements OSH { @@ -36,8 +35,8 @@ public static class OSHWayBuilder extends OSHBuilder { protected boolean extension(ByteArrayOutputWrapper out,OSMEntity version,long baseLongitude, long baseLatitude, Map nodeOffsets,Map wayOffsets, Map relationOffsets) throws IOException { OSMWay way = (OSMWay) version; - if (!memberEquals(way.getRefs(), members)) { - members = way.getRefs(); + if (!memberEquals(way.getMembers(), members)) { + members = way.getMembers(); out.writeUInt32(members.length); long lastId = 0; for (OSMMember member : members) { @@ -100,7 +99,7 @@ protected OSMWay extension() { members[i] = way.getMember(memId); } } - return new OSMWay(entity.id, version, new OSHDBTimestamp(entity.baseTimestamp + timestamp), changeset, userId, keyValues, members); + return new OSMWay(entity.id, version, (entity.baseTimestamp + timestamp), changeset, userId, keyValues, members); } catch (IOException e) { throw new RuntimeException(e); } diff --git a/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/OSMEntity.java b/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/OSMEntity.java index ccb1b3d1e..790beb86f 100644 --- a/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/OSMEntity.java +++ b/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/OSMEntity.java @@ -1,22 +1,26 @@ package org.heigit.ohsome.oshdb.tool.importer.transform.oshdb; import java.util.Arrays; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; +import org.heigit.ohsome.oshdb.OSHDBTemporal; -public interface OSMEntity { +public interface OSMEntity extends OSHDBTemporal { + + long getId(); + + boolean isVisible(); + + int getVersion(); + + long getChangeset(); + + int getUserId(); + + int[] getTags(); - public long getId(); - public boolean isVisible(); - - public int getVersion(); - public OSHDBTimestamp getTimestamp(); - public long getChangeset(); - public int getUserId(); - public int[] getTags(); - public default String asString() { return String.format("ID:%d V:%d TS:%d CS:%d VIS:%s UID:%d TAGS:%S", getId(), getVersion(), - getTimestamp().getRawUnixTimestamp(), getChangeset(), isVisible(), getUserId(), Arrays.toString(getTags())); + getEpochSecond(), getChangeset(), isVisible(), getUserId(), + Arrays.toString(getTags())); } } diff --git a/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/TransfomRelation.java b/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/TransfomRelation.java index d9e2e8ddc..ee8ce6a11 100644 --- a/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/TransfomRelation.java +++ b/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/TransfomRelation.java @@ -7,10 +7,10 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.osm.OSMMember; import org.heigit.ohsome.oshdb.osm.OSMRelation; import org.heigit.ohsome.oshdb.osm.OSMType; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.util.bytearray.ByteArrayOutputWrapper; import org.heigit.ohsome.oshdb.util.bytearray.ByteArrayWrapper; @@ -94,7 +94,7 @@ public static TransfomRelation instance(final byte[] data, final int offset, fin protected TransfomRelation(byte[] data, int offset, int length, byte header, long id, long baseTimestamp, long baseLongitude, long baseLatitude, int dataOffset, int dataLength, long[] nodeIds, long[] wayIds) { - super(data, offset, length, header, id, OSHDBBoundingBox.EMPTY, baseTimestamp, baseLongitude, baseLatitude, new int[0], dataOffset, dataLength); + super(data, offset, length, header, id, OSHDBBoundingBox.INVALID, baseTimestamp, baseLongitude, baseLatitude, new int[0], dataOffset, dataLength); offsetToId = new HashMap<>(2); offsetToId.put(OSMType.NODE,nodeIds); diff --git a/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/TransformOSHEntity.java b/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/TransformOSHEntity.java index 84f6df52c..3d8f8cc51 100644 --- a/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/TransformOSHEntity.java +++ b/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/TransformOSHEntity.java @@ -1,13 +1,15 @@ package org.heigit.ohsome.oshdb.tool.importer.transform.oshdb; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.impl.osh.OSHEntityImpl; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; public abstract class TransformOSHEntity extends OSHEntityImpl { public TransformOSHEntity(byte[] data, int offset, int length, long baseId, long baseTimestamp, long baseLongitude, long baseLatitude, byte header, long id, OSHDBBoundingBox bbox, int[] keys, int dataOffset, int dataLength) { - super(data, offset, length, baseId, baseTimestamp, baseLongitude, baseLatitude, header, id, bbox, keys, dataOffset,dataLength); + super(data, offset, length, baseId, baseTimestamp, baseLongitude, baseLatitude, header, id, + bbox.getMinLonLong(), bbox.getMinLatLong(), bbox.getMaxLonLong(), bbox.getMaxLatLong(), + keys, dataOffset,dataLength); } } diff --git a/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/TransformOSHNode.java b/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/TransformOSHNode.java index 6cb382206..ee3083c00 100644 --- a/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/TransformOSHNode.java +++ b/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/TransformOSHNode.java @@ -3,8 +3,8 @@ import java.io.IOException; import java.util.Collections; import java.util.List; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.osm.OSMNode; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.util.bytearray.ByteArrayOutputWrapper; import org.heigit.ohsome.oshdb.util.bytearray.ByteArrayWrapper; @@ -56,6 +56,6 @@ public static TransformOSHNode instance(final byte[] data, final int offset, fin private TransformOSHNode(final byte[] data, final int offset, final int length, final byte header, final long id, final long baseTimestamp, final long baseLongitude, final long baseLatitude, final int dataOffset, final int dataLength) { - super(data, offset, length, header,id, OSHDBBoundingBox.EMPTY, baseTimestamp, baseLongitude, baseLatitude, new int[0], dataOffset, dataLength); + super(data, offset, length, header,id, OSHDBBoundingBox.INVALID, baseTimestamp, baseLongitude, baseLatitude, new int[0], dataOffset, dataLength); } } diff --git a/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/TransformOSHWay.java b/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/TransformOSHWay.java index 2812920b9..f50799267 100644 --- a/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/TransformOSHWay.java +++ b/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/oshdb/TransformOSHWay.java @@ -7,10 +7,10 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.osm.OSMMember; import org.heigit.ohsome.oshdb.osm.OSMType; import org.heigit.ohsome.oshdb.osm.OSMWay; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.util.bytearray.ByteArrayOutputWrapper; import org.heigit.ohsome.oshdb.util.bytearray.ByteArrayWrapper; @@ -87,7 +87,7 @@ public static TransformOSHWay instance(final byte[] data, final int offset, fina } private TransformOSHWay(final byte[] data, final int offset, final int length, byte header, final long id, final long baseTimestamp,final long baseLongitude, final long baseLatitude, final int dataOffset, final int dataLength, final long[] nodeIds) { - super(data, offset, length, header, id, OSHDBBoundingBox.EMPTY, + super(data, offset, length, header, id, OSHDBBoundingBox.INVALID, baseTimestamp, baseLongitude, baseLatitude, new int[0], dataOffset, dataLength); diff --git a/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/reader/TransformReader.java b/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/reader/TransformReader.java index 6eebd1c5c..9e6487e7a 100644 --- a/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/reader/TransformReader.java +++ b/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/transform/reader/TransformReader.java @@ -8,9 +8,9 @@ import java.nio.file.Path; import java.util.Set; import java.util.TreeSet; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.tool.importer.transform.oshdb.OSHEntity2; import org.heigit.ohsome.oshdb.tool.importer.util.ZGrid; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; public abstract class TransformReader implements Closeable { diff --git a/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/util/ZGrid.java b/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/util/ZGrid.java index f508871d9..657c8472f 100644 --- a/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/util/ZGrid.java +++ b/oshdb-tool/etl/src/main/java/org/heigit/ohsome/oshdb/tool/importer/util/ZGrid.java @@ -2,7 +2,7 @@ import java.util.Comparator; import org.heigit.ohsome.oshdb.OSHDB; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; public class ZGrid { diff --git a/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/celliterator/CellIterator.java b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/celliterator/CellIterator.java index 669ab0cd8..395b4e8ee 100644 --- a/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/celliterator/CellIterator.java +++ b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/celliterator/CellIterator.java @@ -13,9 +13,11 @@ import java.util.SortedSet; import java.util.TreeMap; import java.util.TreeSet; -import java.util.function.Predicate; import java.util.stream.Stream; import javax.annotation.Nonnull; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; +import org.heigit.ohsome.oshdb.OSHDBTemporal; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; import org.heigit.ohsome.oshdb.grid.GridOSHEntity; import org.heigit.ohsome.oshdb.index.XYGrid; import org.heigit.ohsome.oshdb.osh.OSHEntities; @@ -26,8 +28,8 @@ import org.heigit.ohsome.oshdb.osm.OSMType; import org.heigit.ohsome.oshdb.osm.OSMWay; import org.heigit.ohsome.oshdb.util.CellId; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; +import org.heigit.ohsome.oshdb.util.function.OSHEntityFilter; +import org.heigit.ohsome.oshdb.util.function.OSMEntityFilter; import org.heigit.ohsome.oshdb.util.geometry.Geo; import org.heigit.ohsome.oshdb.util.geometry.OSHDBGeometryBuilder; import org.heigit.ohsome.oshdb.util.geometry.fip.FastBboxInPolygon; @@ -60,10 +62,6 @@ public class CellIterator implements Serializable { private static final Logger LOG = LoggerFactory.getLogger(CellIterator.class); - public interface OSHEntityFilter extends Predicate, Serializable {} - - public interface OSMEntityFilter extends Predicate, Serializable {} - private final TreeSet timestamps; private final OSHDBBoundingBox boundingBox; private boolean isBoundByPolygon; @@ -268,8 +266,8 @@ public Stream iterateByTimestamps(GridOSHEntity cell) { return Streams.stream(cellData).flatMap(oshEntity -> { if (!oshEntityPreFilter.test(oshEntity) || !allFullyInside && ( - !oshEntity.getBoundingBox().intersects(boundingBox) - || (isBoundByPolygon && bboxOutsidePolygon.test(oshEntity.getBoundingBox())) + !oshEntity.intersects(boundingBox) + || (isBoundByPolygon && bboxOutsidePolygon.test(oshEntity)) )) { // this osh entity doesn't match the prefilter or is fully outside the requested // area of interest -> skip it @@ -280,8 +278,8 @@ public Stream iterateByTimestamps(GridOSHEntity cell) { return Stream.empty(); } boolean fullyInside = allFullyInside || ( - oshEntity.getBoundingBox().isInside(boundingBox) - && (!isBoundByPolygon || bboxInPolygon.test(oshEntity.getBoundingBox())) + oshEntity.coveredBy(boundingBox) + && (!isBoundByPolygon || bboxInPolygon.test(oshEntity)) ); // optimize loop by requesting modification timestamps first, and skip geometry calculations @@ -294,7 +292,7 @@ public Stream iterateByTimestamps(GridOSHEntity cell) { for (OSHDBTimestamp requestedT : timestamps) { boolean needToRequest = false; while (j < modTs.size() - && modTs.get(j).getRawUnixTimestamp() <= requestedT.getRawUnixTimestamp()) { + && modTs.get(j).getEpochSecond() <= requestedT.getEpochSecond()) { needToRequest = true; j++; } @@ -323,7 +321,7 @@ public Stream iterateByTimestamps(GridOSHEntity cell) { // skip because this entity is deleted at this timestamp continue; } - if (osmEntity instanceof OSMWay && ((OSMWay) osmEntity).getRefs().length == 0 + if (osmEntity instanceof OSMWay && ((OSMWay) osmEntity).getMembers().length == 0 || osmEntity instanceof OSMRelation && ((OSMRelation) osmEntity).getMembers().length == 0) { // skip way/relation with zero nodes/members @@ -438,7 +436,7 @@ private LazyEvaluatedObject constructClippedGeometry( return new LazyEvaluatedObject<>(fastPolygonClipper.intersection(geometry)); } } else { - if (bbox.isInside(this.boundingBox)) { + if (bbox.coveredBy(this.boundingBox)) { return new LazyEvaluatedObject<>(geometry); } else if (!bbox.intersects(this.boundingBox)) { return new LazyEvaluatedObject<>(createEmptyGeometryLike(geometry)); @@ -555,8 +553,8 @@ public Stream iterateByContribution(GridOSHEntity cell) { return Streams.stream(cellData).flatMap(oshEntity -> { if (!oshEntityPreFilter.test(oshEntity) || !allFullyInside && ( - !oshEntity.getBoundingBox().intersects(boundingBox) - || (isBoundByPolygon && bboxOutsidePolygon.test(oshEntity.getBoundingBox())) + !oshEntity.intersects(boundingBox) + || (isBoundByPolygon && bboxOutsidePolygon.test(oshEntity)) )) { // this osh entity doesn't match the prefilter or is fully outside the requested // area of interest -> skip it @@ -568,8 +566,8 @@ public Stream iterateByContribution(GridOSHEntity cell) { } boolean fullyInside = allFullyInside || ( - oshEntity.getBoundingBox().isInside(boundingBox) - && (!isBoundByPolygon || bboxInPolygon.test(oshEntity.getBoundingBox())) + oshEntity.coveredBy(boundingBox) + && (!isBoundByPolygon || bboxInPolygon.test(oshEntity)) ); Map changesetTs = OSHEntityTimeUtils.getChangesetTimestamps(oshEntity); @@ -816,7 +814,7 @@ private static List getVersionsByTimestamps( Iterator itr = osh.getVersions().iterator(); while (itr.hasNext() && i >= 0) { OSMEntity osm = itr.next(); - while (i >= 0 && osm.getTimestamp().compareTo(timestamps.get(i)) <= 0) { + while (i >= 0 && OSHDBTemporal.compare(osm,timestamps.get(i)) <= 0) { result.add(osm); i--; } diff --git a/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/function/OSHEntityFilter.java b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/function/OSHEntityFilter.java new file mode 100644 index 000000000..71f56914f --- /dev/null +++ b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/function/OSHEntityFilter.java @@ -0,0 +1,7 @@ +package org.heigit.ohsome.oshdb.util.function; + +import org.heigit.ohsome.oshdb.osh.OSHEntity; + +public interface OSHEntityFilter extends SerializablePredicate { + +} diff --git a/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/function/OSMEntityFilter.java b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/function/OSMEntityFilter.java new file mode 100644 index 000000000..a965b9dac --- /dev/null +++ b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/function/OSMEntityFilter.java @@ -0,0 +1,7 @@ +package org.heigit.ohsome.oshdb.util.function; + +import org.heigit.ohsome.oshdb.osm.OSMEntity; + +public interface OSMEntityFilter extends SerializablePredicate { + +} diff --git a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/generic/function/SerializableBiConsumer.java b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/function/SerializableBiConsumer.java similarity index 75% rename from oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/generic/function/SerializableBiConsumer.java rename to oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/function/SerializableBiConsumer.java index 4d7c3a434..92d1e6adc 100644 --- a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/generic/function/SerializableBiConsumer.java +++ b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/function/SerializableBiConsumer.java @@ -1,4 +1,4 @@ -package org.heigit.ohsome.oshdb.api.generic.function; +package org.heigit.ohsome.oshdb.util.function; import java.io.Serializable; import java.util.function.BiConsumer; diff --git a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/generic/function/SerializableBiFunction.java b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/function/SerializableBiFunction.java similarity index 75% rename from oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/generic/function/SerializableBiFunction.java rename to oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/function/SerializableBiFunction.java index 5491af642..de379097f 100644 --- a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/generic/function/SerializableBiFunction.java +++ b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/function/SerializableBiFunction.java @@ -1,4 +1,4 @@ -package org.heigit.ohsome.oshdb.api.generic.function; +package org.heigit.ohsome.oshdb.util.function; import java.io.Serializable; import java.util.function.BiFunction; diff --git a/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/function/SerializableBiPredicate.java b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/function/SerializableBiPredicate.java new file mode 100644 index 000000000..28ded9428 --- /dev/null +++ b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/function/SerializableBiPredicate.java @@ -0,0 +1,8 @@ +package org.heigit.ohsome.oshdb.util.function; + +import java.io.Serializable; +import java.util.function.BiPredicate; + +public interface SerializableBiPredicate extends BiPredicate, Serializable { + +} diff --git a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/generic/function/SerializableBinaryOperator.java b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/function/SerializableBinaryOperator.java similarity index 75% rename from oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/generic/function/SerializableBinaryOperator.java rename to oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/function/SerializableBinaryOperator.java index de2b3e503..8cc58a981 100644 --- a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/generic/function/SerializableBinaryOperator.java +++ b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/function/SerializableBinaryOperator.java @@ -1,4 +1,4 @@ -package org.heigit.ohsome.oshdb.api.generic.function; +package org.heigit.ohsome.oshdb.util.function; import java.io.Serializable; import java.util.function.BinaryOperator; diff --git a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/generic/function/SerializableConsumer.java b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/function/SerializableConsumer.java similarity index 73% rename from oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/generic/function/SerializableConsumer.java rename to oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/function/SerializableConsumer.java index a30899946..0dc4a13a3 100644 --- a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/generic/function/SerializableConsumer.java +++ b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/function/SerializableConsumer.java @@ -1,4 +1,4 @@ -package org.heigit.ohsome.oshdb.api.generic.function; +package org.heigit.ohsome.oshdb.util.function; import java.io.Serializable; import java.util.function.Consumer; diff --git a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/generic/function/SerializableFunction.java b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/function/SerializableFunction.java similarity index 73% rename from oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/generic/function/SerializableFunction.java rename to oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/function/SerializableFunction.java index 6eae40452..b9e52e6fa 100644 --- a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/generic/function/SerializableFunction.java +++ b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/function/SerializableFunction.java @@ -1,4 +1,4 @@ -package org.heigit.ohsome.oshdb.api.generic.function; +package org.heigit.ohsome.oshdb.util.function; import java.io.Serializable; import java.util.function.Function; diff --git a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/generic/function/SerializablePredicate.java b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/function/SerializablePredicate.java similarity index 73% rename from oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/generic/function/SerializablePredicate.java rename to oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/function/SerializablePredicate.java index 8a3905279..6bff90131 100644 --- a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/generic/function/SerializablePredicate.java +++ b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/function/SerializablePredicate.java @@ -1,4 +1,4 @@ -package org.heigit.ohsome.oshdb.api.generic.function; +package org.heigit.ohsome.oshdb.util.function; import java.io.Serializable; import java.util.function.Predicate; diff --git a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/generic/function/SerializableSupplier.java b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/function/SerializableSupplier.java similarity index 80% rename from oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/generic/function/SerializableSupplier.java rename to oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/function/SerializableSupplier.java index bde7b1ec0..47338b681 100644 --- a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/generic/function/SerializableSupplier.java +++ b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/function/SerializableSupplier.java @@ -1,4 +1,4 @@ -package org.heigit.ohsome.oshdb.api.generic.function; +package org.heigit.ohsome.oshdb.util.function; import java.io.Serializable; import java.util.function.Supplier; diff --git a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/generic/function/package-info.java b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/function/package-info.java similarity index 51% rename from oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/generic/function/package-info.java rename to oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/function/package-info.java index 4492664ed..31f5d6f37 100644 --- a/oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/generic/function/package-info.java +++ b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/function/package-info.java @@ -1,4 +1,4 @@ /** * Interfaces for functions declared in the API. */ -package org.heigit.ohsome.oshdb.api.generic.function; +package org.heigit.ohsome.oshdb.util.function; diff --git a/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/geometry/Geo.java b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/geometry/Geo.java index 162ffdc69..afff8e563 100644 --- a/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/geometry/Geo.java +++ b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/geometry/Geo.java @@ -1,6 +1,6 @@ package org.heigit.ohsome.oshdb.util.geometry; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.GeometryCollection; diff --git a/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/geometry/OSHDBGeometryBuilder.java b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/geometry/OSHDBGeometryBuilder.java index b4669e5e3..2129a2f36 100644 --- a/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/geometry/OSHDBGeometryBuilder.java +++ b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/geometry/OSHDBGeometryBuilder.java @@ -14,6 +14,10 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import javax.annotation.Nonnull; +import org.heigit.ohsome.oshdb.OSHDBBoundable; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; +import org.heigit.ohsome.oshdb.OSHDBTemporal; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; import org.heigit.ohsome.oshdb.osh.OSHEntities; import org.heigit.ohsome.oshdb.osh.OSHEntity; import org.heigit.ohsome.oshdb.osm.OSMEntity; @@ -21,8 +25,6 @@ import org.heigit.ohsome.oshdb.osm.OSMNode; import org.heigit.ohsome.oshdb.osm.OSMRelation; import org.heigit.ohsome.oshdb.osm.OSMWay; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.heigit.ohsome.oshdb.util.taginterpreter.TagInterpreter; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.CoordinateSequence; @@ -72,7 +74,7 @@ public static Geometry getGeometry( OSMEntity entity, OSHDBTimestamp timestamp, TagInterpreter areaDecider ) { GeometryFactory geometryFactory = new GeometryFactory(); - if (timestamp.compareTo(entity.getTimestamp()) < 0) { + if (OSHDBTemporal.compare(timestamp, entity) < 0) { throw new AssertionError( "cannot produce geometry of entity for timestamp before this entity's version's timestamp" ); @@ -142,7 +144,7 @@ public static Geometry getGeometry( return getGeometryCollectionGeometry(relation, timestamp, areaDecider, geometryFactory); } } - + /** * Converts a OSHDBBoundingBox to a rectangular polygon. * @@ -155,7 +157,7 @@ public static Geometry getGeometry( * @param bbox The BoundingBox the polygon should be created for. * @return a rectangular Polygon */ - public static Polygon getGeometry(@Nonnull OSHDBBoundingBox bbox) { + public static Polygon getGeometry(@Nonnull OSHDBBoundable bbox) { assert bbox != null : "a bounding box is not allowed to be null"; GeometryFactory gf = new GeometryFactory(); diff --git a/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/geometry/fip/FastBboxInPolygon.java b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/geometry/fip/FastBboxInPolygon.java index 3f63a3572..ba7aa983e 100644 --- a/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/geometry/fip/FastBboxInPolygon.java +++ b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/geometry/fip/FastBboxInPolygon.java @@ -6,7 +6,7 @@ import java.util.LinkedList; import java.util.List; import java.util.function.Predicate; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; +import org.heigit.ohsome.oshdb.OSHDBBoundable; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Envelope; import org.locationtech.jts.geom.Geometry; @@ -20,7 +20,7 @@ * Fast bounding-box in (multi)polygon test inspired by * https://blog.jochentopf.com/2017-02-06-expedicious-and-exact-extracts-with-osmium.html */ -public class FastBboxInPolygon extends FastInPolygon implements Predicate, +public class FastBboxInPolygon extends FastInPolygon implements Predicate, Serializable { private Collection innerBboxes = new ArrayList<>(); @@ -53,7 +53,7 @@ public

FastBboxInPolygon(P geom) { * Tests if the given bounding box is fully inside of the polygon. */ @Override - public boolean test(OSHDBBoundingBox boundingBox) { + public boolean test(OSHDBBoundable boundingBox) { GeometryFactory gf = new GeometryFactory(); Point p1 = gf.createPoint(new Coordinate(boundingBox.getMinLon(), boundingBox.getMinLat())); if (crossingNumber(p1, true) % 2 == 0) { diff --git a/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/geometry/fip/FastBboxOutsidePolygon.java b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/geometry/fip/FastBboxOutsidePolygon.java index 9a99081fa..492c6ba02 100644 --- a/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/geometry/fip/FastBboxOutsidePolygon.java +++ b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/geometry/fip/FastBboxOutsidePolygon.java @@ -6,7 +6,7 @@ import java.util.LinkedList; import java.util.List; import java.util.function.Predicate; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; +import org.heigit.ohsome.oshdb.OSHDBBoundable; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Envelope; import org.locationtech.jts.geom.Geometry; @@ -20,7 +20,7 @@ * Fast bounding-box in (multi)polygon test inspired by * https://blog.jochentopf.com/2017-02-06-expedicious-and-exact-extracts-with-osmium.html */ -public class FastBboxOutsidePolygon extends FastInPolygon implements Predicate, +public class FastBboxOutsidePolygon extends FastInPolygon implements Predicate, Serializable { private Collection outerBboxes = new ArrayList<>(); @@ -52,7 +52,7 @@ public

FastBboxOutsidePolygon(P geom) { * Tests if the given bounding box is fully outside of the polygon. */ @Override - public boolean test(OSHDBBoundingBox boundingBox) { + public boolean test(OSHDBBoundable boundingBox) { GeometryFactory gf = new GeometryFactory(); Point p1 = gf.createPoint(new Coordinate(boundingBox.getMinLon(), boundingBox.getMinLat())); if (crossingNumber(p1, true) % 2 == 1) { diff --git a/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/osh/OSHEntityTimeUtils.java b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/osh/OSHEntityTimeUtils.java index 6e29286fa..0d4df0005 100644 --- a/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/osh/OSHEntityTimeUtils.java +++ b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/osh/OSHEntityTimeUtils.java @@ -6,7 +6,6 @@ import java.io.IOException; import java.io.UncheckedIOException; import java.util.ArrayList; -import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; @@ -16,6 +15,7 @@ import java.util.TreeMap; import java.util.TreeSet; import java.util.function.Predicate; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; import org.heigit.ohsome.oshdb.osh.OSHEntities; import org.heigit.ohsome.oshdb.osh.OSHEntity; import org.heigit.ohsome.oshdb.osh.OSHNode; @@ -25,7 +25,6 @@ import org.heigit.ohsome.oshdb.osm.OSMMember; import org.heigit.ohsome.oshdb.osm.OSMRelation; import org.heigit.ohsome.oshdb.osm.OSMWay; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; public class OSHEntityTimeUtils { private OSHEntityTimeUtils() { @@ -87,7 +86,7 @@ private static Map getChangesetTimestamps(OSHRelation osh) /** * Returns all timestamps at which this entity (or one or more of its child entities) has been * modified. - * + * * @param osh the osh entity to work on * @return a list of timestamps where this entity has been modified */ @@ -121,7 +120,7 @@ public static List getModificationTimestamps(OSHEntity osh, bool } private static List getModificationTimestamps(OSHNode osh) { - return Lists.reverse(OSHEntities.toList(osh.getVersions(), OSMEntity::getTimestamp)); + return Lists.reverse(OSHEntities.toList(osh.getVersions(), e -> new OSHDBTimestamp(e))); } /** @@ -167,7 +166,7 @@ public static List getModificationTimestamps(OSHEntity osh, /** * Returns all timestamps at which this entity (or one or more of its child entities) has been * modified and matches a given condition/filter. - * + * * @param osh the osh entity to work on * @param osmEntityFilter only timestamps for which the entity matches this filter are returned * @return a list of timestamps where this entity has been modified @@ -212,10 +211,10 @@ private static List getModificationTimestampsReverseNonRecursed( result.add(nextNonMatchTime); nextNonMatchTime = null; } - result.add(osm.getTimestamp()); + result.add(new OSHDBTimestamp(osm)); } else { // save the time of the next "deletion" for later - nextNonMatchTime = osm.getTimestamp(); + nextNonMatchTime = new OSHDBTimestamp(osm); } } return result; @@ -226,7 +225,7 @@ private static List getModificationTimestampsReverseNonRecursed( */ private static void putChangesetTimestamps(OSHEntity osh, Map result) { for (OSMEntity osm : osh.getVersions()) { - result.putIfAbsent(osm.getTimestamp(), osm.getChangesetId()); + result.putIfAbsent(new OSHDBTimestamp(osm), osm.getChangesetId()); } } @@ -240,7 +239,7 @@ private static void putChangesetTimestamps( continue; } for (OSMEntity osm : osh.getVersions()) { - result.putIfAbsent(osm.getTimestamp(), osm.getChangesetId()); + result.putIfAbsent(new OSHDBTimestamp(osm), osm.getChangesetId()); } } } @@ -267,7 +266,7 @@ private static Map> collectMembershipTimeI Map> memberTimes = new HashMap<>(); OSHDBTimestamp nextT = new OSHDBTimestamp(Long.MAX_VALUE); for (OSMEntity osm : osh.getVersions()) { - OSHDBTimestamp thisT = osm.getTimestamp(); + OSHDBTimestamp thisT = new OSHDBTimestamp(osm); // skip versions which are deleted or don't match the given filter if (!osm.isVisible() || (osmEntityFilter != null && !osmEntityFilter.test(osm))) { // remember "valid-to" time @@ -312,7 +311,7 @@ private static OSMMember[] getRefsOrMembers(OSMEntity osm) { case RELATION: return ((OSMRelation) osm).getMembers(); case WAY: - return ((OSMWay) osm).getRefs(); + return ((OSMWay) osm).getMembers(); default: final String illegalOSMTypeMessage = "cannot collect members from anything other than ways or relations"; diff --git a/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/taginterpreter/BaseTagInterpreter.java b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/taginterpreter/BaseTagInterpreter.java index 36da810f3..d9c03b901 100644 --- a/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/taginterpreter/BaseTagInterpreter.java +++ b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/taginterpreter/BaseTagInterpreter.java @@ -76,7 +76,7 @@ public boolean isArea(OSMEntity entity) { return false; } else if (entity instanceof OSMWay) { OSMWay way = (OSMWay) entity; - OSMMember[] nds = way.getRefs(); + OSMMember[] nds = way.getMembers(); // must form closed ring with at least 3 vertices if (nds.length < 4 || nds[0].getId() != nds[nds.length - 1].getId()) { return false; diff --git a/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/tagtranslator/TagTranslator.java b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/tagtranslator/TagTranslator.java index fde13f78d..8c126790f 100644 --- a/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/tagtranslator/TagTranslator.java +++ b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/tagtranslator/TagTranslator.java @@ -7,8 +7,8 @@ import java.sql.Statement; import java.util.EnumSet; import java.util.concurrent.ConcurrentHashMap; +import org.heigit.ohsome.oshdb.OSHDBTag; import org.heigit.ohsome.oshdb.util.OSHDBRole; -import org.heigit.ohsome.oshdb.util.OSHDBTag; import org.heigit.ohsome.oshdb.util.OSHDBTagKey; import org.heigit.ohsome.oshdb.util.TableNames; import org.heigit.ohsome.oshdb.util.exceptions.OSHDBKeytablesNotFoundException; diff --git a/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/time/OSHDBTimestampInterval.java b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/time/OSHDBTimestampInterval.java index 2a457e84a..321a6b044 100644 --- a/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/time/OSHDBTimestampInterval.java +++ b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/time/OSHDBTimestampInterval.java @@ -3,7 +3,7 @@ import java.io.Serializable; import java.util.SortedSet; import javax.annotation.Nonnull; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; public class OSHDBTimestampInterval implements Serializable, Comparable { private final OSHDBTimestamp fromTimestamp; @@ -23,13 +23,13 @@ public OSHDBTimestampInterval(SortedSet oshdbTimestamps) { } public boolean intersects(OSHDBTimestampInterval other) { - return other.toTimestamp.getRawUnixTimestamp() >= this.fromTimestamp.getRawUnixTimestamp() - && other.fromTimestamp.getRawUnixTimestamp() <= this.toTimestamp.getRawUnixTimestamp(); + return other.toTimestamp.getEpochSecond() >= this.fromTimestamp.getEpochSecond() + && other.fromTimestamp.getEpochSecond() <= this.toTimestamp.getEpochSecond(); } public boolean includes(OSHDBTimestamp timestamp) { - return timestamp.getRawUnixTimestamp() >= this.fromTimestamp.getRawUnixTimestamp() - && timestamp.getRawUnixTimestamp() < this.toTimestamp.getRawUnixTimestamp(); + return timestamp.getEpochSecond() >= this.fromTimestamp.getEpochSecond() + && timestamp.getEpochSecond() < this.toTimestamp.getEpochSecond(); } @SuppressWarnings("MissingJavadocMethod") @@ -37,7 +37,7 @@ public int compareTo(@Nonnull OSHDBTimestamp timestamp) { if (this.includes(timestamp)) { return 0; } - return timestamp.getRawUnixTimestamp() < this.fromTimestamp.getRawUnixTimestamp() ? -1 : 1; + return timestamp.getEpochSecond() < this.fromTimestamp.getEpochSecond() ? -1 : 1; } @Override diff --git a/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/time/OSHDBTimestampList.java b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/time/OSHDBTimestampList.java index 085bcad39..a48b4ab03 100644 --- a/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/time/OSHDBTimestampList.java +++ b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/time/OSHDBTimestampList.java @@ -4,7 +4,7 @@ import java.util.SortedSet; import java.util.TreeSet; import java.util.stream.Collectors; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; /** * Provider of a sorted list of (unix) timestamps. @@ -24,7 +24,7 @@ public interface OSHDBTimestampList extends Serializable { */ default SortedSet getRawUnixTimestamps() { return this.get().stream() - .map(OSHDBTimestamp::getRawUnixTimestamp) + .map(OSHDBTimestamp::getEpochSecond) .collect(Collectors.toCollection(TreeSet::new)); } } diff --git a/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/time/OSHDBTimestamps.java b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/time/OSHDBTimestamps.java index 7b2cb4e30..bda6abe4d 100644 --- a/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/time/OSHDBTimestamps.java +++ b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/time/OSHDBTimestamps.java @@ -11,7 +11,7 @@ import java.util.TreeSet; import java.util.stream.Collectors; import java.util.stream.Stream; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/time/TimestampFormatter.java b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/time/TimestampFormatter.java index 8c454f16f..8e88075a3 100644 --- a/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/time/TimestampFormatter.java +++ b/oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/time/TimestampFormatter.java @@ -3,7 +3,7 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; /** * A helper class to transform timestamps between string, date and long. @@ -73,7 +73,7 @@ public String isoDateTime(long timestamp) { * @return the formatted date string */ public String isoDateTime(OSHDBTimestamp date) { - return this.isoDateTime(date.getRawUnixTimestamp()); + return this.isoDateTime(date.getEpochSecond()); } } diff --git a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/celliterator/IterateAllTest.java b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/celliterator/IterateAllTest.java index 6efd85db9..c3b5d49b9 100644 --- a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/celliterator/IterateAllTest.java +++ b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/celliterator/IterateAllTest.java @@ -11,9 +11,9 @@ import java.util.List; import java.util.TreeSet; import java.util.stream.Collectors; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; import org.heigit.ohsome.oshdb.grid.GridOSHEntity; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.heigit.ohsome.oshdb.util.TableNames; import org.heigit.ohsome.oshdb.util.celliterator.CellIterator.IterateAllEntry; import org.heigit.ohsome.oshdb.util.exceptions.OSHDBKeytablesNotFoundException; diff --git a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/celliterator/IterateByContributionNodesTest.java b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/celliterator/IterateByContributionNodesTest.java index 2a08a50dc..73b53fc0d 100644 --- a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/celliterator/IterateByContributionNodesTest.java +++ b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/celliterator/IterateByContributionNodesTest.java @@ -9,9 +9,9 @@ import java.util.EnumSet; import java.util.List; import java.util.stream.Collectors; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.grid.GridOSHNodes; import org.heigit.ohsome.oshdb.index.XYGrid; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.util.celliterator.CellIterator.IterateAllEntry; import org.heigit.ohsome.oshdb.util.celliterator.helpers.GridOSHFactory; import org.heigit.ohsome.oshdb.util.geometry.helpers.OSMXmlReaderTagInterpreter; diff --git a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/celliterator/IterateByContributionRelationsTest.java b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/celliterator/IterateByContributionRelationsTest.java index 876bbc2a8..33e06af3f 100644 --- a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/celliterator/IterateByContributionRelationsTest.java +++ b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/celliterator/IterateByContributionRelationsTest.java @@ -9,8 +9,8 @@ import java.util.EnumSet; import java.util.List; import java.util.stream.Collectors; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.grid.GridOSHRelations; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.util.celliterator.CellIterator.IterateAllEntry; import org.heigit.ohsome.oshdb.util.celliterator.helpers.GridOSHFactory; import org.heigit.ohsome.oshdb.util.geometry.helpers.OSMXmlReaderTagInterpreter; diff --git a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/celliterator/IterateByContributionTypeNotMultipolygonTest.java b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/celliterator/IterateByContributionTypeNotMultipolygonTest.java index a380a3156..abc835234 100644 --- a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/celliterator/IterateByContributionTypeNotMultipolygonTest.java +++ b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/celliterator/IterateByContributionTypeNotMultipolygonTest.java @@ -9,8 +9,8 @@ import java.util.EnumSet; import java.util.List; import java.util.stream.Collectors; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.grid.GridOSHRelations; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.util.celliterator.CellIterator.IterateAllEntry; import org.heigit.ohsome.oshdb.util.celliterator.helpers.GridOSHFactory; import org.heigit.ohsome.oshdb.util.geometry.helpers.OSMXmlReaderTagInterpreter; diff --git a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/celliterator/IterateByContributionWaysTest.java b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/celliterator/IterateByContributionWaysTest.java index 3de8c504e..c95c0d2f2 100644 --- a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/celliterator/IterateByContributionWaysTest.java +++ b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/celliterator/IterateByContributionWaysTest.java @@ -8,8 +8,8 @@ import java.util.EnumSet; import java.util.List; import java.util.stream.Collectors; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.grid.GridOSHWays; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.util.celliterator.CellIterator.IterateAllEntry; import org.heigit.ohsome.oshdb.util.celliterator.helpers.GridOSHFactory; import org.heigit.ohsome.oshdb.util.geometry.helpers.OSMXmlReaderTagInterpreter; diff --git a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/celliterator/IterateByTimestampNotOsmTypeSpecificTest.java b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/celliterator/IterateByTimestampNotOsmTypeSpecificTest.java index 2cb0c42aa..5508a49a5 100644 --- a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/celliterator/IterateByTimestampNotOsmTypeSpecificTest.java +++ b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/celliterator/IterateByTimestampNotOsmTypeSpecificTest.java @@ -53,7 +53,7 @@ public IterateByTimestampNotOsmTypeSpecificTest() throws IOException { Collection wayVersions = entry.getValue(); oshWays.put(entry.getKey(), OSHWayImpl.build(new ArrayList<>(wayVersions), wayVersions.stream().flatMap(osmWay -> - Arrays.stream(osmWay.getRefs()).map(ref -> oshNodes.get(ref.getId())) + Arrays.stream(osmWay.getMembers()).map(ref -> oshNodes.get(ref.getId())) ).collect(Collectors.toSet()) )); } diff --git a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/celliterator/IterateByTimestampsNodesTest.java b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/celliterator/IterateByTimestampsNodesTest.java index 7366b41cc..f7d5a9407 100644 --- a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/celliterator/IterateByTimestampsNodesTest.java +++ b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/celliterator/IterateByTimestampsNodesTest.java @@ -8,9 +8,9 @@ import java.io.IOException; import java.util.List; import java.util.stream.Collectors; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.grid.GridOSHNodes; import org.heigit.ohsome.oshdb.index.XYGrid; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.util.celliterator.CellIterator.IterateByTimestampEntry; import org.heigit.ohsome.oshdb.util.celliterator.helpers.GridOSHFactory; import org.heigit.ohsome.oshdb.util.geometry.helpers.OSMXmlReaderTagInterpreter; diff --git a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/celliterator/IterateByTimestampsRelationsTest.java b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/celliterator/IterateByTimestampsRelationsTest.java index 898e62ac4..d9dd28c5f 100644 --- a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/celliterator/IterateByTimestampsRelationsTest.java +++ b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/celliterator/IterateByTimestampsRelationsTest.java @@ -8,8 +8,8 @@ import java.io.IOException; import java.util.List; import java.util.stream.Collectors; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.grid.GridOSHRelations; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.util.celliterator.CellIterator.IterateByTimestampEntry; import org.heigit.ohsome.oshdb.util.celliterator.helpers.GridOSHFactory; import org.heigit.ohsome.oshdb.util.geometry.helpers.OSMXmlReaderTagInterpreter; diff --git a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/celliterator/IterateByTimestampsWaysTest.java b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/celliterator/IterateByTimestampsWaysTest.java index 96d5bbaa8..0beb651b0 100644 --- a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/celliterator/IterateByTimestampsWaysTest.java +++ b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/celliterator/IterateByTimestampsWaysTest.java @@ -7,8 +7,8 @@ import java.io.IOException; import java.util.List; import java.util.stream.Collectors; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.grid.GridOSHWays; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.util.celliterator.CellIterator.IterateByTimestampEntry; import org.heigit.ohsome.oshdb.util.celliterator.helpers.GridOSHFactory; import org.heigit.ohsome.oshdb.util.geometry.helpers.OSMXmlReaderTagInterpreter; diff --git a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/celliterator/helpers/GridOSHFactory.java b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/celliterator/helpers/GridOSHFactory.java index 6aa670d6f..fa5bc59fe 100644 --- a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/celliterator/helpers/GridOSHFactory.java +++ b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/celliterator/helpers/GridOSHFactory.java @@ -87,7 +87,7 @@ public static GridOSHWays getGridOSHWays(OSMXmlReader osmXmlReader, int cellZoom Collection wayVersions = entry.getValue(); oshWays.add(OSHWayImpl.build(new ArrayList<>(wayVersions), wayVersions.stream().flatMap(osmWay -> - Arrays.stream(osmWay.getRefs()).map(ref -> oshNodes.get(ref.getId())) + Arrays.stream(osmWay.getMembers()).map(ref -> oshNodes.get(ref.getId())) ).collect(Collectors.toSet()) )); } @@ -153,7 +153,7 @@ private static Map getOSHWays(OSMXmlReader osmXmlReader)throws IOE Collection wayVersions = entry.getValue(); oshWays.put(entry.getKey(), OSHWayImpl.build(new ArrayList<>(wayVersions), wayVersions.stream().flatMap(osmWay -> - Arrays.stream(osmWay.getRefs()).map(ref -> oshNodes.get(ref.getId())) + Arrays.stream(osmWay.getMembers()).map(ref -> oshNodes.get(ref.getId())) ).collect(Collectors.toSet()) )); } diff --git a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/OSHDBGeometryBuilderTest.java b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/OSHDBGeometryBuilderTest.java index d057c7aa3..7935643bd 100644 --- a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/OSHDBGeometryBuilderTest.java +++ b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/OSHDBGeometryBuilderTest.java @@ -4,9 +4,9 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; import org.heigit.ohsome.oshdb.osm.OSMEntity; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.heigit.ohsome.oshdb.util.geometry.helpers.FakeTagInterpreterAreaAlways; import org.heigit.ohsome.oshdb.util.geometry.helpers.FakeTagInterpreterAreaMultipolygonAllOuters; import org.heigit.ohsome.oshdb.util.geometry.helpers.FakeTagInterpreterAreaNever; diff --git a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/fip/FastBboxInPolygonTest.java b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/fip/FastBboxInPolygonTest.java index 62cdc6ea6..4400d1167 100644 --- a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/fip/FastBboxInPolygonTest.java +++ b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/fip/FastBboxInPolygonTest.java @@ -3,7 +3,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.util.geometry.OSHDBGeometryBuilder; import org.junit.Test; import org.locationtech.jts.geom.GeometryFactory; diff --git a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/fip/FastBboxOutsidePolygonTest.java b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/fip/FastBboxOutsidePolygonTest.java index ed27ed1fd..eeaa2cedd 100644 --- a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/fip/FastBboxOutsidePolygonTest.java +++ b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/fip/FastBboxOutsidePolygonTest.java @@ -3,7 +3,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; import org.junit.Test; import org.locationtech.jts.geom.MultiPolygon; import org.locationtech.jts.geom.Polygon; diff --git a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/helpers/FakeTagInterpreterAreaAlways.java b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/helpers/FakeTagInterpreterAreaAlways.java index 708f2ddc2..1ac15c5a7 100644 --- a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/helpers/FakeTagInterpreterAreaAlways.java +++ b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/helpers/FakeTagInterpreterAreaAlways.java @@ -8,7 +8,7 @@ public class FakeTagInterpreterAreaAlways extends FakeTagInterpreter { @Override public boolean isArea(OSMEntity e) { if (e instanceof OSMWay) { - OSMMember[] nds = ((OSMWay) e).getRefs(); + OSMMember[] nds = ((OSMWay) e).getMembers(); return (nds.length >= 4 && nds[0].getId() == nds[nds.length - 1].getId()); } return true; diff --git a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/helpers/OSMXmlReaderTagInterpreter.java b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/helpers/OSMXmlReaderTagInterpreter.java index c03b0c5c8..0a881aa7a 100644 --- a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/helpers/OSMXmlReaderTagInterpreter.java +++ b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/helpers/OSMXmlReaderTagInterpreter.java @@ -34,7 +34,7 @@ public OSMXmlReaderTagInterpreter(OSMXmlReader osmXmlReader) { @Override public boolean isArea(OSMEntity e) { if (e instanceof OSMWay) { - OSMMember[] nds = ((OSMWay) e).getRefs(); + OSMMember[] nds = ((OSMWay) e).getMembers(); return nds.length >= 4 && nds[0].getId() == nds[nds.length - 1].getId() && e.hasTagValue(area, areaYes); } diff --git a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/helpers/TimestampParser.java b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/helpers/TimestampParser.java index 745e32121..6f3614bb2 100644 --- a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/helpers/TimestampParser.java +++ b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/helpers/TimestampParser.java @@ -1,6 +1,6 @@ package org.heigit.ohsome.oshdb.util.geometry.helpers; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; import org.heigit.ohsome.oshdb.util.time.IsoDateTimeParser; public class TimestampParser { diff --git a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/incomplete/OSHDBGeometryBuilderTestPolygonIncompleteDataTest.java b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/incomplete/OSHDBGeometryBuilderTestPolygonIncompleteDataTest.java index 65c38f95e..8f345a8ae 100644 --- a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/incomplete/OSHDBGeometryBuilderTestPolygonIncompleteDataTest.java +++ b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/incomplete/OSHDBGeometryBuilderTestPolygonIncompleteDataTest.java @@ -4,8 +4,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; import org.heigit.ohsome.oshdb.osm.OSMEntity; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.heigit.ohsome.oshdb.util.geometry.OSHDBGeometryBuilder; import org.heigit.ohsome.oshdb.util.geometry.helpers.OSMXmlReaderTagInterpreter; import org.heigit.ohsome.oshdb.util.geometry.helpers.TimestampParser; diff --git a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/incomplete/OSHDBGeometryBuilderTestWayIncompleteDataTest.java b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/incomplete/OSHDBGeometryBuilderTestWayIncompleteDataTest.java index a678c51ed..891575e57 100644 --- a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/incomplete/OSHDBGeometryBuilderTestWayIncompleteDataTest.java +++ b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/incomplete/OSHDBGeometryBuilderTestWayIncompleteDataTest.java @@ -4,8 +4,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; import org.heigit.ohsome.oshdb.osm.OSMEntity; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.heigit.ohsome.oshdb.util.geometry.OSHDBGeometryBuilder; import org.heigit.ohsome.oshdb.util.geometry.helpers.OSMXmlReaderTagInterpreter; import org.heigit.ohsome.oshdb.util.geometry.helpers.TimestampParser; diff --git a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/osmhistorytestdata/OSHDBGeometryBuilderTestOsmHistoryTestDataNodesTest.java b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/osmhistorytestdata/OSHDBGeometryBuilderTestOsmHistoryTestDataNodesTest.java index f4c0fb551..4c9cd4a05 100644 --- a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/osmhistorytestdata/OSHDBGeometryBuilderTestOsmHistoryTestDataNodesTest.java +++ b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/osmhistorytestdata/OSHDBGeometryBuilderTestOsmHistoryTestDataNodesTest.java @@ -3,8 +3,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; import org.heigit.ohsome.oshdb.osm.OSMEntity; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.heigit.ohsome.oshdb.util.geometry.OSHDBGeometryBuilder; import org.heigit.ohsome.oshdb.util.geometry.helpers.OSMXmlReaderTagInterpreter; import org.heigit.ohsome.oshdb.util.geometry.helpers.TimestampParser; @@ -30,21 +30,21 @@ public void testGeometryChange() { // A single node, lat lon changed over time OSMEntity entity = testData.nodes().get(1L).get(0); // first appearance - OSHDBTimestamp timestamp = entity.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity); Geometry result = OSHDBGeometryBuilder.getGeometry(entity, timestamp, areaDecider); assertTrue(result instanceof Point); assertEquals(1.42, ((Point) result).getX(), DELTA); assertEquals(1.22, ((Point) result).getY(), DELTA); // second OSMEntity entity2 = testData.nodes().get(1L).get(1); - OSHDBTimestamp timestamp2 = entity2.getTimestamp(); + OSHDBTimestamp timestamp2 = new OSHDBTimestamp(entity2); Geometry result2 = OSHDBGeometryBuilder.getGeometry(entity2, timestamp2, areaDecider); assertTrue(result2 instanceof Point); assertEquals(1.42, ((Point) result2).getX(), DELTA); assertEquals(1.225, ((Point) result2).getY(), DELTA); // last OSMEntity entity3 = testData.nodes().get(1L).get(2); - OSHDBTimestamp timestamp3 = entity3.getTimestamp(); + OSHDBTimestamp timestamp3 = new OSHDBTimestamp(entity3); Geometry result3 = OSHDBGeometryBuilder.getGeometry(entity3, timestamp3, areaDecider); assertTrue(result3 instanceof Point); assertEquals(1.425, ((Point) result3).getX(), DELTA); @@ -70,19 +70,19 @@ public void testInvalidAccess() { public void testTagChange() { // A single node, tags changed over time OSMEntity entity = testData.nodes().get(2L).get(0); - OSHDBTimestamp timestamp = entity.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity); Geometry result = OSHDBGeometryBuilder.getGeometry(entity, timestamp, areaDecider); assertTrue(result instanceof Point); assertEquals(1.43, ((Point) result).getX(), DELTA); assertEquals(1.24, ((Point) result).getY(), DELTA); OSMEntity entity2 = testData.nodes().get(2L).get(1); - OSHDBTimestamp timestamp2 = entity2.getTimestamp(); + OSHDBTimestamp timestamp2 = new OSHDBTimestamp(entity2); Geometry result2 = OSHDBGeometryBuilder.getGeometry(entity2, timestamp2, areaDecider); assertTrue(result2 instanceof Point); assertEquals(1.43, ((Point) result2).getX(), DELTA); assertEquals(1.24, ((Point) result2).getY(), DELTA); OSMEntity entity3 = testData.nodes().get(2L).get(2); - OSHDBTimestamp timestamp3 = entity3.getTimestamp(); + OSHDBTimestamp timestamp3 = new OSHDBTimestamp(entity3.getEpochSecond()); Geometry result3 = OSHDBGeometryBuilder.getGeometry(entity3, timestamp3, areaDecider); assertTrue(result3 instanceof Point); assertEquals(1.43, ((Point) result3).getX(), DELTA); @@ -93,29 +93,29 @@ public void testTagChange() { public void testVisibleChange() { // A single node, visible changes OSMEntity entity = testData.nodes().get(3L).get(0); - OSHDBTimestamp timestamp = entity.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity); Geometry result = OSHDBGeometryBuilder.getGeometry(entity, timestamp, areaDecider); assertTrue(result instanceof Point); assertEquals(1.44, ((Point) result).getX(), DELTA); assertEquals(1.24, ((Point) result).getY(), DELTA); OSMEntity entity2 = testData.nodes().get(3L).get(1); - OSHDBTimestamp timestamp2 = entity2.getTimestamp(); + OSHDBTimestamp timestamp2 = new OSHDBTimestamp(entity2); Geometry result2 = OSHDBGeometryBuilder.getGeometry(entity2, timestamp2, areaDecider); assertTrue(result2 instanceof Point); assertTrue(result2.isEmpty()); OSMEntity entity3 = testData.nodes().get(3L).get(2); - OSHDBTimestamp timestamp3 = entity3.getTimestamp(); + OSHDBTimestamp timestamp3 = new OSHDBTimestamp(entity3); Geometry result3 = OSHDBGeometryBuilder.getGeometry(entity3, timestamp3, areaDecider); assertTrue(result3 instanceof Point); assertEquals(1.44, ((Point) result3).getX(), DELTA); assertEquals(1.24, ((Point) result3).getY(), DELTA); OSMEntity entity4 = testData.nodes().get(3L).get(3); - OSHDBTimestamp timestamp4 = entity4.getTimestamp(); + OSHDBTimestamp timestamp4 = new OSHDBTimestamp(entity4); Geometry result4 = OSHDBGeometryBuilder.getGeometry(entity4, timestamp4, areaDecider); assertTrue(result4 instanceof Point); assertTrue(result4.isEmpty()); OSMEntity entity5 = testData.nodes().get(3L).get(4); - OSHDBTimestamp timestamp5 = entity5.getTimestamp(); + OSHDBTimestamp timestamp5 = new OSHDBTimestamp(entity5); Geometry result5 = OSHDBGeometryBuilder.getGeometry(entity5, timestamp5, areaDecider); assertTrue(result5 instanceof Point); assertEquals(1.44, ((Point) result5).getX(), DELTA); @@ -126,36 +126,36 @@ public void testVisibleChange() { public void testMultipleChanges() { // A single node, various changes over time OSMEntity entity = testData.nodes().get(4L).get(0); - OSHDBTimestamp timestamp = entity.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity); Geometry result = OSHDBGeometryBuilder.getGeometry(entity, timestamp, areaDecider); assertTrue(result instanceof Point); assertEquals(1.42, ((Point) result).getX(), DELTA); assertEquals(1.21, ((Point) result).getY(), DELTA); OSMEntity entity2 = testData.nodes().get(4L).get(1); - OSHDBTimestamp timestamp2 = entity2.getTimestamp(); + OSHDBTimestamp timestamp2 = new OSHDBTimestamp(entity2); Geometry result2 = OSHDBGeometryBuilder.getGeometry(entity2, timestamp2, areaDecider); assertTrue(result2 instanceof Point); assertEquals(1.425, ((Point) result2).getX(), DELTA); assertEquals(1.20, ((Point) result2).getY(), DELTA); OSMEntity entity3 = testData.nodes().get(4L).get(2); - OSHDBTimestamp timestamp3 = entity3.getTimestamp(); + OSHDBTimestamp timestamp3 = new OSHDBTimestamp(entity3); Geometry result3 = OSHDBGeometryBuilder.getGeometry(entity3, timestamp3, areaDecider); assertTrue(result3 instanceof Point); assertTrue(result3.isEmpty()); OSMEntity entity4 = testData.nodes().get(4L).get(3); - OSHDBTimestamp timestamp4 = entity4.getTimestamp(); + OSHDBTimestamp timestamp4 = new OSHDBTimestamp(entity4); Geometry result4 = OSHDBGeometryBuilder.getGeometry(entity4, timestamp4, areaDecider); assertTrue(result4 instanceof Point); assertEquals(1.42, ((Point) result4).getX(), DELTA); assertEquals(1.21, ((Point) result4).getY(), DELTA); OSMEntity entity5 = testData.nodes().get(4L).get(4); - OSHDBTimestamp timestamp5 = entity5.getTimestamp(); + OSHDBTimestamp timestamp5 = new OSHDBTimestamp(entity5); Geometry result5 = OSHDBGeometryBuilder.getGeometry(entity5, timestamp5, areaDecider); assertTrue(result5 instanceof Point); assertEquals(1.42, ((Point) result5).getX(), DELTA); assertEquals(1.215, ((Point) result5).getY(), DELTA); OSMEntity entity6 = testData.nodes().get(4L).get(5); - OSHDBTimestamp timestamp6 = entity6.getTimestamp(); + OSHDBTimestamp timestamp6 = new OSHDBTimestamp(entity6); Geometry result6 = OSHDBGeometryBuilder.getGeometry(entity6, timestamp6, areaDecider); assertTrue(result6 instanceof Point); assertEquals(1.42, ((Point) result6).getX(), DELTA); diff --git a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/osmhistorytestdata/OSHDBGeometryBuilderTestOsmHistoryTestDataRelationNotMultipolygonTest.java b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/osmhistorytestdata/OSHDBGeometryBuilderTestOsmHistoryTestDataRelationNotMultipolygonTest.java index df50074e1..fc90ac515 100644 --- a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/osmhistorytestdata/OSHDBGeometryBuilderTestOsmHistoryTestDataRelationNotMultipolygonTest.java +++ b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/osmhistorytestdata/OSHDBGeometryBuilderTestOsmHistoryTestDataRelationNotMultipolygonTest.java @@ -5,8 +5,8 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; import org.heigit.ohsome.oshdb.osm.OSMEntity; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.heigit.ohsome.oshdb.util.geometry.OSHDBGeometryBuilder; import org.heigit.ohsome.oshdb.util.geometry.helpers.OSMXmlReaderTagInterpreter; import org.heigit.ohsome.oshdb.util.geometry.helpers.TimestampParser; @@ -33,7 +33,7 @@ public OSHDBGeometryBuilderTestOsmHistoryTestDataRelationNotMultipolygonTest() { public void testGeometryChange() { // relation getting more ways, one disappears, last version not valid OSMEntity entity = testData.relations().get(500L).get(0); - OSHDBTimestamp timestamp = entity.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity); try { Geometry result = OSHDBGeometryBuilder.getGeometry(entity, timestamp, areaDecider); assertTrue(result instanceof GeometryCollection); @@ -44,7 +44,7 @@ public void testGeometryChange() { } // second version OSMEntity entity1 = testData.relations().get(500L).get(1); - OSHDBTimestamp timestamp1 = entity1.getTimestamp(); + OSHDBTimestamp timestamp1 = new OSHDBTimestamp(entity1); try { Geometry result1 = OSHDBGeometryBuilder.getGeometry(entity1, timestamp1, areaDecider); assertTrue(result1 instanceof GeometryCollection); @@ -55,7 +55,7 @@ public void testGeometryChange() { } // third version OSMEntity entity2 = testData.relations().get(500L).get(2); - OSHDBTimestamp timestamp2 = entity2.getTimestamp(); + OSHDBTimestamp timestamp2 = new OSHDBTimestamp(entity2); try { Geometry result2 = OSHDBGeometryBuilder.getGeometry(entity1, timestamp2, areaDecider); assertTrue(result2 instanceof GeometryCollection || result2 instanceof Polygonal); @@ -70,7 +70,7 @@ public void testGeometryChange() { public void testVisibleChange() { // relation visible tag changed OSMEntity entity = testData.relations().get(501L).get(0); - OSHDBTimestamp timestamp = entity.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity); try { Geometry result = OSHDBGeometryBuilder.getGeometry(entity, timestamp, areaDecider); assertTrue(result instanceof GeometryCollection); @@ -84,7 +84,7 @@ public void testVisibleChange() { } // second version OSMEntity entity1 = testData.relations().get(501L).get(1); - OSHDBTimestamp timestamp1 = entity1.getTimestamp(); + OSHDBTimestamp timestamp1 = new OSHDBTimestamp(entity1); try { Geometry result1 = OSHDBGeometryBuilder.getGeometry(entity1, timestamp1, areaDecider); assertTrue(result1.isEmpty()); @@ -94,7 +94,7 @@ public void testVisibleChange() { } // third version OSMEntity entity2 = testData.relations().get(501L).get(2); - OSHDBTimestamp timestamp2 = entity2.getTimestamp(); + OSHDBTimestamp timestamp2 = new OSHDBTimestamp(entity2); try { Geometry result2 = OSHDBGeometryBuilder.getGeometry(entity2, timestamp2, areaDecider); assertTrue(result2 instanceof GeometryCollection); @@ -114,7 +114,7 @@ public void testWaysNotExistent() { OSMEntity entity = testData.relations().get(502L).get(0); Geometry result; try { - OSHDBTimestamp timestamp = entity.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity); result = OSHDBGeometryBuilder.getGeometry(entity, timestamp, areaDecider); assertTrue(result instanceof GeometryCollection); assertTrue(result.isValid()); @@ -129,7 +129,7 @@ public void testWaysNotExistent() { public void testTagChange() { // relation tags changing OSMEntity entity = testData.relations().get(503L).get(0); - OSHDBTimestamp timestamp = entity.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity); try { Geometry result = OSHDBGeometryBuilder.getGeometry(entity, timestamp, areaDecider); assertTrue(result instanceof GeometryCollection); @@ -142,7 +142,7 @@ public void testTagChange() { } // second version OSMEntity entity1 = testData.relations().get(503L).get(1); - OSHDBTimestamp timestamp1 = entity1.getTimestamp(); + OSHDBTimestamp timestamp1 = new OSHDBTimestamp(entity1); try { Geometry result1 = OSHDBGeometryBuilder.getGeometry(entity1, timestamp1, areaDecider); assertTrue(result1 instanceof GeometryCollection); @@ -155,7 +155,7 @@ public void testTagChange() { } // third version OSMEntity entity2 = testData.relations().get(503L).get(2); - OSHDBTimestamp timestamp2 = entity2.getTimestamp(); + OSHDBTimestamp timestamp2 = new OSHDBTimestamp(entity2); try { Geometry result2 = OSHDBGeometryBuilder.getGeometry(entity2, timestamp2, areaDecider); assertTrue(result2 instanceof GeometryCollection); @@ -172,7 +172,7 @@ public void testTagChange() { public void testGeometryChangeOfNodeRefsInWays() { // relation, way 109 -inner- and 110 -outer- ways changed node refs OSMEntity entity = testData.relations().get(504L).get(0); - OSHDBTimestamp timestamp = entity.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity); try { Geometry result = OSHDBGeometryBuilder.getGeometry(entity, timestamp, areaDecider); assertTrue(result instanceof GeometryCollection); @@ -186,7 +186,7 @@ public void testGeometryChangeOfNodeRefsInWays() { } // second version OSMEntity entity1 = testData.relations().get(504L).get(1); - OSHDBTimestamp timestamp1 = entity1.getTimestamp(); + OSHDBTimestamp timestamp1 = new OSHDBTimestamp(entity1); try { Geometry result1 = OSHDBGeometryBuilder.getGeometry(entity1, timestamp1, areaDecider); assertTrue(result1 instanceof GeometryCollection); @@ -219,7 +219,7 @@ public void testGeometryChangeOfNodeRefsInWays() { public void testGeometryChangeOfNodeCoordinatesInWay() { // relation, way 112 changed node coordinates OSMEntity entity = testData.relations().get(505L).get(0); - OSHDBTimestamp timestamp = entity.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity); try { Geometry result = OSHDBGeometryBuilder.getGeometry(entity, timestamp, areaDecider); assertTrue(result instanceof GeometryCollection); @@ -250,7 +250,7 @@ public void testGeometryChangeOfNodeCoordinatesInWay() { public void testGeometryChangeOfNodeCoordinatesInRelationAndWay() { // relation, with node members, nodes changed coordinates OSMEntity entity = testData.relations().get(506L).get(0); - OSHDBTimestamp timestamp = entity.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity); try { Geometry result = OSHDBGeometryBuilder.getGeometry(entity, timestamp, areaDecider); assertTrue(result instanceof GeometryCollection); @@ -286,7 +286,7 @@ public void testGeometryCollection() { // relation, not valid, should be a not empty geometryCollection OSMEntity entity = testData.relations().get(507L).get(0); try { - OSHDBTimestamp timestamp = entity.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity); Geometry result = OSHDBGeometryBuilder.getGeometry(entity, timestamp, areaDecider); assertTrue(result instanceof GeometryCollection); assertEquals(6, result.getNumGeometries()); @@ -303,7 +303,7 @@ public void testNodesOfWaysNotExistent() { OSMEntity entity = testData.relations().get(508L).get(0); Geometry result; try { - OSHDBTimestamp timestamp = entity.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity); result = OSHDBGeometryBuilder.getGeometry(entity, timestamp, areaDecider); assertTrue(result instanceof GeometryCollection); assertTrue(result.isValid()); @@ -318,7 +318,7 @@ public void testVisibleChangeOfNodeInWay() { // relation, way member: node 52 changes visible tag OSMEntity entity = testData.relations().get(509L).get(0); // timestamp where node 52 visible is false - OSHDBTimestamp timestamp = entity.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity); try { Geometry result = OSHDBGeometryBuilder.getGeometry(entity, timestamp, areaDecider); assertTrue(result instanceof GeometryCollection); @@ -350,7 +350,7 @@ public void testVisibleChangeOfNodeInWay() { public void testTagChangeOfNodeInWay() { // relation, way member: node 53 changes tags, 51 changes coordinates OSMEntity entity = testData.relations().get(510L).get(0); - OSHDBTimestamp timestamp = entity.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity); try { Geometry result = OSHDBGeometryBuilder.getGeometry(entity, timestamp, areaDecider); assertTrue(result instanceof GeometryCollection); @@ -381,7 +381,7 @@ public void testTagChangeOfNodeInWay() { public void testVisibleChangeOfWay() { // relation, way member: way 119 changes visible tag OSMEntity entity = testData.relations().get(511L).get(0); - OSHDBTimestamp timestamp = entity.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity); try { Geometry result = OSHDBGeometryBuilder.getGeometry(entity, timestamp, areaDecider); assertTrue(result instanceof GeometryCollection); @@ -410,7 +410,7 @@ public void testVisibleChangeOfWay() { public void testVisibleChangeOfOneWayOfOuterRing() { // relation, 2 way members making outer ring: way 120 changes visible tag later, 121 not OSMEntity entity = testData.relations().get(512L).get(0); - OSHDBTimestamp timestamp = entity.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity); try { Geometry result = OSHDBGeometryBuilder.getGeometry(entity, timestamp, areaDecider); assertTrue(result instanceof GeometryCollection); @@ -442,7 +442,7 @@ public void testVisibleChangeOfOneWayOfOuterRing() { public void testTagChangeOfWay() { // relation, way member: way 122 changes tags OSMEntity entity = testData.relations().get(513L).get(0); - OSHDBTimestamp timestamp = entity.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity); try { Geometry result = OSHDBGeometryBuilder.getGeometry(entity, timestamp, areaDecider); assertTrue(result instanceof GeometryCollection); @@ -485,7 +485,7 @@ public void testTagChangeOfWay() { public void testOneOfTwoPolygonDisappears() { // relation, at the beginning two polygons, one disappears later OSMEntity entity = testData.relations().get(514L).get(0); - OSHDBTimestamp timestamp = entity.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity); try { Geometry result = OSHDBGeometryBuilder.getGeometry(entity, timestamp, areaDecider); assertTrue(result instanceof GeometryCollection); @@ -499,7 +499,7 @@ public void testOneOfTwoPolygonDisappears() { } // second version OSMEntity entity1 = testData.relations().get(514L).get(1); - OSHDBTimestamp timestamp1 = entity1.getTimestamp(); + OSHDBTimestamp timestamp1 = new OSHDBTimestamp(entity1); try { Geometry result1 = OSHDBGeometryBuilder.getGeometry(entity1, timestamp1, areaDecider); assertTrue(result1 instanceof GeometryCollection); @@ -516,7 +516,7 @@ public void testOneOfTwoPolygonDisappears() { public void testWaySplitUpInTwo() { // relation, at the beginning one way, split up later into 2 ways OSMEntity entity = testData.relations().get(515L).get(0); - OSHDBTimestamp timestamp = entity.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity); try { Geometry result = OSHDBGeometryBuilder.getGeometry(entity, timestamp, areaDecider); assertTrue(result instanceof GeometryCollection); @@ -529,7 +529,7 @@ public void testWaySplitUpInTwo() { } // second version OSMEntity entity1 = testData.relations().get(515L).get(1); - OSHDBTimestamp timestamp1 = entity1.getTimestamp(); + OSHDBTimestamp timestamp1 = new OSHDBTimestamp(entity1); try { Geometry result1 = OSHDBGeometryBuilder.getGeometry(entity1, timestamp1, areaDecider); assertTrue(result1 instanceof GeometryCollection); @@ -547,7 +547,7 @@ public void testWaySplitUpInTwo() { public void testRestrictionRoles() { // relation, restriction, role changes OSMEntity entity1 = testData.relations().get(518L).get(0); - OSHDBTimestamp timestamp1 = entity1.getTimestamp(); + OSHDBTimestamp timestamp1 = new OSHDBTimestamp(entity1); try { Geometry result = OSHDBGeometryBuilder.getGeometry(entity1, timestamp1, areaDecider); assertTrue(result instanceof GeometryCollection); @@ -565,7 +565,7 @@ public void testRestrictionRoles() { public void testRolesArePartAndOutline() { // relation as building with role=part and outline OSMEntity entity1 = testData.relations().get(519L).get(0); - OSHDBTimestamp timestamp1 = entity1.getTimestamp(); + OSHDBTimestamp timestamp1 = new OSHDBTimestamp(entity1); try { Geometry result = OSHDBGeometryBuilder.getGeometry(entity1, timestamp1, areaDecider); assertTrue(result instanceof GeometryCollection); @@ -578,7 +578,7 @@ public void testRolesArePartAndOutline() { } // second version OSMEntity entity2 = testData.relations().get(519L).get(1); - OSHDBTimestamp timestamp2 = entity2.getTimestamp(); + OSHDBTimestamp timestamp2 = new OSHDBTimestamp(entity2); try { Geometry result2 = OSHDBGeometryBuilder.getGeometry(entity2, timestamp2, areaDecider); assertTrue(result2 instanceof GeometryCollection); diff --git a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/osmhistorytestdata/OSHDBGeometryBuilderTestOsmHistoryTestDataRelationTest.java b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/osmhistorytestdata/OSHDBGeometryBuilderTestOsmHistoryTestDataRelationTest.java index a932a3b36..bf0ed38eb 100644 --- a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/osmhistorytestdata/OSHDBGeometryBuilderTestOsmHistoryTestDataRelationTest.java +++ b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/osmhistorytestdata/OSHDBGeometryBuilderTestOsmHistoryTestDataRelationTest.java @@ -5,9 +5,9 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; import org.heigit.ohsome.oshdb.osm.OSMEntity; import org.heigit.ohsome.oshdb.osm.OSMRelation; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.heigit.ohsome.oshdb.util.geometry.OSHDBGeometryBuilder; import org.heigit.ohsome.oshdb.util.geometry.helpers.OSMXmlReaderTagInterpreter; import org.heigit.ohsome.oshdb.util.geometry.helpers.TimestampParser; @@ -37,7 +37,7 @@ public OSHDBGeometryBuilderTestOsmHistoryTestDataRelationTest() { public void testGeometryChange() throws ParseException { // relation getting more ways, one disappears, last version not valid OSMEntity entity = testData.relations().get(500L).get(0); - OSHDBTimestamp timestamp = entity.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity); Geometry result = OSHDBGeometryBuilder.getGeometry(entity, timestamp, areaDecider); assertTrue(result instanceof MultiPolygon); assertTrue(result.isValid()); @@ -50,7 +50,7 @@ public void testGeometryChange() throws ParseException { assertEquals(expectedPolygon.getArea(), intersection.getArea(), DELTA); // second version OSMEntity entity1 = testData.relations().get(500L).get(1); - OSHDBTimestamp timestamp1 = entity1.getTimestamp(); + OSHDBTimestamp timestamp1 = new OSHDBTimestamp(entity1); Geometry result1 = OSHDBGeometryBuilder.getGeometry(entity1, timestamp1, areaDecider); assertTrue(result1 instanceof MultiPolygon); assertTrue(result1.isValid()); @@ -64,7 +64,7 @@ public void testGeometryChange() throws ParseException { assertEquals(expectedPolygon1.getArea(), intersection1.getArea(), DELTA); // third version OSMEntity entity2 = testData.relations().get(500L).get(2); - OSHDBTimestamp timestamp2 = entity2.getTimestamp(); + OSHDBTimestamp timestamp2 = new OSHDBTimestamp(entity2); try { Geometry result2 = OSHDBGeometryBuilder.getGeometry(entity1, timestamp2, areaDecider); assertTrue(result2 instanceof GeometryCollection || result2 instanceof Polygonal); @@ -79,7 +79,7 @@ public void testGeometryChange() throws ParseException { public void testVisibleChange() throws ParseException { // relation visible tag changed OSMEntity entity = testData.relations().get(501L).get(0); - OSHDBTimestamp timestamp = entity.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity); Geometry result = OSHDBGeometryBuilder.getGeometry(entity, timestamp, areaDecider); assertTrue(result instanceof MultiPolygon); assertTrue(result.isValid()); @@ -92,12 +92,12 @@ public void testVisibleChange() throws ParseException { assertEquals(expectedPolygon.getArea(), intersection.getArea(), DELTA); // second version OSMEntity entity1 = testData.relations().get(501L).get(1); - OSHDBTimestamp timestamp1 = entity1.getTimestamp(); + OSHDBTimestamp timestamp1 = new OSHDBTimestamp(entity1); Geometry result1 = OSHDBGeometryBuilder.getGeometry(entity1, timestamp1, areaDecider); assertTrue(result1.isEmpty()); // third version OSMEntity entity2 = testData.relations().get(501L).get(2); - OSHDBTimestamp timestamp2 = entity2.getTimestamp(); + OSHDBTimestamp timestamp2 = new OSHDBTimestamp(entity2); Geometry result2 = OSHDBGeometryBuilder.getGeometry(entity2, timestamp2, areaDecider); assertTrue(result2 instanceof MultiPolygon); assertTrue(result2.isValid()); @@ -115,7 +115,7 @@ public void testWaysNotExistent() { // relation with two ways, both missing OSMEntity entity = testData.relations().get(502L).get(0); try { - OSHDBTimestamp timestamp = entity.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity); OSHDBGeometryBuilder.getGeometry(entity, timestamp, areaDecider); } catch (Exception e) { e.printStackTrace(); @@ -127,7 +127,7 @@ public void testWaysNotExistent() { public void testTagChange() throws ParseException { // relation tags changing OSMEntity entity = testData.relations().get(503L).get(0); - OSHDBTimestamp timestamp = entity.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity); Geometry result = OSHDBGeometryBuilder.getGeometry(entity, timestamp, areaDecider); assertTrue(result instanceof Polygon); assertTrue(result.isValid()); @@ -139,7 +139,7 @@ public void testTagChange() throws ParseException { assertEquals(expectedPolygon.getArea(), intersection.getArea(), DELTA); // second version OSMEntity entity1 = testData.relations().get(503L).get(1); - OSHDBTimestamp timestamp1 = entity1.getTimestamp(); + OSHDBTimestamp timestamp1 = new OSHDBTimestamp(entity1); Geometry result1 = OSHDBGeometryBuilder.getGeometry(entity1, timestamp1, areaDecider); assertTrue(result1 instanceof Polygon); assertTrue(result1.isValid()); @@ -151,7 +151,7 @@ public void testTagChange() throws ParseException { assertEquals(expectedPolygon1.getArea(), intersection1.getArea(), DELTA); // third version OSMEntity entity2 = testData.relations().get(503L).get(2); - OSHDBTimestamp timestamp2 = entity2.getTimestamp(); + OSHDBTimestamp timestamp2 = new OSHDBTimestamp(entity2); Geometry result2 = OSHDBGeometryBuilder.getGeometry(entity2, timestamp2, areaDecider); assertTrue(result2 instanceof Polygon); assertTrue(result2.isValid()); @@ -167,7 +167,7 @@ public void testTagChange() throws ParseException { public void testGeometryChangeOfNodeRefsInWays() throws ParseException { // relation, way 109 -inner- and 110 -outer- ways changed node refs OSMEntity entity = testData.relations().get(504L).get(0); - OSHDBTimestamp timestamp = entity.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity); Geometry result = OSHDBGeometryBuilder.getGeometry(entity, timestamp, areaDecider); assertTrue(result instanceof Polygon); assertTrue(result.isValid()); @@ -180,7 +180,7 @@ public void testGeometryChangeOfNodeRefsInWays() throws ParseException { assertEquals(expectedPolygon.getArea(), intersection.getArea(), DELTA); // second version OSMEntity entity1 = testData.relations().get(504L).get(1); - OSHDBTimestamp timestamp1 = entity1.getTimestamp(); + OSHDBTimestamp timestamp1 = new OSHDBTimestamp(entity1); Geometry result1 = OSHDBGeometryBuilder.getGeometry(entity1, timestamp1, areaDecider); assertTrue(result1 instanceof Polygon); assertTrue(result1.isValid()); @@ -211,7 +211,7 @@ public void testGeometryChangeOfNodeRefsInWays() throws ParseException { public void testGeometryChangeOfNodeCoordinatesInWay() throws ParseException { // relation, way 112 changed node coordinates OSMEntity entity = testData.relations().get(505L).get(0); - OSHDBTimestamp timestamp = entity.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity); Geometry result = OSHDBGeometryBuilder.getGeometry(entity, timestamp, areaDecider); assertTrue(result instanceof Polygon); assertTrue(result.isValid()); @@ -240,7 +240,7 @@ public void testGeometryChangeOfNodeCoordinatesInWay() throws ParseException { public void testGeometryChangeOfNodeCoordinatesInRelationAndWay() throws ParseException { // relation, with node members, nodes changed coordinates OSMEntity entity = testData.relations().get(506L).get(0); - OSHDBTimestamp timestamp = entity.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity); Geometry result = OSHDBGeometryBuilder.getGeometry(entity, timestamp, areaDecider); assertTrue(result instanceof Polygon); assertTrue(result.isValid()); @@ -271,7 +271,7 @@ public void testGeometryCollection() { // https://gitlab.gistools.geog.uni-heidelberg.de/giscience/big-data/ohsome/oshdb/issues/143 OSMEntity entity = testData.relations().get(507L).get(0); try { - OSHDBTimestamp timestamp = entity.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity); Geometry result = OSHDBGeometryBuilder.getGeometry(entity, timestamp, areaDecider); assertTrue(result instanceof GeometryCollection); assertEquals(6, result.getNumGeometries()); @@ -287,7 +287,7 @@ public void testNodesOfWaysNotExistent() { // relation with two ways, all nodes not existing OSMEntity entity = testData.relations().get(508L).get(0); try { - OSHDBTimestamp timestamp = entity.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity); OSHDBGeometryBuilder.getGeometry(entity, timestamp, areaDecider); } catch (Exception e) { e.printStackTrace(); @@ -300,7 +300,7 @@ public void testVisibleChangeOfNodeInWay() throws ParseException { // relation, way member: node 52 changes visible tag OSMEntity entity = testData.relations().get(509L).get(0); // timestamp where node 52 visible is false - OSHDBTimestamp timestamp = entity.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity); Geometry result = OSHDBGeometryBuilder.getGeometry(entity, timestamp, areaDecider); assertTrue(result instanceof Polygon); assertTrue(result.isValid()); @@ -330,7 +330,7 @@ public void testVisibleChangeOfNodeInWay() throws ParseException { public void testTagChangeOfNodeInWay() throws ParseException { // relation, way member: node 53 changes tags, 51 changes coordinates OSMEntity entity = testData.relations().get(510L).get(0); - OSHDBTimestamp timestamp = entity.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity); Geometry result = OSHDBGeometryBuilder.getGeometry(entity, timestamp, areaDecider); assertTrue(result instanceof Polygon); assertTrue(result.isValid()); @@ -359,7 +359,7 @@ public void testTagChangeOfNodeInWay() throws ParseException { public void testVisibleChangeOfWay() throws ParseException { // relation, way member: way 119 changes visible tag OSMEntity entity = testData.relations().get(511L).get(0); - OSHDBTimestamp timestamp = entity.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity); Geometry result = OSHDBGeometryBuilder.getGeometry(entity, timestamp, areaDecider); assertTrue(result instanceof Polygon); assertTrue(result.isValid()); @@ -381,7 +381,7 @@ public void testVisibleChangeOfWay() throws ParseException { public void testVisibleChangeOfOneWayOfOuterRing() throws ParseException { // relation, 2 way members making outer ring: way 120 changes visible tag later, 121 not OSMEntity entity = testData.relations().get(512L).get(0); - OSHDBTimestamp timestamp = entity.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity); Geometry result = OSHDBGeometryBuilder.getGeometry(entity, timestamp, areaDecider); assertTrue(result instanceof Polygon); assertTrue(result.isValid()); @@ -404,7 +404,7 @@ public void testVisibleChangeOfOneWayOfOuterRing() throws ParseException { public void testTagChangeOfWay() throws ParseException { // relation, way member: way 122 changes tags OSMEntity entity = testData.relations().get(513L).get(0); - OSHDBTimestamp timestamp = entity.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity); Geometry result = OSHDBGeometryBuilder.getGeometry(entity, timestamp, areaDecider); assertTrue(result instanceof Polygon); assertTrue(result.isValid()); @@ -444,7 +444,7 @@ public void testTagChangeOfWay() throws ParseException { public void testOneOfTwoPolygonDisappears() throws ParseException { // relation getting more ways, one disappears, last version not valid OSMEntity entity = testData.relations().get(514L).get(0); - OSHDBTimestamp timestamp = entity.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity); Geometry result = OSHDBGeometryBuilder.getGeometry(entity, timestamp, areaDecider); assertTrue(result instanceof MultiPolygon); assertTrue(result.isValid()); @@ -457,7 +457,7 @@ public void testOneOfTwoPolygonDisappears() throws ParseException { assertEquals(expectedPolygon.getArea(), intersection.getArea(), DELTA); // second version OSMEntity entity1 = testData.relations().get(514L).get(1); - OSHDBTimestamp timestamp1 = entity1.getTimestamp(); + OSHDBTimestamp timestamp1 = new OSHDBTimestamp(entity1); Geometry result1 = OSHDBGeometryBuilder.getGeometry(entity1, timestamp1, areaDecider); assertTrue(result1 instanceof Polygon); assertTrue(result1.isValid()); @@ -473,7 +473,7 @@ public void testOneOfTwoPolygonDisappears() throws ParseException { public void testWaySplitUpInTwo() throws ParseException { // relation, at the beginning one way, split up later into 2 ways OSMEntity entity = testData.relations().get(515L).get(0); - OSHDBTimestamp timestamp = entity.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity); Geometry result = OSHDBGeometryBuilder.getGeometry(entity, timestamp, areaDecider); assertTrue(result instanceof Polygon); assertTrue(result.isValid()); @@ -485,7 +485,7 @@ public void testWaySplitUpInTwo() throws ParseException { assertEquals(expectedPolygon.getArea(), intersection.getArea(), DELTA); // second version OSMEntity entity1 = testData.relations().get(515L).get(1); - OSHDBTimestamp timestamp1 = entity1.getTimestamp(); + OSHDBTimestamp timestamp1 = new OSHDBTimestamp(entity1); Geometry result1 = OSHDBGeometryBuilder.getGeometry(entity1, timestamp1, areaDecider); assertTrue(result1 instanceof Polygon); assertTrue(result1.isValid()); @@ -501,7 +501,7 @@ public void testWaySplitUpInTwo() throws ParseException { public void testNullRefEntities() { // broken rel references (=invalid OSM data) can occur after "partial" data redactions OSMRelation rel = testData.relations().get(524L).get(0); - OSHDBTimestamp timestamp = rel.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(rel); Geometry result = OSHDBGeometryBuilder.getGeometry(rel, timestamp, areaDecider); // no exception should have been thrown at this point assertTrue(result.getNumGeometries() < rel.getMembers().length); diff --git a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/osmhistorytestdata/OSHDBGeometryBuilderTestOsmHistoryTestDataWaysTest.java b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/osmhistorytestdata/OSHDBGeometryBuilderTestOsmHistoryTestDataWaysTest.java index 38aaa79d4..038fbc7bf 100644 --- a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/osmhistorytestdata/OSHDBGeometryBuilderTestOsmHistoryTestDataWaysTest.java +++ b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/osmhistorytestdata/OSHDBGeometryBuilderTestOsmHistoryTestDataWaysTest.java @@ -3,9 +3,9 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; import org.heigit.ohsome.oshdb.osm.OSMEntity; import org.heigit.ohsome.oshdb.osm.OSMWay; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.heigit.ohsome.oshdb.util.geometry.OSHDBGeometryBuilder; import org.heigit.ohsome.oshdb.util.geometry.helpers.OSMXmlReaderTagInterpreter; import org.heigit.ohsome.oshdb.util.geometry.helpers.TimestampParser; @@ -41,20 +41,20 @@ public void testGeometryChange() { // Way getting more nodes, one disappears // first appearance OSMEntity entity1 = testData.ways().get(100L).get(0); - OSHDBTimestamp timestamp = entity1.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity1); Geometry result1 = OSHDBGeometryBuilder.getGeometry(entity1, timestamp, areaDecider); double[][] expectedCoordinates1 = {{1.42, 1.22}, {1.42, 1.23}, {1.42, 1.24}, {1.42, 1.25}}; checkLineString(expectedCoordinates1, result1, 4); // second appearance OSMEntity entity2 = testData.ways().get(100L).get(1); - OSHDBTimestamp timestamp2 = entity2.getTimestamp(); + OSHDBTimestamp timestamp2 = new OSHDBTimestamp(entity2); Geometry result2 = OSHDBGeometryBuilder.getGeometry(entity2, timestamp2, areaDecider); double[][] expectedCoordinates2 = {{1.42, 1.22}, {1.42, 1.23}, {1.42, 1.24}, {1.42, 1.25}, {1.42, 1.26}, {1.42, 1.27}, {1.42, 1.28}, {1.43, 1.29}}; checkLineString(expectedCoordinates2, result2, 8); // last appearance OSMEntity entity3 = testData.ways().get(100L).get(2); - OSHDBTimestamp timestamp3 = entity3.getTimestamp(); + OSHDBTimestamp timestamp3 = new OSHDBTimestamp(entity3); Geometry result3 = OSHDBGeometryBuilder.getGeometry(entity3, timestamp3, areaDecider); double[][] expectedCoordinates3 = {{1.42, 1.22}, {1.42, 1.23}, {1.42, 1.24}, {1.42, 1.25}, {1.42, 1.26}, {1.42, 1.28}, {1.43, 1.29}, {1.43, 1.30}, {1.43, 1.31}}; @@ -74,13 +74,13 @@ public void testGeometryChangeOfNodeInWay() { // Way with two then three nodes, changing lat lon // first appearance OSMEntity entity1 = testData.ways().get(101L).get(0); - OSHDBTimestamp timestamp = entity1.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity1); Geometry result1 = OSHDBGeometryBuilder.getGeometry(entity1, timestamp, areaDecider); double[][] expectedCoordinates1 = {{1.42, 1.22}, {1.44, 1.22}}; checkLineString(expectedCoordinates1, result1, 2); // last appearance OSMEntity entity2 = testData.ways().get(101L).get(1); - OSHDBTimestamp timestamp2 = entity2.getTimestamp(); + OSHDBTimestamp timestamp2 = new OSHDBTimestamp(entity2); Geometry result2 = OSHDBGeometryBuilder.getGeometry(entity2, timestamp2, areaDecider); double[][] expectedCoordinates2 = {{1.425, 1.23}, {1.44, 1.23}, {1.43, 1.30}}; checkLineString(expectedCoordinates2, result2, 3); @@ -98,14 +98,14 @@ public void testVisibleChange() { // Way visible changed // first appearance OSMEntity entity1 = testData.ways().get(102L).get(0); - OSHDBTimestamp timestamp = entity1.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity1); Geometry result1 = OSHDBGeometryBuilder.getGeometry(entity1, timestamp, areaDecider); assertTrue(result1 instanceof LineString); assertEquals(3, result1.getNumPoints()); // last appearance OSMEntity entity2 = testData.ways().get(102L).get(1); - OSHDBTimestamp timestamp2 = entity2.getTimestamp(); + OSHDBTimestamp timestamp2 = new OSHDBTimestamp(entity2); Geometry result2 = OSHDBGeometryBuilder.getGeometry(entity2, timestamp2, areaDecider); assertTrue(result2.isEmpty()); } @@ -115,19 +115,19 @@ public void testTagChange() { // Way tags changed // first appearance OSMEntity entity1 = testData.ways().get(103L).get(0); - OSHDBTimestamp timestamp = entity1.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity1); Geometry result1 = OSHDBGeometryBuilder.getGeometry(entity1, timestamp, areaDecider); assertTrue(result1 instanceof LineString); assertEquals(3, result1.getNumPoints()); // second appearance OSMEntity entity2 = testData.ways().get(103L).get(1); - OSHDBTimestamp timestamp2 = entity2.getTimestamp(); + OSHDBTimestamp timestamp2 = new OSHDBTimestamp(entity2); Geometry result2 = OSHDBGeometryBuilder.getGeometry(entity2, timestamp2, areaDecider); assertTrue(result2 instanceof LineString); assertEquals(5, result2.getNumPoints()); // last appearance OSMEntity entity3 = testData.ways().get(103L).get(1); - OSHDBTimestamp timestamp3 = entity3.getTimestamp(); + OSHDBTimestamp timestamp3 = new OSHDBTimestamp(entity3); Geometry result3 = OSHDBGeometryBuilder.getGeometry(entity3, timestamp3, areaDecider); assertTrue(result3 instanceof LineString); assertEquals(5, result3.getNumPoints()); @@ -139,14 +139,14 @@ public void testMultipleChangesOnNodesOfWay() { // Way various things changed // first appearance OSMEntity entity1 = testData.ways().get(104L).get(0); - OSHDBTimestamp timestamp = entity1.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity1); Geometry result1 = OSHDBGeometryBuilder.getGeometry(entity1, timestamp, areaDecider); assertTrue(result1 instanceof LineString); assertEquals(2, result1.getNumPoints()); // last appearance OSMEntity entity2 = testData.ways().get(104L).get(1); - OSHDBTimestamp timestamp2 = entity2.getTimestamp(); + OSHDBTimestamp timestamp2 = new OSHDBTimestamp(entity2); Geometry result2 = OSHDBGeometryBuilder.getGeometry(entity2, timestamp2, areaDecider); assertTrue(result2 instanceof LineString); assertEquals(3, result2.getNumPoints()); @@ -157,24 +157,24 @@ public void testMultipleChangesOnNodesAndWays() { // way and nodes have different changes // first appearance OSMEntity entity1 = testData.ways().get(105L).get(0); - OSHDBTimestamp timestamp = entity1.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity1); Geometry result1 = OSHDBGeometryBuilder.getGeometry(entity1, timestamp, areaDecider); assertTrue(result1 instanceof LineString); assertEquals(2, result1.getNumPoints()); // second appearance OSMEntity entity2 = testData.ways().get(105L).get(1); - OSHDBTimestamp timestamp2 = entity2.getTimestamp(); + OSHDBTimestamp timestamp2 = new OSHDBTimestamp(entity2); Geometry result2 = OSHDBGeometryBuilder.getGeometry(entity2, timestamp2, areaDecider); assertTrue(result2 instanceof LineString); assertEquals(2, result2.getNumPoints()); // third appearance OSMEntity entity3 = testData.ways().get(105L).get(2); - OSHDBTimestamp timestamp3 = entity3.getTimestamp(); + OSHDBTimestamp timestamp3 = new OSHDBTimestamp(entity3); Geometry result3 = OSHDBGeometryBuilder.getGeometry(entity3, timestamp3, areaDecider); assertTrue(result3.isEmpty()); // last appearance OSMEntity entity4 = testData.ways().get(105L).get(3); - OSHDBTimestamp timestamp4 = entity4.getTimestamp(); + OSHDBTimestamp timestamp4 = new OSHDBTimestamp(entity4); Geometry result4 = OSHDBGeometryBuilder.getGeometry(entity4, timestamp4, areaDecider); assertTrue(result4 instanceof LineString); assertEquals(4, result4.getNumPoints()); @@ -187,14 +187,14 @@ public void testPolygonAreaYesTagDisappears() { // way seems to be polygon with area=yes, later linestring because area=yes deleted // first appearance OSMEntity entity1 = testData.ways().get(106L).get(0); - OSHDBTimestamp timestamp = entity1.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity1); Geometry result1 = OSHDBGeometryBuilder.getGeometry(entity1, timestamp, areaDecider); assertTrue(result1 instanceof Polygon); assertEquals(5, result1.getNumPoints()); // last appearance OSMEntity entity4 = testData.ways().get(106L).get(1); - OSHDBTimestamp timestamp4 = entity4.getTimestamp(); + OSHDBTimestamp timestamp4 = new OSHDBTimestamp(entity4); Geometry result4 = OSHDBGeometryBuilder.getGeometry(entity4, timestamp4, areaDecider); assertTrue(result4 instanceof LineString); assertEquals(5, result4.getNumPoints()); @@ -206,14 +206,14 @@ public void testPolygonAreaYesNodeDisappears() { // way seems to be polygon with area=yes, later linestring because area=yes deleted // first appearance OSMEntity entity1 = testData.ways().get(107L).get(0); - OSHDBTimestamp timestamp = entity1.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(entity1); Geometry result1 = OSHDBGeometryBuilder.getGeometry(entity1, timestamp, areaDecider); assertTrue(result1 instanceof Polygon); assertEquals(5, result1.getNumPoints()); // last appearance OSMEntity entity4 = testData.ways().get(107L).get(1); - OSHDBTimestamp timestamp4 = entity4.getTimestamp(); + OSHDBTimestamp timestamp4 = new OSHDBTimestamp(entity4); Geometry result4 = OSHDBGeometryBuilder.getGeometry(entity4, timestamp4, areaDecider); assertTrue(result4 instanceof LineString); assertEquals(4, result4.getNumPoints()); @@ -223,9 +223,9 @@ public void testPolygonAreaYesNodeDisappears() { public void testNullRefEntities() { // broken way references (=invalid OSM data) can occur after "partial" data redactions OSMWay way = testData.ways().get(177974941L).get(0); - OSHDBTimestamp timestamp = way.getTimestamp(); + OSHDBTimestamp timestamp = new OSHDBTimestamp(way); Geometry result = OSHDBGeometryBuilder.getGeometry(way, timestamp, areaDecider); // no exception should have been thrown at this point - assertTrue(result.getCoordinates().length < way.getRefs().length); + assertTrue(result.getCoordinates().length < way.getMembers().length); } } diff --git a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/osmtestdata/OSHDBGeometryBuilderTestOsmTestData1xxTest.java b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/osmtestdata/OSHDBGeometryBuilderTestOsmTestData1xxTest.java index 00d2a4cb5..b03e15bac 100644 --- a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/osmtestdata/OSHDBGeometryBuilderTestOsmTestData1xxTest.java +++ b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/osmtestdata/OSHDBGeometryBuilderTestOsmTestData1xxTest.java @@ -9,8 +9,8 @@ import java.util.Arrays; import java.util.Set; import java.util.stream.Collectors; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; import org.heigit.ohsome.oshdb.osm.OSMEntity; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.heigit.ohsome.oshdb.util.geometry.OSHDBGeometryBuilder; import org.heigit.ohsome.oshdb.util.geometry.helpers.FakeTagInterpreterAreaMultipolygonAllOuters; import org.heigit.ohsome.oshdb.util.geometry.helpers.OSMXmlReaderTagInterpreter; diff --git a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/osmtestdata/OSHDBGeometryBuilderTestOsmTestData3xxTest.java b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/osmtestdata/OSHDBGeometryBuilderTestOsmTestData3xxTest.java index 7c0e2f993..0a7f239b5 100644 --- a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/osmtestdata/OSHDBGeometryBuilderTestOsmTestData3xxTest.java +++ b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/osmtestdata/OSHDBGeometryBuilderTestOsmTestData3xxTest.java @@ -3,8 +3,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; import org.heigit.ohsome.oshdb.osm.OSMEntity; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.heigit.ohsome.oshdb.util.geometry.OSHDBGeometryBuilder; import org.heigit.ohsome.oshdb.util.geometry.helpers.OSMXmlReaderTagInterpreter; import org.heigit.ohsome.oshdb.util.geometry.helpers.TimestampParser; diff --git a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/osmtestdata/OSHDBGeometryBuilderTestOsmTestData7xxTest.java b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/osmtestdata/OSHDBGeometryBuilderTestOsmTestData7xxTest.java index 41f0a7e53..f3437ecc4 100644 --- a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/osmtestdata/OSHDBGeometryBuilderTestOsmTestData7xxTest.java +++ b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/osmtestdata/OSHDBGeometryBuilderTestOsmTestData7xxTest.java @@ -5,8 +5,8 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; import org.heigit.ohsome.oshdb.osm.OSMEntity; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.heigit.ohsome.oshdb.util.geometry.OSHDBGeometryBuilder; import org.heigit.ohsome.oshdb.util.geometry.helpers.OSMXmlReaderTagInterpreter; import org.heigit.ohsome.oshdb.util.geometry.helpers.TimestampParser; diff --git a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/relations/OSHDBGeometryBuilderMultipolygonInvalidInnersTest.java b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/relations/OSHDBGeometryBuilderMultipolygonInvalidInnersTest.java index db29aca42..3e815bba9 100644 --- a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/relations/OSHDBGeometryBuilderMultipolygonInvalidInnersTest.java +++ b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/relations/OSHDBGeometryBuilderMultipolygonInvalidInnersTest.java @@ -2,8 +2,8 @@ import static org.junit.Assert.assertTrue; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; import org.heigit.ohsome.oshdb.osm.OSMEntity; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.heigit.ohsome.oshdb.util.geometry.OSHDBGeometryBuilder; import org.heigit.ohsome.oshdb.util.geometry.helpers.OSMXmlReaderTagInterpreter; import org.heigit.ohsome.oshdb.util.geometry.helpers.TimestampParser; diff --git a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/relations/OSHDBGeometryBuilderMultipolygonInvalidOutersTest.java b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/relations/OSHDBGeometryBuilderMultipolygonInvalidOutersTest.java index c20402aae..98149b53b 100644 --- a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/relations/OSHDBGeometryBuilderMultipolygonInvalidOutersTest.java +++ b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/relations/OSHDBGeometryBuilderMultipolygonInvalidOutersTest.java @@ -2,8 +2,8 @@ import static org.junit.Assert.assertTrue; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; import org.heigit.ohsome.oshdb.osm.OSMEntity; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.heigit.ohsome.oshdb.util.geometry.OSHDBGeometryBuilder; import org.heigit.ohsome.oshdb.util.geometry.helpers.OSMXmlReaderTagInterpreter; import org.heigit.ohsome.oshdb.util.geometry.helpers.TimestampParser; diff --git a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/relations/OSHDBGeometryBuilderRelationOuterDirectionsTest.java b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/relations/OSHDBGeometryBuilderRelationOuterDirectionsTest.java index 6060ddbe0..ad08778e4 100644 --- a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/relations/OSHDBGeometryBuilderRelationOuterDirectionsTest.java +++ b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/relations/OSHDBGeometryBuilderRelationOuterDirectionsTest.java @@ -3,8 +3,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; import org.heigit.ohsome.oshdb.osm.OSMEntity; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.heigit.ohsome.oshdb.util.geometry.OSHDBGeometryBuilder; import org.heigit.ohsome.oshdb.util.geometry.helpers.OSMXmlReaderTagInterpreter; import org.heigit.ohsome.oshdb.util.geometry.helpers.TimestampParser; diff --git a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/relations/OSHDBGeometryBuilderRelationTypeNotMultipolygonTest.java b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/relations/OSHDBGeometryBuilderRelationTypeNotMultipolygonTest.java index 3b35e0d65..bdcdca9eb 100644 --- a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/relations/OSHDBGeometryBuilderRelationTypeNotMultipolygonTest.java +++ b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/geometry/relations/OSHDBGeometryBuilderRelationTypeNotMultipolygonTest.java @@ -4,8 +4,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; import org.heigit.ohsome.oshdb.osm.OSMEntity; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.heigit.ohsome.oshdb.util.geometry.OSHDBGeometryBuilder; import org.heigit.ohsome.oshdb.util.geometry.helpers.OSMXmlReaderTagInterpreter; import org.heigit.ohsome.oshdb.util.geometry.helpers.TimestampParser; diff --git a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/osh/TestOSHEntityTimeUtils.java b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/osh/TestOSHEntityTimeUtils.java index a510386df..8208eff31 100644 --- a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/osh/TestOSHEntityTimeUtils.java +++ b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/osh/TestOSHEntityTimeUtils.java @@ -8,6 +8,7 @@ import java.io.IOException; import java.util.Collections; import java.util.List; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; import org.heigit.ohsome.oshdb.impl.osh.OSHNodeImpl; import org.heigit.ohsome.oshdb.impl.osh.OSHRelationImpl; import org.heigit.ohsome.oshdb.impl.osh.OSHWayImpl; @@ -19,24 +20,23 @@ import org.heigit.ohsome.oshdb.osm.OSMRelation; import org.heigit.ohsome.oshdb.osm.OSMType; import org.heigit.ohsome.oshdb.osm.OSMWay; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.junit.Test; public class TestOSHEntityTimeUtils { @Test public void testGetModificationTimestampsNode() throws IOException { OSHNode hnode = OSHNodeImpl.build(Lists.newArrayList( - new OSMNode(123L, 2, new OSHDBTimestamp(2L), 0L, 1, new int[] {1, 1}, + new OSMNode(123L, 2, 2L, 0L, 1, new int[] {1, 1}, 86756350L, 494186210L), - new OSMNode(123L, 1, new OSHDBTimestamp(1L), 0L, 1, new int[] {1, 1}, + new OSMNode(123L, 1, 1L, 0L, 1, new int[] {1, 1}, 86756350L, 494186210L) )); List tss = OSHEntityTimeUtils.getModificationTimestamps(hnode); assertNotNull(tss); assertEquals(2, tss.size()); - assertEquals(1L, tss.get(0).getRawUnixTimestamp()); - assertEquals(2L, tss.get(1).getRawUnixTimestamp()); + assertEquals(1L, tss.get(0).getEpochSecond()); + assertEquals(2L, tss.get(1).getEpochSecond()); // additionally, also make sure that the same result is returned by the "recurse" variant assertEquals( @@ -47,11 +47,11 @@ public void testGetModificationTimestampsNode() throws IOException { @Test public void testGetModificationTimestampsNodeWithFilter() throws IOException { OSHNode hnode = OSHNodeImpl.build(Lists.newArrayList( - new OSMNode(123L, 3, new OSHDBTimestamp(3L), 3L, 1, new int[] {1, 2}, + new OSMNode(123L, 3, 3L, 3L, 1, new int[] {1, 2}, 86756350L, 494186210L), - new OSMNode(123L, 2, new OSHDBTimestamp(2L), 2L, 1, new int[] {1, 2}, + new OSMNode(123L, 2, 2L, 2L, 1, new int[] {1, 2}, 86756350L, 494186210L), - new OSMNode(123L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1}, + new OSMNode(123L, 1, 1L, 1L, 1, new int[] {1, 1}, 86756350L, 494186210L) )); @@ -60,8 +60,8 @@ public void testGetModificationTimestampsNodeWithFilter() throws IOException { assertNotNull(tss); assertEquals(2, tss.size()); - assertEquals(1L, tss.get(0).getRawUnixTimestamp()); - assertEquals(2L, tss.get(1).getRawUnixTimestamp()); + assertEquals(1L, tss.get(0).getEpochSecond()); + assertEquals(2L, tss.get(1).getEpochSecond()); // make sure that if no filter is supplied, the full result is returned assertEquals( @@ -72,30 +72,30 @@ public void testGetModificationTimestampsNodeWithFilter() throws IOException { @Test public void testGetModificationTimestampsWay() throws IOException { OSHNode hnode1 = OSHNodeImpl.build(Lists.newArrayList( - new OSMNode(123L, -3, new OSHDBTimestamp(14L), 13L, 0, new int[]{}, 0, 0), - new OSMNode(123L, 2, new OSHDBTimestamp(2L), 12L, 0, new int[]{}, 0, 0), - new OSMNode(123L, 1, new OSHDBTimestamp(1L), 11L, 0, new int[]{}, 0, 0) + new OSMNode(123L, -3, 14L, 13L, 0, new int[]{}, 0, 0), + new OSMNode(123L, 2, 2L, 12L, 0, new int[]{}, 0, 0), + new OSMNode(123L, 1, 1L, 11L, 0, new int[]{}, 0, 0) )); OSHNode hnode2 = OSHNodeImpl.build(Lists.newArrayList( - new OSMNode(124L, 5, new OSHDBTimestamp(14L), 25L, 0, new int[]{}, 0, 0), - new OSMNode(124L, 4, new OSHDBTimestamp(12L), 24L, 0, new int[]{}, 0, 0), - new OSMNode(124L, 3, new OSHDBTimestamp(8L), 23L, 0, new int[]{}, 0, 0), - new OSMNode(124L, 2, new OSHDBTimestamp(4L), 22L, 0, new int[]{}, 0, 0), - new OSMNode(124L, 1, new OSHDBTimestamp(3L), 21L, 0, new int[]{}, 0, 0) + new OSMNode(124L, 5, 14L, 25L, 0, new int[]{}, 0, 0), + new OSMNode(124L, 4, 12L, 24L, 0, new int[]{}, 0, 0), + new OSMNode(124L, 3, 8L, 23L, 0, new int[]{}, 0, 0), + new OSMNode(124L, 2, 4L, 22L, 0, new int[]{}, 0, 0), + new OSMNode(124L, 1, 3L, 21L, 0, new int[]{}, 0, 0) )); OSHNode hnode3 = OSHNodeImpl.build(Lists.newArrayList( - new OSMNode(125L, 3, new OSHDBTimestamp(9L), 33L, 0, new int[]{}, 0, 0), - new OSMNode(125L, 2, new OSHDBTimestamp(6L), 32L, 0, new int[]{}, 0, 0), - new OSMNode(125L, 1, new OSHDBTimestamp(1L), 31L, 0, new int[]{}, 0, 0) + new OSMNode(125L, 3, 9L, 33L, 0, new int[]{}, 0, 0), + new OSMNode(125L, 2, 6L, 32L, 0, new int[]{}, 0, 0), + new OSMNode(125L, 1, 1L, 31L, 0, new int[]{}, 0, 0) )); OSHWay hway = OSHWayImpl.build(Lists.newArrayList( - new OSMWay(123, -3, new OSHDBTimestamp(13L), 4446L, 23, new int[]{}, new OSMMember[]{}), - new OSMWay(123, 2, new OSHDBTimestamp(7L), + new OSMWay(123, -3, 13L, 4446L, 23, new int[]{}, new OSMMember[]{}), + new OSMWay(123, 2, 7L, 4445L, 23, new int[]{1, 1, 2, 2}, new OSMMember[]{ new OSMMember(123, OSMType.NODE, 0), new OSMMember(124, OSMType.NODE, 0)}), - new OSMWay(123, 1, new OSHDBTimestamp(5L), + new OSMWay(123, 1, 5L, 4444L, 23, new int[]{1, 1, 2, 1}, new OSMMember[]{ new OSMMember(123, OSMType.NODE, 0), new OSMMember(124, OSMType.NODE, 0), @@ -105,55 +105,55 @@ public void testGetModificationTimestampsWay() throws IOException { List tss = OSHEntityTimeUtils.getModificationTimestamps(hway, false); assertNotNull(tss); assertEquals(3, tss.size()); - assertEquals(5L, tss.get(0).getRawUnixTimestamp()); - assertEquals(7L, tss.get(1).getRawUnixTimestamp()); - assertEquals(13L, tss.get(2).getRawUnixTimestamp()); + assertEquals(5L, tss.get(0).getEpochSecond()); + assertEquals(7L, tss.get(1).getEpochSecond()); + assertEquals(13L, tss.get(2).getEpochSecond()); tss = OSHEntityTimeUtils.getModificationTimestamps(hway, true); assertNotNull(tss); assertEquals(6, tss.size()); - assertEquals(5L, tss.get(0).getRawUnixTimestamp()); - assertEquals(6L, tss.get(1).getRawUnixTimestamp()); - assertEquals(7L, tss.get(2).getRawUnixTimestamp()); - assertEquals(8L, tss.get(3).getRawUnixTimestamp()); - assertEquals(12L, tss.get(4).getRawUnixTimestamp()); - assertEquals(13L, tss.get(5).getRawUnixTimestamp()); + assertEquals(5L, tss.get(0).getEpochSecond()); + assertEquals(6L, tss.get(1).getEpochSecond()); + assertEquals(7L, tss.get(2).getEpochSecond()); + assertEquals(8L, tss.get(3).getEpochSecond()); + assertEquals(12L, tss.get(4).getEpochSecond()); + assertEquals(13L, tss.get(5).getEpochSecond()); } @Test public void testGetModificationTimestampsWayWithFilter() throws IOException { OSHNode hnode1 = OSHNodeImpl.build(Lists.newArrayList( - new OSMNode(123L, 2, new OSHDBTimestamp(2L), 12L, 0, new int[]{}, 0, 0), - new OSMNode(123L, 1, new OSHDBTimestamp(1L), 11L, 0, new int[]{}, 0, 0) + new OSMNode(123L, 2, 2L, 12L, 0, new int[]{}, 0, 0), + new OSMNode(123L, 1, 1L, 11L, 0, new int[]{}, 0, 0) )); OSHNode hnode2 = OSHNodeImpl.build(Lists.newArrayList( - new OSMNode(124L, 5, new OSHDBTimestamp(16L), 25L, 0, new int[]{}, 0, 0), - new OSMNode(124L, 4, new OSHDBTimestamp(12L), 24L, 0, new int[]{}, 0, 0), - new OSMNode(124L, 3, new OSHDBTimestamp(8L), 23L, 0, new int[]{}, 0, 0), - new OSMNode(124L, 2, new OSHDBTimestamp(4L), 22L, 0, new int[]{}, 0, 0), - new OSMNode(124L, 1, new OSHDBTimestamp(3L), 21L, 0, new int[]{}, 0, 0) + new OSMNode(124L, 5, 16L, 25L, 0, new int[]{}, 0, 0), + new OSMNode(124L, 4, 12L, 24L, 0, new int[]{}, 0, 0), + new OSMNode(124L, 3, 8L, 23L, 0, new int[]{}, 0, 0), + new OSMNode(124L, 2, 4L, 22L, 0, new int[]{}, 0, 0), + new OSMNode(124L, 1, 3L, 21L, 0, new int[]{}, 0, 0) )); OSHNode hnode3 = OSHNodeImpl.build(Lists.newArrayList( - new OSMNode(125L, 4, new OSHDBTimestamp(15L), 34L, 0, new int[]{}, 0, 0), - new OSMNode(125L, 3, new OSHDBTimestamp(9L), 33L, 0, new int[]{}, 0, 0), - new OSMNode(125L, 2, new OSHDBTimestamp(6L), 32L, 0, new int[]{}, 0, 0), - new OSMNode(125L, 1, new OSHDBTimestamp(1L), 31L, 0, new int[]{}, 0, 0) + new OSMNode(125L, 4, 15L, 34L, 0, new int[]{}, 0, 0), + new OSMNode(125L, 3, 9L, 33L, 0, new int[]{}, 0, 0), + new OSMNode(125L, 2, 6L, 32L, 0, new int[]{}, 0, 0), + new OSMNode(125L, 1, 1L, 31L, 0, new int[]{}, 0, 0) )); OSHWay hway = OSHWayImpl.build(Lists.newArrayList( - new OSMWay(123, 4, new OSHDBTimestamp(14L), + new OSMWay(123, 4, 14L, 4447L, 23, new int[]{1, 1, 2, 1}, new OSMMember[]{ new OSMMember(123, OSMType.NODE, 0), new OSMMember(124, OSMType.NODE, 0)}), - new OSMWay(123, 3, new OSHDBTimestamp(13L), + new OSMWay(123, 3, 13L, 4446L, 23, new int[]{1, 1, 2, 2}, new OSMMember[]{ new OSMMember(123, OSMType.NODE, 0), new OSMMember(124, OSMType.NODE, 0)}), - new OSMWay(123, 2, new OSHDBTimestamp(7L), + new OSMWay(123, 2, 7L, 4445L, 23, new int[]{1, 1, 2, 2}, new OSMMember[]{ new OSMMember(123, OSMType.NODE, 0), new OSMMember(124, OSMType.NODE, 0)}), - new OSMWay(123, 1, new OSHDBTimestamp(5L), + new OSMWay(123, 1, 5L, 4444L, 23, new int[]{1, 1, 2, 1}, new OSMMember[]{ new OSMMember(123, OSMType.NODE, 0), new OSMMember(124, OSMType.NODE, 0), @@ -163,14 +163,14 @@ public void testGetModificationTimestampsWayWithFilter() throws IOException { List tss = OSHEntityTimeUtils.getModificationTimestamps(hway, true); assertNotNull(tss); assertEquals(8, tss.size()); - assertEquals(5L, tss.get(0).getRawUnixTimestamp()); - assertEquals(6L, tss.get(1).getRawUnixTimestamp()); - assertEquals(7L, tss.get(2).getRawUnixTimestamp()); - assertEquals(8L, tss.get(3).getRawUnixTimestamp()); - assertEquals(12L, tss.get(4).getRawUnixTimestamp()); - assertEquals(13L, tss.get(5).getRawUnixTimestamp()); - assertEquals(14L, tss.get(6).getRawUnixTimestamp()); - assertEquals(16L, tss.get(7).getRawUnixTimestamp()); + assertEquals(5L, tss.get(0).getEpochSecond()); + assertEquals(6L, tss.get(1).getEpochSecond()); + assertEquals(7L, tss.get(2).getEpochSecond()); + assertEquals(8L, tss.get(3).getEpochSecond()); + assertEquals(12L, tss.get(4).getEpochSecond()); + assertEquals(13L, tss.get(5).getEpochSecond()); + assertEquals(14L, tss.get(6).getEpochSecond()); + assertEquals(16L, tss.get(7).getEpochSecond()); tss = OSHEntityTimeUtils.getModificationTimestamps( hway, @@ -178,42 +178,42 @@ public void testGetModificationTimestampsWayWithFilter() throws IOException { ); assertNotNull(tss); assertEquals(5, tss.size()); - assertEquals(5L, tss.get(0).getRawUnixTimestamp()); - assertEquals(6L, tss.get(1).getRawUnixTimestamp()); - assertEquals(7L, tss.get(2).getRawUnixTimestamp()); - assertEquals(14L, tss.get(3).getRawUnixTimestamp()); - assertEquals(16L, tss.get(4).getRawUnixTimestamp()); + assertEquals(5L, tss.get(0).getEpochSecond()); + assertEquals(6L, tss.get(1).getEpochSecond()); + assertEquals(7L, tss.get(2).getEpochSecond()); + assertEquals(14L, tss.get(3).getEpochSecond()); + assertEquals(16L, tss.get(4).getEpochSecond()); } @Test public void testGetModificationTimestampsRelation() throws IOException { OSHNode hnode1 = OSHNodeImpl.build(Lists.newArrayList( - new OSMNode(123L, 2, new OSHDBTimestamp(2L), 12L, 0, new int[]{}, 0, 0), - new OSMNode(123L, 1, new OSHDBTimestamp(1L), 11L, 0, new int[]{}, 0, 0) + new OSMNode(123L, 2, 2L, 12L, 0, new int[]{}, 0, 0), + new OSMNode(123L, 1, 1L, 11L, 0, new int[]{}, 0, 0) )); OSHNode hnode2 = OSHNodeImpl.build(Lists.newArrayList( - new OSMNode(124L, 4, new OSHDBTimestamp(12L), 24L, 0, new int[]{}, 0, 0), - new OSMNode(124L, 3, new OSHDBTimestamp(9L), 23L, 0, new int[]{}, 0, 0), - new OSMNode(124L, 2, new OSHDBTimestamp(4L), 22L, 0, new int[]{}, 0, 0), - new OSMNode(124L, 1, new OSHDBTimestamp(3L), 21L, 0, new int[]{}, 0, 0) + new OSMNode(124L, 4, 12L, 24L, 0, new int[]{}, 0, 0), + new OSMNode(124L, 3, 9L, 23L, 0, new int[]{}, 0, 0), + new OSMNode(124L, 2, 4L, 22L, 0, new int[]{}, 0, 0), + new OSMNode(124L, 1, 3L, 21L, 0, new int[]{}, 0, 0) )); OSHNode hnode3 = OSHNodeImpl.build(Lists.newArrayList( - new OSMNode(125L, 3, new OSHDBTimestamp(11L), 34L, 0, new int[]{}, 0, 0), - new OSMNode(125L, 2, new OSHDBTimestamp(6L), 32L, 0, new int[]{}, 0, 0), - new OSMNode(125L, 1, new OSHDBTimestamp(1L), 31L, 0, new int[]{}, 0, 0) + new OSMNode(125L, 3, 11L, 34L, 0, new int[]{}, 0, 0), + new OSMNode(125L, 2, 6L, 32L, 0, new int[]{}, 0, 0), + new OSMNode(125L, 1, 1L, 31L, 0, new int[]{}, 0, 0) )); OSHWay hway1 = OSHWayImpl.build(Lists.newArrayList( - new OSMWay(1, 3, new OSHDBTimestamp(7L), + new OSMWay(1, 3, 7L, 4445L, 23, new int[]{}, new OSMMember[]{ new OSMMember(123, OSMType.NODE, 0), new OSMMember(124, OSMType.NODE, 0)}), - new OSMWay(1, 2, new OSHDBTimestamp(5L), + new OSMWay(1, 2, 5L, 4444L, 23, new int[]{}, new OSMMember[]{ new OSMMember(123, OSMType.NODE, 0), new OSMMember(124, OSMType.NODE, 0), new OSMMember(125, OSMType.NODE, 0)}), - new OSMWay(1, 1, new OSHDBTimestamp(4L), + new OSMWay(1, 1, 4L, 4443L, 23, new int[]{}, new OSMMember[]{ new OSMMember(123, OSMType.NODE, 0), new OSMMember(124, OSMType.NODE, 0), @@ -221,13 +221,13 @@ public void testGetModificationTimestampsRelation() throws IOException { ), List.of(hnode1, hnode2, hnode3)); OSHRelation hrelation = OSHRelationImpl.build(Lists.newArrayList( - new OSMRelation(1, -4, new OSHDBTimestamp(20L), 10004L, 1, new int[]{}, new OSMMember[]{}), - new OSMRelation(1, 3, new OSHDBTimestamp(10L), 10003L, 1, new int[]{1, 1, 2, 2}, + new OSMRelation(1, -4, 20L, 10004L, 1, new int[]{}, new OSMMember[]{}), + new OSMRelation(1, 3, 10L, 10003L, 1, new int[]{1, 1, 2, 2}, new OSMMember[]{new OSMMember(1, OSMType.WAY, 0)}), - new OSMRelation(1, 2, new OSHDBTimestamp(8L), + new OSMRelation(1, 2, 8L, 10002L, 1, new int[]{1, 1, 2, 2}, new OSMMember[]{new OSMMember(123, OSMType.NODE, 1)}), - new OSMRelation(1, 1, new OSHDBTimestamp(5L), + new OSMRelation(1, 1, 5L, 10001L, 1, new int[]{1, 1, 2, 2}, new OSMMember[]{new OSMMember(1, OSMType.WAY, 0)}) ), List.of(hnode1), List.of(hway1)); @@ -235,46 +235,46 @@ public void testGetModificationTimestampsRelation() throws IOException { List tss = OSHEntityTimeUtils.getModificationTimestamps(hrelation, false); assertNotNull(tss); assertEquals(4, tss.size()); - assertEquals(5L, tss.get(0).getRawUnixTimestamp()); - assertEquals(8L, tss.get(1).getRawUnixTimestamp()); - assertEquals(10L, tss.get(2).getRawUnixTimestamp()); - assertEquals(20L, tss.get(3).getRawUnixTimestamp()); + assertEquals(5L, tss.get(0).getEpochSecond()); + assertEquals(8L, tss.get(1).getEpochSecond()); + assertEquals(10L, tss.get(2).getEpochSecond()); + assertEquals(20L, tss.get(3).getEpochSecond()); tss = OSHEntityTimeUtils.getModificationTimestamps(hrelation, true); assertNotNull(tss); assertEquals(7, tss.size()); - assertEquals(5L, tss.get(0).getRawUnixTimestamp()); - assertEquals(6L, tss.get(1).getRawUnixTimestamp()); - assertEquals(7L, tss.get(2).getRawUnixTimestamp()); - assertEquals(8L, tss.get(3).getRawUnixTimestamp()); + assertEquals(5L, tss.get(0).getEpochSecond()); + assertEquals(6L, tss.get(1).getEpochSecond()); + assertEquals(7L, tss.get(2).getEpochSecond()); + assertEquals(8L, tss.get(3).getEpochSecond()); // timestamp 9 has to be missing because at the time, the way wasn't a member of the // relation anymore - assertEquals(10L, tss.get(4).getRawUnixTimestamp()); + assertEquals(10L, tss.get(4).getEpochSecond()); // timestamp 11 has to be missing because at the time, the node wasn't part of the way // member of the relation anymore - assertEquals(12L, tss.get(5).getRawUnixTimestamp()); - assertEquals(20L, tss.get(6).getRawUnixTimestamp()); + assertEquals(12L, tss.get(5).getEpochSecond()); + assertEquals(20L, tss.get(6).getEpochSecond()); } @Test public void testGetModificationTimestampsRelationWithFilter() throws IOException { OSHNode hnode1 = OSHNodeImpl.build(Lists.newArrayList( - new OSMNode(123L, 7, new OSHDBTimestamp(17L), 17L, 0, new int[]{}, 0, 0), - new OSMNode(123L, 6, new OSHDBTimestamp(6L), 16L, 0, new int[]{}, 0, 0), - new OSMNode(123L, 5, new OSHDBTimestamp(5L), 15L, 0, new int[]{}, 0, 0), - new OSMNode(123L, 4, new OSHDBTimestamp(4L), 14L, 0, new int[]{}, 0, 0), - new OSMNode(123L, 3, new OSHDBTimestamp(3L), 13L, 0, new int[]{}, 0, 0), - new OSMNode(123L, 2, new OSHDBTimestamp(2L), 12L, 0, new int[]{}, 0, 0), - new OSMNode(123L, 1, new OSHDBTimestamp(1L), 11L, 0, new int[]{}, 0, 0) + new OSMNode(123L, 7, 17L, 17L, 0, new int[]{}, 0, 0), + new OSMNode(123L, 6, 6L, 16L, 0, new int[]{}, 0, 0), + new OSMNode(123L, 5, 5L, 15L, 0, new int[]{}, 0, 0), + new OSMNode(123L, 4, 4L, 14L, 0, new int[]{}, 0, 0), + new OSMNode(123L, 3, 3L, 13L, 0, new int[]{}, 0, 0), + new OSMNode(123L, 2, 2L, 12L, 0, new int[]{}, 0, 0), + new OSMNode(123L, 1, 1L, 11L, 0, new int[]{}, 0, 0) )); OSHRelation hrelation = OSHRelationImpl.build(Lists.newArrayList( - new OSMRelation(1, -4, new OSHDBTimestamp(6L), 10004L, 1, new int[]{}, new OSMMember[]{}), - new OSMRelation(1, 3, new OSHDBTimestamp(5L), + new OSMRelation(1, -4, 6L, 10004L, 1, new int[]{}, new OSMMember[]{}), + new OSMRelation(1, 3, 5L, 10003L, 1, new int[]{}, new OSMMember[]{new OSMMember(123, OSMType.NODE, 0)}), - new OSMRelation(1, 2, new OSHDBTimestamp(3L), + new OSMRelation(1, 2, 3L, 10002L, 1, new int[]{}, new OSMMember[]{new OSMMember(123, OSMType.NODE, 1)}), - new OSMRelation(1, 1, new OSHDBTimestamp(1L), + new OSMRelation(1, 1, 1L, 10001L, 1, new int[]{}, new OSMMember[]{new OSMMember(123, OSMType.NODE, 0)}) ), List.of(hnode1), List.of()); @@ -284,12 +284,12 @@ public void testGetModificationTimestampsRelationWithFilter() throws IOException ); assertNotNull(tss); assertEquals(5, tss.size()); - assertEquals(1L, tss.get(0).getRawUnixTimestamp()); - assertEquals(2L, tss.get(1).getRawUnixTimestamp()); - assertEquals(3L, tss.get(2).getRawUnixTimestamp()); + assertEquals(1L, tss.get(0).getEpochSecond()); + assertEquals(2L, tss.get(1).getEpochSecond()); + assertEquals(3L, tss.get(2).getEpochSecond()); // ts 4 missing since entity filter doesn't match then - assertEquals(5L, tss.get(3).getRawUnixTimestamp()); - assertEquals(6L, tss.get(4).getRawUnixTimestamp()); + assertEquals(5L, tss.get(3).getEpochSecond()); + assertEquals(6L, tss.get(4).getEpochSecond()); } @Test @@ -298,28 +298,28 @@ public void testIssue325() throws IOException { // relations referencing redacted ways caused a crash in the OSHEntities utility class // when calculating the relation's modification timestamps OSHNode hnode1 = OSHNodeImpl.build(Lists.newArrayList( - new OSMNode(123L, 2, new OSHDBTimestamp(2L), 2L, 0, new int[]{}, 0, 0), - new OSMNode(123L, 1, new OSHDBTimestamp(1L), 1L, 0, new int[]{}, 0, 0))); + new OSMNode(123L, 2, 2L, 2L, 0, new int[]{}, 0, 0), + new OSMNode(123L, 1, 1L, 1L, 0, new int[]{}, 0, 0))); OSHNode hnode2 = OSHNodeImpl.build(Lists.newArrayList( - new OSMNode(124L, 2, new OSHDBTimestamp(2L), 2L, 0, new int[]{}, 0, 0), - new OSMNode(124L, 1, new OSHDBTimestamp(1L), 1L, 0, new int[]{}, 0, 0))); + new OSMNode(124L, 2, 2L, 2L, 0, new int[]{}, 0, 0), + new OSMNode(124L, 1, 1L, 1L, 0, new int[]{}, 0, 0))); OSHWay hway1 = OSHWayImpl.build(Lists.newArrayList( - new OSMWay(1, 1, new OSHDBTimestamp(1L), 1L, 0, new int[]{}, new OSMMember[]{ + new OSMWay(1, 1, 1L, 1L, 0, new int[]{}, new OSMMember[]{ new OSMMember(123L, OSMType.NODE, 0), new OSMMember(124L, OSMType.NODE, 0)}) ), List.of(hnode1, hnode2)); OSHWay hway2 = OSHWayImpl.build(Lists.newArrayList( - new OSMWay(2L, -4, new OSHDBTimestamp(9L), 9L, 9, new int[]{}, new OSMMember[]{}) + new OSMWay(2L, -4, 9L, 9L, 9, new int[]{}, new OSMMember[]{}) ), Collections.emptyList()); OSHRelation hrelation = OSHRelationImpl.build(Lists.newArrayList( - new OSMRelation(1L, 2, new OSHDBTimestamp(8L), 8L, 8, new int[]{1, 1, 2, 2}, + new OSMRelation(1L, 2, 8L, 8L, 8, new int[]{1, 1, 2, 2}, new OSMMember[]{ new OSMMember(1L, OSMType.WAY, 0), new OSMMember(2L, OSMType.WAY, 0)}), - new OSMRelation(1L, 1, new OSHDBTimestamp(1L), 1L, 0, new int[]{1, 1, 2, 2}, + new OSMRelation(1L, 1, 1L, 1L, 0, new int[]{1, 1, 2, 2}, new OSMMember[]{new OSMMember(1L, OSMType.WAY, 0)}) ), List.of(hnode1, hnode2), List.of(hway1, hway2)); @@ -330,9 +330,9 @@ public void testIssue325() throws IOException { @Test public void testGetChangesetTimestampsNode() throws IOException { OSHNode hnode = OSHNodeImpl.build(Lists.newArrayList( - new OSMNode(123L, 2, new OSHDBTimestamp(2L), 8L, 1, new int[] {1, 1}, + new OSMNode(123L, 2, 2L, 8L, 1, new int[] {1, 1}, 86756350L, 494186210L), - new OSMNode(123L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 2}, + new OSMNode(123L, 1, 1L, 1L, 1, new int[] {1, 2}, 86756350L, 494186210L) )); @@ -346,33 +346,33 @@ public void testGetChangesetTimestampsNode() throws IOException { @Test public void testGetChangesetTimestampsWay() throws IOException { OSHNode hnode1 = OSHNodeImpl.build(Lists.newArrayList( - new OSMNode(1L, 3, new OSHDBTimestamp(5L), 5L, 1, new int[] {}, + new OSMNode(1L, 3, 5L, 5L, 1, new int[] {}, 86756340L, 494186210L), - new OSMNode(1L, 2, new OSHDBTimestamp(3L), 3L, 1, new int[] {}, + new OSMNode(1L, 2, 3L, 3L, 1, new int[] {}, 86756340L, 494186210L), - new OSMNode(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {}, + new OSMNode(1L, 1, 1L, 1L, 1, new int[] {}, 86756340L, 494186200L) )); OSHNode hnode2 = OSHNodeImpl.build(Lists.newArrayList( - new OSMNode(2L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {}, + new OSMNode(2L, 1, 1L, 1L, 1, new int[] {}, 86756380L, 494186210L) )); OSHNode hnode3 = OSHNodeImpl.build(Lists.newArrayList( - new OSMNode(3L, 1, new OSHDBTimestamp(4L), 4L, 1, new int[] {}, + new OSMNode(3L, 1, 4L, 4L, 1, new int[] {}, 86756390L, 494186210L) )); OSHWay hway = OSHWayImpl.build(Lists.newArrayList( - new OSMWay(1L, 3, new OSHDBTimestamp(4L), 4L, 1, new int[] {1, 2}, new OSMMember[] { + new OSMWay(1L, 3, 4L, 4L, 1, new int[] {1, 2}, new OSMMember[] { new OSMMember(1L, OSMType.NODE, 0), new OSMMember(2L, OSMType.NODE, 0), new OSMMember(3L, OSMType.NODE, 0) }), - new OSMWay(1L, 2, new OSHDBTimestamp(2L), 2L, 1, new int[] {1, 2}, new OSMMember[] { + new OSMWay(1L, 2, 2L, 2L, 1, new int[] {1, 2}, new OSMMember[] { new OSMMember(1L, OSMType.NODE, 0), new OSMMember(2L, OSMType.NODE, 0) }), - new OSMWay(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1}, new OSMMember[] { + new OSMWay(1L, 1, 1L, 1L, 1, new int[] {1, 1}, new OSMMember[] { new OSMMember(1L, OSMType.NODE, 0), new OSMMember(2L, OSMType.NODE, 0) }) @@ -397,53 +397,53 @@ public void testGetChangesetTimestampsWay() throws IOException { @Test public void testGetChangesetTimestampsRelation() throws IOException { OSHNode hnode1 = OSHNodeImpl.build(Lists.newArrayList( - new OSMNode(1L, 2, new OSHDBTimestamp(3L), 3L, 1, new int[] {}, + new OSMNode(1L, 2, 3L, 3L, 1, new int[] {}, 86756340L, 494186210L), - new OSMNode(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {}, + new OSMNode(1L, 1, 1L, 1L, 1, new int[] {}, 86756340L, 494186200L) )); OSHNode hnode2 = OSHNodeImpl.build(Lists.newArrayList( - new OSMNode(2L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {}, + new OSMNode(2L, 1, 1L, 1L, 1, new int[] {}, 86756380L, 494186210L) )); OSHNode hnode3 = OSHNodeImpl.build(Lists.newArrayList( - new OSMNode(3L, 1, new OSHDBTimestamp(4L), 4L, 1, new int[] {}, + new OSMNode(3L, 1, 4L, 4L, 1, new int[] {}, 86756390L, 494186210L) )); OSHNode hnode4 = OSHNodeImpl.build(Lists.newArrayList( - new OSMNode(4L, 3, new OSHDBTimestamp(8L), 8L, 1, new int[] {1, 1}, + new OSMNode(4L, 3, 8L, 8L, 1, new int[] {1, 1}, 86756340L, 494186210L), - new OSMNode(4L, 2, new OSHDBTimestamp(6L), 6L, 1, new int[] {2, 2}, + new OSMNode(4L, 2, 6L, 6L, 1, new int[] {2, 2}, 86756340L, 494186210L), - new OSMNode(4L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1}, + new OSMNode(4L, 1, 1L, 1L, 1, new int[] {1, 1}, 86756390L, 494186210L) )); OSHWay hway = OSHWayImpl.build(Lists.newArrayList( - new OSMWay(1L, 1, new OSHDBTimestamp(4L), 4L, 1, new int[] {1, 1}, new OSMMember[] { + new OSMWay(1L, 1, 4L, 4L, 1, new int[] {1, 1}, new OSMMember[] { new OSMMember(1L, OSMType.NODE, 0), new OSMMember(2L, OSMType.NODE, 0), new OSMMember(3L, OSMType.NODE, 0) }), - new OSMWay(1L, 1, new OSHDBTimestamp(2L), 2L, 1, new int[] {1, 2}, new OSMMember[] { + new OSMWay(1L, 1, 2L, 2L, 1, new int[] {1, 2}, new OSMMember[] { new OSMMember(1L, OSMType.NODE, 0), new OSMMember(2L, OSMType.NODE, 0) }), - new OSMWay(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 2}, new OSMMember[] { + new OSMWay(1L, 1, 1L, 1L, 1, new int[] {1, 2}, new OSMMember[] { new OSMMember(1L, OSMType.NODE, 0), new OSMMember(2L, OSMType.NODE, 0) }) ), List.of(hnode1, hnode2, hnode3)); OSHRelation hrel = OSHRelationImpl.build(Lists.newArrayList( - new OSMRelation(1L, 3, new OSHDBTimestamp(7L), 7L, 1, new int[] {1, 2}, new OSMMember[] { + new OSMRelation(1L, 3, 7L, 7L, 1, new int[] {1, 2}, new OSMMember[] { new OSMMember(1L, OSMType.WAY, 0) }), - new OSMRelation(1L, 2, new OSHDBTimestamp(5L), 5L, 1, new int[] {1, 2}, new OSMMember[] { + new OSMRelation(1L, 2, 5L, 5L, 1, new int[] {1, 2}, new OSMMember[] { new OSMMember(1L, OSMType.WAY, 0), new OSMMember(4L, OSMType.NODE, 0) }), - new OSMRelation(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1}, new OSMMember[] { + new OSMRelation(1L, 1, 1L, 1L, 1, new int[] {1, 1}, new OSMMember[] { new OSMMember(1L, OSMType.WAY, 0), new OSMMember(4L, OSMType.NODE, 0) }) @@ -475,12 +475,12 @@ public void testGetChangesetTimestampsRelation() throws IOException { public void testGetModificationTimestampsBrokenData() throws IOException { // missing way node reference OSHNode hnode = OSHNodeImpl.build(Lists.newArrayList( - new OSMNode(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {}, + new OSMNode(1L, 1, 1L, 1L, 1, new int[] {}, 86756380L, 494186210L) )); OSHWay hway = OSHWayImpl.build(Lists.newArrayList( - new OSMWay(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1}, new OSMMember[] { + new OSMWay(1L, 1, 1L, 1L, 1, new int[] {1, 1}, new OSMMember[] { new OSMMember(1L, OSMType.NODE, 0), new OSMMember(2L, OSMType.NODE, 0) }) @@ -489,11 +489,11 @@ public void testGetModificationTimestampsBrokenData() throws IOException { var tss = OSHEntityTimeUtils.getModificationTimestamps(hway); assertNotNull(tss); assertEquals(1, tss.size()); - assertEquals(1L, tss.get(0).getRawUnixTimestamp()); + assertEquals(1L, tss.get(0).getEpochSecond()); // missing relation member OSHRelation hrel = OSHRelationImpl.build(Lists.newArrayList( - new OSMRelation(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1}, new OSMMember[] { + new OSMRelation(1L, 1, 1L, 1L, 1, new int[] {1, 1}, new OSMMember[] { new OSMMember(1L, OSMType.WAY, 0), new OSMMember(3L, OSMType.NODE, 0) }) @@ -502,11 +502,11 @@ public void testGetModificationTimestampsBrokenData() throws IOException { tss = OSHEntityTimeUtils.getModificationTimestamps(hrel); assertNotNull(tss); assertEquals(1, tss.size()); - assertEquals(1L, tss.get(0).getRawUnixTimestamp()); + assertEquals(1L, tss.get(0).getEpochSecond()); // broken reference (potentially due to data redaction) hnode = OSHNodeImpl.build(Lists.newArrayList( - new OSMNode(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {}, + new OSMNode(1L, 1, 1L, 1L, 1, new int[] {}, 86756380L, 494186210L) )); } @@ -515,12 +515,12 @@ public void testGetModificationTimestampsBrokenData() throws IOException { public void testGetChangesetTimestampsBrokenData() throws IOException { // missing way node reference OSHNode hnode = OSHNodeImpl.build(Lists.newArrayList( - new OSMNode(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {}, + new OSMNode(1L, 1, 1L, 1L, 1, new int[] {}, 86756380L, 494186210L) )); OSHWay hway = OSHWayImpl.build(Lists.newArrayList( - new OSMWay(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1}, new OSMMember[] { + new OSMWay(1L, 1, 1L, 1L, 1, new int[] {1, 1}, new OSMMember[] { new OSMMember(1L, OSMType.NODE, 0), new OSMMember(2L, OSMType.NODE, 0) }) @@ -533,7 +533,7 @@ public void testGetChangesetTimestampsBrokenData() throws IOException { // missing relation member OSHRelation hrel = OSHRelationImpl.build(Lists.newArrayList( - new OSMRelation(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1}, new OSMMember[] { + new OSMRelation(1L, 1, 1L, 1L, 1, new int[] {1, 1}, new OSMMember[] { new OSMMember(1L, OSMType.WAY, 0), new OSMMember(3L, OSMType.NODE, 0) }) @@ -548,11 +548,11 @@ public void testGetChangesetTimestampsBrokenData() throws IOException { @Test public void testGetModificationTimestampsNestedRelations() throws IOException { OSHNode hnode = OSHNodeImpl.build(Lists.newArrayList( - new OSMNode(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {}, + new OSMNode(1L, 1, 1L, 1L, 1, new int[] {}, 86756380L, 494186210L) )); OSHRelation hrel = OSHRelationImpl.build(Lists.newArrayList( - new OSMRelation(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1}, new OSMMember[] { + new OSMRelation(1L, 1, 1L, 1L, 1, new int[] {1, 1}, new OSMMember[] { new OSMMember(1L, OSMType.WAY, 0), new OSMMember(2L, OSMType.RELATION, 0) }) @@ -561,6 +561,6 @@ public void testGetModificationTimestampsNestedRelations() throws IOException { var tss = OSHEntityTimeUtils.getModificationTimestamps(hrel); assertNotNull(tss); assertEquals(1, tss.size()); - assertEquals(1L, tss.get(0).getRawUnixTimestamp()); + assertEquals(1L, tss.get(0).getEpochSecond()); } } diff --git a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/tagtranslator/TagTranslatorTest.java b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/tagtranslator/TagTranslatorTest.java index 0748b6c25..5f9b0a37a 100644 --- a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/tagtranslator/TagTranslatorTest.java +++ b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/tagtranslator/TagTranslatorTest.java @@ -5,8 +5,8 @@ import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; +import org.heigit.ohsome.oshdb.OSHDBTag; import org.heigit.ohsome.oshdb.util.OSHDBRole; -import org.heigit.ohsome.oshdb.util.OSHDBTag; import org.heigit.ohsome.oshdb.util.OSHDBTagKey; import org.heigit.ohsome.oshdb.util.exceptions.OSHDBKeytablesNotFoundException; import org.junit.AfterClass; diff --git a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/xmlreader/MutableOSMEntity.java b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/xmlreader/MutableOSMEntity.java index 2bc896aaf..2a48c74ce 100644 --- a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/xmlreader/MutableOSMEntity.java +++ b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/xmlreader/MutableOSMEntity.java @@ -1,6 +1,6 @@ package org.heigit.ohsome.oshdb.util.xmlreader; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; public class MutableOSMEntity { @@ -8,7 +8,7 @@ public class MutableOSMEntity { private int version; private boolean visible; - private OSHDBTimestamp timestamp = new OSHDBTimestamp(0L); + private long timestamp; private long changeset; private int userId; private int[] tags; @@ -38,16 +38,17 @@ public void setVersion(int version) { this.version = version; } - public OSHDBTimestamp getTimestamp() { + public long getEpochSecond() { return timestamp; } + public void setTimestamp(OSHDBTimestamp timestamp) { - this.timestamp = timestamp; + this.timestamp = timestamp.getEpochSecond(); } public void setTimestamp(long timestamp) { - this.timestamp.setTimestamp(timestamp); + this.timestamp = timestamp; } public long getChangeset() { diff --git a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/xmlreader/OSMXmlReader.java b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/xmlreader/OSMXmlReader.java index 877a92a24..3ae66e7f2 100644 --- a/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/xmlreader/OSMXmlReader.java +++ b/oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/xmlreader/OSMXmlReader.java @@ -130,7 +130,7 @@ private void read(Document doc) throws IOException { osm.setExtension(longitude, latitude); OSMNode oldOSM = new OSMNode(osm.getId(), osm.getVersion() * (osm.isVisible() ? 1 : -1), - osm.getTimestamp(), osm.getChangeset(), osm.getUserId(), osm.getTags(), osm.getLon(), + osm.getEpochSecond(), osm.getChangeset(), osm.getUserId(), osm.getTags(), osm.getLon(), osm.getLat()); nodes.put(id, oldOSM); } @@ -163,7 +163,7 @@ private void read(Document doc) throws IOException { } // osm.setExtension(members); OSMWay oldOSM = new OSMWay(osm.getId(), osm.getVersion() * (osm.isVisible() ? 1 : -1), - osm.getTimestamp(), osm.getChangeset(), osm.getUserId(), osm.getTags(), members); + osm.getEpochSecond(), osm.getChangeset(), osm.getUserId(), osm.getTags(), members); ways.put(id, oldOSM); } lastId = id; @@ -210,7 +210,7 @@ private void read(Document doc) throws IOException { t = OSMType.WAY; Map wayNodes = new TreeMap<>(); for (OSMWay way : this.ways().get(memId)) { - for (OSMMember wayNode : way.getRefs()) { + for (OSMMember wayNode : way.getMembers()) { wayNodes.putIfAbsent(wayNode.getId(), (OSHNode) wayNode.getEntity()); } } @@ -232,7 +232,7 @@ private void read(Document doc) throws IOException { // osm.setExtension(members); OSMRelation oldOSM = new OSMRelation(osm.getId(), osm.getVersion() * (osm.isVisible() ? 1 : -1), - osm.getTimestamp(), osm.getChangeset(), osm.getUserId(), osm.getTags(), members); + osm.getEpochSecond(), osm.getChangeset(), osm.getUserId(), osm.getTags(), members); relations.put(id, oldOSM); } lastId = id; diff --git a/oshdb/src/main/java/org/heigit/ohsome/oshdb/OSHDBBoundable.java b/oshdb/src/main/java/org/heigit/ohsome/oshdb/OSHDBBoundable.java new file mode 100644 index 000000000..0f5fb487d --- /dev/null +++ b/oshdb/src/main/java/org/heigit/ohsome/oshdb/OSHDBBoundable.java @@ -0,0 +1,81 @@ +package org.heigit.ohsome.oshdb; + +/** + * Interface for spatially boundable objects, i.e. objects which have a bounding box. + */ +public interface OSHDBBoundable { + + long getMinLonLong(); + + long getMinLatLong(); + + long getMaxLonLong(); + + long getMaxLatLong(); + + default double getMinLon() { + return getMinLonLong() * OSHDB.GEOM_PRECISION; + } + + default double getMinLat() { + return getMinLatLong() * OSHDB.GEOM_PRECISION; + } + + default double getMaxLon() { + return getMaxLonLong() * OSHDB.GEOM_PRECISION; + } + + default double getMaxLat() { + return getMaxLatLong() * OSHDB.GEOM_PRECISION; + } + + /** + * Calculates the intersection between this and {@code other} {@code OSHDBBoundable}. + * + * @param other the {@code OSHDBBoundable} + * @return the intersection between this and {@code other} {@code OSHDBBoundable} + */ + default boolean intersects(OSHDBBoundable other) { + return (other != null) + && (getMaxLatLong() >= other.getMinLatLong()) + && (getMinLatLong() <= other.getMaxLatLong()) + && (getMaxLonLong() >= other.getMinLonLong()) + && (getMinLonLong() <= other.getMaxLonLong()); + } + + /** + * Returns true if this {@code OSHDBBoundable} is inside/coveredBy the {@code other} object. + * @param other the {@code OSHDBBoundable} which is being checked for inside/coveredBy + * this {@code OSHDBBoundable} + * @return {@code true} if the {@code OSHDBBoundable} is inside + */ + default boolean coveredBy(OSHDBBoundable other) { + return (other != null) + && (getMinLatLong() >= other.getMinLatLong()) + && (getMaxLatLong() <= other.getMaxLatLong()) + && (getMinLonLong() >= other.getMinLonLong()) + && (getMaxLonLong() <= other.getMaxLonLong()); + } + + default boolean isPoint() { + return getMinLonLong() == getMaxLonLong() && getMinLatLong() == getMaxLatLong(); + } + + default boolean isValid() { + return getMinLonLong() <= getMaxLonLong() && getMinLatLong() <= getMaxLatLong(); + } + + /** + * Calculates the intersection of this and {@code other} bounding boxes. + * + * @param other the bounding box for which to get the intersection + * @return the intersection of the two bboxes + */ + default OSHDBBoundingBox intersection(OSHDBBoundable other) { + return new OSHDBBoundingBox( + Math.max(getMinLonLong(), other.getMinLonLong()), + Math.max(getMinLatLong(), other.getMinLatLong()), + Math.min(getMaxLonLong(), other.getMaxLonLong()), + Math.min(getMaxLatLong(), other.getMaxLatLong())); + } +} diff --git a/oshdb/src/main/java/org/heigit/ohsome/oshdb/OSHDBBoundingBox.java b/oshdb/src/main/java/org/heigit/ohsome/oshdb/OSHDBBoundingBox.java new file mode 100644 index 000000000..999a10d6a --- /dev/null +++ b/oshdb/src/main/java/org/heigit/ohsome/oshdb/OSHDBBoundingBox.java @@ -0,0 +1,136 @@ +package org.heigit.ohsome.oshdb; + +import java.io.Serializable; +import java.util.Locale; + +public class OSHDBBoundingBox implements OSHDBBoundable, Serializable { + private static final long serialVersionUID = 1L; + public static final OSHDBBoundingBox INVALID = new OSHDBBoundingBox(1L, 1L, -1L, -1L); + + public static OVERLAP overlap(OSHDBBoundingBox a, OSHDBBoundingBox b) { + if (b.minLon >= a.maxLon + || b.maxLon <= a.minLon + || b.minLat >= a.maxLat + || b.maxLat <= a.minLat) { + return OVERLAP.NONE; // no overlap + } + // fit bbox in test + if (a.minLon >= b.minLon + && a.maxLon <= b.maxLon + && a.minLat >= b.minLat + && a.maxLat <= b.maxLat) { + return OVERLAP.A_COMPLETE_IN_B; + } + // fit test in bbox + if (b.minLon >= a.minLon + && b.maxLon <= a.maxLon + && b.minLat >= a.minLat + && b.maxLat <= a.maxLat) { + return OVERLAP.B_COMPLETE_IN_A; + } + return OVERLAP.OVERLAPPING; + } + + private final long minLon; + private final long maxLon; + private final long minLat; + private final long maxLat; + + public OSHDBBoundingBox(long minLon, long minLat, long maxLon, long maxLat) { + this.minLon = minLon; + this.maxLon = maxLon; + this.minLat = minLat; + this.maxLat = maxLat; + } + + public OSHDBBoundingBox(double minLon, double minLat, double maxLon, double maxLat) { + this.minLon = Math.round(minLon * OSHDB.GEOM_PRECISION_TO_LONG); + this.maxLon = Math.round(maxLon * OSHDB.GEOM_PRECISION_TO_LONG); + this.minLat = Math.round(minLat * OSHDB.GEOM_PRECISION_TO_LONG); + this.maxLat = Math.round(maxLat * OSHDB.GEOM_PRECISION_TO_LONG); + } + + public OSHDBBoundingBox(int minLon, int minLat, int maxLon, int maxLat) { + this((double) minLon, (double) minLat, (double) maxLon, (double) maxLat); + } + + @Override + public long getMinLonLong() { + return minLon; + } + + @Override + public long getMaxLonLong() { + return maxLon; + } + + @Override + public long getMinLatLong() { + return minLat; + } + + @Override + public long getMaxLatLong() { + return maxLat; + } + + public long[] getLon() { + return new long[] {minLon, maxLon}; + } + + public long[] getLat() { + return new long[] {minLat, maxLat}; + } + + @Override + public String toString() { + return String.format(Locale.ENGLISH, + "(%3.7f,%3.7f,%3.7f,%3.7f)", + this.getMinLon(), + this.getMinLat(), + this.getMaxLon(), + this.getMaxLat()); + } + + @Override + public int hashCode() { + int hash = 7; + hash = 79 * hash + (int) (this.minLon ^ (this.minLon >>> 32)); + hash = 79 * hash + (int) (this.maxLon ^ (this.maxLon >>> 32)); + hash = 79 * hash + (int) (this.minLat ^ (this.minLat >>> 32)); + hash = 79 * hash + (int) (this.maxLat ^ (this.maxLat >>> 32)); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final OSHDBBoundingBox other = (OSHDBBoundingBox) obj; + if (this.minLon != other.minLon) { + return false; + } + if (this.maxLon != other.maxLon) { + return false; + } + if (this.minLat != other.minLat) { + return false; + } + return this.maxLat == other.maxLat; + } + + public enum OVERLAP { + NONE, + OVERLAPPING, + A_COMPLETE_IN_B, + B_COMPLETE_IN_A + } + +} diff --git a/oshdb/src/main/java/org/heigit/ohsome/oshdb/util/OSHDBTag.java b/oshdb/src/main/java/org/heigit/ohsome/oshdb/OSHDBTag.java similarity index 77% rename from oshdb/src/main/java/org/heigit/ohsome/oshdb/util/OSHDBTag.java rename to oshdb/src/main/java/org/heigit/ohsome/oshdb/OSHDBTag.java index fdad7f55f..1aaf3bba8 100644 --- a/oshdb/src/main/java/org/heigit/ohsome/oshdb/util/OSHDBTag.java +++ b/oshdb/src/main/java/org/heigit/ohsome/oshdb/OSHDBTag.java @@ -1,12 +1,13 @@ -package org.heigit.ohsome.oshdb.util; +package org.heigit.ohsome.oshdb; import java.io.Serializable; import java.util.Objects; public class OSHDBTag implements Serializable { + private static final long serialVersionUID = 1L; - private int key; - private int value; + private final int key; + private final int value; public OSHDBTag(int key, int value) { this.key = key; @@ -27,8 +28,8 @@ public boolean isPresentInKeytables() { @Override public boolean equals(Object o) { - return o instanceof OSHDBTag && - ((OSHDBTag)o).key == this.key && ((OSHDBTag)o).value == this.value; + return o instanceof OSHDBTag + && ((OSHDBTag) o).key == this.key && ((OSHDBTag) o).value == this.value; } @Override diff --git a/oshdb/src/main/java/org/heigit/ohsome/oshdb/OSHDBTemporal.java b/oshdb/src/main/java/org/heigit/ohsome/oshdb/OSHDBTemporal.java new file mode 100644 index 000000000..3d3d5989a --- /dev/null +++ b/oshdb/src/main/java/org/heigit/ohsome/oshdb/OSHDBTemporal.java @@ -0,0 +1,37 @@ +package org.heigit.ohsome.oshdb; + +import java.time.Instant; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; + +/** + * Interface for objects which are associated to a single timestamp. + */ +public interface OSHDBTemporal { + + long getEpochSecond(); + + default boolean isBefore(OSHDBTemporal other) { + return getEpochSecond() < other.getEpochSecond(); + } + + default boolean isAfter(OSHDBTemporal other) { + return getEpochSecond() > other.getEpochSecond(); + } + + static int compare(OSHDBTemporal a, OSHDBTemporal b) { + return Long.compare(a.getEpochSecond(), b.getEpochSecond()); + } + + /** + * Converts the given {@code OSHDBTemporal} to an iso-date-time string. + * @param temporal The {@code OSHDBTemporal} which should converted. + * @return the iso-date-time string for the {@code OSHDBTemporal} + */ + static String toIsoDateTime(OSHDBTemporal temporal) { + ZonedDateTime zdt = + ZonedDateTime.ofInstant(Instant.ofEpochSecond(temporal.getEpochSecond()), ZoneOffset.UTC); + return zdt.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME); + } +} diff --git a/oshdb/src/main/java/org/heigit/ohsome/oshdb/OSHDBTimestamp.java b/oshdb/src/main/java/org/heigit/ohsome/oshdb/OSHDBTimestamp.java new file mode 100644 index 000000000..7402d6176 --- /dev/null +++ b/oshdb/src/main/java/org/heigit/ohsome/oshdb/OSHDBTimestamp.java @@ -0,0 +1,54 @@ +package org.heigit.ohsome.oshdb; + +import java.io.Serializable; +import java.util.Date; + +public class OSHDBTimestamp implements OSHDBTemporal, Comparable, Serializable { + private static final long serialVersionUID = 1L; + private final long epochSecond; + + public OSHDBTimestamp(OSHDBTemporal temporal) { + this(temporal.getEpochSecond()); + } + + public OSHDBTimestamp(long tstamp) { + this.epochSecond = tstamp; + } + + public OSHDBTimestamp(Date tstamp) { + this(tstamp.getTime() / 1000); + } + + @Override + public int compareTo(OSHDBTimestamp other) { + return Long.compare(this.epochSecond, other.epochSecond); + } + + @Override + public boolean equals(Object other) { + if (other instanceof OSHDBTimestamp) { + return this.epochSecond == ((OSHDBTimestamp) other).epochSecond; + } else { + return super.equals(other); + } + } + + @Override + public int hashCode() { + return Long.hashCode(this.epochSecond); + } + + public Date toDate() { + return new Date(this.epochSecond * 1000); + } + + @Override + public long getEpochSecond() { + return this.epochSecond; + } + + @Override + public String toString() { + return OSHDBTemporal.toIsoDateTime(this); + } +} diff --git a/oshdb/src/main/java/org/heigit/ohsome/oshdb/grid/GridOSHEntity.java b/oshdb/src/main/java/org/heigit/ohsome/oshdb/grid/GridOSHEntity.java index 607f4b3c0..2ced227e1 100644 --- a/oshdb/src/main/java/org/heigit/ohsome/oshdb/grid/GridOSHEntity.java +++ b/oshdb/src/main/java/org/heigit/ohsome/oshdb/grid/GridOSHEntity.java @@ -2,10 +2,10 @@ import java.io.Serializable; import java.util.Locale; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.index.XYGrid; import org.heigit.ohsome.oshdb.osh.OSHEntity; import org.heigit.ohsome.oshdb.util.CellId; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; public abstract class GridOSHEntity implements Serializable { diff --git a/oshdb/src/main/java/org/heigit/ohsome/oshdb/impl/osh/OSHEntityImpl.java b/oshdb/src/main/java/org/heigit/ohsome/oshdb/impl/osh/OSHEntityImpl.java index 05ffd738c..25a39cecf 100644 --- a/oshdb/src/main/java/org/heigit/ohsome/oshdb/impl/osh/OSHEntityImpl.java +++ b/oshdb/src/main/java/org/heigit/ohsome/oshdb/impl/osh/OSHEntityImpl.java @@ -10,12 +10,11 @@ import javax.annotation.Nonnull; import org.heigit.ohsome.oshdb.osh.OSHEntity; import org.heigit.ohsome.oshdb.osm.OSMEntity; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.util.OSHDBTagKey; import org.heigit.ohsome.oshdb.util.bytearray.ByteArrayOutputWrapper; public abstract class OSHEntityImpl - implements OSHEntity, Comparable{ + implements OSHEntity, Comparable { public static class Builder { @@ -55,17 +54,19 @@ public void build(OSMEntity version, byte changed) throws IOException { lastVersion = v; output.writeSInt64( - (version.getTimestamp().getRawUnixTimestamp() - lastTimestamp) - baseTimestamp); - if (!firstVersion && lastTimestamp < version.getTimestamp().getRawUnixTimestamp()) + (version.getEpochSecond() - lastTimestamp) - baseTimestamp); + if (!firstVersion && lastTimestamp < version.getEpochSecond()) { timestampsNotInOrder = true; - lastTimestamp = version.getTimestamp().getRawUnixTimestamp(); + } + lastTimestamp = version.getEpochSecond(); output.writeSInt64(version.getChangesetId() - lastChangeset); lastChangeset = version.getChangesetId(); int userId = version.getUserId(); - if (userId != lastUserId) + if (userId != lastUserId) { changed |= CHANGED_USER_ID; + } int[] keyValues = version.getRawTags(); @@ -84,8 +85,9 @@ public void build(OSMEntity version, byte changed) throws IOException { output.writeUInt32(keyValues.length); for (int kv = 0; kv < keyValues.length; kv++) { output.writeUInt32(keyValues[kv]); - if (kv % 2 == 0) // only keys + if (kv % 2 == 0) { keySet.add(Integer.valueOf(keyValues[kv])); + } } lastKeyValues = keyValues; } @@ -104,14 +106,19 @@ public void build(OSMEntity version, byte changed) throws IOException { protected final long id; protected final byte header; - protected final OSHDBBoundingBox bbox; + protected long minLon; + protected long maxLon; + protected long minLat; + protected long maxLat; protected final int[] keys; protected final int dataOffset; protected final int dataLength; public OSHEntityImpl(final byte[] data, final int offset, final int length, final long baseId, final long baseTimestamp, final long baseLongitude, final long baseLatitude, - final byte header, final long id, final OSHDBBoundingBox bbox, final int[] keys, + final byte header, final long id, + long minLon, long minLat, long maxLon, long maxLat, + final int[] keys, final int dataOffset, final int dataLength) { this.data = data; this.offset = offset; @@ -123,7 +130,11 @@ public OSHEntityImpl(final byte[] data, final int offset, final int length, fina this.header = header; this.id = id; - this.bbox = bbox; + this.minLon = minLon; + this.minLat = minLat; + this.maxLon = maxLon; + this.maxLat = maxLat; + this.keys = keys; this.dataOffset = dataOffset; this.dataLength = dataLength; @@ -138,6 +149,7 @@ public byte[] getData() { return result; } + @Override public long getId() { return id; } @@ -146,8 +158,24 @@ public int getLength() { return length; } - public OSHDBBoundingBox getBoundingBox() { - return bbox; + @Override + public long getMinLonLong() { + return minLon; + } + + @Override + public long getMinLatLong() { + return minLat; + } + + @Override + public long getMaxLonLong() { + return maxLon; + } + + @Override + public long getMaxLatLong() { + return maxLat; } public Iterable getTagKeys() { @@ -172,14 +200,17 @@ public OSHDBTagKey next() { }; } + @Override public int[] getRawTagKeys() { return keys; } + @Override public boolean hasTagKey(OSHDBTagKey tag) { return this.hasTagKey(tag.toInt()); } + @Override public boolean hasTagKey(int key) { // todo: replace with binary search (keys are sorted) for (int i = 0; i < keys.length; i++) { @@ -207,16 +238,17 @@ protected int writeTo(ObjectOutput out) throws IOException { @Override public String toString() { Iterator itr = getVersions().iterator(); - OSMEntity last, first; + OSMEntity last; + OSMEntity first; last = first = itr.next(); - while(itr.hasNext()) + while (itr.hasNext()) { first = itr.next(); - + } + return String.format(Locale.ENGLISH, "ID:%d Vmax:+%d+ Creation:%d BBox:(%f,%f),(%f,%f)", id, last.getVersion(), - first.getTimestamp().getRawUnixTimestamp(), - getBoundingBox().getMinLat(), getBoundingBox().getMinLon(), getBoundingBox().getMaxLat(), - getBoundingBox().getMaxLon()); + first.getEpochSecond(), + getMinLat(), getMinLon(), getMaxLat(), getMaxLon()); } } diff --git a/oshdb/src/main/java/org/heigit/ohsome/oshdb/impl/osh/OSHNodeImpl.java b/oshdb/src/main/java/org/heigit/ohsome/oshdb/impl/osh/OSHNodeImpl.java index 398adb9d8..c397e3aa4 100644 --- a/oshdb/src/main/java/org/heigit/ohsome/oshdb/impl/osh/OSHNodeImpl.java +++ b/oshdb/src/main/java/org/heigit/ohsome/oshdb/impl/osh/OSHNodeImpl.java @@ -13,8 +13,6 @@ import org.heigit.ohsome.oshdb.osm.OSMEntity; import org.heigit.ohsome.oshdb.osm.OSMNode; import org.heigit.ohsome.oshdb.osm.OSMType; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.heigit.ohsome.oshdb.util.bytearray.ByteArrayOutputWrapper; import org.heigit.ohsome.oshdb.util.bytearray.ByteArrayWrapper; @@ -44,17 +42,20 @@ public static OSHNodeImpl instance(final byte[] data, final int offset, final in // header holds data on bitlevel and can then be compared to stereotypical // bitcombinations (e.g. this.HEADER_HAS_TAGS) final byte header = wrapper.readRawByte(); - final OSHDBBoundingBox bbox; + final long minLon; + final long minLat; + final long maxLon; + final long maxLat; if ((header & HEADER_HAS_BOUNDINGBOX) != 0) { - final long minLon = baseLongitude + wrapper.readSInt64(); - final long maxLon = minLon + wrapper.readUInt64(); - final long minLat = baseLatitude + wrapper.readSInt64(); - final long maxLat = minLat + wrapper.readUInt64(); - - bbox = new OSHDBBoundingBox(minLon, minLat, maxLon, maxLat); - + minLon = baseLongitude + wrapper.readSInt64(); + maxLon = minLon + wrapper.readUInt64(); + minLat = baseLatitude + wrapper.readSInt64(); + maxLat = minLat + wrapper.readUInt64(); } else { - bbox = null; + minLon = 1; + minLat = 1; + maxLon = -1; + maxLat = -1; } final int[] keys; if ((header & HEADER_HAS_TAGS) != 0) { @@ -73,55 +74,52 @@ public static OSHNodeImpl instance(final byte[] data, final int offset, final in // TODO maybe better to store number of versions instead final int dataLength = length - (dataOffset - offset); - return new OSHNodeImpl(data, offset, length, baseNodeId, baseTimestamp, baseLongitude, baseLatitude, - header, id, bbox, keys, dataOffset, dataLength); + return new OSHNodeImpl(data, offset, length, + baseNodeId, baseTimestamp, baseLongitude, baseLatitude, + header, id, minLon, minLat, maxLon, maxLat, keys, dataOffset, dataLength); } private OSHNodeImpl(final byte[] data, final int offset, final int length, final long baseNodeId, final long baseTimestamp, final long baseLongitude, final long baseLatitude, - final byte header, final long id, final OSHDBBoundingBox bbox, final int[] keys, + final byte header, final long id, long minLon, long minLat, long maxLon, long maxLat, + final int[] keys, final int dataOffset, final int dataLength) { super(data, offset, length, baseNodeId, baseTimestamp, baseLongitude, baseLatitude, header, id, - bbox, keys, dataOffset, dataLength); + minLon, minLat, maxLon, maxLat, keys, dataOffset, dataLength); + + // correct bbox! + if (!(minLon <= maxLon && minLat <= maxLat)) { + minLon = Long.MAX_VALUE; + maxLon = Long.MIN_VALUE; + minLat = Long.MAX_VALUE; + maxLat = Long.MIN_VALUE; + for (OSMNode osm : this) { + if (osm.isVisible()) { + minLon = Math.min(minLon, osm.getLon()); + maxLon = Math.max(maxLon, osm.getLon()); + + minLat = Math.min(minLat, osm.getLat()); + maxLat = Math.max(maxLat, osm.getLat()); + } + } + + this.minLon = minLon; + this.minLat = minLat; + this.maxLon = maxLon; + this.maxLat = maxLat; + } } @Override public OSMType getType() { return OSMType.NODE; } - + @Override public Iterable getVersions() { return this; } - @Override - public OSHDBBoundingBox getBoundingBox() { - if (bbox != null) { - return bbox; - } - - long minLon = Long.MAX_VALUE; - long maxLon = Long.MIN_VALUE; - long minLat = Long.MAX_VALUE; - long maxLat = Long.MIN_VALUE; - for (OSMNode osm : this) { - if (osm.isVisible()) { - minLon = Math.min(minLon, osm.getLon()); - maxLon = Math.max(maxLon, osm.getLon()); - - minLat = Math.min(minLat, osm.getLat()); - maxLat = Math.max(maxLat, osm.getLat()); - } - } - - if (minLon == Long.MAX_VALUE || minLat == Long.MAX_VALUE) { - return null; - } - - return new OSHDBBoundingBox(minLon, minLat, maxLon, maxLat); - } - @Override public Iterator iterator() { return new Iterator() { @@ -170,7 +168,7 @@ public OSMNode next() { latitude = wrapper.readSInt64() + latitude; } - return new OSMNode(id, version, new OSHDBTimestamp(baseTimestamp + timestamp), changeset, + return new OSMNode(id, version, (baseTimestamp + timestamp), changeset, userId, keyValues, (version > 0) ? baseLongitude + longitude : 0, (version > 0) ? baseLatitude + latitude : 0); } catch (IOException e) { @@ -185,11 +183,11 @@ public OSMNode next() { public static OSHNodeImpl build(List versions) throws IOException { return build(versions, 0, 0, 0, 0); } - + public static OSHNodeImpl build(List versions, final long baseId, final long baseTimestamp, final long baseLongitude, final long baseLatitude) throws IOException { ByteBuffer bb = buildRecord(versions, baseId, baseTimestamp, baseLongitude, baseLatitude); - + return OSHNodeImpl.instance(bb.array(), 0, bb.remaining(), baseId, baseTimestamp, baseLongitude, baseLatitude); } @@ -270,7 +268,7 @@ public static ByteBuffer buildRecord(List versions, final long baseId, record.writeUInt64(id - baseId); record.writeByteArray(output.array(), 0, output.length()); - + return ByteBuffer.wrap(record.array(), 0, record.length()); } diff --git a/oshdb/src/main/java/org/heigit/ohsome/oshdb/impl/osh/OSHRelationImpl.java b/oshdb/src/main/java/org/heigit/ohsome/oshdb/impl/osh/OSHRelationImpl.java index 076bb4064..04281347b 100644 --- a/oshdb/src/main/java/org/heigit/ohsome/oshdb/impl/osh/OSHRelationImpl.java +++ b/oshdb/src/main/java/org/heigit/ohsome/oshdb/impl/osh/OSHRelationImpl.java @@ -14,6 +14,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import org.heigit.ohsome.oshdb.OSHDBBoundable; import org.heigit.ohsome.oshdb.osh.OSHEntities; import org.heigit.ohsome.oshdb.osh.OSHEntity; import org.heigit.ohsome.oshdb.osh.OSHNode; @@ -24,12 +25,11 @@ import org.heigit.ohsome.oshdb.osm.OSMNode; import org.heigit.ohsome.oshdb.osm.OSMRelation; import org.heigit.ohsome.oshdb.osm.OSMType; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.heigit.ohsome.oshdb.util.bytearray.ByteArrayOutputWrapper; import org.heigit.ohsome.oshdb.util.bytearray.ByteArrayWrapper; -public class OSHRelationImpl extends OSHEntityImpl implements OSHRelation, Iterable, Serializable { +public class OSHRelationImpl extends OSHEntityImpl + implements OSHRelation, Iterable, Serializable { private static final long serialVersionUID = 1L; @@ -68,9 +68,6 @@ public static OSHRelationImpl instance(final byte[] data, final int offset, fina final long minLat = baseLatitude + wrapper.readSInt64(); final long maxLat = minLat + wrapper.readUInt64(); - final OSHDBBoundingBox bbox = new OSHDBBoundingBox(minLon, minLat, maxLon, maxLat); - - final int[] keys; if ((header & HEADER_HAS_TAGS) != 0) { final int size = wrapper.readUInt32(); @@ -129,20 +126,20 @@ public static OSHRelationImpl instance(final byte[] data, final int offset, fina return new OSHRelationImpl(data, offset, length, // baseId, baseTimestamp, baseLongitude, baseLatitude, // - header, id, bbox, keys, // + header, id, minLon, minLat, maxLon, maxLat, keys, // dataOffset, dataLength, // nodeIndex, nodeDataOffset, nodeDataLength, // wayIndex, wayDataOffset, wayDataLength); } private OSHRelationImpl(final byte[] data, final int offset, final int length, final long baseId, - final long baseTimestamp, final long baseLongitude, final long baseLatitude, - final byte header, final long id, final OSHDBBoundingBox bbox, final int[] keys, + final long baseTimestamp, final long baseLongitude, final long baseLatitude, byte header, + long id, long minLon, long minLat, long maxLon, long maxLat, int[] keys, final int dataOffset, final int dataLength, final int[] nodeIndex, final int nodeDataOffset, final int nodeDataLength, final int[] wayIndex, final int wayDataOffset, final int wayDataLength) { super(data, offset, length, baseId, baseTimestamp, baseLongitude, baseLatitude, header, id, - bbox, keys, dataOffset, dataLength); + minLon, minLat, maxLon, maxLat, keys, dataOffset, dataLength); this.nodeIndex = nodeIndex; this.nodeDataOffset = nodeDataOffset; @@ -161,7 +158,7 @@ public OSMType getType() { @Override public Iterable getVersions() { - return this; + return this; } @Override @@ -257,7 +254,7 @@ public OSMRelation next() { members[i] = new OSMMember(memberId, memberType, memberRole, member); } } - return new OSMRelation(id, version, new OSHDBTimestamp(baseTimestamp + timestamp), + return new OSMRelation(id, version, (baseTimestamp + timestamp), changeset, userId, keyValues, members); } catch (IOException e) { e.printStackTrace(); @@ -267,10 +264,12 @@ public OSMRelation next() { } }; } catch (IOException e1) { + // no-op } return Collections.emptyIterator(); } + @Override public List getNodes() throws IOException { List nodes = new ArrayList<>(nodeIndex.length); for (int index = 0; index < nodeIndex.length; index++) { @@ -284,31 +283,37 @@ public List getNodes() throws IOException { return nodes; } + @Override public List getWays() throws IOException { List ways = new ArrayList<>(wayIndex.length); for (int index = 0; index < wayIndex.length; index++) { int offset = wayIndex[index]; int length = ((index < wayIndex.length - 1) ? wayIndex[index + 1] : wayDataLength) - offset; - OSHWay w = - OSHWayImpl.instance(data, wayDataOffset + offset, length, 0, 0, baseLongitude, baseLatitude); + OSHWay w = OSHWayImpl.instance(data, wayDataOffset + offset, length, 0, 0, baseLongitude, + baseLatitude); ways.add(w); } return ways; } - public static OSHRelationImpl build(final List versions, final Collection nodes, + public static OSHRelationImpl build(final List versions, + final Collection nodes, final Collection ways) throws IOException { return build(versions, nodes, ways, 0, 0, 0, 0); } - - public static OSHRelationImpl build(final List versions, final Collection nodes, + + public static OSHRelationImpl build(final List versions, + final Collection nodes, final Collection ways, final long baseId, final long baseTimestamp, final long baseLongitude, final long baseLatitude) throws IOException { - ByteBuffer buffer = buildRecord(versions, nodes, ways, baseId, baseTimestamp, baseLongitude, baseLatitude); - return OSHRelationImpl.instance(buffer.array(), 0, buffer.remaining(), baseId, baseTimestamp, baseLongitude, baseLatitude); + ByteBuffer buffer = + buildRecord(versions, nodes, ways, baseId, baseTimestamp, baseLongitude, baseLatitude); + return OSHRelationImpl.instance(buffer.array(), 0, buffer.remaining(), baseId, baseTimestamp, + baseLongitude, baseLatitude); } - public static ByteBuffer buildRecord(final List versions, final Collection nodes, + public static ByteBuffer buildRecord(final List versions, + final Collection nodes, final Collection ways, final long baseId, final long baseTimestamp, final long baseLongitude, final long baseLatitude) throws IOException { Collections.sort(versions, Collections.reverseOrder()); @@ -329,8 +334,8 @@ public static ByteBuffer buildRecord(final List versions, final Col int idx = 0; int offset = 0; for (OSHNode node : nodes) { - OSHDBBoundingBox bbox = node.getBoundingBox(); - if (bbox != null) { + OSHDBBoundable bbox = node; + if (bbox.isValid()) { minLon = Math.min(minLon, bbox.getMinLonLong()); maxLon = Math.max(maxLon, bbox.getMaxLonLong()); minLat = Math.min(minLat, bbox.getMinLatLong()); @@ -349,9 +354,10 @@ public static ByteBuffer buildRecord(final List versions, final Col } } - - - ByteBuffer buffer = OSHNodeImpl.buildRecord(OSHEntities.toList(node.getVersions()), 0, 0, baseLongitude, baseLatitude); + + + ByteBuffer buffer = OSHNodeImpl.buildRecord(OSHEntities.toList(node.getVersions()), 0, 0, + baseLongitude, baseLatitude); nodeOffsets.put(node.getId(), idx); nodeByteArrayIndex[idx++] = offset; offset = buffer.remaining(); @@ -365,13 +371,14 @@ public static ByteBuffer buildRecord(final List versions, final Col idx = 0; offset = 0; for (OSHWay way : ways) { - OSHDBBoundingBox bbox = way.getBoundingBox(); + OSHDBBoundable bbox = way; minLon = Math.min(minLon, bbox.getMinLonLong()); maxLon = Math.max(maxLon, bbox.getMaxLonLong()); minLat = Math.min(minLat, bbox.getMinLatLong()); maxLat = Math.max(maxLat, bbox.getMaxLatLong()); - - ByteBuffer buffer = OSHWayImpl.buildRecord(OSHEntities.toList(way.getVersions()), way.getNodes(), 0, 0, baseLongitude, baseLatitude); + + ByteBuffer buffer = OSHWayImpl.buildRecord(OSHEntities.toList(way.getVersions()), + way.getNodes(), 0, 0, baseLongitude, baseLatitude); wayOffsets.put(way.getId(), idx); wayByteArrayIndex[idx++] = offset; offset = buffer.remaining(); diff --git a/oshdb/src/main/java/org/heigit/ohsome/oshdb/impl/osh/OSHWayImpl.java b/oshdb/src/main/java/org/heigit/ohsome/oshdb/impl/osh/OSHWayImpl.java index 272ddc89b..b5b320597 100644 --- a/oshdb/src/main/java/org/heigit/ohsome/oshdb/impl/osh/OSHWayImpl.java +++ b/oshdb/src/main/java/org/heigit/ohsome/oshdb/impl/osh/OSHWayImpl.java @@ -22,8 +22,6 @@ import org.heigit.ohsome.oshdb.osm.OSMNode; import org.heigit.ohsome.oshdb.osm.OSMType; import org.heigit.ohsome.oshdb.osm.OSMWay; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.heigit.ohsome.oshdb.util.bytearray.ByteArrayOutputWrapper; import org.heigit.ohsome.oshdb.util.bytearray.ByteArrayWrapper; @@ -61,8 +59,6 @@ public static OSHWayImpl instance(final byte[] data, final int offset, final int final long minLat = baseLatitude + wrapper.readSInt64(); final long maxLat = minLat + wrapper.readUInt64(); - final OSHDBBoundingBox bbox = new OSHDBBoundingBox(minLon, minLat, maxLon, maxLat); - final int[] keys; if ((header & HEADER_HAS_TAGS) != 0) { final int size = wrapper.readUInt32(); @@ -98,17 +94,17 @@ public static OSHWayImpl instance(final byte[] data, final int offset, final int final int dataLength = length - (dataOffset - offset); return new OSHWayImpl(data, offset, length, baseId, baseTimestamp, baseLongitude, baseLatitude, - header, id, bbox, keys, dataOffset, dataLength, nodeIndex, nodeDataOffset, nodeDataLength); + header, id, minLon, minLat, maxLon, maxLat, keys, + dataOffset, dataLength, nodeIndex, nodeDataOffset, nodeDataLength); } private OSHWayImpl(final byte[] data, final int offset, final int length, final long baseId, final long baseTimestamp, final long baseLongitude, final long baseLatitude, - final byte header, final long id, final OSHDBBoundingBox bbox, final int[] keys, + byte header, final long id, long minLon, long minLat, long maxLon, long maxLat, int[] keys, final int dataOffset, final int dataLength, final int[] nodeIndex, final int nodeDataOffset, final int nodeDataLength) { super(data, offset, length, baseId, baseTimestamp, baseLongitude, baseLatitude, header, id, - bbox, keys, dataOffset, dataLength); - + minLon, minLat, maxLon, maxLat, keys, dataOffset, dataLength); this.nodeIndex = nodeIndex; this.nodeDataOffset = nodeDataOffset; @@ -181,7 +177,7 @@ public OSMWay next() { } } - return new OSMWay(id, version, new OSHDBTimestamp(baseTimestamp + timestamp), changeset, + return new OSMWay(id, version, (baseTimestamp + timestamp), changeset, userId, keyValues, members); } catch (IOException e) { @@ -270,7 +266,7 @@ public static ByteBuffer buildRecord(List versions, Collection OSMEntity version = way; byte changed = 0; - OSMMember[] refs = way.getRefs(); + OSMMember[] refs = way.getMembers(); if (version.isVisible() && !memberEquals(refs, lastRefs)) { changed |= CHANGED_REFS; } diff --git a/oshdb/src/main/java/org/heigit/ohsome/oshdb/index/XYGrid.java b/oshdb/src/main/java/org/heigit/ohsome/oshdb/index/XYGrid.java index 4ca4b6c3b..32ba130bc 100644 --- a/oshdb/src/main/java/org/heigit/ohsome/oshdb/index/XYGrid.java +++ b/oshdb/src/main/java/org/heigit/ohsome/oshdb/index/XYGrid.java @@ -5,14 +5,14 @@ import java.util.Set; import java.util.TreeSet; import org.heigit.ohsome.oshdb.OSHDB; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.util.CellId; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * XYGrid spans an equal degree grid over the world. - * + * *

Example IDs for zoom = 2: * * @@ -38,7 +38,6 @@ */ public class XYGrid implements Serializable { - private static final long serialVersionUID = 1L; private static final Logger LOG = LoggerFactory.getLogger(XYGrid.class); @@ -75,9 +74,13 @@ public static OSHDBBoundingBox getBoundingBox(final CellId cellID, boolean enlar if (y < grid.zoompow / 2 - 1) { topRightId += grid.zoompow; } - OSHDBBoundingBox result = grid.getCellDimensions(id); - result.add(grid.getCellDimensions(topRightId)); - return result; + OSHDBBoundingBox bbox = grid.getCellDimensions(id); + OSHDBBoundingBox topRight = grid.getCellDimensions(topRightId); + return new OSHDBBoundingBox( + Math.min(bbox.getMinLonLong(), topRight.getMinLonLong()), + Math.min(bbox.getMinLatLong(), topRight.getMinLatLong()), + Math.max(bbox.getMaxLonLong(), topRight.getMaxLonLong()), + Math.max(bbox.getMaxLatLong(), topRight.getMaxLatLong())); } private final int zoom; @@ -115,12 +118,16 @@ public XYGrid(final int zoom) { * @return Returns the ID of the tile as shown above */ public long getId(double longitude, double latitude) { - return this.getId((long) (longitude * OSHDB.GEOM_PRECISION_TO_LONG), (long) (latitude * OSHDB.GEOM_PRECISION_TO_LONG)); + return this.getId((long) (longitude * OSHDB.GEOM_PRECISION_TO_LONG), + (long) (latitude * OSHDB.GEOM_PRECISION_TO_LONG)); } public long getId(long longitude, long latitude) { //return -1, if point is outside geographical coordinate range - if (longitude > (long) (180.0 * OSHDB.GEOM_PRECISION_TO_LONG) || longitude < (long) (-180.0 * OSHDB.GEOM_PRECISION_TO_LONG) || latitude > (long) (90.0 * OSHDB.GEOM_PRECISION_TO_LONG) || latitude < (long) (-90.0 * OSHDB.GEOM_PRECISION_TO_LONG)) { + if (longitude > (long) (180.0 * OSHDB.GEOM_PRECISION_TO_LONG) + || longitude < (long) (-180.0 * OSHDB.GEOM_PRECISION_TO_LONG) + || latitude > (long) (90.0 * OSHDB.GEOM_PRECISION_TO_LONG) + || latitude < (long) (-90.0 * OSHDB.GEOM_PRECISION_TO_LONG)) { return -1l; } @@ -207,9 +214,10 @@ public OSHDBBoundingBox getCellDimensions(final long cellId) { public long getEstimatedIdCount(final OSHDBBoundingBox data) { //number of Cells in x * number of cells in y return Math.max( - (long) Math.ceil(data.getMaxLonLong() / cellWidth) - (long) Math.floor(data.getMinLonLong() / cellWidth), - (long) Math.ceil(data.getMaxLatLong() / cellWidth) - (long) Math.floor(data.getMinLatLong() / cellWidth) - ); + (long) Math.ceil(data.getMaxLonLong() / cellWidth) + - (long) Math.floor(data.getMinLonLong() / cellWidth), + (long) Math.ceil(data.getMaxLatLong() / cellWidth) + - (long) Math.floor(data.getMinLatLong() / cellWidth)); } /** @@ -220,18 +228,18 @@ public long getEstimatedIdCount(final OSHDBBoundingBox data) { public int getLevel() { return zoom; } - + public static class IdRange implements Comparable, Serializable { private static final long serialVersionUID = 371851731642753753L; - public static final IdRange INVALID = new IdRange(-1L,-1L); + public static final IdRange INVALID = new IdRange(-1L, -1L); private final long start; private final long end; public static IdRange of(long start, long end) { - return new IdRange(start,end); + return new IdRange(start, end); } private IdRange(long start, long end) { @@ -280,8 +288,10 @@ public int compareTo(IdRange o) { /** * Calculates all tiles, that lie within a bounding-box. * + *

* TODO but priority 999: Add possibility to snap the BBX to the tile-grid. * TODO: is an exception needed? + *

* * @param bbox The bounding box. First dimension is longitude, second is latitude. * @param enlarge if true, the BBOX is enlarged by one tile to the south-west (bottom-left) @@ -291,31 +301,38 @@ public int compareTo(IdRange o) { public Set bbox2CellIdRanges(OSHDBBoundingBox bbox, boolean enlarge) { //initialise basic variables Set result = new TreeSet<>(); - long minlong = bbox.getMinLonLong(); + long minlat = bbox.getMinLatLong(); - long maxlong = bbox.getMaxLonLong(); long maxlat = bbox.getMaxLatLong(); if (minlat > maxlat) { - LOG.warn("The minimum values are not smaller than the maximum values. This might throw an exeption one day?"); + LOG.warn("The minimum values are not smaller than the maximum values. " + + "This might throw an exeption one day?"); return null; } + long minlong = bbox.getMinLonLong(); + long maxlong = bbox.getMaxLonLong(); + IdRange outofboundsCell = IdRange.INVALID; //test if bbox is on earth or extends further - if (minlong < (long) (-180.0 * OSHDB.GEOM_PRECISION_TO_LONG) || minlong > (long) (180.0 * OSHDB.GEOM_PRECISION_TO_LONG)) { + if (minlong < (long) (-180.0 * OSHDB.GEOM_PRECISION_TO_LONG) + || minlong > (long) (180.0 * OSHDB.GEOM_PRECISION_TO_LONG)) { result.add(outofboundsCell); minlong = (long) (-180.0 * OSHDB.GEOM_PRECISION_TO_LONG); } - if (minlat < (long) (-90.0 * OSHDB.GEOM_PRECISION_TO_LONG) || minlat > (long) (90.0 * OSHDB.GEOM_PRECISION_TO_LONG)) { + if (minlat < (long) (-90.0 * OSHDB.GEOM_PRECISION_TO_LONG) + || minlat > (long) (90.0 * OSHDB.GEOM_PRECISION_TO_LONG)) { result.add(outofboundsCell); minlat = (long) (-90.0 * OSHDB.GEOM_PRECISION_TO_LONG); } - if (maxlong > (long) (180.0 * OSHDB.GEOM_PRECISION_TO_LONG) || maxlong < (long) (-180.0 * OSHDB.GEOM_PRECISION_TO_LONG)) { + if (maxlong > (long) (180.0 * OSHDB.GEOM_PRECISION_TO_LONG) + || maxlong < (long) (-180.0 * OSHDB.GEOM_PRECISION_TO_LONG)) { result.add(outofboundsCell); maxlong = (long) (180.0 * OSHDB.GEOM_PRECISION_TO_LONG); } - if (maxlat > (long) (90.0 * OSHDB.GEOM_PRECISION_TO_LONG) || maxlat < (long) (-90.0 * OSHDB.GEOM_PRECISION_TO_LONG)) { + if (maxlat > (long) (90.0 * OSHDB.GEOM_PRECISION_TO_LONG) + || maxlat < (long) (-90.0 * OSHDB.GEOM_PRECISION_TO_LONG)) { result.add(outofboundsCell); maxlat = (long) (90.0 * OSHDB.GEOM_PRECISION_TO_LONG); } @@ -339,7 +356,7 @@ public Set bbox2CellIdRanges(OSHDBBoundingBox bbox, boolean enlarge) { new OSHDBBoundingBox( minlong, minlat, (long) (180.0 * OSHDB.GEOM_PRECISION_TO_LONG) - 1L, maxlat - ), enlarge)); + ), enlarge)); minlong = (long) (-180.0 * OSHDB.GEOM_PRECISION_TO_LONG); } @@ -354,7 +371,8 @@ public Set bbox2CellIdRanges(OSHDBBoundingBox bbox, boolean enlarge) { int rowmax = (int) ((maxlat + (long) (90.0 * OSHDB.GEOM_PRECISION_TO_LONG)) / cellWidth); if (enlarge) { - //it is impossible vor features to span over the datelimit, so the enlargement stops at column 0 + // it is impossible for features to span over the datelimit, so the enlargement stops at + // column 0 if (columnmin > 0) { columnmin -= 1; } diff --git a/oshdb/src/main/java/org/heigit/ohsome/oshdb/index/XYGridTree.java b/oshdb/src/main/java/org/heigit/ohsome/oshdb/index/XYGridTree.java index 0a25d8443..af4e78af5 100644 --- a/oshdb/src/main/java/org/heigit/ohsome/oshdb/index/XYGridTree.java +++ b/oshdb/src/main/java/org/heigit/ohsome/oshdb/index/XYGridTree.java @@ -6,9 +6,9 @@ import java.util.Objects; import java.util.TreeMap; import org.heigit.ohsome.oshdb.OSHDB; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.index.XYGrid.IdRange; import org.heigit.ohsome.oshdb.util.CellId; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; /** * Multi zoomlevel functionality for the XYGrid. diff --git a/oshdb/src/main/java/org/heigit/ohsome/oshdb/osh/OSHEntities.java b/oshdb/src/main/java/org/heigit/ohsome/oshdb/osh/OSHEntities.java index 8db03b945..b1b63e65c 100644 --- a/oshdb/src/main/java/org/heigit/ohsome/oshdb/osh/OSHEntities.java +++ b/oshdb/src/main/java/org/heigit/ohsome/oshdb/osh/OSHEntities.java @@ -5,8 +5,8 @@ import java.util.Iterator; import java.util.List; import java.util.function.Function; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; import org.heigit.ohsome.oshdb.osm.OSMEntity; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; public final class OSHEntities { private OSHEntities() { @@ -64,7 +64,7 @@ public static List toList( */ public static OSMEntity getByTimestamp(OSHEntity osh, OSHDBTimestamp timestamp) { for (OSMEntity osm : osh.getVersions()) { - if (osm.getTimestamp().getRawUnixTimestamp() <= timestamp.getRawUnixTimestamp()) { + if (osm.getEpochSecond() <= timestamp.getEpochSecond()) { return osm; } } diff --git a/oshdb/src/main/java/org/heigit/ohsome/oshdb/osh/OSHEntity.java b/oshdb/src/main/java/org/heigit/ohsome/oshdb/osh/OSHEntity.java index a29498a0d..c3c6a1121 100644 --- a/oshdb/src/main/java/org/heigit/ohsome/oshdb/osh/OSHEntity.java +++ b/oshdb/src/main/java/org/heigit/ohsome/oshdb/osh/OSHEntity.java @@ -3,19 +3,18 @@ import java.io.IOException; import java.util.Collections; import java.util.List; +import org.heigit.ohsome.oshdb.OSHDBBoundable; import org.heigit.ohsome.oshdb.osm.OSMEntity; import org.heigit.ohsome.oshdb.osm.OSMType; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.util.OSHDBTagKey; -public interface OSHEntity { +public interface OSHEntity extends OSHDBBoundable { long getId(); OSMType getType(); - OSHDBBoundingBox getBoundingBox(); - + @Deprecated int[] getRawTagKeys(); boolean hasTagKey(OSHDBTagKey tag); @@ -23,7 +22,7 @@ public interface OSHEntity { boolean hasTagKey(int key); Iterable getVersions(); - + default List getNodes() throws IOException { return Collections.emptyList(); } diff --git a/oshdb/src/main/java/org/heigit/ohsome/oshdb/osm/OSMEntity.java b/oshdb/src/main/java/org/heigit/ohsome/oshdb/osm/OSMEntity.java index 1a8991c7d..263e4def6 100644 --- a/oshdb/src/main/java/org/heigit/ohsome/oshdb/osm/OSMEntity.java +++ b/oshdb/src/main/java/org/heigit/ohsome/oshdb/osm/OSMEntity.java @@ -4,16 +4,16 @@ import java.util.Iterator; import java.util.stream.IntStream; import javax.annotation.Nonnull; -import org.heigit.ohsome.oshdb.util.OSHDBTag; +import org.heigit.ohsome.oshdb.OSHDBTag; +import org.heigit.ohsome.oshdb.OSHDBTemporal; import org.heigit.ohsome.oshdb.util.OSHDBTagKey; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; -public abstract class OSMEntity { +public abstract class OSMEntity implements OSHDBTemporal { protected final long id; protected final int version; - protected final OSHDBTimestamp timestamp; + protected final long timestamp; protected final long changesetId; protected final int userId; protected final int[] tags; @@ -28,7 +28,7 @@ public abstract class OSMEntity { * @param userId UserID * @param tags An array of OSHDB key-value ids. The format is [KID1,VID1,KID2,VID2...KIDn,VIDn]. */ - public OSMEntity(final long id, final int version, final OSHDBTimestamp timestamp, + public OSMEntity(final long id, final int version, final long timestamp, final long changesetId, final int userId, final int[] tags) { this.id = id; this.version = version; @@ -48,7 +48,8 @@ public int getVersion() { return Math.abs(version); } - public OSHDBTimestamp getTimestamp() { + @Override + public long getEpochSecond() { return timestamp; } @@ -86,6 +87,7 @@ public OSHDBTag next() { }; } + @Deprecated public int[] getRawTags() { return tags; } @@ -151,17 +153,15 @@ public boolean hasTagValue(int key, int value) { return false; } - - public boolean equalsTo(OSMEntity o) { - return id == o.id && version == o.version && timestamp.equals(o.timestamp) + return id == o.id && version == o.version && timestamp == o.timestamp && changesetId == o.changesetId && userId == o.userId && Arrays.equals(tags, o.tags); } @Override public String toString() { return String.format("ID:%d V:+%d+ TS:%d CS:%d VIS:%s UID:%d TAGS:%S", getId(), getVersion(), - getTimestamp().getRawUnixTimestamp(), getChangesetId(), isVisible(), getUserId(), + getEpochSecond(), getChangesetId(), isVisible(), getUserId(), Arrays.toString(getRawTags())); } } diff --git a/oshdb/src/main/java/org/heigit/ohsome/oshdb/osm/OSMNode.java b/oshdb/src/main/java/org/heigit/ohsome/oshdb/osm/OSMNode.java index 5fc56ff2f..a0ea64c05 100644 --- a/oshdb/src/main/java/org/heigit/ohsome/oshdb/osm/OSMNode.java +++ b/oshdb/src/main/java/org/heigit/ohsome/oshdb/osm/OSMNode.java @@ -3,7 +3,6 @@ import java.io.Serializable; import java.util.Locale; import org.heigit.ohsome.oshdb.OSHDB; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; public class OSMNode extends OSMEntity implements Comparable, Serializable { @@ -12,7 +11,7 @@ public class OSMNode extends OSMEntity implements Comparable, Serializa private final long longitude; private final long latitude; - public OSMNode(final long id, final int version, final OSHDBTimestamp timestamp, final long changeset, + public OSMNode(final long id, final int version, final long timestamp, final long changeset, final int userId, final int[] tags, final long longitude, final long latitude) { super(id, version, timestamp, changeset, userId, tags); this.longitude = longitude; @@ -57,7 +56,7 @@ public int compareTo(OSMNode o) { c = Integer.compare(Math.abs(version), Math.abs(o.version)); } if (c == 0) { - c = Long.compare(timestamp.getRawUnixTimestamp(), o.timestamp.getRawUnixTimestamp()); + c = Long.compare(timestamp, o.timestamp); } return c; } diff --git a/oshdb/src/main/java/org/heigit/ohsome/oshdb/osm/OSMRelation.java b/oshdb/src/main/java/org/heigit/ohsome/oshdb/osm/OSMRelation.java index 98da274d6..b3b7cb3a3 100644 --- a/oshdb/src/main/java/org/heigit/ohsome/oshdb/osm/OSMRelation.java +++ b/oshdb/src/main/java/org/heigit/ohsome/oshdb/osm/OSMRelation.java @@ -5,15 +5,15 @@ import java.util.Objects; import java.util.function.Predicate; import java.util.stream.Stream; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; import org.heigit.ohsome.oshdb.osh.OSHEntities; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; public class OSMRelation extends OSMEntity implements Comparable, Serializable { private static final long serialVersionUID = 1L; private final OSMMember[] members; - public OSMRelation(final long id, final int version, final OSHDBTimestamp timestamp, final long changeset, + public OSMRelation(final long id, final int version, final long timestamp, final long changeset, final int userId, final int[] tags, final OSMMember[] members) { super(id, version, timestamp, changeset, userId, tags); this.members = members; @@ -46,7 +46,7 @@ public int compareTo(OSMRelation o) { if (c == 0) { c = Integer.compare(Math.abs(version), Math.abs(o.version)); if (c == 0) { - c = Long.compare(timestamp.getRawUnixTimestamp(), o.timestamp.getRawUnixTimestamp()); + c = Long.compare(timestamp, o.timestamp); } } return c; diff --git a/oshdb/src/main/java/org/heigit/ohsome/oshdb/osm/OSMWay.java b/oshdb/src/main/java/org/heigit/ohsome/oshdb/osm/OSMWay.java index b27b766f4..84e3f4736 100644 --- a/oshdb/src/main/java/org/heigit/ohsome/oshdb/osm/OSMWay.java +++ b/oshdb/src/main/java/org/heigit/ohsome/oshdb/osm/OSMWay.java @@ -4,18 +4,18 @@ import java.util.Arrays; import java.util.Objects; import java.util.stream.Stream; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; import org.heigit.ohsome.oshdb.osh.OSHEntities; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; public class OSMWay extends OSMEntity implements Comparable, Serializable { private static final long serialVersionUID = 1L; - private final OSMMember[] refs; + private final OSMMember[] members; - public OSMWay(final long id, final int version, final OSHDBTimestamp timestamp, final long changeset, + public OSMWay(final long id, final int version, final long timestamp, final long changeset, final int userId, final int[] tags, final OSMMember[] refs) { super(id, version, timestamp, changeset, userId, tags); - this.refs = refs; + this.members = refs; } @Override @@ -23,12 +23,16 @@ public OSMType getType() { return OSMType.WAY; } - public OSMMember[] getRefs() { - return refs; + /** + * Returns the members for this current version. + * + * @return OSMMember for this version + */ public OSMMember[] getMembers() { + return members; } public Stream getRefEntities(OSHDBTimestamp timestamp) { - return Arrays.stream(this.getRefs()) + return Arrays.stream(this.getMembers()) .map(OSMMember::getEntity) .filter(Objects::nonNull) .map(entity -> (OSMNode) OSHEntities.getByTimestamp(entity, timestamp)); @@ -36,7 +40,7 @@ public Stream getRefEntities(OSHDBTimestamp timestamp) { @Override public String toString() { - return String.format("WAY-> %s Refs:%s", super.toString(), Arrays.toString(getRefs())); + return String.format("WAY-> %s Refs:%s", super.toString(), Arrays.toString(getMembers())); } @Override @@ -46,7 +50,7 @@ public int compareTo(OSMWay o) { c = Integer.compare(Math.abs(version), Math.abs(o.version)); } if (c == 0) { - c = Long.compare(timestamp.getRawUnixTimestamp(), o.timestamp.getRawUnixTimestamp()); + c = Long.compare(timestamp, o.timestamp); } return c; } diff --git a/oshdb/src/main/java/org/heigit/ohsome/oshdb/util/OSHDBBoundingBox.java b/oshdb/src/main/java/org/heigit/ohsome/oshdb/util/OSHDBBoundingBox.java deleted file mode 100644 index 7d666175b..000000000 --- a/oshdb/src/main/java/org/heigit/ohsome/oshdb/util/OSHDBBoundingBox.java +++ /dev/null @@ -1,205 +0,0 @@ -package org.heigit.ohsome.oshdb.util; - -import java.io.Serializable; -import java.util.Locale; -import org.heigit.ohsome.oshdb.OSHDB; - -public class OSHDBBoundingBox implements Serializable { - private static final long serialVersionUID = 1L; - public static final OSHDBBoundingBox EMPTY = new OSHDBBoundingBox(0L, 0L, 0L, 0L); - public static final OSHDBBoundingBox INVALID = new OSHDBBoundingBox(Long.MAX_VALUE,Long.MAX_VALUE,Long.MIN_VALUE,Long.MIN_VALUE); - - - /** - * calculates the intersection of two bounding boxes - * - * @param first the first bounding box - * @param second the second bounding box - * @return the intersection of the two bboxes - */ - public static OSHDBBoundingBox intersect(OSHDBBoundingBox first, OSHDBBoundingBox second) { - return new OSHDBBoundingBox( - Math.max(first.minLon, second.minLon), - Math.max(first.minLat, second.minLat), - Math.min(first.maxLon, second.maxLon), - Math.min(first.maxLat, second.maxLat) - ); - } - - public static OVERLAP overlap(OSHDBBoundingBox a, OSHDBBoundingBox b) { - if (b.minLon >= a.maxLon - || b.maxLon <= a.minLon - || b.minLat >= a.maxLat - || b.maxLat <= a.minLat) { - return OVERLAP.NONE; // no overlap - } - // fit bbox in test - if (a.minLon >= b.minLon && a.maxLon <= b.maxLon && a.minLat >= b.minLat - && a.maxLat <= b.maxLat) { - return OVERLAP.A_COMPLETE_IN_B; - } - // fit test in bbox - if (b.minLon >= a.minLon && b.maxLon <= a.maxLon && b.minLat >= a.minLat - && b.maxLat <= a.maxLat) { - return OVERLAP.B_COMPLETE_IN_A; - } - return OVERLAP.OVERLAPPING; - } - - private long minLon; - private long maxLon; - private long minLat; - private long maxLat; - - public OSHDBBoundingBox(long minLon, long minLat, long maxLon, long maxLat) { - this.minLon = minLon; - this.maxLon = maxLon; - this.minLat = minLat; - this.maxLat = maxLat; - } - - public void set(long minLon, long minLat, long maxLon, long maxLat) { - this.minLon = minLon; - this.maxLon = maxLon; - this.minLat = minLat; - this.maxLat = maxLat; - } - - public OSHDBBoundingBox(double minLon, double minLat, double maxLon, double maxLat) { - this.minLon = Math.round(minLon * OSHDB.GEOM_PRECISION_TO_LONG); - this.maxLon = Math.round(maxLon * OSHDB.GEOM_PRECISION_TO_LONG); - this.minLat = Math.round(minLat * OSHDB.GEOM_PRECISION_TO_LONG); - this.maxLat = Math.round(maxLat * OSHDB.GEOM_PRECISION_TO_LONG); - } - - public OSHDBBoundingBox(int minLon, int minLat, int maxLon, int maxLat) { - this((double) minLon, (double) minLat, (double) maxLon, (double) maxLat); - } - - public void set(OSHDBBoundingBox bbox) { - this.minLon = bbox.minLon; - this.maxLon = bbox.maxLon; - this.minLat = bbox.minLat; - this.maxLat = bbox.maxLat; - } - - public void add(OSHDBBoundingBox bbox){ - this.minLon = Math.min(minLon,bbox.minLon); - this.maxLon = Math.max(maxLon,bbox.maxLon); - this.minLat = Math.min(minLat,bbox.minLat); - this.maxLat = Math.max(maxLat,bbox.maxLat); - } - - public double getMinLon() { - return minLon * OSHDB.GEOM_PRECISION; - } - - public long getMinLonLong(){ - return minLon; - } - - public double getMaxLon() { - return maxLon * OSHDB.GEOM_PRECISION; - } - - public long getMaxLonLong(){ - return maxLon; - } - - public double getMinLat() { - return minLat * OSHDB.GEOM_PRECISION; - } - - public long getMinLatLong(){ - return minLat; - } - - public double getMaxLat() { - return maxLat * OSHDB.GEOM_PRECISION; - } - - public long getMaxLatLong(){ - return maxLat; - } - - public long[] getLon() { - return new long[]{minLon, maxLon}; - } - - public long[] getLat() { - return new long[]{minLat, maxLat}; - } - - public boolean intersects(OSHDBBoundingBox otherBbox) { - return (otherBbox != null) - && (maxLat >= otherBbox.minLat) && (minLat <= otherBbox.maxLat) - && (maxLon >= otherBbox.minLon) && (minLon <= otherBbox.maxLon); - } - - public boolean isInside(OSHDBBoundingBox otherBbox) { - return (otherBbox != null) - && (minLat >= otherBbox.minLat) && (maxLat <= otherBbox.maxLat) - && (minLon >= otherBbox.minLon) && (maxLon <= otherBbox.maxLon); - } - - @Override - public String toString() { - return String.format(Locale.ENGLISH, - "(%3.7f,%3.7f,%3.7f,%3.7f)", - this.getMinLon(), - this.getMinLat(), - this.getMaxLon(), - this.getMaxLat()); - } - - @Override - public int hashCode() { - int hash = 7; - hash = 79 * hash + (int) (this.minLon ^ (this.minLon >>> 32)); - hash = 79 * hash + (int) (this.maxLon ^ (this.maxLon >>> 32)); - hash = 79 * hash + (int) (this.minLat ^ (this.minLat >>> 32)); - hash = 79 * hash + (int) (this.maxLat ^ (this.maxLat >>> 32)); - return hash; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final OSHDBBoundingBox other = (OSHDBBoundingBox) obj; - if (this.minLon != other.minLon) { - return false; - } - if (this.maxLon != other.maxLon) { - return false; - } - if (this.minLat != other.minLat) { - return false; - } - return this.maxLat == other.maxLat; - } - - public enum OVERLAP { - NONE, - OVERLAPPING, - A_COMPLETE_IN_B, - B_COMPLETE_IN_A - } - - public boolean isPoint() { - return minLon == maxLon && minLat == maxLat; - } - - public boolean isValid(){ - return minLon <= maxLon && minLat <= maxLat; - } - - -} diff --git a/oshdb/src/main/java/org/heigit/ohsome/oshdb/util/OSHDBTagKey.java b/oshdb/src/main/java/org/heigit/ohsome/oshdb/util/OSHDBTagKey.java index f3765c8ab..df3685ec6 100644 --- a/oshdb/src/main/java/org/heigit/ohsome/oshdb/util/OSHDBTagKey.java +++ b/oshdb/src/main/java/org/heigit/ohsome/oshdb/util/OSHDBTagKey.java @@ -20,7 +20,7 @@ public boolean isPresentInKeytables() { @Override public boolean equals(Object o) { - return o instanceof OSHDBTagKey && ((OSHDBTagKey)o).key == this.key; + return o instanceof OSHDBTagKey && ((OSHDBTagKey) o).key == this.key; } @Override diff --git a/oshdb/src/main/java/org/heigit/ohsome/oshdb/util/OSHDBTimestamp.java b/oshdb/src/main/java/org/heigit/ohsome/oshdb/util/OSHDBTimestamp.java deleted file mode 100644 index f82e3fd8c..000000000 --- a/oshdb/src/main/java/org/heigit/ohsome/oshdb/util/OSHDBTimestamp.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.heigit.ohsome.oshdb.util; - -import java.io.Serializable; -import java.time.Instant; -import java.time.ZoneOffset; -import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; -import java.util.Date; - -public class OSHDBTimestamp implements Comparable, Serializable { - private static final long serialVersionUID = 1L; - private long tstamp; - - public OSHDBTimestamp(long tstamp) { - this.tstamp = tstamp; - } - - public OSHDBTimestamp(Date tstamp) { - this(tstamp.getTime() / 1000); - } - - public void setTimestamp(long tstamp){ - this.tstamp = tstamp; - } - - @Override - public int compareTo(OSHDBTimestamp other) { - return Long.compare(this.tstamp, other.tstamp); - } - - @Override - public boolean equals(Object other) { - if (other instanceof OSHDBTimestamp) - return this.tstamp == ((OSHDBTimestamp)other).tstamp; - else - return super.equals(other); - } - - @Override - public int hashCode() { - return Long.hashCode(this.tstamp); - } - - public Date toDate() { - return new Date(this.tstamp * 1000); - } - - public long getRawUnixTimestamp() { - return this.tstamp; - } - - public String toString() { - ZonedDateTime zdt = ZonedDateTime.ofInstant(Instant.ofEpochSecond(tstamp), ZoneOffset.UTC); - return zdt.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME); - } -} diff --git a/oshdb/src/test/java/org/heigit/ohsome/oshdb/grid/GridOSHNodesTest.java b/oshdb/src/test/java/org/heigit/ohsome/oshdb/grid/GridOSHNodesTest.java index 3c5fdbeac..63f38f9f6 100644 --- a/oshdb/src/test/java/org/heigit/ohsome/oshdb/grid/GridOSHNodesTest.java +++ b/oshdb/src/test/java/org/heigit/ohsome/oshdb/grid/GridOSHNodesTest.java @@ -6,10 +6,10 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; import org.heigit.ohsome.oshdb.impl.osh.OSHNodeImpl; import org.heigit.ohsome.oshdb.osh.OSHNode; import org.heigit.ohsome.oshdb.osm.OSMNode; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.junit.Test; public class GridOSHNodesTest { @@ -21,9 +21,9 @@ public void testHOSMCell() { List hosmNodes = new ArrayList<>(); for (int i = 0; i < 3; i++) { List versions = new ArrayList<>(); - versions.add(new OSMNode(123l + 10 * i, 1, new OSHDBTimestamp(123001l + 10 * i), 0l, 123, new int[] {}, + versions.add(new OSMNode(123l + 10 * i, 1, (123001l + 10 * i), 0l, 123, new int[] {}, 86809727l - 1000000 * i, 494094984l - 1000000 * i)); - versions.add(new OSMNode(123l + 10 * i, 2, new OSHDBTimestamp(123002l + 10 * i), 0l, 123, new int[] {}, + versions.add(new OSMNode(123l + 10 * i, 2, (123002l + 10 * i), 0l, 123, new int[] {}, 86809727l - 1000000 * i, 494094984l - 1000000 * i)); hosmNodes.add(OSHNodeImpl.build(versions)); } @@ -56,9 +56,9 @@ public void testToString() throws IOException { List hosmNodes = new ArrayList<>(); for (int i = 0; i < 3; i++) { List versions = new ArrayList<>(); - versions.add(new OSMNode(123l + 10 * i, 1, new OSHDBTimestamp(123001l + 10 * i), 0l, 123, new int[] {}, + versions.add(new OSMNode(123l + 10 * i, 1, (123001l + 10 * i), 0l, 123, new int[] {}, 86809727l - 1000000 * i, 494094984l - 1000000 * i)); - versions.add(new OSMNode(123l + 10 * i, 2, new OSHDBTimestamp(123002l + 10 * i), 0l, 123, new int[] {}, + versions.add(new OSMNode(123l + 10 * i, 2, (123002l + 10 * i), 0l, 123, new int[] {}, 86809727l - 1000000 * i, 494094984l - 1000000 * i)); hosmNodes.add(OSHNodeImpl.build(versions)); } diff --git a/oshdb/src/test/java/org/heigit/ohsome/oshdb/grid/GridOSHRelationsTest.java b/oshdb/src/test/java/org/heigit/ohsome/oshdb/grid/GridOSHRelationsTest.java index 955a9f456..0979bf5f8 100644 --- a/oshdb/src/test/java/org/heigit/ohsome/oshdb/grid/GridOSHRelationsTest.java +++ b/oshdb/src/test/java/org/heigit/ohsome/oshdb/grid/GridOSHRelationsTest.java @@ -5,6 +5,7 @@ import java.io.IOException; import java.util.Arrays; import java.util.List; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; import org.heigit.ohsome.oshdb.impl.osh.OSHNodeImpl; import org.heigit.ohsome.oshdb.impl.osh.OSHRelationImpl; import org.heigit.ohsome.oshdb.impl.osh.OSHWayImpl; @@ -17,7 +18,6 @@ import org.heigit.ohsome.oshdb.osm.OSMRelation; import org.heigit.ohsome.oshdb.osm.OSMType; import org.heigit.ohsome.oshdb.osm.OSMWay; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.junit.Test; public class GridOSHRelationsTest { @@ -25,23 +25,23 @@ public class GridOSHRelationsTest { @Test public void test() throws IOException { OSHNode node100 = buildHOSMNode( - Arrays.asList(new OSMNode(100l, 1, new OSHDBTimestamp(1l), 0l, 123, new int[]{1, 2}, 494094984l, 86809727l))); + Arrays.asList(new OSMNode(100l, 1, 1l, 0l, 123, new int[]{1, 2}, 494094984l, 86809727l))); OSHNode node102 = buildHOSMNode( - Arrays.asList(new OSMNode(102l, 1, new OSHDBTimestamp(1l), 0l, 123, new int[]{2, 1}, 494094984l, 86809727l))); + Arrays.asList(new OSMNode(102l, 1, 1l, 0l, 123, new int[]{2, 1}, 494094984l, 86809727l))); OSHNode node104 = buildHOSMNode( - Arrays.asList(new OSMNode(104l, 1, new OSHDBTimestamp(1l), 0l, 123, new int[]{2, 4}, 494094984l, 86809727l))); + Arrays.asList(new OSMNode(104l, 1, 1l, 0l, 123, new int[]{2, 4}, 494094984l, 86809727l))); - OSHWay way200 = buildHOSMWay(Arrays.asList(new OSMWay(200, 1, new OSHDBTimestamp(3333l), 4444l, 23, new int[]{1, 2}, new OSMMember[]{new OSMMember(100, OSMType.NODE, 0), new OSMMember(104, OSMType.NODE, 0)})), Arrays.asList(node100, node104)); - OSHWay way202 = buildHOSMWay(Arrays.asList(new OSMWay(202, 1, new OSHDBTimestamp(3333l), 4444l, 23, new int[]{1, 2}, new OSMMember[]{new OSMMember(100, OSMType.NODE, 0), new OSMMember(102, OSMType.NODE, 0)})), Arrays.asList(node100, node102)); + OSHWay way200 = buildHOSMWay(Arrays.asList(new OSMWay(200, 1, 3333l, 4444l, 23, new int[]{1, 2}, new OSMMember[]{new OSMMember(100, OSMType.NODE, 0), new OSMMember(104, OSMType.NODE, 0)})), Arrays.asList(node100, node104)); + OSHWay way202 = buildHOSMWay(Arrays.asList(new OSMWay(202, 1, 3333l, 4444l, 23, new int[]{1, 2}, new OSMMember[]{new OSMMember(100, OSMType.NODE, 0), new OSMMember(102, OSMType.NODE, 0)})), Arrays.asList(node100, node102)); OSHRelation relation300 = OSHRelationImpl.build(Arrays.asList(// - new OSMRelation(300, 1, new OSHDBTimestamp(3333l), 4444l, 23, new int[]{}, new OSMMember[]{new OSMMember(100, OSMType.NODE, 0, null), new OSMMember(102, OSMType.NODE, 0, null)}), // - new OSMRelation(300, 2, new OSHDBTimestamp(3333l), 4444l, 23, new int[]{1, 2}, new OSMMember[]{new OSMMember(100, OSMType.NODE, 0, null), new OSMMember(102, OSMType.NODE, 0, null)})), // + new OSMRelation(300, 1, 3333l, 4444l, 23, new int[]{}, new OSMMember[]{new OSMMember(100, OSMType.NODE, 0, null), new OSMMember(102, OSMType.NODE, 0, null)}), // + new OSMRelation(300, 2, 3333l, 4444l, 23, new int[]{1, 2}, new OSMMember[]{new OSMMember(100, OSMType.NODE, 0, null), new OSMMember(102, OSMType.NODE, 0, null)})), // Arrays.asList(node100, node102), Arrays.asList()); OSHRelation relation301 = OSHRelationImpl.build(Arrays.asList(// - new OSMRelation(301, 1, new OSHDBTimestamp(3333l), 4444l, 23, new int[]{}, new OSMMember[]{new OSMMember(200, OSMType.WAY, 1, null), new OSMMember(202, OSMType.WAY, 1, null)}), // - new OSMRelation(301, 2, new OSHDBTimestamp(3333l), 4444l, 23, new int[]{1, 2}, new OSMMember[]{new OSMMember(200, OSMType.WAY, 1, null), new OSMMember(202, OSMType.WAY, 1, null)})), // + new OSMRelation(301, 1, 3333l, 4444l, 23, new int[]{}, new OSMMember[]{new OSMMember(200, OSMType.WAY, 1, null), new OSMMember(202, OSMType.WAY, 1, null)}), // + new OSMRelation(301, 2, 3333l, 4444l, 23, new int[]{1, 2}, new OSMMember[]{new OSMMember(200, OSMType.WAY, 1, null), new OSMMember(202, OSMType.WAY, 1, null)})), // Arrays.asList(), Arrays.asList(way200, way202)); long cellId = 1; @@ -96,23 +96,23 @@ static OSHWay buildHOSMWay(List versions, List nodes) { @Test public void testToString() throws IOException { OSHNode node100 = buildHOSMNode( - Arrays.asList(new OSMNode(100l, 1, new OSHDBTimestamp(1l), 0l, 123, new int[]{1, 2}, 494094984l, 86809727l))); + Arrays.asList(new OSMNode(100l, 1, 1l, 0l, 123, new int[]{1, 2}, 494094984l, 86809727l))); OSHNode node102 = buildHOSMNode( - Arrays.asList(new OSMNode(102l, 1, new OSHDBTimestamp(1l), 0l, 123, new int[]{2, 1}, 494094984l, 86809727l))); + Arrays.asList(new OSMNode(102l, 1, 1l, 0l, 123, new int[]{2, 1}, 494094984l, 86809727l))); OSHNode node104 = buildHOSMNode( - Arrays.asList(new OSMNode(104l, 1, new OSHDBTimestamp(1l), 0l, 123, new int[]{2, 4}, 494094984l, 86809727l))); + Arrays.asList(new OSMNode(104l, 1, 1l, 0l, 123, new int[]{2, 4}, 494094984l, 86809727l))); - OSHWay way200 = buildHOSMWay(Arrays.asList(new OSMWay(200, 1, new OSHDBTimestamp(3333l), 4444l, 23, new int[]{1, 2}, new OSMMember[]{new OSMMember(100, OSMType.NODE, 0), new OSMMember(104, OSMType.NODE, 0)})), Arrays.asList(node100, node104)); - OSHWay way202 = buildHOSMWay(Arrays.asList(new OSMWay(202, 1, new OSHDBTimestamp(3333l), 4444l, 23, new int[]{1, 2}, new OSMMember[]{new OSMMember(100, OSMType.NODE, 0), new OSMMember(102, OSMType.NODE, 0)})), Arrays.asList(node100, node102)); + OSHWay way200 = buildHOSMWay(Arrays.asList(new OSMWay(200, 1, 3333l, 4444l, 23, new int[]{1, 2}, new OSMMember[]{new OSMMember(100, OSMType.NODE, 0), new OSMMember(104, OSMType.NODE, 0)})), Arrays.asList(node100, node104)); + OSHWay way202 = buildHOSMWay(Arrays.asList(new OSMWay(202, 1, 3333l, 4444l, 23, new int[]{1, 2}, new OSMMember[]{new OSMMember(100, OSMType.NODE, 0), new OSMMember(102, OSMType.NODE, 0)})), Arrays.asList(node100, node102)); OSHRelation relation300 = OSHRelationImpl.build(Arrays.asList(// - new OSMRelation(300, 1, new OSHDBTimestamp(3333l), 4444l, 23, new int[]{}, new OSMMember[]{new OSMMember(100, OSMType.NODE, 0, null), new OSMMember(102, OSMType.NODE, 0, null)}), // - new OSMRelation(300, 2, new OSHDBTimestamp(3333l), 4444l, 23, new int[]{1, 2}, new OSMMember[]{new OSMMember(100, OSMType.NODE, 0, null), new OSMMember(102, OSMType.NODE, 0, null)})), // + new OSMRelation(300, 1, 3333l, 4444l, 23, new int[]{}, new OSMMember[]{new OSMMember(100, OSMType.NODE, 0, null), new OSMMember(102, OSMType.NODE, 0, null)}), // + new OSMRelation(300, 2, 3333l, 4444l, 23, new int[]{1, 2}, new OSMMember[]{new OSMMember(100, OSMType.NODE, 0, null), new OSMMember(102, OSMType.NODE, 0, null)})), // Arrays.asList(node100, node102), Arrays.asList()); OSHRelation relation301 = OSHRelationImpl.build(Arrays.asList(// - new OSMRelation(301, 1, new OSHDBTimestamp(3333l), 4444l, 23, new int[]{}, new OSMMember[]{new OSMMember(200, OSMType.WAY, 1, null), new OSMMember(202, OSMType.WAY, 1, null)}), // - new OSMRelation(301, 2, new OSHDBTimestamp(3333l), 4444l, 23, new int[]{1, 2}, new OSMMember[]{new OSMMember(200, OSMType.WAY, 1, null), new OSMMember(202, OSMType.WAY, 1, null)})), // + new OSMRelation(301, 1, 3333l, 4444l, 23, new int[]{}, new OSMMember[]{new OSMMember(200, OSMType.WAY, 1, null), new OSMMember(202, OSMType.WAY, 1, null)}), // + new OSMRelation(301, 2, 3333l, 4444l, 23, new int[]{1, 2}, new OSMMember[]{new OSMMember(200, OSMType.WAY, 1, null), new OSMMember(202, OSMType.WAY, 1, null)})), // Arrays.asList(), Arrays.asList(way200, way202)); long cellId = 2; diff --git a/oshdb/src/test/java/org/heigit/ohsome/oshdb/grid/GridOSHWaysTest.java b/oshdb/src/test/java/org/heigit/ohsome/oshdb/grid/GridOSHWaysTest.java index f462027dd..6ff0746c0 100644 --- a/oshdb/src/test/java/org/heigit/ohsome/oshdb/grid/GridOSHWaysTest.java +++ b/oshdb/src/test/java/org/heigit/ohsome/oshdb/grid/GridOSHWaysTest.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; import org.heigit.ohsome.oshdb.impl.osh.OSHNodeImpl; import org.heigit.ohsome.oshdb.impl.osh.OSHWayImpl; import org.heigit.ohsome.oshdb.osh.OSHNode; @@ -14,7 +15,6 @@ import org.heigit.ohsome.oshdb.osm.OSMNode; import org.heigit.ohsome.oshdb.osm.OSMType; import org.heigit.ohsome.oshdb.osm.OSMWay; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.junit.Test; public class GridOSHWaysTest { @@ -29,11 +29,11 @@ static OSHNode buildHOSMNode(List versions) { } OSHNode node100 = buildHOSMNode( - Arrays.asList(new OSMNode(100l, 1, new OSHDBTimestamp(1l), 0l, 123, new int[]{1, 2}, 494094984l, 86809727l))); + Arrays.asList(new OSMNode(100l, 1, 1l, 0l, 123, new int[]{1, 2}, 494094984l, 86809727l))); OSHNode node102 = buildHOSMNode( - Arrays.asList(new OSMNode(102l, 1, new OSHDBTimestamp(1l), 0l, 123, new int[]{2, 1}, 494094984l, 86809727l))); + Arrays.asList(new OSMNode(102l, 1, 1l, 0l, 123, new int[]{2, 1}, 494094984l, 86809727l))); OSHNode node104 = buildHOSMNode( - Arrays.asList(new OSMNode(104l, 1, new OSHDBTimestamp(1l), 0l, 123, new int[]{2, 4}, 494094984l, 86809727l))); + Arrays.asList(new OSMNode(104l, 1, 1l, 0l, 123, new int[]{2, 4}, 494094984l, 86809727l))); @Test public void testToString() throws IOException { @@ -41,9 +41,9 @@ public void testToString() throws IOException { for (int i = 0; i < 3; i++) { List versions = new ArrayList<>(); versions.add( - new OSMWay(123, 1, new OSHDBTimestamp(3333l), 4444l, 23, new int[]{1, 1, 2, 1}, new OSMMember[]{new OSMMember(102, OSMType.NODE, 0), new OSMMember(104, OSMType.NODE, 0)})); + new OSMWay(123, 1, 3333l, 4444l, 23, new int[]{1, 1, 2, 1}, new OSMMember[]{new OSMMember(102, OSMType.NODE, 0), new OSMMember(104, OSMType.NODE, 0)})); versions.add( - new OSMWay(123, 3, new OSHDBTimestamp(3333l), 4444l, 23, new int[]{1, 1, 2, 2}, new OSMMember[]{new OSMMember(100, OSMType.NODE, 0), new OSMMember(104, OSMType.NODE, 0)})); + new OSMWay(123, 3, 3333l, 4444l, 23, new int[]{1, 1, 2, 2}, new OSMMember[]{new OSMMember(100, OSMType.NODE, 0), new OSMMember(104, OSMType.NODE, 0)})); hosmWays.add(OSHWayImpl.build(versions, Arrays.asList(node100, node102, node104))); } diff --git a/oshdb/src/test/java/org/heigit/ohsome/oshdb/index/XYGridTest.java b/oshdb/src/test/java/org/heigit/ohsome/oshdb/index/XYGridTest.java index 43b804c14..4b7b2fc23 100644 --- a/oshdb/src/test/java/org/heigit/ohsome/oshdb/index/XYGridTest.java +++ b/oshdb/src/test/java/org/heigit/ohsome/oshdb/index/XYGridTest.java @@ -5,9 +5,9 @@ import java.util.Set; import java.util.TreeSet; import org.heigit.ohsome.oshdb.OSHDB; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.index.XYGrid.IdRange; import org.heigit.ohsome.oshdb.util.CellId; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; import org.junit.Before; import org.junit.Test; import org.slf4j.Logger; @@ -261,8 +261,8 @@ public void testGetLevel() { @Test public void testBbox2Ids() { - OSHDBBoundingBox BBOX = new OSHDBBoundingBox(-180, -90, 180, 90); - Set result = zero.bbox2CellIdRanges(BBOX, false); + OSHDBBoundingBox bbox = new OSHDBBoundingBox(-180, -90, 180, 90); + Set result = zero.bbox2CellIdRanges(bbox, false); assertEquals(1, result.size()); IdRange interval = result.iterator().next(); @@ -270,8 +270,8 @@ public void testBbox2Ids() { assertEquals(0, interval.getStart()); assertEquals(0, interval.getEnd()); - BBOX = new OSHDBBoundingBox(-180, -90, 180, 90); - result = two.bbox2CellIdRanges(BBOX, false); + bbox = new OSHDBBoundingBox(-180, -90, 180, 90); + result = two.bbox2CellIdRanges(bbox, false); assertEquals(2, result.size()); interval = result.iterator().next(); @@ -279,8 +279,8 @@ public void testBbox2Ids() { assertEquals(0, interval.getStart()); assertEquals(3, interval.getEnd()); - BBOX = new OSHDBBoundingBox(-10, -10, 10, 10); - result = zero.bbox2CellIdRanges(BBOX, false); + bbox = new OSHDBBoundingBox(-10, -10, 10, 10); + result = zero.bbox2CellIdRanges(bbox, false); assertEquals(1, result.size()); interval = result.iterator().next(); @@ -288,8 +288,8 @@ public void testBbox2Ids() { assertEquals(0, interval.getStart()); assertEquals(0, interval.getEnd()); - BBOX = new OSHDBBoundingBox(179, 0, 89, 5); - result = zero.bbox2CellIdRanges(BBOX, false); + bbox = new OSHDBBoundingBox(179, 0, 89, 5); + result = zero.bbox2CellIdRanges(bbox, false); assertEquals(1, result.size()); interval = result.iterator().next(); @@ -297,13 +297,13 @@ public void testBbox2Ids() { assertEquals(0, interval.getStart()); assertEquals(0, interval.getEnd()); - BBOX = new OSHDBBoundingBox(-10, -10, 10, 10); + bbox = new OSHDBBoundingBox(-10, -10, 10, 10); TreeSet expectedCellIds = new TreeSet<>(); expectedCellIds.add(1L); expectedCellIds.add(2L); expectedCellIds.add(5L); expectedCellIds.add(6L); - result = two.bbox2CellIdRanges(BBOX, false); + result = two.bbox2CellIdRanges(bbox, false); for (IdRange interval2 : result) { for (long cellId = interval2.getStart(); cellId <= interval2.getEnd(); cellId++) { assertEquals(true, expectedCellIds.remove(cellId)); @@ -311,13 +311,13 @@ public void testBbox2Ids() { } assertEquals(0, expectedCellIds.size()); - BBOX = new OSHDBBoundingBox(-180, 0, 89, 5); + bbox = new OSHDBBoundingBox(-180, 0, 89, 5); expectedCellIds = new TreeSet<>(); expectedCellIds.add(4L); expectedCellIds.add(5L); expectedCellIds.add(6L); - result = two.bbox2CellIdRanges(BBOX, false); + result = two.bbox2CellIdRanges(bbox, false); for (IdRange interval2 : result) { for (long cellId = interval2.getStart(); cellId <= interval2.getEnd(); cellId++) { assertEquals(true, expectedCellIds.remove(cellId)); @@ -325,14 +325,14 @@ public void testBbox2Ids() { } assertEquals(0, expectedCellIds.size()); - BBOX = new OSHDBBoundingBox(90, -90, 89, -1); + bbox = new OSHDBBoundingBox(90, -90, 89, -1); expectedCellIds = new TreeSet<>(); expectedCellIds.add(0L); expectedCellIds.add(1L); expectedCellIds.add(2L); expectedCellIds.add(3L); - result = two.bbox2CellIdRanges(BBOX, false); + result = two.bbox2CellIdRanges(bbox, false); for (IdRange interval2 : result) { for (long cellId = interval2.getStart(); cellId <= interval2.getEnd(); cellId++) { assertEquals(true, expectedCellIds.remove(cellId)); @@ -347,10 +347,10 @@ public void testBbox2Ids() { assertEquals(0, interval.getEnd()); // test performance for maximum sized BBOX - BBOX = new OSHDBBoundingBox(-180, -90, 180, 90); + bbox = new OSHDBBoundingBox(-180, -90, 180, 90); int expResult = (int)Math.pow(2,MAXZOOM)/2; LOG.info("If this throws a warning because of the maximum zoomlevel, we have to change XYGrid-Code:"); - result = new XYGrid(MAXZOOM).bbox2CellIdRanges(BBOX, true); + result = new XYGrid(MAXZOOM).bbox2CellIdRanges(bbox, true); assertEquals(expResult, result.size()); interval = result.iterator().next(); assertEquals(0, interval.getStart()); diff --git a/oshdb/src/test/java/org/heigit/ohsome/oshdb/index/XYGridTreeTest.java b/oshdb/src/test/java/org/heigit/ohsome/oshdb/index/XYGridTreeTest.java index 78fe85628..fbb175ebf 100644 --- a/oshdb/src/test/java/org/heigit/ohsome/oshdb/index/XYGridTreeTest.java +++ b/oshdb/src/test/java/org/heigit/ohsome/oshdb/index/XYGridTreeTest.java @@ -7,8 +7,8 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Set; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; import org.heigit.ohsome.oshdb.util.CellId; -import org.heigit.ohsome.oshdb.util.OSHDBBoundingBox; import org.junit.Test; public class XYGridTreeTest { diff --git a/oshdb/src/test/java/org/heigit/ohsome/oshdb/osh/OSHNodeTest.java b/oshdb/src/test/java/org/heigit/ohsome/oshdb/osh/OSHNodeTest.java index 3ff8ada56..3303bce3b 100644 --- a/oshdb/src/test/java/org/heigit/ohsome/oshdb/osh/OSHNodeTest.java +++ b/oshdb/src/test/java/org/heigit/ohsome/oshdb/osh/OSHNodeTest.java @@ -8,7 +8,6 @@ import java.util.List; import org.heigit.ohsome.oshdb.impl.osh.OSHNodeImpl; import org.heigit.ohsome.oshdb.osm.OSMNode; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.junit.Test; public class OSHNodeTest { @@ -20,8 +19,8 @@ public class OSHNodeTest { @Test public void testBuild() throws IOException { OSHNode hnode = buildOSHNode( - new OSMNode(123L, 1, new OSHDBTimestamp(1L), 0L, USER_A, TAGS_A, LONLAT_A[0], LONLAT_A[1]), - new OSMNode(123L, -2, new OSHDBTimestamp(2L), 0L, USER_A, TAGS_A, LONLAT_A[0], LONLAT_A[1]) + new OSMNode(123L, 1, 1L, 0L, USER_A, TAGS_A, LONLAT_A[0], LONLAT_A[1]), + new OSMNode(123L, -2, 2L, 0L, USER_A, TAGS_A, LONLAT_A[0], LONLAT_A[1]) ); assertNotNull(hnode); @@ -49,9 +48,9 @@ public void testRebase() throws IOException { // 85391383800:27676689900 // NODE: ID:3718143950 V:+1+ TS:1440747974000 CS:33637224 VIS:true USER:3191558 TAGS:[] // 49619125:78983750 - versions.add(new OSMNode(3718143950L, 2, new OSHDBTimestamp(1480304071000L / 1000), + versions.add(new OSMNode(3718143950L, 2, 1480304071000L / 1000, 43996323L, 4803525, new int[0], 85391383800L / 100, 27676689900L / 100)); - versions.add(new OSMNode(3718143950L, 1, new OSHDBTimestamp(1440747974000L / 1000), + versions.add(new OSMNode(3718143950L, 1, 1440747974000L / 1000, 33637224, 3191558, new int[0], 85391416000L / 100, 27676640000L / 100)); OSHNode hosm = OSHNodeImpl.build(versions); @@ -67,8 +66,8 @@ public void testRebase() throws IOException { @Test public void testToString() throws IOException { OSHNode instance = buildOSHNode( - new OSMNode(123L, 2, new OSHDBTimestamp(2L), 0L, USER_A, TAGS_A, LONLAT_A[0], LONLAT_A[1]), - new OSMNode(123L, 1, new OSHDBTimestamp(1L), 0L, USER_A, TAGS_A, LONLAT_B[0], LONLAT_B[1]) + new OSMNode(123L, 2, 2L, 0L, USER_A, TAGS_A, LONLAT_A[0], LONLAT_A[1]), + new OSMNode(123L, 1, 1L, 0L, USER_A, TAGS_A, LONLAT_B[0], LONLAT_B[1]) ); String expResult = diff --git a/oshdb/src/test/java/org/heigit/ohsome/oshdb/osh/OSHRelationTest.java b/oshdb/src/test/java/org/heigit/ohsome/oshdb/osh/OSHRelationTest.java index 52b56c9ca..8db7dcf39 100644 --- a/oshdb/src/test/java/org/heigit/ohsome/oshdb/osh/OSHRelationTest.java +++ b/oshdb/src/test/java/org/heigit/ohsome/oshdb/osh/OSHRelationTest.java @@ -17,25 +17,24 @@ import org.heigit.ohsome.oshdb.osm.OSMRelation; import org.heigit.ohsome.oshdb.osm.OSMType; import org.heigit.ohsome.oshdb.osm.OSMWay; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.junit.Test; public class OSHRelationTest { OSHNode node100 = OSHNodeTest.buildOSHNode(new OSMNode( - 100L, 1, new OSHDBTimestamp(1L), 0L, 123, new int[]{1, 2}, 494094980L, 86809720L)); + 100L, 1, 1L, 0L, 123, new int[]{1, 2}, 494094980L, 86809720L)); OSHNode node102 = OSHNodeTest.buildOSHNode(new OSMNode( - 102L, 1, new OSHDBTimestamp(1L), 0L, 123, new int[]{2, 1}, 494094970L, 86809730L)); + 102L, 1, 1L, 0L, 123, new int[]{2, 1}, 494094970L, 86809730L)); OSHNode node104 = OSHNodeTest.buildOSHNode(new OSMNode( - 104L, 1, new OSHDBTimestamp(1L), 0L, 123, new int[]{2, 4}, 494094960L, 86809740L)); + 104L, 1, 1L, 0L, 123, new int[]{2, 4}, 494094960L, 86809740L)); OSHWay way200 = OSHWayImpl.build(Lists.newArrayList( - new OSMWay(200, 1, new OSHDBTimestamp(3333L), 4444L, 23, new int[]{1, 2}, new OSMMember[]{ + new OSMWay(200, 1, 3333L, 4444L, 23, new int[]{1, 2}, new OSMMember[]{ new OSMMember(100, OSMType.NODE, 0), new OSMMember(104, OSMType.NODE, 0)}) ), List.of(node100, node104)); OSHWay way202 = OSHWayImpl.build(Lists.newArrayList( - new OSMWay(202, 1, new OSHDBTimestamp(3333L), 4444L, 23, new int[]{1, 2}, new OSMMember[]{ + new OSMWay(202, 1, 3333L, 4444L, 23, new int[]{1, 2}, new OSMMember[]{ new OSMMember(100, OSMType.NODE, 0), new OSMMember(102, OSMType.NODE, 0)}) ), List.of(node100, node102)); @@ -45,7 +44,7 @@ public OSHRelationTest() throws IOException {} @Test public void testGetNodes() throws IOException { OSHRelation hrelation = OSHRelationImpl.build(Lists.newArrayList( - new OSMRelation(300, 1, new OSHDBTimestamp(3333L), 4444L, 23, new int[]{}, new OSMMember[]{ + new OSMRelation(300, 1, 3333L, 4444L, 23, new int[]{}, new OSMMember[]{ new OSMMember(100, OSMType.NODE, 0), new OSMMember(102, OSMType.NODE, 0), new OSMMember(104, OSMType.NODE, 0)}) @@ -58,7 +57,7 @@ public void testGetNodes() throws IOException { @Test public void testWithMissingNode() throws IOException { OSHRelation hrelation = OSHRelationImpl.build(Lists.newArrayList( - new OSMRelation(300, 1, new OSHDBTimestamp(3333L), 4444L, 23, new int[]{}, new OSMMember[]{ + new OSMRelation(300, 1, 3333L, 4444L, 23, new int[]{}, new OSMMember[]{ new OSMMember(100, OSMType.NODE, 0), new OSMMember(102, OSMType.NODE, 0), new OSMMember(104, OSMType.NODE, 0)}) @@ -87,7 +86,7 @@ public void testWithMissingNode() throws IOException { @Test public void testGetWays() throws IOException { OSHRelation hrelation = OSHRelationImpl.build(Lists.newArrayList( - new OSMRelation(300, 1, new OSHDBTimestamp(3333L), 4444L, 23, new int[]{}, new OSMMember[]{ + new OSMRelation(300, 1, 3333L, 4444L, 23, new int[]{}, new OSMMember[]{ new OSMMember(200, OSMType.WAY, 0), new OSMMember(202, OSMType.WAY, 0)}) ), Collections.emptyList(), List.of(way200, way202), @@ -104,7 +103,7 @@ public void testGetWays() throws IOException { @Test public void testCompact() throws IOException { OSHRelation hrelation = OSHRelationImpl.build(Lists.newArrayList( - new OSMRelation(300, 1, new OSHDBTimestamp(3333L), 4444L, 23, new int[]{}, new OSMMember[]{ + new OSMRelation(300, 1, 3333L, 4444L, 23, new int[]{}, new OSMMember[]{ new OSMMember(100, OSMType.NODE, 0), new OSMMember(102, OSMType.NODE, 0), new OSMMember(104, OSMType.NODE, 0), @@ -152,7 +151,7 @@ public void testCompact() throws IOException { @Test public void testToString() throws IOException { OSHRelation instance = OSHRelationImpl.build(Lists.newArrayList( - new OSMRelation(300, 1, new OSHDBTimestamp(3333L), 4444L, 23, new int[]{}, new OSMMember[]{ + new OSMRelation(300, 1, 3333L, 4444L, 23, new int[]{}, new OSMMember[]{ new OSMMember(100, OSMType.NODE, 0), new OSMMember(102, OSMType.NODE, 0), new OSMMember(104, OSMType.NODE, 0)}) diff --git a/oshdb/src/test/java/org/heigit/ohsome/oshdb/osh/OSHWayTest.java b/oshdb/src/test/java/org/heigit/ohsome/oshdb/osh/OSHWayTest.java index 04b842c66..e9c63f149 100644 --- a/oshdb/src/test/java/org/heigit/ohsome/oshdb/osh/OSHWayTest.java +++ b/oshdb/src/test/java/org/heigit/ohsome/oshdb/osh/OSHWayTest.java @@ -14,28 +14,27 @@ import org.heigit.ohsome.oshdb.osm.OSMNode; import org.heigit.ohsome.oshdb.osm.OSMType; import org.heigit.ohsome.oshdb.osm.OSMWay; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.junit.Test; public class OSHWayTest { OSHNode node100 = OSHNodeTest.buildOSHNode(new OSMNode( - 100L, 1, new OSHDBTimestamp(1L), 0L, 123, new int[]{1, 2}, 494094984L, 86809727L)); + 100L, 1, 1L, 0L, 123, new int[]{1, 2}, 494094984L, 86809727L)); OSHNode node102 = OSHNodeTest.buildOSHNode(new OSMNode( - 102L, 1, new OSHDBTimestamp(1L), 0L, 123, new int[]{2, 1}, 494094984L, 86809727L)); + 102L, 1, 1L, 0L, 123, new int[]{2, 1}, 494094984L, 86809727L)); OSHNode node104 = OSHNodeTest.buildOSHNode(new OSMNode( - 104L, 1, new OSHDBTimestamp(1L), 0L, 123, new int[]{2, 4}, 494094984L, 86809727L)); + 104L, 1, 1L, 0L, 123, new int[]{2, 4}, 494094984L, 86809727L)); public OSHWayTest() throws IOException {} @Test public void testGetNodes() throws IOException { OSHWay hway = OSHWayImpl.build(Lists.newArrayList( - new OSMWay(123, 1, new OSHDBTimestamp(3333L), 4444L, 23, new int[]{1, 1, 2, 1}, + new OSMWay(123, 1, 3333L, 4444L, 23, new int[]{1, 1, 2, 1}, new OSMMember[]{ new OSMMember(102, OSMType.NODE, 0), new OSMMember(104, OSMType.NODE, 0)}), - new OSMWay(123, 3, new OSHDBTimestamp(3333L), 4444L, 23, new int[]{1, 1, 2, 2}, + new OSMWay(123, 3, 3333L, 4444L, 23, new int[]{1, 1, 2, 2}, new OSMMember[]{ new OSMMember(100, OSMType.NODE, 0), new OSMMember(104, OSMType.NODE, 0)}) @@ -49,11 +48,11 @@ public void testGetNodes() throws IOException { @Test public void testWithMissingNode() throws IOException { OSHWay hway = OSHWayImpl.build(Lists.newArrayList( - new OSMWay(123, 3, new OSHDBTimestamp(3333L), 4444L, 23, new int[]{1, 1, 2, 2}, + new OSMWay(123, 3, 3333L, 4444L, 23, new int[]{1, 1, 2, 2}, new OSMMember[]{ new OSMMember(100, OSMType.NODE, 0), new OSMMember(104, OSMType.NODE, 0)}), - new OSMWay(123, 1, new OSHDBTimestamp(3333L), 4444L, 23, new int[]{1, 1, 2, 1}, + new OSMWay(123, 1, 3333L, 4444L, 23, new int[]{1, 1, 2, 1}, new OSMMember[]{ new OSMMember(102, OSMType.NODE, 0), new OSMMember(104, OSMType.NODE, 0)}) @@ -68,14 +67,14 @@ public void testWithMissingNode() throws IOException { Iterator itr = hway.getVersions().iterator(); assertTrue(itr.hasNext()); way = itr.next(); - members = way.getRefs(); + members = way.getMembers(); assertEquals(2, members.length); assertEquals(100, members[0].getId()); assertEquals(104, members[1].getId()); assertTrue(itr.hasNext()); way = itr.next(); - members = way.getRefs(); + members = way.getMembers(); assertEquals(2, members.length); assertEquals(102, members[0].getId()); @@ -85,11 +84,11 @@ public void testWithMissingNode() throws IOException { @Test public void testToString() throws IOException { OSHWay instance = OSHWayImpl.build(Lists.newArrayList( - new OSMWay(123, 1, new OSHDBTimestamp(3333L), 4444L, 23, new int[]{1, 1, 2, 1}, + new OSMWay(123, 1, 3333L, 4444L, 23, new int[]{1, 1, 2, 1}, new OSMMember[]{ new OSMMember(102, OSMType.NODE, 0), new OSMMember(104, OSMType.NODE, 0)}), - new OSMWay(123, 3, new OSHDBTimestamp(3333L), 4444L, 23, new int[]{1, 1, 2, 2}, + new OSMWay(123, 3, 3333L, 4444L, 23, new int[]{1, 1, 2, 2}, new OSMMember[]{ new OSMMember(100, OSMType.NODE, 0), new OSMMember(104, OSMType.NODE, 0)}) diff --git a/oshdb/src/test/java/org/heigit/ohsome/oshdb/osm/OSMMemberTest.java b/oshdb/src/test/java/org/heigit/ohsome/oshdb/osm/OSMMemberTest.java index 2541cc739..cf759bdb6 100644 --- a/oshdb/src/test/java/org/heigit/ohsome/oshdb/osm/OSMMemberTest.java +++ b/oshdb/src/test/java/org/heigit/ohsome/oshdb/osm/OSMMemberTest.java @@ -1,7 +1,3 @@ -/* - * To change this license header, choose License Headers in Project Properties. To change this - * template file, choose Tools | Templates and open the template in the editor. - */ package org.heigit.ohsome.oshdb.osm; import static org.junit.Assert.assertEquals; diff --git a/oshdb/src/test/java/org/heigit/ohsome/oshdb/osm/OSMNodeTest.java b/oshdb/src/test/java/org/heigit/ohsome/oshdb/osm/OSMNodeTest.java index 710a29c26..4848e2155 100644 --- a/oshdb/src/test/java/org/heigit/ohsome/oshdb/osm/OSMNodeTest.java +++ b/oshdb/src/test/java/org/heigit/ohsome/oshdb/osm/OSMNodeTest.java @@ -3,7 +3,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; import org.junit.Assert; import org.junit.Test; @@ -13,7 +12,7 @@ public OSMNodeTest() {} @Test public void testGetLongitude() { - OSMNode instance = new OSMNode(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {}, 1000000000L, 1L); + OSMNode instance = new OSMNode(1L, 1, 1L, 1L, 1, new int[] {}, 1000000000L, 1L); double expResult = 100.0; double result = instance.getLongitude(); assertEquals(expResult, result, 0.0); @@ -21,7 +20,7 @@ public void testGetLongitude() { @Test public void testGetLatitude() { - OSMNode instance = new OSMNode(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {}, 1000000000L, 1000000000L); + OSMNode instance = new OSMNode(1L, 1, 1L, 1L, 1, new int[] {}, 1000000000L, 1000000000L); double expResult = 100.0; double result = instance.getLatitude(); assertEquals(expResult, result, 0.0); @@ -29,7 +28,7 @@ public void testGetLatitude() { @Test public void testGetLon() { - OSMNode instance = new OSMNode(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {}, 1000000000L, 1000000000L); + OSMNode instance = new OSMNode(1L, 1, 1L, 1L, 1, new int[] {}, 1000000000L, 1000000000L); long expResult = 1000000000L; long result = instance.getLon(); assertEquals(expResult, result); @@ -37,7 +36,7 @@ public void testGetLon() { @Test public void testGetLat() { - OSMNode instance = new OSMNode(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {}, 1000000000L, 1000000000L); + OSMNode instance = new OSMNode(1L, 1, 1L, 1L, 1, new int[] {}, 1000000000L, 1000000000L); long expResult = 1000000000L; long result = instance.getLat(); assertEquals(expResult, result); @@ -45,7 +44,7 @@ public void testGetLat() { @Test public void testToString() { - OSMNode instance = new OSMNode(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {}, 1100000000L, 100000000L); + OSMNode instance = new OSMNode(1L, 1, 1L, 1L, 1, new int[] {}, 1100000000L, 100000000L); String expResult = "NODE: ID:1 V:+1+ TS:1 CS:1 VIS:true UID:1 TAGS:[] 110.0000000:10.0000000"; String result = instance.toString(); assertEquals(expResult, result); @@ -55,9 +54,9 @@ public void testToString() { @Test public void testEqualsTo() { OSMNode o = - new OSMNode(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1, 2, 2, 3, 3}, 1000000000L, 1000000000L); + new OSMNode(1L, 1, 1L, 1L, 1, new int[] {1, 1, 2, 2, 3, 3}, 1000000000L, 1000000000L); OSMNode instance = - new OSMNode(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1, 2, 2, 3, 3}, 1000000000L, 1000000000L); + new OSMNode(1L, 1, 1L, 1L, 1, new int[] {1, 1, 2, 2, 3, 3}, 1000000000L, 1000000000L); boolean expResult = true; boolean result = instance.equalsTo(o); assertEquals(expResult, result); @@ -66,9 +65,9 @@ public void testEqualsTo() { @Test public void testEqualsToII() { OSMNode o = - new OSMNode(2L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1, 2, 2, 3, 3}, 1000000000L, 1000000000L); + new OSMNode(2L, 1, 1L, 1L, 1, new int[] {1, 1, 2, 2, 3, 3}, 1000000000L, 1000000000L); OSMNode instance = - new OSMNode(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1, 2, 2, 3, 3}, 1000000000L, 1000000000L); + new OSMNode(1L, 1, 1L, 1L, 1, new int[] {1, 1, 2, 2, 3, 3}, 1000000000L, 1000000000L); boolean expResult = false; boolean result = instance.equalsTo(o); assertEquals(expResult, result); @@ -77,31 +76,31 @@ public void testEqualsToII() { @Test public void testCompareTo() { OSMNode o = - new OSMNode(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1, 2, 2, 3, 3}, 1000000000L, 1000000000L); + new OSMNode(1L, 1, 1L, 1L, 1, new int[] {1, 1, 2, 2, 3, 3}, 1000000000L, 1000000000L); OSMNode instance = - new OSMNode(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1, 2, 2, 3, 3}, 1000000000L, 1000000000L); + new OSMNode(1L, 1, 1L, 1L, 1, new int[] {1, 1, 2, 2, 3, 3}, 1000000000L, 1000000000L); assertTrue(instance.compareTo(o) == 0); - o = new OSMNode(1L, 3, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1, 2, 2, 3, 3}, 1000000000L, 1000000000L); + o = new OSMNode(1L, 3, 1L, 1L, 1, new int[] {1, 1, 2, 2, 3, 3}, 1000000000L, 1000000000L); instance = - new OSMNode(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1, 2, 2, 3, 3}, 1000000000L, 1000000000L); + new OSMNode(1L, 1, 1L, 1L, 1, new int[] {1, 1, 2, 2, 3, 3}, 1000000000L, 1000000000L); assertTrue(instance.compareTo(o) < 0); - o = new OSMNode(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1, 2, 2, 3, 3}, 1000000000L, 1000000000L); + o = new OSMNode(1L, 1, 1L, 1L, 1, new int[] {1, 1, 2, 2, 3, 3}, 1000000000L, 1000000000L); instance = - new OSMNode(1L, 3, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1, 2, 2, 3, 3}, 1000000000L, 1000000000L); + new OSMNode(1L, 3, 1L, 1L, 1, new int[] {1, 1, 2, 2, 3, 3}, 1000000000L, 1000000000L); assertTrue(instance.compareTo(o) > 0); - o = new OSMNode(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1, 2, 2, 3, 3}, 1000000000L, 1000000000L); + o = new OSMNode(1L, 1, 1L, 1L, 1, new int[] {1, 1, 2, 2, 3, 3}, 1000000000L, 1000000000L); instance = - new OSMNode(1L, -6, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1, 2, 2, 3, 3}, 1000000000L, 1000000000L); + new OSMNode(1L, -6, 1L, 1L, 1, new int[] {1, 1, 2, 2, 3, 3}, 1000000000L, 1000000000L); assertTrue(instance.compareTo(o) > 0); } // ------------------- @Test public void testGetId() { - OSMNode instance = new OSMNode(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {}, 1000000000L, 1000000000L); + OSMNode instance = new OSMNode(1L, 1, 1L, 1L, 1, new int[] {}, 1000000000L, 1000000000L); long expResult = 1L; long result = instance.getId(); assertEquals(expResult, result); @@ -109,7 +108,7 @@ public void testGetId() { @Test public void testGetVersion() { - OSMNode instance = new OSMNode(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {}, 1000000000L, 1000000000L); + OSMNode instance = new OSMNode(1L, 1, 1L, 1L, 1, new int[] {}, 1000000000L, 1000000000L); int expResult = 1; int result = instance.getVersion(); assertEquals(expResult, result); @@ -117,15 +116,15 @@ public void testGetVersion() { @Test public void testGetTimestamp() { - OSMNode instance = new OSMNode(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {}, 1000000000L, 1000000000L); + OSMNode instance = new OSMNode(1L, 1, 1L, 1L, 1, new int[] {}, 1000000000L, 1000000000L); long expResult = 1L; - long result = instance.getTimestamp().getRawUnixTimestamp(); + long result = instance.getEpochSecond(); assertEquals(expResult, result); } @Test public void testGetChangeset() { - OSMNode instance = new OSMNode(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {}, 1000000000L, 1000000000L); + OSMNode instance = new OSMNode(1L, 1, 1L, 1L, 1, new int[] {}, 1000000000L, 1000000000L); long expResult = 1L; long result = instance.getChangesetId(); assertEquals(expResult, result); @@ -133,7 +132,7 @@ public void testGetChangeset() { @Test public void testGetUserId() { - OSMNode instance = new OSMNode(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {}, 1000000000L, 1000000000L); + OSMNode instance = new OSMNode(1L, 1, 1L, 1L, 1, new int[] {}, 1000000000L, 1000000000L); int expResult = 1; int result = instance.getUserId(); assertEquals(expResult, result); @@ -141,7 +140,7 @@ public void testGetUserId() { @Test public void testisVisible() { - OSMNode instance = new OSMNode(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {}, 1000000000L, 1000000000L); + OSMNode instance = new OSMNode(1L, 1, 1L, 1L, 1, new int[] {}, 1000000000L, 1000000000L); boolean expResult = true; boolean result = instance.isVisible(); assertEquals(expResult, result); @@ -149,7 +148,7 @@ public void testisVisible() { @Test public void testisVisibleII() { - OSMNode instance = new OSMNode(1L, -1, new OSHDBTimestamp(1L), 1L, 1, new int[] {}, 1000000000L, 1000000000L); + OSMNode instance = new OSMNode(1L, -1, 1L, 1L, 1, new int[] {}, 1000000000L, 1000000000L); boolean expResult = false; boolean result = instance.isVisible(); assertEquals(expResult, result); @@ -157,7 +156,7 @@ public void testisVisibleII() { @Test public void testGetTags() { - OSMNode instance = new OSMNode(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {}, 1000000000L, 1000000000L); + OSMNode instance = new OSMNode(1L, 1, 1L, 1L, 1, new int[] {}, 1000000000L, 1000000000L); int[] expResult = new int[] {}; int[] result = instance.getRawTags(); Assert.assertArrayEquals(expResult, result); @@ -165,30 +164,30 @@ public void testGetTags() { @Test public void testHasTagKey() { - OSMNode instance = new OSMNode(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {}, 1000000000L, 1000000000L); + OSMNode instance = new OSMNode(1L, 1, 1L, 1L, 1, new int[] {}, 1000000000L, 1000000000L); boolean expResult = false; boolean result = instance.hasTagKey(1); assertEquals(expResult, result); instance = - new OSMNode(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1, 2, 2, 3, 3}, 1000000000L, 1000000000L); + new OSMNode(1L, 1, 1L, 1L, 1, new int[] {1, 1, 2, 2, 3, 3}, 1000000000L, 1000000000L); expResult = true; result = instance.hasTagKey(1); assertEquals(expResult, result); instance = - new OSMNode(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 2, 2, 2, 3, 3}, 1000000000L, 1000000000L); + new OSMNode(1L, 1, 1L, 1L, 1, new int[] {1, 2, 2, 2, 3, 3}, 1000000000L, 1000000000L); expResult = false; result = instance.hasTagKeyExcluding(1, new int[] {2, 3}); assertEquals(expResult, result); instance = - new OSMNode(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1, 2, 2, 3, 3}, 1000000000L, 1000000000L); + new OSMNode(1L, 1, 1L, 1L, 1, new int[] {1, 1, 2, 2, 3, 3}, 1000000000L, 1000000000L); expResult = true; result = instance.hasTagKeyExcluding(1, new int[] {2, 3}); assertEquals(expResult, result); - instance = new OSMNode(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {2, 1, 3, 3}, 1000000000L, 1000000000L); + instance = new OSMNode(1L, 1, 1L, 1L, 1, new int[] {2, 1, 3, 3}, 1000000000L, 1000000000L); expResult = false; result = instance.hasTagKeyExcluding(1, new int[] {1, 3}); assertEquals(expResult, result); @@ -197,12 +196,12 @@ public void testHasTagKey() { @Test public void testHasTagValue() { OSMNode instance = - new OSMNode(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 2, 2, 3}, 1000000000L, 1000000000L); + new OSMNode(1L, 1, 1L, 1L, 1, new int[] {1, 2, 2, 3}, 1000000000L, 1000000000L); boolean expResult = false; boolean result = instance.hasTagValue(1, 1); assertEquals(expResult, result); - instance = new OSMNode(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1, 2, 3}, 1000000000L, 1000000000L); + instance = new OSMNode(1L, 1, 1L, 1L, 1, new int[] {1, 1, 2, 3}, 1000000000L, 1000000000L); expResult = true; result = instance.hasTagValue(1, 1); assertEquals(expResult, result); @@ -220,8 +219,8 @@ public void testEqualsToOSMNode() { long longitude = 86809727l; long latitude = 494094984l; - OSMNode a = new OSMNode(id, version, new OSHDBTimestamp(timestamp), changeset, userId, tags, longitude, latitude); - OSMNode b = new OSMNode(id, version, new OSHDBTimestamp(timestamp), changeset, userId, tags, longitude, latitude); + OSMNode a = new OSMNode(id, version, timestamp, changeset, userId, tags, longitude, latitude); + OSMNode b = new OSMNode(id, version, timestamp, changeset, userId, tags, longitude, latitude); assertTrue(a.equalsTo(b)); } @@ -236,11 +235,11 @@ public void testCompareToV() { long longitude = 86809727l; long latitude = 494094984l; - OSMNode a = new OSMNode(id, version, new OSHDBTimestamp(timestamp), changeset, userId, tags, longitude, latitude); + OSMNode a = new OSMNode(id, version, timestamp, changeset, userId, tags, longitude, latitude); OSMNode b; - b = new OSMNode(id, version + 2, new OSHDBTimestamp(timestamp), changeset, userId, tags, longitude, latitude); + b = new OSMNode(id, version + 2, timestamp, changeset, userId, tags, longitude, latitude); assertTrue(a.compareTo(b) < 0); } diff --git a/oshdb/src/test/java/org/heigit/ohsome/oshdb/osm/OSMRelationTest.java b/oshdb/src/test/java/org/heigit/ohsome/oshdb/osm/OSMRelationTest.java index fe5138cf9..fd20a3865 100644 --- a/oshdb/src/test/java/org/heigit/ohsome/oshdb/osm/OSMRelationTest.java +++ b/oshdb/src/test/java/org/heigit/ohsome/oshdb/osm/OSMRelationTest.java @@ -4,7 +4,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; import org.junit.Assert; import org.junit.Test; @@ -16,7 +16,7 @@ public OSMRelationTest() {} public void testGetMembers() { OSMMember part = new OSMMember(1L, OSMType.WAY, 1); OSMRelation instance = - new OSMRelation(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1, 2, 2}, new OSMMember[] {part, part}); + new OSMRelation(1L, 1, 1L, 1L, 1, new int[] {1, 1, 2, 2}, new OSMMember[] {part, part}); OSMMember[] expResult = new OSMMember[] {part, part}; OSMMember[] result = instance.getMembers(); assertArrayEquals(expResult, result); @@ -26,21 +26,21 @@ public void testGetMembers() { public void testCompareTo() { OSMMember part = new OSMMember(1L, OSMType.WAY, 1); OSMRelation instance = - new OSMRelation(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1, 2, 2}, new OSMMember[] {part, part}); + new OSMRelation(1L, 1, 1L, 1L, 1, new int[] {1, 1, 2, 2}, new OSMMember[] {part, part}); OSMRelation o = - new OSMRelation(1L, 2, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1, 2, 2}, new OSMMember[] {part, part}); + new OSMRelation(1L, 2, 1L, 1L, 1, new int[] {1, 1, 2, 2}, new OSMMember[] {part, part}); assertTrue(instance.compareTo(o) < 0); part = new OSMMember(1L, OSMType.WAY, 1); instance = - new OSMRelation(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1, 2, 2}, new OSMMember[] {part, part}); - o = new OSMRelation(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1, 2, 2}, new OSMMember[] {part, part}); + new OSMRelation(1L, 1, 1L, 1L, 1, new int[] {1, 1, 2, 2}, new OSMMember[] {part, part}); + o = new OSMRelation(1L, 1, 1L, 1L, 1, new int[] {1, 1, 2, 2}, new OSMMember[] {part, part}); assertTrue(instance.compareTo(o) == 0); part = new OSMMember(1L, OSMType.WAY, 1); instance = - new OSMRelation(1L, 2, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1, 2, 2}, new OSMMember[] {part, part}); - o = new OSMRelation(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1, 2, 2}, new OSMMember[] {part, part}); + new OSMRelation(1L, 2, 1L, 1L, 1, new int[] {1, 1, 2, 2}, new OSMMember[] {part, part}); + o = new OSMRelation(1L, 1, 1L, 1L, 1, new int[] {1, 1, 2, 2}, new OSMMember[] {part, part}); assertTrue(instance.compareTo(o) > 0); } @@ -49,7 +49,7 @@ public void testCompareTo() { public void testGetId() { OSMMember part = new OSMMember(1L, OSMType.WAY, 1); OSMRelation instance = - new OSMRelation(1L, 2, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1, 2, 2}, new OSMMember[] {part, part}); + new OSMRelation(1L, 2, 1L, 1L, 1, new int[] {1, 1, 2, 2}, new OSMMember[] {part, part}); long expResult = 1L; long result = instance.getId(); assertEquals(expResult, result); @@ -59,7 +59,7 @@ public void testGetId() { public void testGetVersion() { OSMMember part = new OSMMember(1L, OSMType.WAY, 1); OSMRelation instance = - new OSMRelation(1L, 2, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1, 2, 2}, new OSMMember[] {part, part}); + new OSMRelation(1L, 2, 1L, 1L, 1, new int[] {1, 1, 2, 2}, new OSMMember[] {part, part}); int expResult = 2; int result = instance.getVersion(); assertEquals(expResult, result); @@ -69,9 +69,9 @@ public void testGetVersion() { public void testGetTimestamp() { OSMMember part = new OSMMember(1L, OSMType.WAY, 1); OSMRelation instance = - new OSMRelation(1L, 2, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1, 2, 2}, new OSMMember[] {part, part}); + new OSMRelation(1L, 2, 1L, 1L, 1, new int[] {1, 1, 2, 2}, new OSMMember[] {part, part}); long expResult = 1L; - long result = instance.getTimestamp().getRawUnixTimestamp(); + long result = instance.getEpochSecond(); assertEquals(expResult, result); } @@ -79,7 +79,7 @@ public void testGetTimestamp() { public void testGetChangeset() { OSMMember part = new OSMMember(1L, OSMType.WAY, 1); OSMRelation instance = - new OSMRelation(1L, 2, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1, 2, 2}, new OSMMember[] {part, part}); + new OSMRelation(1L, 2, 1L, 1L, 1, new int[] {1, 1, 2, 2}, new OSMMember[] {part, part}); long expResult = 1L; long result = instance.getChangesetId(); assertEquals(expResult, result); @@ -89,7 +89,7 @@ public void testGetChangeset() { public void testGetUserId() { OSMMember part = new OSMMember(1L, OSMType.WAY, 1); OSMRelation instance = - new OSMRelation(1L, 2, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1, 2, 2}, new OSMMember[] {part, part}); + new OSMRelation(1L, 2, 1L, 1L, 1, new int[] {1, 1, 2, 2}, new OSMMember[] {part, part}); int expResult = 1; int result = instance.getUserId(); assertEquals(expResult, result); @@ -99,14 +99,14 @@ public void testGetUserId() { public void testisVisible() { OSMMember part = new OSMMember(1L, OSMType.WAY, 1); OSMRelation instance = - new OSMRelation(1L, 2, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1, 2, 2}, new OSMMember[] {part, part}); + new OSMRelation(1L, 2, 1L, 1L, 1, new int[] {1, 1, 2, 2}, new OSMMember[] {part, part}); boolean expResult = true; boolean result = instance.isVisible(); assertEquals(expResult, result); part = new OSMMember(1L, OSMType.WAY, 1); instance = - new OSMRelation(1L, -2, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1, 2, 2}, new OSMMember[] {part, part}); + new OSMRelation(1L, -2, 1L, 1L, 1, new int[] {1, 1, 2, 2}, new OSMMember[] {part, part}); expResult = false; result = instance.isVisible(); assertEquals(expResult, result); @@ -116,7 +116,7 @@ public void testisVisible() { public void testGetTags() { OSMMember part = new OSMMember(1L, OSMType.WAY, 1); OSMRelation instance = - new OSMRelation(1L, 2, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1, 2, 2}, new OSMMember[] {part, part}); + new OSMRelation(1L, 2, 1L, 1L, 1, new int[] {1, 1, 2, 2}, new OSMMember[] {part, part}); int[] expResult = new int[] {1, 1, 2, 2}; int[] result = instance.getRawTags(); Assert.assertArrayEquals(expResult, result); @@ -126,27 +126,27 @@ public void testGetTags() { public void testHasTagKey() { OSMMember part = new OSMMember(1L, OSMType.WAY, 1); OSMRelation instance = - new OSMRelation(1L, 2, new OSHDBTimestamp(1L), 1L, 1, new int[] {}, new OSMMember[] {part, part}); + new OSMRelation(1L, 2, 1L, 1L, 1, new int[] {}, new OSMMember[] {part, part}); boolean expResult = false; boolean result = instance.hasTagKey(1); assertEquals(expResult, result); part = new OSMMember(1L, OSMType.WAY, 1); - instance = new OSMRelation(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1, 2, 2, 3, 3}, + instance = new OSMRelation(1L, 1, 1L, 1L, 1, new int[] {1, 1, 2, 2, 3, 3}, new OSMMember[] {part, part}); expResult = true; result = instance.hasTagKey(1); assertEquals(expResult, result); part = new OSMMember(1L, OSMType.WAY, 1); - instance = new OSMRelation(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 2, 2, 2, 3, 3}, + instance = new OSMRelation(1L, 1, 1L, 1L, 1, new int[] {1, 2, 2, 2, 3, 3}, new OSMMember[] {part, part}); expResult = false; result = instance.hasTagKeyExcluding(1, new int[] {2, 3}); assertEquals(expResult, result); part = new OSMMember(1L, OSMType.WAY, 1); - instance = new OSMRelation(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1, 2, 2, 3, 3}, + instance = new OSMRelation(1L, 1, 1L, 1L, 1, new int[] {1, 1, 2, 2, 3, 3}, new OSMMember[] {part, part}); expResult = true; result = instance.hasTagKeyExcluding(1, new int[] {2, 3}); @@ -154,7 +154,7 @@ public void testHasTagKey() { part = new OSMMember(1L, OSMType.WAY, 1); instance = - new OSMRelation(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {2, 1, 3, 3}, new OSMMember[] {part, part}); + new OSMRelation(1L, 1, 1L, 1L, 1, new int[] {2, 1, 3, 3}, new OSMMember[] {part, part}); expResult = false; result = instance.hasTagKeyExcluding(1, new int[] {1, 3}); assertEquals(expResult, result); @@ -164,7 +164,7 @@ public void testHasTagKey() { public void testHasTagValue() { OSMMember part = new OSMMember(1L, OSMType.WAY, 1); OSMRelation instance = - new OSMRelation(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 2, 2, 3}, new OSMMember[] {part, part}); + new OSMRelation(1L, 1, 1L, 1L, 1, new int[] {1, 2, 2, 3}, new OSMMember[] {part, part}); boolean expResult = false; boolean result = instance.hasTagValue(1, 1); assertEquals(expResult, result); @@ -174,7 +174,7 @@ public void testHasTagValue() { public void testHasTagValueII() { OSMMember part = new OSMMember(1L, OSMType.WAY, 1); OSMRelation instance = - new OSMRelation(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1, 2, 3}, new OSMMember[] {part, part}); + new OSMRelation(1L, 1, 1L, 1L, 1, new int[] {1, 1, 2, 3}, new OSMMember[] {part, part}); boolean expResult = true; boolean result = instance.hasTagValue(1, 1); assertEquals(expResult, result); @@ -184,7 +184,7 @@ public void testHasTagValueII() { public void testToString() { OSMMember part = new OSMMember(1L, OSMType.WAY, 1); OSMRelation instance = - new OSMRelation(1L, 2, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 2}, new OSMMember[] {part, part}); + new OSMRelation(1L, 2, 1L, 1L, 1, new int[] {1, 2}, new OSMMember[] {part, part}); String expResult = "Relation-> ID:1 V:+2+ TS:1 CS:1 VIS:true UID:1 TAGS:[1, 2] Mem:[T:WAY ID:1 R:1, T:WAY ID:1 R:1]"; String result = instance.toString(); diff --git a/oshdb/src/test/java/org/heigit/ohsome/oshdb/osm/OSMWayTest.java b/oshdb/src/test/java/org/heigit/ohsome/oshdb/osm/OSMWayTest.java index 9178328ea..392aae5dd 100644 --- a/oshdb/src/test/java/org/heigit/ohsome/oshdb/osm/OSMWayTest.java +++ b/oshdb/src/test/java/org/heigit/ohsome/oshdb/osm/OSMWayTest.java @@ -4,7 +4,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import org.heigit.ohsome.oshdb.util.OSHDBTimestamp; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; import org.junit.Assert; import org.junit.Test; @@ -15,37 +15,37 @@ public OSMWayTest() {} @Test public void testGetRefs() { OSMMember part = new OSMMember(1L, OSMType.NODE, 1); - OSMWay instance = new OSMWay(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {}, new OSMMember[] {part, part}); + OSMWay instance = new OSMWay(1L, 1, 1L, 1L, 1, new int[] {}, new OSMMember[] {part, part}); OSMMember[] expResult = new OSMMember[] {part, part}; - OSMMember[] result = instance.getRefs(); + OSMMember[] result = instance.getMembers(); assertArrayEquals(expResult, result); - instance = new OSMWay(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {}, new OSMMember[] {}); + instance = new OSMWay(1L, 1, 1L, 1L, 1, new int[] {}, new OSMMember[] {}); expResult = new OSMMember[] {}; - result = instance.getRefs(); + result = instance.getMembers(); assertArrayEquals(expResult, result); - instance = new OSMWay(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {}, null); + instance = new OSMWay(1L, 1, 1L, 1L, 1, new int[] {}, null); expResult = null; - result = instance.getRefs(); + result = instance.getMembers(); assertArrayEquals(expResult, result); } @Test public void testToString() { OSMMember part = new OSMMember(1L, OSMType.NODE, 1); - OSMWay instance = new OSMWay(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {}, new OSMMember[] {part, part}); + OSMWay instance = new OSMWay(1L, 1, 1L, 1L, 1, new int[] {}, new OSMMember[] {part, part}); String expResult = "WAY-> ID:1 V:+1+ TS:1 CS:1 VIS:true UID:1 TAGS:[] Refs:[T:NODE ID:1 R:1, T:NODE ID:1 R:1]"; String result = instance.toString(); assertEquals(expResult, result); - instance = new OSMWay(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1, 2, 2}, new OSMMember[] {}); + instance = new OSMWay(1L, 1, 1L, 1L, 1, new int[] {1, 1, 2, 2}, new OSMMember[] {}); expResult = "WAY-> ID:1 V:+1+ TS:1 CS:1 VIS:true UID:1 TAGS:[1, 1, 2, 2] Refs:[]"; result = instance.toString(); assertEquals(expResult, result); - instance = new OSMWay(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {}, null); + instance = new OSMWay(1L, 1, 1L, 1L, 1, new int[] {}, null); expResult = "WAY-> ID:1 V:+1+ TS:1 CS:1 VIS:true UID:1 TAGS:[] Refs:null"; result = instance.toString(); assertEquals(expResult, result); @@ -55,18 +55,18 @@ public void testToString() { @Test public void testCompareTo() { OSMMember part = new OSMMember(1L, OSMType.NODE, 1); - OSMWay o = new OSMWay(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {}, new OSMMember[] {part}); - OSMWay instance = new OSMWay(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {}, new OSMMember[] {part}); + OSMWay o = new OSMWay(1L, 1, 1L, 1L, 1, new int[] {}, new OSMMember[] {part}); + OSMWay instance = new OSMWay(1L, 1, 1L, 1L, 1, new int[] {}, new OSMMember[] {part}); assertTrue(instance.compareTo(o) == 0); part = new OSMMember(1L, OSMType.NODE, 1); - o = new OSMWay(1L, 3, new OSHDBTimestamp(1L), 1L, 1, new int[] {}, new OSMMember[] {part}); - instance = new OSMWay(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {}, new OSMMember[] {part}); + o = new OSMWay(1L, 3, 1L, 1L, 1, new int[] {}, new OSMMember[] {part}); + instance = new OSMWay(1L, 1, 1L, 1L, 1, new int[] {}, new OSMMember[] {part}); assertTrue(instance.compareTo(o) < 0); part = new OSMMember(1L, OSMType.NODE, 1); - o = new OSMWay(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {}, new OSMMember[] {part}); - instance = new OSMWay(1L, 3, new OSHDBTimestamp(1L), 1L, 1, new int[] {}, new OSMMember[] {part}); + o = new OSMWay(1L, 1, 1L, 1L, 1, new int[] {}, new OSMMember[] {part}); + instance = new OSMWay(1L, 3, 1L, 1L, 1, new int[] {}, new OSMMember[] {part}); assertTrue(instance.compareTo(o) > 0); } @@ -74,7 +74,7 @@ public void testCompareTo() { @Test public void testGetId() { OSMMember part = new OSMMember(1L, OSMType.NODE, 1); - OSMWay instance = new OSMWay(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {}, new OSMMember[] {part, part}); + OSMWay instance = new OSMWay(1L, 1, 1L, 1L, 1, new int[] {}, new OSMMember[] {part, part}); long expResult = 1L; long result = instance.getId(); assertEquals(expResult, result); @@ -83,7 +83,7 @@ public void testGetId() { @Test public void testGetVersion() { OSMMember part = new OSMMember(1L, OSMType.NODE, 1); - OSMWay instance = new OSMWay(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {}, new OSMMember[] {part, part}); + OSMWay instance = new OSMWay(1L, 1, 1L, 1L, 1, new int[] {}, new OSMMember[] {part, part}); int expResult = 1; int result = instance.getVersion(); assertEquals(expResult, result); @@ -92,16 +92,16 @@ public void testGetVersion() { @Test public void testGetTimestamp() { OSMMember part = new OSMMember(1L, OSMType.NODE, 1); - OSMWay instance = new OSMWay(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {}, new OSMMember[] {part, part}); + OSMWay instance = new OSMWay(1L, 1, 1L, 1L, 1, new int[] {}, new OSMMember[] {part, part}); long expResult = 1L; - long result = instance.getTimestamp().getRawUnixTimestamp(); + long result = instance.getEpochSecond(); assertEquals(expResult, result); } @Test public void testGetChangeset() { OSMMember part = new OSMMember(1L, OSMType.NODE, 1); - OSMWay instance = new OSMWay(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {}, new OSMMember[] {part, part}); + OSMWay instance = new OSMWay(1L, 1, 1L, 1L, 1, new int[] {}, new OSMMember[] {part, part}); long expResult = 1L; long result = instance.getChangesetId(); assertEquals(expResult, result); @@ -110,7 +110,7 @@ public void testGetChangeset() { @Test public void testGetUserId() { OSMMember part = new OSMMember(1L, OSMType.NODE, 1); - OSMWay instance = new OSMWay(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {}, new OSMMember[] {part, part}); + OSMWay instance = new OSMWay(1L, 1, 1L, 1L, 1, new int[] {}, new OSMMember[] {part, part}); int expResult = 1; int result = instance.getUserId(); assertEquals(expResult, result); @@ -119,13 +119,13 @@ public void testGetUserId() { @Test public void testisVisible() { OSMMember part = new OSMMember(1L, OSMType.NODE, 1); - OSMWay instance = new OSMWay(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {}, new OSMMember[] {part, part}); + OSMWay instance = new OSMWay(1L, 1, 1L, 1L, 1, new int[] {}, new OSMMember[] {part, part}); boolean expResult = true; boolean result = instance.isVisible(); assertEquals(expResult, result); part = new OSMMember(1L, OSMType.NODE, 1); - instance = new OSMWay(1L, -1, new OSHDBTimestamp(1L), 1L, 1, new int[] {}, new OSMMember[] {part, part}); + instance = new OSMWay(1L, -1, 1L, 1L, 1, new int[] {}, new OSMMember[] {part, part}); expResult = false; result = instance.isVisible(); assertEquals(expResult, result); @@ -134,7 +134,7 @@ public void testisVisible() { @Test public void testGetTags() { OSMMember part = new OSMMember(1L, OSMType.NODE, 1); - OSMWay instance = new OSMWay(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1}, new OSMMember[] {part, part}); + OSMWay instance = new OSMWay(1L, 1, 1L, 1L, 1, new int[] {1, 1}, new OSMMember[] {part, part}); int[] expResult = new int[] {1, 1}; int[] result = instance.getRawTags(); Assert.assertArrayEquals(expResult, result); @@ -143,34 +143,34 @@ public void testGetTags() { @Test public void testHasTagKey() { OSMMember part = new OSMMember(1L, OSMType.NODE, 1); - OSMWay instance = new OSMWay(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {}, new OSMMember[] {part, part}); + OSMWay instance = new OSMWay(1L, 1, 1L, 1L, 1, new int[] {}, new OSMMember[] {part, part}); boolean expResult = false; boolean result = instance.hasTagKey(1); assertEquals(expResult, result); part = new OSMMember(1L, OSMType.NODE, 1); instance = - new OSMWay(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1, 2, 2, 3, 3}, new OSMMember[] {part, part}); + new OSMWay(1L, 1, 1L, 1L, 1, new int[] {1, 1, 2, 2, 3, 3}, new OSMMember[] {part, part}); expResult = true; result = instance.hasTagKey(1); assertEquals(expResult, result); part = new OSMMember(1L, OSMType.NODE, 1); instance = - new OSMWay(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 2, 2, 2, 3, 3}, new OSMMember[] {part, part}); + new OSMWay(1L, 1, 1L, 1L, 1, new int[] {1, 2, 2, 2, 3, 3}, new OSMMember[] {part, part}); expResult = false; result = instance.hasTagKeyExcluding(1, new int[] {2, 3}); assertEquals(expResult, result); part = new OSMMember(1L, OSMType.NODE, 1); instance = - new OSMWay(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1, 2, 2, 3, 3}, new OSMMember[] {part, part}); + new OSMWay(1L, 1, 1L, 1L, 1, new int[] {1, 1, 2, 2, 3, 3}, new OSMMember[] {part, part}); expResult = true; result = instance.hasTagKeyExcluding(1, new int[] {2, 3}); assertEquals(expResult, result); part = new OSMMember(1L, OSMType.NODE, 1); - instance = new OSMWay(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {2, 1, 3, 3}, new OSMMember[] {part, part}); + instance = new OSMWay(1L, 1, 1L, 1L, 1, new int[] {2, 1, 3, 3}, new OSMMember[] {part, part}); expResult = false; result = instance.hasTagKeyExcluding(1, new int[] {1, 3}); assertEquals(expResult, result); @@ -180,13 +180,13 @@ public void testHasTagKey() { public void testHasTagValue() { OSMMember part = new OSMMember(1L, OSMType.NODE, 1); OSMWay instance = - new OSMWay(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 2, 2, 3}, new OSMMember[] {part, part}); + new OSMWay(1L, 1, 1L, 1L, 1, new int[] {1, 2, 2, 3}, new OSMMember[] {part, part}); boolean expResult = false; boolean result = instance.hasTagValue(1, 1); assertEquals(expResult, result); part = new OSMMember(1L, OSMType.NODE, 1); - instance = new OSMWay(1L, 1, new OSHDBTimestamp(1L), 1L, 1, new int[] {1, 1, 2, 3}, new OSMMember[] {part, part}); + instance = new OSMWay(1L, 1, 1L, 1L, 1, new int[] {1, 1, 2, 3}, new OSMMember[] {part, part}); expResult = true; result = instance.hasTagValue(1, 1); assertEquals(expResult, result); diff --git a/oshdb/src/test/java/org/heigit/ohsome/oshdb/util/CellIdTest.java b/oshdb/src/test/java/org/heigit/ohsome/oshdb/util/CellIdTest.java index c4a7be1c7..b120d77ac 100644 --- a/oshdb/src/test/java/org/heigit/ohsome/oshdb/util/CellIdTest.java +++ b/oshdb/src/test/java/org/heigit/ohsome/oshdb/util/CellIdTest.java @@ -1,8 +1,3 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ package org.heigit.ohsome.oshdb.util; import static org.junit.Assert.assertEquals; diff --git a/oshdb/src/test/java/org/heigit/ohsome/oshdb/util/OSHDBBoundableTest.java b/oshdb/src/test/java/org/heigit/ohsome/oshdb/util/OSHDBBoundableTest.java new file mode 100644 index 000000000..b835fc3d7 --- /dev/null +++ b/oshdb/src/test/java/org/heigit/ohsome/oshdb/util/OSHDBBoundableTest.java @@ -0,0 +1,50 @@ +package org.heigit.ohsome.oshdb.util; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.heigit.ohsome.oshdb.OSHDBBoundable; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; +import org.junit.Test; + +public class OSHDBBoundableTest { + private OSHDBBoundable point = new OSHDBBoundingBox(0L, 0L, 0L, 0L); + private OSHDBBoundable box = new OSHDBBoundingBox(-1L, -1L, 1L, 1L); + + @Test + public void testPoint() { + assertTrue(point.isPoint()); + assertFalse(box.isPoint()); + } + + @Test + public void testValid() { + assertTrue(point.isValid()); + assertTrue(box.isValid()); + OSHDBBoundable invalid = new OSHDBBoundingBox(1L, 1L, -1L, -1L); + assertFalse(invalid.isValid()); + } + + @Test + public void testCovered() { + assertTrue(point.coveredBy(box)); + assertFalse(point.coveredBy(null)); + } + + @Test + public void testIntersects() { + assertTrue(point.intersects(box)); + assertFalse(point.intersects(null)); + } + + @Test + public void testIntersection() { + OSHDBBoundable box2 = new OSHDBBoundingBox(0L, 0L, 2L, 2L); + OSHDBBoundable intersection = box2.intersection(box); + assertEquals(0, intersection.getMinLonLong()); + assertEquals(0, intersection.getMinLatLong()); + assertEquals(1, intersection.getMaxLonLong()); + assertEquals(1, intersection.getMaxLatLong()); + } +} diff --git a/oshdb/src/test/java/org/heigit/ohsome/oshdb/util/OSHDBBoundingBoxTest.java b/oshdb/src/test/java/org/heigit/ohsome/oshdb/util/OSHDBBoundingBoxTest.java index 669829f27..39465edc0 100644 --- a/oshdb/src/test/java/org/heigit/ohsome/oshdb/util/OSHDBBoundingBoxTest.java +++ b/oshdb/src/test/java/org/heigit/ohsome/oshdb/util/OSHDBBoundingBoxTest.java @@ -3,6 +3,7 @@ import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; +import org.heigit.ohsome.oshdb.OSHDBBoundingBox; import org.junit.Test; public class OSHDBBoundingBoxTest { @@ -23,7 +24,7 @@ public void testIntersect() { OSHDBBoundingBox first = new OSHDBBoundingBox(0.0, 89.0, 1.0, 90.0); OSHDBBoundingBox second = new OSHDBBoundingBox(0.0, 89.9, 2.0, 90.0); OSHDBBoundingBox expResult = new OSHDBBoundingBox(0.0, 89.9, 1.0, 90.0); - OSHDBBoundingBox result = OSHDBBoundingBox.intersect(first, second); + OSHDBBoundingBox result = first.intersection(second); assertEquals(expResult, result); } diff --git a/oshdb/src/test/java/org/heigit/ohsome/oshdb/util/OSHDBTemporalTest.java b/oshdb/src/test/java/org/heigit/ohsome/oshdb/util/OSHDBTemporalTest.java new file mode 100644 index 000000000..5968f2c72 --- /dev/null +++ b/oshdb/src/test/java/org/heigit/ohsome/oshdb/util/OSHDBTemporalTest.java @@ -0,0 +1,21 @@ +package org.heigit.ohsome.oshdb.util; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.heigit.ohsome.oshdb.OSHDBTemporal; +import org.heigit.ohsome.oshdb.OSHDBTimestamp; +import org.junit.Test; + +public class OSHDBTemporalTest { + @Test + public void testBeforeAfter() { + OSHDBTemporal t1 = new OSHDBTimestamp(0); + OSHDBTemporal t2 = new OSHDBTimestamp(1); + assertTrue(t1.isBefore(t2)); + assertTrue(t2.isAfter(t1)); + assertEquals(0, OSHDBTemporal.compare(t1, t1)); + assertTrue(OSHDBTemporal.compare(t1, t2) < 0); + assertTrue(OSHDBTemporal.compare(t2, t1) > 0); + } +}
How XYGrid sees the world.