Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add experimental support for lua profiles #736

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .idea/jsonSchemas.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"java.sources.organizeImports.starThreshold": 999,
"java.saveActions.organizeImports": true,
"yaml.schemas": {
"./planetiler-custommap/planetiler.schema.json": "planetiler-custommap/**/*.yml"
"./planetiler-custommap/planetiler.schema.json": [
"planetiler-custommap/**/*.y*ml",
"planetiler-experimental/**/*.y*ml"
]
}
}
5 changes: 4 additions & 1 deletion NOTICE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Planetiler licensed under the Apache license, Version 2.0

Copyright 2021 Michael Barry and Planetiler Contributors.

The `planetiler-core` module includes the following software:
Planetiler includes the following software:

- Maven Dependencies:
- Jackson for JSON/XML handling (Apache license)
Expand All @@ -29,6 +29,8 @@ The `planetiler-core` module includes the following software:
- org.snakeyaml:snakeyaml-engine (Apache license)
- org.commonmark:commonmark (BSD 2-clause license)
- org.tukaani:xz (public domain)
- org.luaj:luaj-jse (MIT license)
- org.apache.bcel:bcel (Apache license)
- Adapted code:
- `DouglasPeuckerSimplifier` from [JTS](https://github.com/locationtech/jts) (EDL)
- `OsmMultipolygon` from [imposm3](https://github.com/omniscale/imposm3) (Apache license)
Expand All @@ -48,6 +50,7 @@ The `planetiler-core` module includes the following software:
- `SeekableInMemoryByteChannel`
from [Apache Commons compress](https://commons.apache.org/proper/commons-compress/apidocs/org/apache/commons/compress/utils/SeekableInMemoryByteChannel.html) (
Apache License)
- Several classes in `org.luaj.vm2.*` from [luaj](https://github.com/luaj/luaj) (MIT License)
- [`planetiler-openmaptiles`](https://github.com/openmaptiles/planetiler-openmaptiles) submodule (BSD 3-Clause License)
- Schema
- The cartography and visual design features of the map tile schema are licensed
Expand Down
5 changes: 5 additions & 0 deletions planetiler-benchmarks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
<artifactId>planetiler-openmaptiles</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>com.onthegomap.planetiler</groupId>
<artifactId>planetiler-experimental</artifactId>
<version>${revision}</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.onthegomap.planetiler.benchmarks;

import com.onthegomap.planetiler.FeatureCollector;
import com.onthegomap.planetiler.config.Arguments;
import com.onthegomap.planetiler.config.PlanetilerConfig;
import com.onthegomap.planetiler.experimental.lua.LuaEnvironment;
import com.onthegomap.planetiler.geo.GeoUtils;
import com.onthegomap.planetiler.reader.SimpleFeature;
import com.onthegomap.planetiler.stats.Stats;
import com.onthegomap.planetiler.util.Format;
import java.io.IOException;
import java.nio.file.Path;
import java.util.List;
import java.util.Map;
import org.locationtech.jts.geom.CoordinateXY;

public class BenchmarkLua {

public static void main(String[] args) throws IOException {
var env =
LuaEnvironment.loadScript(Arguments.of(), Path.of("planetiler-experimental/src/test/resources/power.lua"));
var feature = SimpleFeature.createFakeOsmFeature(GeoUtils.JTS_FACTORY.createPoint(new CoordinateXY(0, 0)), Map.of(),
"", "", 1, List.of());
int batch = 1_000_000;
var fc = new FeatureCollector.Factory(PlanetilerConfig.defaults(), Stats.inMemory());
for (int i = 0; i < batch; i++) {
env.profile.processFeature(feature, fc.get(feature));
}
long start = System.currentTimeMillis();
int num = 0;
do {
for (int i = 0; i < batch; i++) {
env.profile.processFeature(feature, fc.get(feature));
}
num += batch;
} while (System.currentTimeMillis() - start < 1_000);
long end = System.currentTimeMillis();
System.err.println(Format.defaultInstance().numeric(num / ((end - start) / 1000.0)) + " calls/sec");
}
}
4 changes: 4 additions & 0 deletions planetiler-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@
<artifactId>geopackage</artifactId>
<version>${geopackage.version}</version>
</dependency>
<dependency>
<groupId>org.snakeyaml</groupId>
<artifactId>snakeyaml-engine</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,10 @@ public Planetiler setDefaultLanguages(List<String> languages) {
return this;
}

public List<String> getDefaultLanguages() {
return languages;
}

/**
* Updates {@link #translations()} to use name translations fetched from wikidata based on the
* <a href="https://www.wikidata.org/wiki/Wikidata:OpenStreetMap">wikidata tag</a> on OSM elements.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.onthegomap.planetiler.reader.osm.OsmRelationInfo;
import com.onthegomap.planetiler.util.Wikidata;
import java.util.List;
import java.util.Locale;
import java.util.function.Consumer;

/**
Expand Down Expand Up @@ -114,7 +115,9 @@ default List<VectorTile.Feature> postProcessLayerFeatures(String layer, int zoom
*
* @see <a href="https://github.com/mapbox/mbtiles-spec/blob/master/1.3/spec.md#metadata">MBTiles specification</a>
*/
String name();
default String name() {
return getClass().getSimpleName().toLowerCase(Locale.ROOT);
}

/**
* Returns the description of the generated tileset to put into {@link Mbtiles} metadata
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,13 +426,17 @@ public int threads() {
public Stats getStats() {
String prometheus = getArg("pushgateway");
if (prometheus != null && !prometheus.isBlank()) {
LOGGER.info("argument: stats=use prometheus push gateway stats");
if (!silent) {
LOGGER.info("argument: stats=use prometheus push gateway stats");
}
String job = getString("pushgateway.job", "prometheus pushgateway job ID", "planetiler");
Duration interval = getDuration("pushgateway.interval", "how often to send stats to prometheus push gateway",
"15s");
return Stats.prometheusPushGateway(prometheus, job, interval);
} else {
LOGGER.info("argument: stats=use in-memory stats");
if (!silent) {
LOGGER.info("argument: stats=use in-memory stats");
}
return Stats.inMemory();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.onthegomap.planetiler.custommap;
package com.onthegomap.planetiler.util;

import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.ByteArrayInputStream;
Expand Down
Loading
Loading