kopia lustrzana https://github.com/onthegomap/planetiler
break out into subpoms
rodzic
2f13a74929
commit
0000a655fe
|
@ -0,0 +1,150 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>flatmap-core</artifactId>
|
||||
|
||||
<parent>
|
||||
<groupId>com.onthegomap</groupId>
|
||||
<artifactId>flatmap-parent</artifactId>
|
||||
<version>0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<graphhopper.version>2.3</graphhopper.version>
|
||||
<geotools.version>25.0</geotools.version>
|
||||
<junit.version>5.7.1</junit.version>
|
||||
<jackson.version>2.12.3</jackson.version>
|
||||
<log4j.version>2.14.1</log4j.version>
|
||||
<prometheus.version>0.11.0</prometheus.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.graphhopper</groupId>
|
||||
<artifactId>graphhopper-reader-osm</artifactId>
|
||||
<version>${graphhopper.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.locationtech.jts</groupId>
|
||||
<artifactId>jts-core</artifactId>
|
||||
<version>1.18.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.geotools</groupId>
|
||||
<artifactId>gt-shapefile</artifactId>
|
||||
<version>${geotools.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.geotools</groupId>
|
||||
<artifactId>gt-epsg-hsql</artifactId>
|
||||
<version>${geotools.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.xerial</groupId>
|
||||
<artifactId>sqlite-jdbc</artifactId>
|
||||
<version>3.34.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mapdb</groupId>
|
||||
<artifactId>mapdb</artifactId>
|
||||
<version>3.0.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.msgpack</groupId>
|
||||
<artifactId>msgpack-core</artifactId>
|
||||
<version>0.8.22</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.30</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-slf4j-impl</artifactId>
|
||||
<version>${log4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-api</artifactId>
|
||||
<version>${log4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
<version>${log4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jdk8</artifactId>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.prometheus</groupId>
|
||||
<artifactId>simpleclient</artifactId>
|
||||
<version>${prometheus.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.prometheus</groupId>
|
||||
<artifactId>simpleclient_common</artifactId>
|
||||
<version>${prometheus.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.prometheus</groupId>
|
||||
<artifactId>simpleclient_pushgateway</artifactId>
|
||||
<version>${prometheus.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.prometheus</groupId>
|
||||
<artifactId>simpleclient_hotspot</artifactId>
|
||||
<version>${prometheus.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-params</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>3.9.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<testResources>
|
||||
<testResource>
|
||||
<directory>src/test/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</testResource>
|
||||
</testResources>
|
||||
</build>
|
||||
</project>
|
|
@ -121,7 +121,7 @@ public class FeatureMerge {
|
|||
current.addPoint(lastX, lastY);
|
||||
}
|
||||
|
||||
if (!current.isEmpty()) {
|
||||
if (current.size() >= 2) {
|
||||
output.add(GeoUtils.JTS_FACTORY.createLineString(current));
|
||||
}
|
||||
}
|
|
@ -7,14 +7,19 @@ import java.util.List;
|
|||
|
||||
public interface Profile {
|
||||
|
||||
List<OpenStreetMapReader.RelationInfo> preprocessOsmRelation(ReaderRelation relation);
|
||||
default List<OpenStreetMapReader.RelationInfo> preprocessOsmRelation(ReaderRelation relation) {
|
||||
return null;
|
||||
}
|
||||
|
||||
void processFeature(SourceFeature sourceFeature, FeatureCollector features);
|
||||
|
||||
void release();
|
||||
default void release() {
|
||||
}
|
||||
|
||||
List<VectorTileEncoder.Feature> postProcessLayerFeatures(String layer, int zoom,
|
||||
List<VectorTileEncoder.Feature> items) throws GeometryException;
|
||||
default List<VectorTileEncoder.Feature> postProcessLayerFeatures(String layer, int zoom,
|
||||
List<VectorTileEncoder.Feature> items) throws GeometryException {
|
||||
return items;
|
||||
}
|
||||
|
||||
String name();
|
||||
|
||||
|
@ -30,23 +35,17 @@ public interface Profile {
|
|||
return null;
|
||||
}
|
||||
|
||||
default boolean isOverlay() {
|
||||
return false;
|
||||
}
|
||||
|
||||
class NullProfile implements Profile {
|
||||
|
||||
@Override
|
||||
public List<OpenStreetMapReader.RelationInfo> preprocessOsmRelation(ReaderRelation relation) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processFeature(SourceFeature sourceFeature, FeatureCollector features) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void release() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VectorTileEncoder.Feature> postProcessLayerFeatures(String layer, int zoom,
|
||||
List<VectorTileEncoder.Feature> items) {
|
|
@ -15,13 +15,15 @@ public abstract class SourceFeature {
|
|||
private final String source;
|
||||
private final String sourceLayer;
|
||||
private final List<OpenStreetMapReader.RelationInfo> relationInfos;
|
||||
private final long id;
|
||||
|
||||
protected SourceFeature(Map<String, Object> properties, String source, String sourceLayer,
|
||||
List<OpenStreetMapReader.RelationInfo> relationInfos) {
|
||||
List<OpenStreetMapReader.RelationInfo> relationInfos, long id) {
|
||||
this.properties = properties;
|
||||
this.source = source;
|
||||
this.sourceLayer = sourceLayer;
|
||||
this.relationInfos = relationInfos;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public abstract Geometry latLonGeometry() throws GeometryException;
|
||||
|
@ -168,4 +170,8 @@ public abstract class SourceFeature {
|
|||
}
|
||||
return result == null ? List.of() : result;
|
||||
}
|
||||
|
||||
public final long id() {
|
||||
return id;
|
||||
}
|
||||
}
|
|
@ -20,6 +20,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import org.msgpack.core.MessageBufferPacker;
|
||||
|
@ -329,14 +330,14 @@ public final class FeatureGroup implements Consumer<FeatureSort.Entry>, Iterable
|
|||
private final List<FeatureSort.Entry> entries = new ArrayList<>();
|
||||
private LongLongHashMap counts = null;
|
||||
private byte layer = Byte.MAX_VALUE;
|
||||
private long numFeaturesProcessed = 0;
|
||||
private final AtomicLong numFeaturesProcessed = new AtomicLong(0);
|
||||
|
||||
public TileFeatures(int tile) {
|
||||
this.tile = TileCoord.decode(tile);
|
||||
}
|
||||
|
||||
public long getNumFeatures() {
|
||||
return numFeaturesProcessed;
|
||||
return numFeaturesProcessed.get();
|
||||
}
|
||||
|
||||
public TileCoord coord() {
|
||||
|
@ -395,7 +396,7 @@ public final class FeatureGroup implements Consumer<FeatureSort.Entry>, Iterable
|
|||
|
||||
@Override
|
||||
public void accept(FeatureSort.Entry entry) {
|
||||
numFeaturesProcessed++;
|
||||
numFeaturesProcessed.incrementAndGet();
|
||||
long sortKey = entry.sortKey();
|
||||
if (extractHasGroupFromSortKey(sortKey)) {
|
||||
byte thisLayer = extractLayerIdFromSortKey(sortKey);
|
|
@ -104,6 +104,7 @@ public class NaturalEarthReader extends Reader {
|
|||
@Override
|
||||
public Topology.SourceStep<ReaderFeature> read() {
|
||||
return next -> {
|
||||
long id = 0;
|
||||
var tables = tableNames();
|
||||
for (int i = 0; i < tables.size(); i++) {
|
||||
String table = tables.get(i);
|
||||
|
@ -127,7 +128,8 @@ public class NaturalEarthReader extends Reader {
|
|||
continue;
|
||||
}
|
||||
Geometry latLonGeometry = GeoUtils.wkbReader.read(geometry);
|
||||
ReaderFeature readerGeometry = new ReaderFeature(latLonGeometry, column.length - 1, sourceName, table);
|
||||
ReaderFeature readerGeometry = new ReaderFeature(latLonGeometry, column.length - 1, sourceName, table,
|
||||
id);
|
||||
for (int c = 0; c < column.length; c++) {
|
||||
if (c != geometryColumn) {
|
||||
Object value = rs.getObject(c + 1);
|
|
@ -280,15 +280,13 @@ public class OpenStreetMapReader implements Closeable, MemoryEstimator.HasEstima
|
|||
final boolean polygon;
|
||||
final boolean line;
|
||||
final boolean point;
|
||||
final long osmId;
|
||||
|
||||
public ProxyFeature(ReaderElement elem, boolean point, boolean line, boolean polygon,
|
||||
List<RelationInfo> relationInfo) {
|
||||
super(ReaderElementUtils.getProperties(elem), name, null, relationInfo);
|
||||
super(ReaderElementUtils.getProperties(elem), name, null, relationInfo, elem.getId());
|
||||
this.point = point;
|
||||
this.line = line;
|
||||
this.polygon = polygon;
|
||||
this.osmId = elem.getId();
|
||||
}
|
||||
|
||||
private Geometry latLonGeom;
|
||||
|
@ -349,7 +347,7 @@ public class OpenStreetMapReader implements Closeable, MemoryEstimator.HasEstima
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "OsmNode[" + osmId + ']';
|
||||
return "OsmNode[" + id() + ']';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -375,7 +373,7 @@ public class OpenStreetMapReader implements Closeable, MemoryEstimator.HasEstima
|
|||
CoordinateSequence coords = nodeCache.getWayGeometry(nodeIds);
|
||||
return GeoUtils.JTS_FACTORY.createLineString(coords);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new GeometryException("osm_invalid_line", "Error building line for way " + osmId + ": " + e);
|
||||
throw new GeometryException("osm_invalid_line", "Error building line for way " + id() + ": " + e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -385,7 +383,7 @@ public class OpenStreetMapReader implements Closeable, MemoryEstimator.HasEstima
|
|||
CoordinateSequence coords = nodeCache.getWayGeometry(nodeIds);
|
||||
return GeoUtils.JTS_FACTORY.createPolygon(coords);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new GeometryException("osm_invalid_polygon", "Error building polygon for way " + osmId + ": " + e);
|
||||
throw new GeometryException("osm_invalid_polygon", "Error building polygon for way " + id() + ": " + e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -396,7 +394,7 @@ public class OpenStreetMapReader implements Closeable, MemoryEstimator.HasEstima
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "OsmWay[" + osmId + ']';
|
||||
return "OsmWay[" + id() + ']';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -425,12 +423,12 @@ public class OpenStreetMapReader implements Closeable, MemoryEstimator.HasEstima
|
|||
}
|
||||
}
|
||||
}
|
||||
return OsmMultipolygon.build(rings, nodeCache, osmId);
|
||||
return OsmMultipolygon.build(rings, nodeCache, id());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "OsmRelation[" + osmId + ']';
|
||||
return "OsmRelation[" + id() + ']';
|
||||
}
|
||||
}
|
||||
|
|
@ -14,18 +14,19 @@ public class ReaderFeature extends SourceFeature {
|
|||
private final Geometry latLonGeometry;
|
||||
private final Map<String, Object> properties;
|
||||
|
||||
public ReaderFeature(Geometry latLonGeometry, Map<String, Object> properties) {
|
||||
this(latLonGeometry, properties, null, null);
|
||||
public ReaderFeature(Geometry latLonGeometry, Map<String, Object> properties, long id) {
|
||||
this(latLonGeometry, properties, null, null, id);
|
||||
}
|
||||
|
||||
public ReaderFeature(Geometry latLonGeometry, Map<String, Object> properties, String source, String sourceLayer) {
|
||||
super(properties, source, sourceLayer, null);
|
||||
public ReaderFeature(Geometry latLonGeometry, Map<String, Object> properties, String source, String sourceLayer,
|
||||
long id) {
|
||||
super(properties, source, sourceLayer, null, id);
|
||||
this.latLonGeometry = latLonGeometry;
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public ReaderFeature(Geometry latLonGeometry, int numProperties, String source, String sourceLayer) {
|
||||
this(latLonGeometry, new HashMap<>(numProperties), source, sourceLayer);
|
||||
public ReaderFeature(Geometry latLonGeometry, int numProperties, String source, String sourceLayer, long id) {
|
||||
this(latLonGeometry, new HashMap<>(numProperties), source, sourceLayer, id);
|
||||
}
|
||||
|
||||
@Override
|
|
@ -106,7 +106,9 @@ public class ShapefileReader extends Reader implements Closeable {
|
|||
public Topology.SourceStep<ReaderFeature> read() {
|
||||
return next -> {
|
||||
try (var iter = inputSource.features()) {
|
||||
long id = 0;
|
||||
while (iter.hasNext()) {
|
||||
id++;
|
||||
SimpleFeature feature = iter.next();
|
||||
Geometry source = (Geometry) feature.getDefaultGeometry();
|
||||
Geometry latLonGeometry = source;
|
||||
|
@ -114,7 +116,7 @@ public class ShapefileReader extends Reader implements Closeable {
|
|||
latLonGeometry = JTS.transform(source, transformToLatLon);
|
||||
}
|
||||
if (latLonGeometry != null) {
|
||||
ReaderFeature geom = new ReaderFeature(latLonGeometry, attributeNames.length, sourceName, null);
|
||||
ReaderFeature geom = new ReaderFeature(latLonGeometry, attributeNames.length, sourceName, null, id);
|
||||
for (int i = 1; i < attributeNames.length; i++) {
|
||||
geom.setTag(attributeNames[i], feature.getAttribute(i));
|
||||
}
|
|
@ -138,7 +138,7 @@ public class MbtilesWriter {
|
|||
.setDescription(profile.description())
|
||||
.setAttribution(profile.attribution())
|
||||
.setVersion(profile.version())
|
||||
.setTypeIsBaselayer()
|
||||
.setType(profile.isOverlay() ? "overlay" : "baselayer")
|
||||
.setBoundsAndCenter(config.latLonBounds())
|
||||
.setMinzoom(config.minzoom())
|
||||
.setMaxzoom(config.maxzoom())
|
Plik diff jest za duży
Load Diff
|
@ -16,6 +16,7 @@ import java.util.stream.StreamSupport;
|
|||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
import org.locationtech.jts.geom.Geometry;
|
||||
|
||||
public class FeatureCollectorTest {
|
||||
|
||||
|
@ -30,9 +31,15 @@ public class FeatureCollectorTest {
|
|||
}
|
||||
}
|
||||
|
||||
private long id = 0;
|
||||
|
||||
private ReaderFeature newReaderFeature(Geometry latLonGeometry, Map<String, Object> properties) {
|
||||
return new ReaderFeature(latLonGeometry, properties, id++);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmpty() {
|
||||
var collector = factory.get(new ReaderFeature(newPoint(0, 0), Map.of(
|
||||
var collector = factory.get(newReaderFeature(newPoint(0, 0), Map.of(
|
||||
"key", "val"
|
||||
)));
|
||||
assertFeatures(14, List.of(), collector);
|
||||
|
@ -40,7 +47,7 @@ public class FeatureCollectorTest {
|
|||
|
||||
@Test
|
||||
public void testPoint() {
|
||||
var collector = factory.get(new ReaderFeature(newPoint(0, 0), Map.of(
|
||||
var collector = factory.get(newReaderFeature(newPoint(0, 0), Map.of(
|
||||
"key", "val"
|
||||
)));
|
||||
collector.point("layername")
|
||||
|
@ -74,7 +81,7 @@ public class FeatureCollectorTest {
|
|||
|
||||
@Test
|
||||
public void testAttrWithMinzoom() {
|
||||
var collector = factory.get(new ReaderFeature(newPoint(0, 0), Map.of(
|
||||
var collector = factory.get(newReaderFeature(newPoint(0, 0), Map.of(
|
||||
"key", "val"
|
||||
)));
|
||||
collector.point("layername")
|
||||
|
@ -96,7 +103,7 @@ public class FeatureCollectorTest {
|
|||
|
||||
@Test
|
||||
public void testLine() {
|
||||
var collector = factory.get(new ReaderFeature(newLineString(
|
||||
var collector = factory.get(newReaderFeature(newLineString(
|
||||
0, 0,
|
||||
1, 1
|
||||
), Map.of(
|
||||
|
@ -123,7 +130,7 @@ public class FeatureCollectorTest {
|
|||
|
||||
@Test
|
||||
public void testPolygon() {
|
||||
var collector = factory.get(new ReaderFeature(newPolygon(
|
||||
var collector = factory.get(newReaderFeature(newPolygon(
|
||||
0, 0,
|
||||
1, 0,
|
||||
1, 1,
|
||||
|
@ -159,7 +166,7 @@ public class FeatureCollectorTest {
|
|||
|
||||
@Test
|
||||
public void testMinSizeAtMaxZoomDefaultsToTileResolution() {
|
||||
var collector = factory.get(new ReaderFeature(rectangle(10, 20), Map.of()));
|
||||
var collector = factory.get(newReaderFeature(rectangle(10, 20), Map.of()));
|
||||
var poly = collector.polygon("layername")
|
||||
.setMinPixelSize(1)
|
||||
.setMinPixelSizeBelowZoom(12, 10);
|
||||
|
@ -170,7 +177,7 @@ public class FeatureCollectorTest {
|
|||
|
||||
@Test
|
||||
public void testSetMinSizeAtMaxZoom() {
|
||||
var collector = factory.get(new ReaderFeature(rectangle(10, 20), Map.of()));
|
||||
var collector = factory.get(newReaderFeature(rectangle(10, 20), Map.of()));
|
||||
var poly = collector.polygon("layername")
|
||||
.setMinPixelSize(1)
|
||||
.setMinPixelSizeAtMaxZoom(0.5)
|
||||
|
@ -182,7 +189,7 @@ public class FeatureCollectorTest {
|
|||
|
||||
@Test
|
||||
public void testSetMinSizeAtAllZooms() {
|
||||
var collector = factory.get(new ReaderFeature(rectangle(10, 20), Map.of()));
|
||||
var collector = factory.get(newReaderFeature(rectangle(10, 20), Map.of()));
|
||||
var poly = collector.polygon("layername")
|
||||
.setMinPixelSizeAtAllZooms(2)
|
||||
.setMinPixelSizeBelowZoom(12, 10);
|
||||
|
@ -193,7 +200,7 @@ public class FeatureCollectorTest {
|
|||
|
||||
@Test
|
||||
public void testDefaultMinPixelSize() {
|
||||
var collector = factory.get(new ReaderFeature(rectangle(10, 20), Map.of()));
|
||||
var collector = factory.get(newReaderFeature(rectangle(10, 20), Map.of()));
|
||||
var poly = collector.polygon("layername");
|
||||
assertEquals(1, poly.getMinPixelSize(12));
|
||||
assertEquals(1, poly.getMinPixelSize(13));
|
||||
|
@ -202,7 +209,7 @@ public class FeatureCollectorTest {
|
|||
|
||||
@Test
|
||||
public void testToleranceDefault() {
|
||||
var collector = factory.get(new ReaderFeature(rectangle(10, 20), Map.of()));
|
||||
var collector = factory.get(newReaderFeature(rectangle(10, 20), Map.of()));
|
||||
var poly = collector.polygon("layername");
|
||||
assertEquals(0.1, poly.getPixelTolerance(12));
|
||||
assertEquals(0.1, poly.getPixelTolerance(13));
|
||||
|
@ -211,7 +218,7 @@ public class FeatureCollectorTest {
|
|||
|
||||
@Test
|
||||
public void testSetTolerance() {
|
||||
var collector = factory.get(new ReaderFeature(rectangle(10, 20), Map.of()));
|
||||
var collector = factory.get(newReaderFeature(rectangle(10, 20), Map.of()));
|
||||
var poly = collector.polygon("layername")
|
||||
.setPixelTolerance(1);
|
||||
assertEquals(1d, poly.getPixelTolerance(12));
|
||||
|
@ -221,7 +228,7 @@ public class FeatureCollectorTest {
|
|||
|
||||
@Test
|
||||
public void testSetToleranceAtAllZooms() {
|
||||
var collector = factory.get(new ReaderFeature(rectangle(10, 20), Map.of()));
|
||||
var collector = factory.get(newReaderFeature(rectangle(10, 20), Map.of()));
|
||||
var poly = collector.polygon("layername")
|
||||
.setPixelToleranceAtAllZooms(1);
|
||||
assertEquals(1d, poly.getPixelTolerance(12));
|
||||
|
@ -231,7 +238,7 @@ public class FeatureCollectorTest {
|
|||
|
||||
@Test
|
||||
public void testSetMaxZoom() {
|
||||
var collector = factory.get(new ReaderFeature(rectangle(10, 20), Map.of()));
|
||||
var collector = factory.get(newReaderFeature(rectangle(10, 20), Map.of()));
|
||||
var poly = collector.polygon("layername")
|
||||
.setPixelToleranceAtMaxZoom(2);
|
||||
assertEquals(0.1d, poly.getPixelTolerance(12));
|
||||
|
@ -241,7 +248,7 @@ public class FeatureCollectorTest {
|
|||
|
||||
@Test
|
||||
public void testSetAllZoomMethods() {
|
||||
var collector = factory.get(new ReaderFeature(rectangle(10, 20), Map.of()));
|
||||
var collector = factory.get(newReaderFeature(rectangle(10, 20), Map.of()));
|
||||
var poly = collector.polygon("layername")
|
||||
.setPixelTolerance(1)
|
||||
.setPixelToleranceAtMaxZoom(2)
|
||||
|
@ -256,7 +263,7 @@ public class FeatureCollectorTest {
|
|||
*/
|
||||
@Test
|
||||
public void testPointReaderFeatureCoercion() throws GeometryException {
|
||||
var pointSourceFeature = new ReaderFeature(newPoint(0, 0), Map.of());
|
||||
var pointSourceFeature = newReaderFeature(newPoint(0, 0), Map.of());
|
||||
assertEquals(0, pointSourceFeature.area());
|
||||
assertEquals(0, pointSourceFeature.length());
|
||||
|
||||
|
@ -285,7 +292,7 @@ public class FeatureCollectorTest {
|
|||
Arrays.fill(coords, 0d);
|
||||
double[] worldCoords = new double[nPoints * 2];
|
||||
Arrays.fill(worldCoords, 0.5d);
|
||||
var sourceLine = new ReaderFeature(newLineString(coords), Map.of());
|
||||
var sourceLine = newReaderFeature(newLineString(coords), Map.of());
|
||||
assertEquals(0, sourceLine.length());
|
||||
assertEquals(0, sourceLine.area());
|
||||
|
||||
|
@ -324,7 +331,7 @@ public class FeatureCollectorTest {
|
|||
|
||||
@Test
|
||||
public void testNonZeroLineStringReaderFeatureCoercion() throws GeometryException {
|
||||
var sourceLine = new ReaderFeature(newLineString(worldToLatLon(
|
||||
var sourceLine = newReaderFeature(newLineString(worldToLatLon(
|
||||
0.2, 0.2,
|
||||
0.75, 0.75,
|
||||
0.25, 0.75,
|
||||
|
@ -365,7 +372,7 @@ public class FeatureCollectorTest {
|
|||
|
||||
@Test
|
||||
public void testPolygonReaderFeatureCoercion() throws GeometryException {
|
||||
var sourceLine = new ReaderFeature(newPolygon(worldToLatLon(
|
||||
var sourceLine = newReaderFeature(newPolygon(worldToLatLon(
|
||||
0.25, 0.25,
|
||||
0.75, 0.75,
|
||||
0.25, 0.75,
|
||||
|
@ -415,7 +422,7 @@ public class FeatureCollectorTest {
|
|||
|
||||
@Test
|
||||
public void testPolygonWithHoleCoercion() throws GeometryException {
|
||||
var sourceLine = new ReaderFeature(newPolygon(newCoordinateList(worldToLatLon(
|
||||
var sourceLine = newReaderFeature(newPolygon(newCoordinateList(worldToLatLon(
|
||||
0, 0,
|
||||
1, 0,
|
||||
1, 1,
|
||||
|
@ -468,7 +475,7 @@ public class FeatureCollectorTest {
|
|||
|
||||
@Test
|
||||
public void testPointOnSurface() {
|
||||
var sourceLine = new ReaderFeature(newPolygon(worldToLatLon(
|
||||
var sourceLine = newReaderFeature(newPolygon(worldToLatLon(
|
||||
0, 0,
|
||||
1, 0,
|
||||
1, 0.25,
|
||||
|
@ -498,7 +505,7 @@ public class FeatureCollectorTest {
|
|||
|
||||
@Test
|
||||
public void testMultiPolygonCoercion() throws GeometryException {
|
||||
var sourceLine = new ReaderFeature(newMultiPolygon(
|
||||
var sourceLine = newReaderFeature(newMultiPolygon(
|
||||
newPolygon(worldToLatLon(
|
||||
0, 0,
|
||||
1, 0,
|
||||
|
@ -552,7 +559,7 @@ public class FeatureCollectorTest {
|
|||
|
||||
@Test
|
||||
public void testMultiLineStringCoercion() throws GeometryException {
|
||||
var sourceLine = new ReaderFeature(newMultiLineString(
|
||||
var sourceLine = newReaderFeature(newMultiLineString(
|
||||
newLineString(worldToLatLon(
|
||||
0, 0,
|
||||
1, 0,
|
|
@ -176,6 +176,12 @@ public class FlatMapTest {
|
|||
);
|
||||
}
|
||||
|
||||
private long id = 0;
|
||||
|
||||
private ReaderFeature newReaderFeature(Geometry geometry, Map<String, Object> attrs) {
|
||||
return new ReaderFeature(geometry, attrs, id++);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMetadataButNoPoints() throws Exception {
|
||||
var results = runWithReaderFeatures(
|
||||
|
@ -218,7 +224,7 @@ public class FlatMapTest {
|
|||
var results = runWithReaderFeatures(
|
||||
Map.of("threads", "1"),
|
||||
List.of(
|
||||
new ReaderFeature(newPoint(lng, lat), Map.of(
|
||||
newReaderFeature(newPoint(lng, lat), Map.of(
|
||||
"attr", "value"
|
||||
))
|
||||
),
|
||||
|
@ -270,7 +276,7 @@ public class FlatMapTest {
|
|||
var results = runWithReaderFeatures(
|
||||
Map.of("threads", "1"),
|
||||
List.of(
|
||||
new ReaderFeature(newMultiPoint(
|
||||
newReaderFeature(newMultiPoint(
|
||||
newPoint(lng1, lat1),
|
||||
newPoint(lng2, lat2)
|
||||
), Map.of(
|
||||
|
@ -320,9 +326,9 @@ public class FlatMapTest {
|
|||
var results = runWithReaderFeatures(
|
||||
Map.of("threads", "1"),
|
||||
List.of(
|
||||
new ReaderFeature(newPoint(lng1, lat), Map.of("rank", "1")),
|
||||
new ReaderFeature(newPoint(lng2, lat), Map.of("rank", "2")),
|
||||
new ReaderFeature(newPoint(lng3, lat), Map.of("rank", "3"))
|
||||
newReaderFeature(newPoint(lng1, lat), Map.of("rank", "1")),
|
||||
newReaderFeature(newPoint(lng2, lat), Map.of("rank", "2")),
|
||||
newReaderFeature(newPoint(lng3, lat), Map.of("rank", "3"))
|
||||
),
|
||||
(in, features) -> {
|
||||
features.point("layer")
|
||||
|
@ -361,7 +367,7 @@ public class FlatMapTest {
|
|||
var results = runWithReaderFeatures(
|
||||
Map.of("threads", "1"),
|
||||
List.of(
|
||||
new ReaderFeature(newLineString(lng1, lat1, lng2, lat2), Map.of(
|
||||
newReaderFeature(newLineString(lng1, lat1, lng2, lat2), Map.of(
|
||||
"attr", "value"
|
||||
))
|
||||
),
|
||||
|
@ -399,7 +405,7 @@ public class FlatMapTest {
|
|||
var results = runWithReaderFeatures(
|
||||
Map.of("threads", "1"),
|
||||
List.of(
|
||||
new ReaderFeature(newMultiLineString(
|
||||
newReaderFeature(newMultiLineString(
|
||||
newLineString(lng1, lat1, lng2, lat2),
|
||||
newLineString(lng2, lat2, lng1, lat1)
|
||||
), Map.of(
|
||||
|
@ -468,7 +474,7 @@ public class FlatMapTest {
|
|||
var results = runWithReaderFeatures(
|
||||
Map.of("threads", "1"),
|
||||
List.of(
|
||||
new ReaderFeature(newPolygon(
|
||||
newReaderFeature(newPolygon(
|
||||
outerPoints,
|
||||
List.of(innerPoints)
|
||||
), Map.of())
|
||||
|
@ -572,7 +578,7 @@ public class FlatMapTest {
|
|||
var results = runWithReaderFeatures(
|
||||
Map.of("threads", "1"),
|
||||
List.of(
|
||||
new ReaderFeature(newPolygon(
|
||||
newReaderFeature(newPolygon(
|
||||
outerPoints,
|
||||
List.of()
|
||||
), Map.of())
|
||||
|
@ -607,7 +613,7 @@ public class FlatMapTest {
|
|||
var results = runWithReaderFeatures(
|
||||
Map.of("threads", "1"),
|
||||
List.of(
|
||||
new ReaderFeature(geometry, Map.of())
|
||||
newReaderFeature(geometry, Map.of())
|
||||
),
|
||||
(in, features) -> {
|
||||
features.polygon("layer")
|
||||
|
@ -629,7 +635,7 @@ public class FlatMapTest {
|
|||
var results = runWithReaderFeatures(
|
||||
Map.of("threads", "1"),
|
||||
List.of(
|
||||
new ReaderFeature(newMultiPolygon(
|
||||
newReaderFeature(newMultiPolygon(
|
||||
newPolygon(outerPoints2, List.of(innerPoints2)),
|
||||
newPolygon(outerPoints1, List.of(innerPoints1))
|
||||
), Map.of())
|
||||
|
@ -895,9 +901,9 @@ public class FlatMapTest {
|
|||
var results = runWithReaderFeatures(
|
||||
Map.of("threads", "1"),
|
||||
List.of(
|
||||
new ReaderFeature(newPoint(lng1, lat), Map.of("rank", "1")),
|
||||
new ReaderFeature(newPoint(lng2, lat), Map.of("rank", "2")),
|
||||
new ReaderFeature(newPoint(lng3, lat), Map.of("rank", "3"))
|
||||
newReaderFeature(newPoint(lng1, lat), Map.of("rank", "1")),
|
||||
newReaderFeature(newPoint(lng2, lat), Map.of("rank", "2")),
|
||||
newReaderFeature(newPoint(lng3, lat), Map.of("rank", "3"))
|
||||
),
|
||||
(in, features) -> {
|
||||
features.point("layer")
|
||||
|
@ -953,16 +959,16 @@ public class FlatMapTest {
|
|||
Map.of("threads", "1"),
|
||||
List.of(
|
||||
// merge at z13 (same "group"):
|
||||
new ReaderFeature(newLineString(
|
||||
newReaderFeature(newLineString(
|
||||
lng1, lat,
|
||||
lng2, lat
|
||||
), Map.of("group", "1", "other", "1")),
|
||||
new ReaderFeature(newLineString(
|
||||
newReaderFeature(newLineString(
|
||||
lng2, lat,
|
||||
lng3, lat
|
||||
), Map.of("group", "1", "other", "2")),
|
||||
// don't merge at z13:
|
||||
new ReaderFeature(newLineString(
|
||||
newReaderFeature(newLineString(
|
||||
lng3, lat,
|
||||
lng4, lat
|
||||
), Map.of("group", "2", "other", "3"))
|
||||
|
@ -996,14 +1002,14 @@ public class FlatMapTest {
|
|||
Map.of("threads", "1"),
|
||||
List.of(
|
||||
// merge same group:
|
||||
new ReaderFeature(newPolygon(z14CoordinatePixelList(
|
||||
newReaderFeature(newPolygon(z14CoordinatePixelList(
|
||||
10, 10,
|
||||
20, 10,
|
||||
20, 20,
|
||||
10, 20,
|
||||
10, 10
|
||||
)), Map.of("group", "1")),
|
||||
new ReaderFeature(newPolygon(z14CoordinatePixelList(
|
||||
newReaderFeature(newPolygon(z14CoordinatePixelList(
|
||||
20.5, 10,
|
||||
30, 10,
|
||||
30, 20,
|
||||
|
@ -1011,7 +1017,7 @@ public class FlatMapTest {
|
|||
20.5, 10
|
||||
)), Map.of("group", "1")),
|
||||
// don't merge - different group:
|
||||
new ReaderFeature(newPolygon(z14CoordinatePixelList(
|
||||
newReaderFeature(newPolygon(z14CoordinatePixelList(
|
||||
10, 20.5,
|
||||
20, 20.5,
|
||||
20, 30,
|
|
@ -21,7 +21,7 @@ public class ReaderFeatureTest {
|
|||
MultiPolygon multiPolygon = (MultiPolygon) new ReaderFeature(newMultiPolygon(
|
||||
newPolygon(outerPoints2, List.of(innerPoints2)),
|
||||
newPolygon(outerPoints1, List.of(innerPoints1))
|
||||
), Map.of()).worldGeometry();
|
||||
), Map.of(), 1).worldGeometry();
|
||||
|
||||
assertEquals(2, multiPolygon.getNumGeometries());
|
||||
assertSameNormalizedFeature(round(newPolygon(
|
|
@ -44,7 +44,7 @@ public class FeatureRendererTest {
|
|||
|
||||
private FeatureCollector collector(Geometry worldGeom) {
|
||||
var latLonGeom = GeoUtils.worldToLatLonCoords(worldGeom);
|
||||
return new FeatureCollector.Factory(config, stats).get(new ReaderFeature(latLonGeom, 0, null, null));
|
||||
return new FeatureCollector.Factory(config, stats).get(new ReaderFeature(latLonGeom, 0, null, null, 1));
|
||||
}
|
||||
|
||||
private Map<TileCoord, Collection<Geometry>> renderGeometry(FeatureCollector.Feature feature) {
|
Some files were not shown because too many files have changed in this diff Show More
Ładowanie…
Reference in New Issue