Skip to content

Commit 7507c4c

Browse files
committed
Split input and output, remove warnings and errors, add check at the end of the CI
1 parent 26879f8 commit 7507c4c

File tree

5 files changed

+21
-8
lines changed

5 files changed

+21
-8
lines changed

.github/workflows/CI.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@ jobs:
1919
docker compose build planet-search
2020
- name: End to End tests using curl
2121
run: |-
22-
mkdir -p ./data/sources
23-
cp ./src/test/resources/extenal.geojson ./data/sources/external.geojson
22+
mkdir -p ./data/input
23+
cp ./src/test/resources/extenal.geojson ./data/input/external.geojson
2424
docker compose up planet-search
2525
curl -s -X GET http://localhost:9200/points/_search?pretty -H 'Content-Type: application/json'
26+
- name: Check that a PMTiles was created
27+
if: ! exists('./data/output/global_points.pmtiles')
28+
run: echo "File was not created" && exit 1
2629

2730
Java:
2831
runs-on: ubuntu-latest

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Additional arguments to this wrapper besides the Planetiler's arguments:
1515
| `es-address` | The address of the Elasticsearch database | `http://localhost:9200` |
1616
| `es-points-index-alias` | The alias of the index to insert points into, it will create "1" and "2" suffix for the relevant index before switching | `points` |
1717
| `es-bbox-index-alias` | The alias of the index to insert bounding boxes into, it will create "1" and "2" suffix for the relevant index before switching | `bbox` |
18+
| `external-file-path` | Extranl geojson file path to allow adding non OSM features to the search and POIs. these features should have a specific format | `data/sources/external.geojson` |
1819

1920
To run using docker (While having a local elasticsearch running at 9200):
2021

docker-compose.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ services:
33
build: .
44
network_mode: host
55
volumes:
6-
- ./data:/app/data
6+
- ./data/output:/app/data/sources
7+
- ./data/input:/app/data/target
78
environment:
89
- JAVA_OPTS=-Xmx2g -Xms2g
910
command:

src/main/java/il/org/osm/israelhiking/MainClass.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static void run(Arguments args) throws Exception {
3939
.addOsmSource("osm", Path.of("data", "sources", area + ".osm.pbf"), "geofabrik:" + area)
4040
.addGeoJsonSource("external", externalFilePath)
4141
// override this default with mbtiles="path/to/output.mbtiles"
42-
.overwriteOutput(Path.of("data", PlanetSearchProfile.POINTS_LAYER_NAME + ".pmtiles"))
42+
.overwriteOutput(Path.of("data", "target", PlanetSearchProfile.POINTS_LAYER_NAME + ".pmtiles"))
4343
.run();
4444

4545
ElasticsearchHelper.switchAlias(esClient, pointsIndexAlias, targetPointsIndex);

src/main/java/il/org/osm/israelhiking/PlanetSearchProfile.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import java.util.concurrent.ConcurrentMap;
1212
import java.util.stream.Collectors;
1313

14+
import org.locationtech.jts.geom.Envelope;
1415
import org.locationtech.jts.geom.Geometry;
1516
import org.locationtech.jts.geom.LineString;
1617
import org.locationtech.jts.geom.Point;
@@ -186,7 +187,7 @@ private void processExternalFeautre(SourceFeature sourceFeature, FeatureCollecto
186187
try {
187188
point = GeoUtils.point(sourceFeature.worldGeometry().getCoordinate());
188189
} catch (GeometryException e2) {
189-
LOGGER.warn("Failed to process external feature: {}", docId);
190+
// ignore bad geometries
190191
return;
191192
}
192193
}
@@ -382,7 +383,7 @@ private void processOtherSourceFeature(SourceFeature feature, FeatureCollector f
382383
try {
383384
point = GeoUtils.point(feature.worldGeometry().getCoordinate());
384385
} catch (GeometryException e2) {
385-
LOGGER.warn("Failed to process feature: {} (this is usually a relations outside the area)", docId);
386+
// ignore bad geometries
386387
return;
387388
}
388389
}
@@ -431,10 +432,17 @@ private void insertPointToElasticsearch(PointDocument pointDocument, String docI
431432
}
432433

433434
private void insertBboxToElasticsearch(SourceFeature feature, String[] supportedLanguages) {
435+
Envelope envelope;
436+
try {
437+
envelope = feature.polygon().getEnvelopeInternal();
438+
} catch (GeometryException e) {
439+
return;
440+
}
434441
try {
435442
var bbox = new BBoxDocument();
436443
bbox.area = feature.areaMeters();
437-
bbox.setBBox(GeoUtils.toLatLonBoundsBounds(feature.polygon().getEnvelopeInternal()));
444+
445+
bbox.setBBox(GeoUtils.toLatLonBoundsBounds(envelope));
438446
for (String lang : supportedLanguages) {
439447
bbox.name.put(lang, Coalesce(feature.getString("name:" + lang), feature.getString("name")));
440448
}
@@ -445,7 +453,7 @@ private void insertBboxToElasticsearch(SourceFeature feature, String[] supported
445453
);
446454
} catch (Exception e) {
447455
// swallow
448-
LOGGER.error("Unable to insert" + e.getMessage());
456+
LOGGER.error("Unable to insert: " + e.getMessage());
449457
}
450458
}
451459

0 commit comments

Comments
 (0)