kopia lustrzana https://github.com/onthegomap/planetiler
fix issues in generated code
rodzic
b5c2ab0d80
commit
157b7305fe
|
@ -18,6 +18,8 @@ import com.onthegomap.planetiler.util.Format;
|
|||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
|
@ -174,6 +176,12 @@ public class Generate {
|
|||
LOGGER.info("Done!");
|
||||
}
|
||||
|
||||
private static final String GENERATED_ANNOTATION =
|
||||
"@javax.annotation.processing.Generated(value = %s, date = %s)".formatted(
|
||||
Format.quote(Generate.class.getName()),
|
||||
Format.quote(Instant.now().truncatedTo(ChronoUnit.SECONDS).toString())
|
||||
);
|
||||
|
||||
/** Generates {@code OpenMapTilesSchema.java} */
|
||||
private static void emitLayerSchemaDefinitions(OpenmaptilesTileSet info, List<LayerConfig> layers, String packageName,
|
||||
Path output, String tag)
|
||||
|
@ -198,7 +206,7 @@ public class Generate {
|
|||
* All vector tile layer definitions, attributes, and allowed values generated from the
|
||||
* <a href="https://github.com/openmaptiles/openmaptiles/blob/%s/openmaptiles.yaml">OpenMapTiles vector tile schema %s</a>.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
%s
|
||||
public class OpenMapTilesSchema {
|
||||
public static final String NAME = %s;
|
||||
public static final String DESCRIPTION = %s;
|
||||
|
@ -218,6 +226,7 @@ public class Generate {
|
|||
packageName,
|
||||
escapeJavadoc(tag),
|
||||
escapeJavadoc(tag),
|
||||
GENERATED_ANNOTATION,
|
||||
Format.quote(info.name),
|
||||
Format.quote(info.description),
|
||||
Format.quote(info.version),
|
||||
|
@ -277,7 +286,7 @@ public class Generate {
|
|||
iterToList(valuesNode.elements()).stream().filter(JsonNode::isTextual).map(JsonNode::textValue)
|
||||
.map(t -> t.replaceAll(" .*", "")).toList() :
|
||||
iterToList(valuesNode.fieldNames());
|
||||
if (values.size() > 0) {
|
||||
if (!values.isEmpty()) {
|
||||
fieldValues.append(values.stream()
|
||||
.map(v -> "public static final String %s = %s;"
|
||||
.formatted(name.toUpperCase(Locale.ROOT) + "_" + v.toUpperCase(Locale.ROOT).replace('-', '_'),
|
||||
|
@ -373,7 +382,7 @@ public class Generate {
|
|||
* "table" but implementing the table's {@code Handler} interface and use the element's typed API to access
|
||||
* attributes.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
%s
|
||||
public class Tables {
|
||||
/** A parsed OSM element that would appear in a "row" of the imposm3 table. */
|
||||
public interface Row {
|
||||
|
@ -409,7 +418,7 @@ public class Generate {
|
|||
RowHandler<T> handler
|
||||
) {}
|
||||
"""
|
||||
.formatted(GENERATED_FILE_HEADER, packageName, escapeJavadoc(tag)));
|
||||
.formatted(GENERATED_FILE_HEADER, packageName, escapeJavadoc(tag), GENERATED_ANNOTATION));
|
||||
|
||||
List<String> classNames = new ArrayList<>();
|
||||
Map<String, String> fieldNameToType = new TreeMap<>();
|
||||
|
@ -681,7 +690,7 @@ public class Generate {
|
|||
|
||||
/** Returns {@code comment} text safe to insert in generated javadoc. */
|
||||
private static String escapeJavadoc(String comment) {
|
||||
return comment.strip().replaceAll("[\n\r*\\s]+", " ");
|
||||
return comment.strip().replaceAll("\\s+", " ");
|
||||
}
|
||||
|
||||
private static String getFieldDescription(JsonNode value) {
|
||||
|
|
|
@ -52,7 +52,8 @@ import java.util.Set;
|
|||
* <a href="https://github.com/openmaptiles/openmaptiles/blob/v3.13/openmaptiles.yaml">OpenMapTiles vector tile schema
|
||||
* v3.13</a>.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
@javax.annotation.processing.Generated(value = "com.onthegomap.planetiler.basemap.Generate",
|
||||
date = "2022-04-25T10:45:22Z")
|
||||
public class OpenMapTilesSchema {
|
||||
public static final String NAME = "OpenMapTiles";
|
||||
public static final String DESCRIPTION = "A tileset showcasing all layers in OpenMapTiles. https://openmaptiles.org";
|
||||
|
@ -886,9 +887,9 @@ public class OpenMapTilesSchema {
|
|||
/**
|
||||
* The network type derived mainly from
|
||||
* <a href="http://wiki.openstreetmap.org/wiki/Key:network"><code>network</code></a> tag of the road. See more
|
||||
* info about <a href="http://wiki.openstreetmap.org/wiki/Road_signs_in_the_United_States"><code>us- </code></a>,
|
||||
* info about <a href="http://wiki.openstreetmap.org/wiki/Road_signs_in_the_United_States"><code>us-*</code></a>,
|
||||
* <a href="https://en.wikipedia.org/wiki/Trans-Canada_Highway"><code>ca-transcanada</code></a>, or
|
||||
* <a href="http://wiki.openstreetmap.org/wiki/United_Kingdom_Tagging_Guidelines#UK_roads"><code>gb- </code></a>.
|
||||
* <a href="http://wiki.openstreetmap.org/wiki/United_Kingdom_Tagging_Guidelines#UK_roads"><code>gb-*</code></a>.
|
||||
*/
|
||||
public static final String NETWORK = "network";
|
||||
|
||||
|
@ -1138,7 +1139,7 @@ public class OpenMapTilesSchema {
|
|||
}
|
||||
/**
|
||||
* All <a href="http://wiki.openstreetmap.org/wiki/Buildings">OSM Buildings</a>. All building tags are imported
|
||||
* (<a href="http://wiki.openstreetmap.org/wiki/Key:building"><code>building= </code></a>). The buildings are not yet
|
||||
* (<a href="http://wiki.openstreetmap.org/wiki/Key:building"><code>building=*</code></a>). The buildings are not yet
|
||||
* ready for 3D rendering support and any help to improve this is welcomed.
|
||||
*
|
||||
* Generated from
|
||||
|
@ -1244,7 +1245,7 @@ public class OpenMapTilesSchema {
|
|||
}
|
||||
}
|
||||
/**
|
||||
* This is the layer for labelling the highways. Only highways that are named <code>name= </code> and are long enough
|
||||
* This is the layer for labelling the highways. Only highways that are named <code>name=*</code> and are long enough
|
||||
* to place text upon appear. The OSM roads are stitched together if they contain the same name to have better label
|
||||
* placement than having many small linestrings. For motorways you should use the <code>ref</code> field to label them
|
||||
* while for other roads you should use <code>name</code>.
|
||||
|
@ -1283,9 +1284,9 @@ public class OpenMapTilesSchema {
|
|||
/**
|
||||
* The network type derived mainly from
|
||||
* <a href="http://wiki.openstreetmap.org/wiki/Key:network"><code>network</code></a> tag of the road. See more
|
||||
* info about <a href="http://wiki.openstreetmap.org/wiki/Road_signs_in_the_United_States"><code>us- </code></a>,
|
||||
* info about <a href="http://wiki.openstreetmap.org/wiki/Road_signs_in_the_United_States"><code>us-*</code></a>,
|
||||
* <a href="https://en.wikipedia.org/wiki/Trans-Canada_Highway"><code>ca-transcanada</code></a>, or
|
||||
* <a href="http://wiki.openstreetmap.org/wiki/United_Kingdom_Tagging_Guidelines#UK_roads"><code>gb- </code></a>.
|
||||
* <a href="http://wiki.openstreetmap.org/wiki/United_Kingdom_Tagging_Guidelines#UK_roads"><code>gb-*</code></a>.
|
||||
* <p>
|
||||
* allowed values:
|
||||
* <ul>
|
||||
|
|
|
@ -57,7 +57,8 @@ import java.util.Map;
|
|||
* in the tables that imposm3 would generate. Layer implementations can "subscribe" to elements from each "table" but
|
||||
* implementing the table's {@code Handler} interface and use the element's typed API to access attributes.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
@javax.annotation.processing.Generated(value = "com.onthegomap.planetiler.basemap.Generate",
|
||||
date = "2022-04-25T10:45:22Z")
|
||||
public class Tables {
|
||||
/** A parsed OSM element that would appear in a "row" of the imposm3 table. */
|
||||
public interface Row {
|
||||
|
|
Ładowanie…
Reference in New Issue