mirror of
https://github.com/cfpwastaken/planetiler-openmaptiles.git
synced 2026-02-04 20:41:09 +00:00
Migrate to eclipse formatter to support multiple IDEs (#122)
This commit is contained in:
@@ -33,8 +33,8 @@ import java.util.List;
|
|||||||
* <li>{@link OsmAllProcessor} to process every OSM feature</li>
|
* <li>{@link OsmAllProcessor} to process every OSM feature</li>
|
||||||
* <li>{@link OsmRelationPreprocessor} to process every OSM relation during first pass through OSM file</li>
|
* <li>{@link OsmRelationPreprocessor} to process every OSM relation during first pass through OSM file</li>
|
||||||
* <li>A {@link Tables.RowHandler} implementation in {@code Tables.java} to process input features filtered and parsed
|
* <li>A {@link Tables.RowHandler} implementation in {@code Tables.java} to process input features filtered and parsed
|
||||||
* according to the imposm3 mappings defined in the OpenMapTiles schema. Each element corresponds to a row in the
|
* according to the imposm3 mappings defined in the OpenMapTiles schema. Each element corresponds to a row in the table
|
||||||
* table that imposm3 would have generated, with generated methods for accessing the data that would have been in each
|
* that imposm3 would have generated, with generated methods for accessing the data that would have been in each
|
||||||
* column</li>
|
* column</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
* Layers can also subscribe to notifications when we finished processing an input source by implementing
|
* Layers can also subscribe to notifications when we finished processing an input source by implementing
|
||||||
@@ -118,8 +118,7 @@ public class BasemapProfile extends ForwardingProfile {
|
|||||||
return new RowDispatch(constructor.create(), handlers);
|
return new RowDispatch(constructor.create(), handlers);
|
||||||
}).simplify().index();
|
}).simplify().index();
|
||||||
wikidataMappings = Tables.MAPPINGS
|
wikidataMappings = Tables.MAPPINGS
|
||||||
.mapResults(constructor ->
|
.mapResults(constructor -> handlerMap.getOrDefault(constructor.rowClass(), List.of()).stream()
|
||||||
handlerMap.getOrDefault(constructor.rowClass(), List.of()).stream()
|
|
||||||
.anyMatch(handler -> !IgnoreWikidata.class.isAssignableFrom(handler.handlerClass()))
|
.anyMatch(handler -> !IgnoreWikidata.class.isAssignableFrom(handler.handlerClass()))
|
||||||
).filterResults(b -> b).simplify().index();
|
).filterResults(b -> b).simplify().index();
|
||||||
|
|
||||||
@@ -149,8 +148,8 @@ public class BasemapProfile extends ForwardingProfile {
|
|||||||
if (elem instanceof OsmElement.Node) {
|
if (elem instanceof OsmElement.Node) {
|
||||||
return wikidataMappings.getOrElse(SimpleFeature.create(EMPTY_POINT, tags), false);
|
return wikidataMappings.getOrElse(SimpleFeature.create(EMPTY_POINT, tags), false);
|
||||||
} else if (elem instanceof OsmElement.Way) {
|
} else if (elem instanceof OsmElement.Way) {
|
||||||
return wikidataMappings.getOrElse(SimpleFeature.create(EMPTY_POLYGON, tags), false)
|
return wikidataMappings.getOrElse(SimpleFeature.create(EMPTY_POLYGON, tags), false) ||
|
||||||
|| wikidataMappings.getOrElse(SimpleFeature.create(EMPTY_LINE, tags), false);
|
wikidataMappings.getOrElse(SimpleFeature.create(EMPTY_LINE, tags), false);
|
||||||
} else if (elem instanceof OsmElement.Relation) {
|
} else if (elem instanceof OsmElement.Relation) {
|
||||||
return wikidataMappings.getOrElse(SimpleFeature.create(EMPTY_POLYGON, tags), false);
|
return wikidataMappings.getOrElse(SimpleFeature.create(EMPTY_POLYGON, tags), false);
|
||||||
} else {
|
} else {
|
||||||
@@ -201,14 +200,13 @@ public class BasemapProfile extends ForwardingProfile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Layers should implement this interface to subscribe to elements from <a href="https://www.naturalearthdata.com/">natural
|
* Layers should implement this interface to subscribe to elements from
|
||||||
* earth</a>.
|
* <a href="https://www.naturalearthdata.com/">natural earth</a>.
|
||||||
*/
|
*/
|
||||||
public interface NaturalEarthProcessor {
|
public interface NaturalEarthProcessor {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process an element from {@code table} in the<a href="https://www.naturalearthdata.com/">natural earth
|
* Process an element from {@code table} in the<a href="https://www.naturalearthdata.com/">natural earth source</a>.
|
||||||
* source</a>.
|
|
||||||
*
|
*
|
||||||
* @see Profile#processFeature(SourceFeature, FeatureCollector)
|
* @see Profile#processFeature(SourceFeature, FeatureCollector)
|
||||||
*/
|
*/
|
||||||
@@ -216,8 +214,8 @@ public class BasemapProfile extends ForwardingProfile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Layers should implement this interface to subscribe to elements from <a href="https://github.com/lukasmartinelli/osm-lakelines">OSM
|
* Layers should implement this interface to subscribe to elements from
|
||||||
* lake centerlines source</a>.
|
* <a href="https://github.com/lukasmartinelli/osm-lakelines">OSM lake centerlines source</a>.
|
||||||
*/
|
*/
|
||||||
public interface LakeCenterlineProcessor {
|
public interface LakeCenterlineProcessor {
|
||||||
|
|
||||||
@@ -231,8 +229,8 @@ public class BasemapProfile extends ForwardingProfile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Layers should implement this interface to subscribe to elements from <a href="https://osmdata.openstreetmap.de/data/water-polygons.html">OSM
|
* Layers should implement this interface to subscribe to elements from
|
||||||
* water polygons source</a>.
|
* <a href="https://osmdata.openstreetmap.de/data/water-polygons.html">OSM water polygons source</a>.
|
||||||
*/
|
*/
|
||||||
public interface OsmWaterPolygonProcessor {
|
public interface OsmWaterPolygonProcessor {
|
||||||
|
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ import org.yaml.snakeyaml.LoaderOptions;
|
|||||||
import org.yaml.snakeyaml.Yaml;
|
import org.yaml.snakeyaml.Yaml;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates code in the {@code generated} package from the OpenMapTiles schema crawled from a tag or branch in the <a
|
* Generates code in the {@code generated} package from the OpenMapTiles schema crawled from a tag or branch in the
|
||||||
* href="https://github.com/openmaptiles/openmaptiles">OpenMapTiles GitHub repo</a>.
|
* <a href="https://github.com/openmaptiles/openmaptiles">OpenMapTiles GitHub repo</a>.
|
||||||
* <p>
|
* <p>
|
||||||
* {@code OpenMapTilesSchema.java} contains the output layer definitions (i.e. attributes and allowed values) so that
|
* {@code OpenMapTilesSchema.java} contains the output layer definitions (i.e. attributes and allowed values) so that
|
||||||
* layer implementations in {@code layers} package can reference them instead of hard-coding.
|
* layer implementations in {@code layers} package can reference them instead of hard-coding.
|
||||||
@@ -169,8 +169,7 @@ public class Generate {
|
|||||||
|
|
||||||
emitLayerSchemaDefinitions(config.tileset, layers, packageName, output, tag);
|
emitLayerSchemaDefinitions(config.tileset, layers, packageName, output, tag);
|
||||||
emitTableDefinitions(tables, packageName, output, tag);
|
emitTableDefinitions(tables, packageName, output, tag);
|
||||||
LOGGER.info(
|
LOGGER.info("Done!");
|
||||||
"Done generating code in 'generated' package, now run IntelliJ 'Reformat Code' operation with 'Optimize imports' and 'Cleanup code' options selected.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Generates {@code OpenMapTilesSchema.java} */
|
/** Generates {@code OpenMapTilesSchema.java} */
|
||||||
@@ -178,7 +177,8 @@ public class Generate {
|
|||||||
Path output, String tag)
|
Path output, String tag)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
StringBuilder schemaClass = new StringBuilder();
|
StringBuilder schemaClass = new StringBuilder();
|
||||||
schemaClass.append("""
|
schemaClass.append(
|
||||||
|
"""
|
||||||
%s
|
%s
|
||||||
package %s;
|
package %s;
|
||||||
|
|
||||||
@@ -344,7 +344,8 @@ public class Generate {
|
|||||||
String tag)
|
String tag)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
StringBuilder tablesClass = new StringBuilder();
|
StringBuilder tablesClass = new StringBuilder();
|
||||||
tablesClass.append("""
|
tablesClass.append(
|
||||||
|
"""
|
||||||
%s
|
%s
|
||||||
package %s;
|
package %s;
|
||||||
|
|
||||||
@@ -405,7 +406,8 @@ public class Generate {
|
|||||||
Class<?> handlerClass,
|
Class<?> handlerClass,
|
||||||
RowHandler<T> handler
|
RowHandler<T> handler
|
||||||
) {}
|
) {}
|
||||||
""".formatted(GENERATED_FILE_HEADER, packageName, escapeJavadoc(tag)));
|
"""
|
||||||
|
.formatted(GENERATED_FILE_HEADER, packageName, escapeJavadoc(tag)));
|
||||||
|
|
||||||
List<String> classNames = new ArrayList<>();
|
List<String> classNames = new ArrayList<>();
|
||||||
Map<String, String> fieldNameToType = new TreeMap<>();
|
Map<String, String> fieldNameToType = new TreeMap<>();
|
||||||
@@ -494,11 +496,13 @@ public class Generate {
|
|||||||
.collect(joining("," + LINE_SEPARATOR)).indent(2).strip()
|
.collect(joining("," + LINE_SEPARATOR)).indent(2).strip()
|
||||||
).indent(2));
|
).indent(2));
|
||||||
|
|
||||||
String handlerCondition = classNames.stream().map(className ->
|
String handlerCondition = classNames.stream()
|
||||||
"""
|
.map(
|
||||||
|
className -> """
|
||||||
if (handler instanceof %s.Handler typedHandler) {
|
if (handler instanceof %s.Handler typedHandler) {
|
||||||
result.computeIfAbsent(%s.class, cls -> new ArrayList<>()).add(new RowHandlerAndClass<>(typedHandler.getClass(), typedHandler::process));
|
result.computeIfAbsent(%s.class, cls -> new ArrayList<>()).add(new RowHandlerAndClass<>(typedHandler.getClass(), typedHandler::process));
|
||||||
}""".formatted(className, className)
|
}"""
|
||||||
|
.formatted(className, className)
|
||||||
).collect(joining(LINE_SEPARATOR));
|
).collect(joining(LINE_SEPARATOR));
|
||||||
tablesClass.append("""
|
tablesClass.append("""
|
||||||
/**
|
/**
|
||||||
@@ -518,14 +522,14 @@ public class Generate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an {@link Expression} that implements the same logic as the <a href="https://imposm.org/docs/imposm3/latest/mapping.html">Imposm3
|
* Returns an {@link Expression} that implements the same logic as the
|
||||||
* Data Mapping</a> definition for a table.
|
* <a href="https://imposm.org/docs/imposm3/latest/mapping.html">Imposm3 Data Mapping</a> definition for a table.
|
||||||
*/
|
*/
|
||||||
static Expression parseImposm3MappingExpression(Imposm3Table table) {
|
static Expression parseImposm3MappingExpression(Imposm3Table table) {
|
||||||
if (table.type_mappings != null) {
|
if (table.type_mappings != null) {
|
||||||
return or(
|
return or(
|
||||||
table.type_mappings.entrySet().stream().map(entry ->
|
table.type_mappings.entrySet().stream()
|
||||||
parseImposm3MappingExpression(entry.getKey(), entry.getValue(), table.filters)
|
.map(entry -> parseImposm3MappingExpression(entry.getKey(), entry.getValue(), table.filters)
|
||||||
).toList()
|
).toList()
|
||||||
).simplify();
|
).simplify();
|
||||||
} else {
|
} else {
|
||||||
@@ -534,8 +538,8 @@ public class Generate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an {@link Expression} that implements the same logic as the <a href="https://imposm.org/docs/imposm3/latest/mapping.html#filters">Imposm3
|
* Returns an {@link Expression} that implements the same logic as the
|
||||||
* Data Mapping filters</a> for a table.
|
* <a href="https://imposm.org/docs/imposm3/latest/mapping.html#filters">Imposm3 Data Mapping filters</a> for a table.
|
||||||
*/
|
*/
|
||||||
static Expression parseImposm3MappingExpression(String type, JsonNode mapping, Imposm3Filters filters) {
|
static Expression parseImposm3MappingExpression(String type, JsonNode mapping, Imposm3Filters filters) {
|
||||||
return and(
|
return and(
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -51,7 +51,8 @@ import com.onthegomap.planetiler.util.Translations;
|
|||||||
/**
|
/**
|
||||||
* Defines the logic for generating map elements in the {@code aerodrome_label} layer from source features.
|
* Defines the logic for generating map elements in the {@code aerodrome_label} layer from source features.
|
||||||
* <p>
|
* <p>
|
||||||
* This class is ported to Java from <a href="https://github.com/openmaptiles/openmaptiles/tree/master/layers/aerodrome_label">OpenMapTiles
|
* This class is ported to Java from
|
||||||
|
* <a href="https://github.com/openmaptiles/openmaptiles/tree/master/layers/aerodrome_label">OpenMapTiles
|
||||||
* aerodrome_layer sql files</a>.
|
* aerodrome_layer sql files</a>.
|
||||||
*/
|
*/
|
||||||
public class AerodromeLabel implements
|
public class AerodromeLabel implements
|
||||||
|
|||||||
@@ -45,8 +45,8 @@ import com.onthegomap.planetiler.util.Translations;
|
|||||||
/**
|
/**
|
||||||
* Defines the logic for generating map elements in the {@code aeroway} layer from source features.
|
* Defines the logic for generating map elements in the {@code aeroway} layer from source features.
|
||||||
* <p>
|
* <p>
|
||||||
* This class is ported to Java from <a href="https://github.com/openmaptiles/openmaptiles/tree/master/layers/aeroway">OpenMapTiles
|
* This class is ported to Java from
|
||||||
* aeroway sql files</a>.
|
* <a href="https://github.com/openmaptiles/openmaptiles/tree/master/layers/aeroway">OpenMapTiles aeroway sql files</a>.
|
||||||
*/
|
*/
|
||||||
public class Aeroway implements
|
public class Aeroway implements
|
||||||
OpenMapTilesSchema.Aeroway,
|
OpenMapTilesSchema.Aeroway,
|
||||||
@@ -54,8 +54,7 @@ public class Aeroway implements
|
|||||||
Tables.OsmAerowayPolygon.Handler,
|
Tables.OsmAerowayPolygon.Handler,
|
||||||
Tables.OsmAerowayPoint.Handler {
|
Tables.OsmAerowayPoint.Handler {
|
||||||
|
|
||||||
public Aeroway(Translations translations, PlanetilerConfig config, Stats stats) {
|
public Aeroway(Translations translations, PlanetilerConfig config, Stats stats) {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void process(Tables.OsmAerowayPolygon element, FeatureCollector features) {
|
public void process(Tables.OsmAerowayPolygon element, FeatureCollector features) {
|
||||||
|
|||||||
@@ -86,8 +86,9 @@ import org.slf4j.LoggerFactory;
|
|||||||
* Defines the logic for generating map elements for country, state, and town boundaries in the {@code boundary} layer
|
* Defines the logic for generating map elements for country, state, and town boundaries in the {@code boundary} layer
|
||||||
* from source features.
|
* from source features.
|
||||||
* <p>
|
* <p>
|
||||||
* This class is ported to Java from <a href="https://github.com/openmaptiles/openmaptiles/tree/master/layers/boundary">OpenMapTiles
|
* This class is ported to Java from
|
||||||
* boundary sql files</a>.
|
* <a href="https://github.com/openmaptiles/openmaptiles/tree/master/layers/boundary">OpenMapTiles boundary sql
|
||||||
|
* files</a>.
|
||||||
*/
|
*/
|
||||||
public class Boundary implements
|
public class Boundary implements
|
||||||
OpenMapTilesSchema.Boundary,
|
OpenMapTilesSchema.Boundary,
|
||||||
@@ -164,8 +165,8 @@ public class Boundary implements
|
|||||||
BoundaryInfo info = switch (table) {
|
BoundaryInfo info = switch (table) {
|
||||||
case "ne_110m_admin_0_boundary_lines_land" -> new BoundaryInfo(2, 0, 0);
|
case "ne_110m_admin_0_boundary_lines_land" -> new BoundaryInfo(2, 0, 0);
|
||||||
case "ne_50m_admin_0_boundary_lines_land" -> new BoundaryInfo(2, 1, 3);
|
case "ne_50m_admin_0_boundary_lines_land" -> new BoundaryInfo(2, 1, 3);
|
||||||
case "ne_10m_admin_0_boundary_lines_land" -> feature.hasTag("featurecla", "Lease Limit") ? null
|
case "ne_10m_admin_0_boundary_lines_land" -> feature.hasTag("featurecla", "Lease Limit") ? null :
|
||||||
: new BoundaryInfo(2, 4, 4);
|
new BoundaryInfo(2, 4, 4);
|
||||||
case "ne_10m_admin_1_states_provinces_lines" -> {
|
case "ne_10m_admin_1_states_provinces_lines" -> {
|
||||||
Double minZoom = Parse.parseDoubleOrNull(feature.getTag("min_zoom"));
|
Double minZoom = Parse.parseDoubleOrNull(feature.getTag("min_zoom"));
|
||||||
yield minZoom != null && minZoom <= 7 ? new BoundaryInfo(4, 1, 4) :
|
yield minZoom != null && minZoom <= 7 ? new BoundaryInfo(4, 1, 4) :
|
||||||
@@ -398,8 +399,7 @@ public class Boundary implements
|
|||||||
try {
|
try {
|
||||||
Geometry combined = polygonizer.getGeometry().union();
|
Geometry combined = polygonizer.getGeometry().union();
|
||||||
if (combined.isEmpty()) {
|
if (combined.isEmpty()) {
|
||||||
LOGGER.warn("Unable to form closed polygon for OSM relation " + regionId
|
LOGGER.warn("Unable to form closed polygon for OSM relation " + regionId + " (likely missing edges)");
|
||||||
+ " (likely missing edges)");
|
|
||||||
} else {
|
} else {
|
||||||
countryBoundaries.put(regionId, PreparedGeometryFactory.prepare(combined));
|
countryBoundaries.put(regionId, PreparedGeometryFactory.prepare(combined));
|
||||||
}
|
}
|
||||||
@@ -429,8 +429,7 @@ public class Boundary implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Minimal set of information extracted from a boundary relation to be used when processing each way in that
|
* Minimal set of information extracted from a boundary relation to be used when processing each way in that relation.
|
||||||
* relation.
|
|
||||||
*/
|
*/
|
||||||
private record BoundaryRelation(
|
private record BoundaryRelation(
|
||||||
long id,
|
long id,
|
||||||
@@ -443,17 +442,15 @@ public class Boundary implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long estimateMemoryUsageBytes() {
|
public long estimateMemoryUsageBytes() {
|
||||||
return CLASS_HEADER_BYTES
|
return CLASS_HEADER_BYTES + MemoryEstimator.estimateSizeLong(id) + MemoryEstimator.estimateSizeInt(adminLevel) +
|
||||||
+ MemoryEstimator.estimateSizeLong(id)
|
estimateSize(disputed) + POINTER_BYTES + estimateSize(name) + POINTER_BYTES + estimateSize(claimedBy) +
|
||||||
+ MemoryEstimator.estimateSizeInt(adminLevel)
|
POINTER_BYTES + estimateSize(iso3166alpha3);
|
||||||
+ estimateSize(disputed)
|
|
||||||
+ POINTER_BYTES + estimateSize(name)
|
|
||||||
+ POINTER_BYTES + estimateSize(claimedBy)
|
|
||||||
+ POINTER_BYTES + estimateSize(iso3166alpha3);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Information to hold onto from processing a way in a boundary relation to determine the left/right region ID later. */
|
/**
|
||||||
|
* Information to hold onto from processing a way in a boundary relation to determine the left/right region ID later.
|
||||||
|
*/
|
||||||
private record CountryBoundaryComponent(
|
private record CountryBoundaryComponent(
|
||||||
int adminLevel,
|
int adminLevel,
|
||||||
boolean disputed,
|
boolean disputed,
|
||||||
|
|||||||
@@ -60,8 +60,9 @@ import java.util.Map;
|
|||||||
/**
|
/**
|
||||||
* Defines the logic for generating map elements for buildings in the {@code building} layer from source features.
|
* Defines the logic for generating map elements for buildings in the {@code building} layer from source features.
|
||||||
* <p>
|
* <p>
|
||||||
* This class is ported to Java from <a href="https://github.com/openmaptiles/openmaptiles/tree/master/layers/building">OpenMapTiles
|
* This class is ported to Java from
|
||||||
* building sql files</a>.
|
* <a href="https://github.com/openmaptiles/openmaptiles/tree/master/layers/building">OpenMapTiles building sql
|
||||||
|
* files</a>.
|
||||||
*/
|
*/
|
||||||
public class Building implements
|
public class Building implements
|
||||||
OpenMapTilesSchema.Building,
|
OpenMapTilesSchema.Building,
|
||||||
@@ -154,10 +155,8 @@ public class Building implements
|
|||||||
parseDoubleOrNull(element.buildingminLevel())
|
parseDoubleOrNull(element.buildingminLevel())
|
||||||
);
|
);
|
||||||
|
|
||||||
int renderHeight = (int) Math.ceil(height != null ? height
|
int renderHeight = (int) Math.ceil(height != null ? height : levels != null ? (levels * 3.66) : 5);
|
||||||
: levels != null ? (levels * 3.66) : 5);
|
int renderMinHeight = (int) Math.floor(minHeight != null ? minHeight : minLevels != null ? (minLevels * 3.66) : 0);
|
||||||
int renderMinHeight = (int) Math.floor(minHeight != null ? minHeight
|
|
||||||
: minLevels != null ? (minLevels * 3.66) : 0);
|
|
||||||
|
|
||||||
if (renderHeight < 3660 && renderMinHeight < 3660) {
|
if (renderHeight < 3660 && renderMinHeight < 3660) {
|
||||||
var feature = features.polygon(LAYER_NAME).setBufferPixels(BUFFER_SIZE)
|
var feature = features.polygon(LAYER_NAME).setBufferPixels(BUFFER_SIZE)
|
||||||
|
|||||||
@@ -45,15 +45,15 @@ import com.onthegomap.planetiler.util.Translations;
|
|||||||
/**
|
/**
|
||||||
* Defines the logic for generating map elements in the {@code housenumber} layer from source features.
|
* Defines the logic for generating map elements in the {@code housenumber} layer from source features.
|
||||||
* <p>
|
* <p>
|
||||||
* This class is ported to Java from <a href="https://github.com/openmaptiles/openmaptiles/tree/master/layers/housenumber">OpenMapTiles
|
* This class is ported to Java from
|
||||||
* housenumber sql files</a>.
|
* <a href="https://github.com/openmaptiles/openmaptiles/tree/master/layers/housenumber">OpenMapTiles housenumber sql
|
||||||
|
* files</a>.
|
||||||
*/
|
*/
|
||||||
public class Housenumber implements
|
public class Housenumber implements
|
||||||
OpenMapTilesSchema.Housenumber,
|
OpenMapTilesSchema.Housenumber,
|
||||||
Tables.OsmHousenumberPoint.Handler {
|
Tables.OsmHousenumberPoint.Handler {
|
||||||
|
|
||||||
public Housenumber(Translations translations, PlanetilerConfig config, Stats stats) {
|
public Housenumber(Translations translations, PlanetilerConfig config, Stats stats) {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void process(Tables.OsmHousenumberPoint element, FeatureCollector features) {
|
public void process(Tables.OsmHousenumberPoint element, FeatureCollector features) {
|
||||||
|
|||||||
@@ -57,8 +57,9 @@ import java.util.Set;
|
|||||||
* Defines the logic for generating map elements for natural land cover polygons like ice, sand, and forest in the
|
* Defines the logic for generating map elements for natural land cover polygons like ice, sand, and forest in the
|
||||||
* {@code landcover} layer from source features.
|
* {@code landcover} layer from source features.
|
||||||
* <p>
|
* <p>
|
||||||
* This class is ported to Java from <a href="https://github.com/openmaptiles/openmaptiles/tree/master/layers/landcover">OpenMapTiles
|
* This class is ported to Java from
|
||||||
* landcover sql files</a>.
|
* <a href="https://github.com/openmaptiles/openmaptiles/tree/master/layers/landcover">OpenMapTiles landcover sql
|
||||||
|
* files</a>.
|
||||||
*/
|
*/
|
||||||
public class Landcover implements
|
public class Landcover implements
|
||||||
OpenMapTilesSchema.Landcover,
|
OpenMapTilesSchema.Landcover,
|
||||||
|
|||||||
@@ -55,8 +55,8 @@ import java.util.Set;
|
|||||||
* Defines the logic for generating map elements for man-made land use polygons like cemeteries, zoos, and hospitals in
|
* Defines the logic for generating map elements for man-made land use polygons like cemeteries, zoos, and hospitals in
|
||||||
* the {@code landuse} layer from source features.
|
* the {@code landuse} layer from source features.
|
||||||
* <p>
|
* <p>
|
||||||
* This class is ported to Java from <a href="https://github.com/openmaptiles/openmaptiles/tree/master/layers/landuse">OpenMapTiles
|
* This class is ported to Java from
|
||||||
* landuse sql files</a>.
|
* <a href="https://github.com/openmaptiles/openmaptiles/tree/master/layers/landuse">OpenMapTiles landuse sql files</a>.
|
||||||
*/
|
*/
|
||||||
public class Landuse implements
|
public class Landuse implements
|
||||||
OpenMapTilesSchema.Landuse,
|
OpenMapTilesSchema.Landuse,
|
||||||
@@ -75,8 +75,7 @@ public class Landuse implements
|
|||||||
FieldValues.CLASS_NEIGHBOURHOOD
|
FieldValues.CLASS_NEIGHBOURHOOD
|
||||||
);
|
);
|
||||||
|
|
||||||
public Landuse(Translations translations, PlanetilerConfig config, Stats stats) {
|
public Landuse(Translations translations, PlanetilerConfig config, Stats stats) {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processNaturalEarth(String table, SourceFeature feature, FeatureCollector features) {
|
public void processNaturalEarth(String table, SourceFeature feature, FeatureCollector features) {
|
||||||
|
|||||||
@@ -65,8 +65,9 @@ import org.slf4j.LoggerFactory;
|
|||||||
* Defines the logic for generating map elements for mountain peak label points in the {@code mountain_peak} layer from
|
* Defines the logic for generating map elements for mountain peak label points in the {@code mountain_peak} layer from
|
||||||
* source features.
|
* source features.
|
||||||
* <p>
|
* <p>
|
||||||
* This class is ported to Java from <a href="https://github.com/openmaptiles/openmaptiles/tree/master/layers/mountain_peak">OpenMapTiles
|
* This class is ported to Java from
|
||||||
* mountain_peak sql files</a>.
|
* <a href="https://github.com/openmaptiles/openmaptiles/tree/master/layers/mountain_peak">OpenMapTiles mountain_peak
|
||||||
|
* sql files</a>.
|
||||||
*/
|
*/
|
||||||
public class MountainPeak implements
|
public class MountainPeak implements
|
||||||
BasemapProfile.NaturalEarthProcessor,
|
BasemapProfile.NaturalEarthProcessor,
|
||||||
|
|||||||
@@ -62,8 +62,8 @@ import java.util.Locale;
|
|||||||
* Defines the logic for generating map elements for designated parks polygons and their label points in the {@code
|
* Defines the logic for generating map elements for designated parks polygons and their label points in the {@code
|
||||||
* park} layer from source features.
|
* park} layer from source features.
|
||||||
* <p>
|
* <p>
|
||||||
* This class is ported to Java from <a href="https://github.com/openmaptiles/openmaptiles/tree/master/layers/park">OpenMapTiles
|
* This class is ported to Java from
|
||||||
* park sql files</a>.
|
* <a href="https://github.com/openmaptiles/openmaptiles/tree/master/layers/park">OpenMapTiles park sql files</a>.
|
||||||
*/
|
*/
|
||||||
public class Park implements
|
public class Park implements
|
||||||
OpenMapTilesSchema.Park,
|
OpenMapTilesSchema.Park,
|
||||||
|
|||||||
@@ -76,8 +76,8 @@ import org.locationtech.jts.geom.Point;
|
|||||||
* Defines the logic for generating label points for populated places like continents, countries, cities, and towns in
|
* Defines the logic for generating label points for populated places like continents, countries, cities, and towns in
|
||||||
* the {@code place} layer from source features.
|
* the {@code place} layer from source features.
|
||||||
* <p>
|
* <p>
|
||||||
* This class is ported to Java from <a href="https://github.com/openmaptiles/openmaptiles/tree/master/layers/place">OpenMapTiles
|
* This class is ported to Java from
|
||||||
* place sql files</a>.
|
* <a href="https://github.com/openmaptiles/openmaptiles/tree/master/layers/place">OpenMapTiles place sql files</a>.
|
||||||
*/
|
*/
|
||||||
public class Place implements
|
public class Place implements
|
||||||
OpenMapTilesSchema.Place,
|
OpenMapTilesSchema.Place,
|
||||||
@@ -420,9 +420,7 @@ public class Place implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Information extracted from a natural earth place label that will be inspected when joining with OpenStreetMap
|
* Information extracted from a natural earth place label that will be inspected when joining with OpenStreetMap data.
|
||||||
* data.
|
|
||||||
*/
|
*/
|
||||||
private record NaturalEarthPoint(String name, String wikidata, int scaleRank, Set<String> names) {}
|
private record NaturalEarthPoint(String name, String wikidata, int scaleRank, Set<String> names) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,8 +61,8 @@ import java.util.Map;
|
|||||||
* Defines the logic for generating map elements for things like shops, parks, and schools in the {@code poi} layer from
|
* Defines the logic for generating map elements for things like shops, parks, and schools in the {@code poi} layer from
|
||||||
* source features.
|
* source features.
|
||||||
* <p>
|
* <p>
|
||||||
* This class is ported to Java from <a href="https://github.com/openmaptiles/openmaptiles/tree/master/layers/poi">OpenMapTiles
|
* This class is ported to Java from
|
||||||
* poi sql files</a>.
|
* <a href="https://github.com/openmaptiles/openmaptiles/tree/master/layers/poi">OpenMapTiles poi sql files</a>.
|
||||||
*/
|
*/
|
||||||
public class Poi implements
|
public class Poi implements
|
||||||
OpenMapTilesSchema.Poi,
|
OpenMapTilesSchema.Poi,
|
||||||
@@ -136,19 +136,8 @@ public class Poi implements
|
|||||||
setupPoiFeature(element, features.centroidIfConvex(LAYER_NAME));
|
setupPoiFeature(element, features.centroidIfConvex(LAYER_NAME));
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T extends
|
private <T extends Tables.WithSubclass & Tables.WithStation & Tables.WithFunicular & Tables.WithSport & Tables.WithInformation & Tables.WithReligion & Tables.WithMappingKey & Tables.WithName & Tables.WithIndoor & Tables.WithLayer & Tables.WithSource> void setupPoiFeature(
|
||||||
Tables.WithSubclass &
|
T element, FeatureCollector.Feature output) {
|
||||||
Tables.WithStation &
|
|
||||||
Tables.WithFunicular &
|
|
||||||
Tables.WithSport &
|
|
||||||
Tables.WithInformation &
|
|
||||||
Tables.WithReligion &
|
|
||||||
Tables.WithMappingKey &
|
|
||||||
Tables.WithName &
|
|
||||||
Tables.WithIndoor &
|
|
||||||
Tables.WithLayer &
|
|
||||||
Tables.WithSource>
|
|
||||||
void setupPoiFeature(T element, FeatureCollector.Feature output) {
|
|
||||||
String rawSubclass = element.subclass();
|
String rawSubclass = element.subclass();
|
||||||
if ("station".equals(rawSubclass) && "subway".equals(element.station())) {
|
if ("station".equals(rawSubclass) && "subway".equals(element.station())) {
|
||||||
rawSubclass = "subway";
|
rawSubclass = "subway";
|
||||||
|
|||||||
@@ -80,8 +80,9 @@ import org.slf4j.LoggerFactory;
|
|||||||
* Defines the logic for generating map elements for roads, shipways, railroads, and paths in the {@code transportation}
|
* Defines the logic for generating map elements for roads, shipways, railroads, and paths in the {@code transportation}
|
||||||
* layer from source features.
|
* layer from source features.
|
||||||
* <p>
|
* <p>
|
||||||
* This class is ported to Java from <a href="https://github.com/openmaptiles/openmaptiles/tree/master/layers/transportation">OpenMapTiles
|
* This class is ported to Java from
|
||||||
* transportation sql files</a>.
|
* <a href="https://github.com/openmaptiles/openmaptiles/tree/master/layers/transportation">OpenMapTiles transportation
|
||||||
|
* sql files</a>.
|
||||||
*/
|
*/
|
||||||
public class Transportation implements
|
public class Transportation implements
|
||||||
OpenMapTilesSchema.Transportation,
|
OpenMapTilesSchema.Transportation,
|
||||||
@@ -320,8 +321,8 @@ public class Transportation implements
|
|||||||
Geometry wayGeometry = element.source().worldGeometry();
|
Geometry wayGeometry = element.source().worldGeometry();
|
||||||
if (greatBritain.intersects(wayGeometry)) {
|
if (greatBritain.intersects(wayGeometry)) {
|
||||||
Transportation.RouteNetwork networkType =
|
Transportation.RouteNetwork networkType =
|
||||||
"motorway".equals(element.highway()) ? Transportation.RouteNetwork.GB_MOTORWAY
|
"motorway".equals(element.highway()) ? Transportation.RouteNetwork.GB_MOTORWAY :
|
||||||
: Transportation.RouteNetwork.GB_TRUNK;
|
Transportation.RouteNetwork.GB_TRUNK;
|
||||||
String network = "motorway".equals(element.highway()) ? "omt-gb-motorway" : "omt-gb-trunk";
|
String network = "motorway".equals(element.highway()) ? "omt-gb-motorway" : "omt-gb-trunk";
|
||||||
result.add(new RouteRelation(refMatcher.group(), network, networkType, (byte) -1,
|
result.add(new RouteRelation(refMatcher.group(), network, networkType, (byte) -1,
|
||||||
0));
|
0));
|
||||||
@@ -434,7 +435,7 @@ public class Transportation implements
|
|||||||
private boolean isPierPolygon(Tables.OsmHighwayLinestring element) {
|
private boolean isPierPolygon(Tables.OsmHighwayLinestring element) {
|
||||||
if ("pier".equals(element.manMade())) {
|
if ("pier".equals(element.manMade())) {
|
||||||
try {
|
try {
|
||||||
if (element.source().worldGeometry() instanceof LineString lineString && lineString.isClosed()) {
|
if (element.source().worldGeometry()instanceof LineString lineString && lineString.isClosed()) {
|
||||||
// ignore this because it's a polygon
|
// ignore this because it's a polygon
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,8 @@ import java.util.function.Function;
|
|||||||
* Defines the logic for generating map elements for road, shipway, rail, and path names in the {@code
|
* Defines the logic for generating map elements for road, shipway, rail, and path names in the {@code
|
||||||
* transportation_name} layer from source features.
|
* transportation_name} layer from source features.
|
||||||
* <p>
|
* <p>
|
||||||
* This class is ported to Java from <a href="https://github.com/openmaptiles/openmaptiles/tree/master/layers/transportation_name">OpenMapTiles
|
* This class is ported to Java from
|
||||||
|
* <a href="https://github.com/openmaptiles/openmaptiles/tree/master/layers/transportation_name">OpenMapTiles
|
||||||
* transportation_name sql files</a>.
|
* transportation_name sql files</a>.
|
||||||
*/
|
*/
|
||||||
public class TransportationName implements
|
public class TransportationName implements
|
||||||
@@ -235,8 +236,8 @@ public class TransportationName implements
|
|||||||
.setAttr(Fields.REF, ref)
|
.setAttr(Fields.REF, ref)
|
||||||
.setAttr(Fields.REF_LENGTH, ref != null ? ref.length() : null)
|
.setAttr(Fields.REF_LENGTH, ref != null ? ref.length() : null)
|
||||||
.setAttr(Fields.NETWORK,
|
.setAttr(Fields.NETWORK,
|
||||||
(relation != null && relation.networkType() != null) ? relation.networkType().name
|
(relation != null && relation.networkType() != null) ? relation.networkType().name :
|
||||||
: !nullOrEmpty(ref) ? "road" : null)
|
!nullOrEmpty(ref) ? "road" : null)
|
||||||
.setAttr(Fields.CLASS, highwayClass)
|
.setAttr(Fields.CLASS, highwayClass)
|
||||||
.setAttr(Fields.SUBCLASS, highwaySubclass(highwayClass, null, highway))
|
.setAttr(Fields.SUBCLASS, highwaySubclass(highwayClass, null, highway))
|
||||||
.setMinPixelSize(0)
|
.setMinPixelSize(0)
|
||||||
|
|||||||
@@ -49,8 +49,8 @@ import com.onthegomap.planetiler.util.Translations;
|
|||||||
/**
|
/**
|
||||||
* Defines the logic for generating map elements for oceans and lakes in the {@code water} layer from source features.
|
* Defines the logic for generating map elements for oceans and lakes in the {@code water} layer from source features.
|
||||||
* <p>
|
* <p>
|
||||||
* This class is ported to Java from <a href="https://github.com/openmaptiles/openmaptiles/tree/master/layers/water">OpenMapTiles
|
* This class is ported to Java from
|
||||||
* water sql files</a>.
|
* <a href="https://github.com/openmaptiles/openmaptiles/tree/master/layers/water">OpenMapTiles water sql files</a>.
|
||||||
*/
|
*/
|
||||||
public class Water implements
|
public class Water implements
|
||||||
OpenMapTilesSchema.Water,
|
OpenMapTilesSchema.Water,
|
||||||
|
|||||||
@@ -61,8 +61,9 @@ import org.slf4j.LoggerFactory;
|
|||||||
* Defines the logic for generating map elements for ocean and lake names in the {@code water_name} layer from source
|
* Defines the logic for generating map elements for ocean and lake names in the {@code water_name} layer from source
|
||||||
* features.
|
* features.
|
||||||
* <p>
|
* <p>
|
||||||
* This class is ported to Java from <a href="https://github.com/openmaptiles/openmaptiles/tree/master/layers/water_name">OpenMapTiles
|
* This class is ported to Java from
|
||||||
* water_name sql files</a>.
|
* <a href="https://github.com/openmaptiles/openmaptiles/tree/master/layers/water_name">OpenMapTiles water_name sql
|
||||||
|
* files</a>.
|
||||||
*/
|
*/
|
||||||
public class WaterName implements
|
public class WaterName implements
|
||||||
OpenMapTilesSchema.WaterName,
|
OpenMapTilesSchema.WaterName,
|
||||||
|
|||||||
@@ -63,8 +63,9 @@ import java.util.Map;
|
|||||||
/**
|
/**
|
||||||
* Defines the logic for generating river map elements in the {@code waterway} layer from source features.
|
* Defines the logic for generating river map elements in the {@code waterway} layer from source features.
|
||||||
* <p>
|
* <p>
|
||||||
* This class is ported to Java from <a href="https://github.com/openmaptiles/openmaptiles/tree/master/layers/waterway">OpenMapTiles
|
* This class is ported to Java from
|
||||||
* waterway sql files</a>.
|
* <a href="https://github.com/openmaptiles/openmaptiles/tree/master/layers/waterway">OpenMapTiles waterway sql
|
||||||
|
* files</a>.
|
||||||
*/
|
*/
|
||||||
public class Waterway implements
|
public class Waterway implements
|
||||||
OpenMapTilesSchema.Waterway,
|
OpenMapTilesSchema.Waterway,
|
||||||
|
|||||||
@@ -49,7 +49,8 @@ import java.util.stream.Stream;
|
|||||||
* Utilities to extract common name fields (name, name_en, name_de, name:latin, name:nonlatin, name_int) that the
|
* Utilities to extract common name fields (name, name_en, name_de, name:latin, name:nonlatin, name_int) that the
|
||||||
* OpenMapTiles schema uses across any map element with a name.
|
* OpenMapTiles schema uses across any map element with a name.
|
||||||
* <p>
|
* <p>
|
||||||
* Ported from <a href="https://github.com/openmaptiles/openmaptiles-tools/blob/master/sql/zzz_language.sql">openmaptiles-tools</a>.
|
* Ported from
|
||||||
|
* <a href="https://github.com/openmaptiles/openmaptiles-tools/blob/master/sql/zzz_language.sql">openmaptiles-tools</a>.
|
||||||
*/
|
*/
|
||||||
public class LanguageUtils {
|
public class LanguageUtils {
|
||||||
|
|
||||||
@@ -126,8 +127,8 @@ public class LanguageUtils {
|
|||||||
String nameDe = string(tags.get("name:de"));
|
String nameDe = string(tags.get("name:de"));
|
||||||
|
|
||||||
boolean isLatin = containsOnlyLatinCharacters(name);
|
boolean isLatin = containsOnlyLatinCharacters(name);
|
||||||
String latin = isLatin ? name
|
String latin = isLatin ? name :
|
||||||
: Stream.concat(Stream.of(nameEn, intName, nameDe), getAllNameTranslationsBesidesEnglishAndGerman(tags))
|
Stream.concat(Stream.of(nameEn, intName, nameDe), getAllNameTranslationsBesidesEnglishAndGerman(tags))
|
||||||
.filter(LanguageUtils::containsOnlyLatinCharacters)
|
.filter(LanguageUtils::containsOnlyLatinCharacters)
|
||||||
.findFirst().orElse(null);
|
.findFirst().orElse(null);
|
||||||
if (latin == null && translations != null && translations.getShouldTransliterate()) {
|
if (latin == null && translations != null && translations.getShouldTransliterate()) {
|
||||||
|
|||||||
@@ -61,8 +61,8 @@ public abstract class AbstractLayerTest {
|
|||||||
if (vals[i - 1] > vals[i]) {
|
if (vals[i - 1] > vals[i]) {
|
||||||
fail(
|
fail(
|
||||||
Arrays.toString(vals) +
|
Arrays.toString(vals) +
|
||||||
System.lineSeparator() + "element at " + (i - 1) + " (" + vals[i - 1] + ") is greater than element at " + i
|
System.lineSeparator() + "element at " + (i - 1) + " (" + vals[i - 1] + ") is greater than element at " +
|
||||||
+ " (" + vals[i] + ")");
|
i + " (" + vals[i] + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public class ParkTest extends AbstractLayerTest {
|
|||||||
"name", "Grand Canyon National Park",
|
"name", "Grand Canyon National Park",
|
||||||
"name_int", "Grand Canyon National Park",
|
"name_int", "Grand Canyon National Park",
|
||||||
"name:latin", "Grand Canyon National Park",
|
"name:latin", "Grand Canyon National Park",
|
||||||
// "name:es", "es name", // don't include all translations
|
// "name:es", "es name", // don't include all translations
|
||||||
"_minzoom", 5,
|
"_minzoom", 5,
|
||||||
"_maxzoom", 14
|
"_maxzoom", 14
|
||||||
)), process(polygonFeature(Map.of(
|
)), process(polygonFeature(Map.of(
|
||||||
|
|||||||
Reference in New Issue
Block a user