@@ -72,12 +72,15 @@ public PlanetSearchProfile(PlanetilerConfig config, ElasticsearchClient esClient
7272 * point with attributes derived from the relation as well as for ways with mtb:name tag.
7373 */
7474
75- static private final String Coalesce (String ... strings ) {
76- return Arrays .stream (strings )
77- .filter (Objects ::nonNull )
78- .filter (s -> !s .isEmpty ())
79- .findFirst ()
80- .orElse (null );
75+ static private final void CoalesceIntoMap (Map <String , String > map , String language , String ... strings ) {
76+ var value = Arrays .stream (strings )
77+ .filter (Objects ::nonNull )
78+ .filter (s -> !s .isEmpty ())
79+ .findFirst ()
80+ .orElse (null );
81+ if (value != null ) {
82+ map .put (language , value );
83+ }
8184 }
8285
8386 @ Override
@@ -107,8 +110,8 @@ public List<OsmRelationInfo> preprocessOsmRelation(OsmElement.Relation relation)
107110 var info = new RelationInfo (relation .id ());
108111
109112 for (String language : supportedLanguages ) {
110- pointDocument .name . put ( language , Coalesce ( relation .getString ("name:" + language ), relation .getString ("name" ) ));
111- pointDocument .description . put ( language , Coalesce ( relation .getString ("description:" + language ), relation .getString ("description" ) ));
113+ CoalesceIntoMap ( pointDocument .name , language , relation .getString ("name:" + language ), relation .getString ("name" ));
114+ CoalesceIntoMap ( pointDocument .description , language , relation .getString ("description:" + language ), relation .getString ("description" ));
112115 }
113116 pointDocument .poiSource = "OSM" ;
114117 pointDocument .wikidata = relation .getString ("wikidata" );
@@ -172,8 +175,8 @@ private void processExternalFeautre(SourceFeature sourceFeature, FeatureCollecto
172175 pointDocument .poiIconColor = sourceFeature .getString ("poiIconColor" );
173176 pointDocument .poiCategory = sourceFeature .getString ("poiCategory" );
174177 for (String language : supportedLanguages ) {
175- pointDocument .name . put ( language , Coalesce ( sourceFeature .getString ("name:" + language ), sourceFeature .getString ("name" ) ));
176- pointDocument .description . put ( language , Coalesce ( sourceFeature .getString ("description:" + language ), sourceFeature .getString ("description" ) ));
178+ CoalesceIntoMap ( pointDocument .name , language , sourceFeature .getString ("name:" + language ), sourceFeature .getString ("name" ));
179+ CoalesceIntoMap ( pointDocument .description , language , sourceFeature .getString ("description:" + language ), sourceFeature .getString ("description" ));
177180 }
178181 pointDocument .poiSource = sourceFeature .getString ("poiSource" );
179182 pointDocument .wikidata = sourceFeature .getString ("wikidata" );
@@ -209,7 +212,7 @@ private void processOsmRelationFeature(SourceFeature sourceFeature, FeatureColle
209212 for (var routeInfo : sourceFeature .relationInfo (RelationInfo .class )) {
210213 // (routeInfo.role() also has the "role" of this relation member if needed)
211214 RelationInfo relation = routeInfo .relation ();
212- if (relation .pointDocument .name .size () == 0 ) {
215+ if (relation .pointDocument .name .isEmpty () ) {
213216 continue ;
214217 }
215218 // Collect all relation way members
@@ -229,8 +232,8 @@ private void processOsmRelationFeature(SourceFeature sourceFeature, FeatureColle
229232 if (!relation .memberIds .isEmpty ()) {
230233 continue ;
231234 }
232- // All relation members were reached. Add a POI element for trail relation
233- var point = getFirstPointOfTrailRelation (mergedLines );
235+ // All relation members were reached. Add a POI element for line relation
236+ var point = getFirstPointOfLineRelation (mergedLines );
234237 var lngLatPoint = GeoUtils .worldToLatLonCoords (point ).getCoordinate ();
235238 relation .pointDocument .location = new double []{lngLatPoint .getX (), lngLatPoint .getY ()};
236239
@@ -277,8 +280,8 @@ private void processMtbNameFeature(SourceFeature sourceFeature, FeatureCollector
277280
278281 var pointDocument = new PointDocument ();
279282 for (String language : supportedLanguages ) {
280- pointDocument .name . put ( language , Coalesce ( feature .getString ("mtb:name:" + language ), feature .getString ("name:" + language ), feature .getString ("name" ), feature .getString ("mtb:name" ) ));
281- pointDocument .description . put ( language , Coalesce ( feature .getString ("description:" + language ), feature .getString ("description" ) ));
283+ CoalesceIntoMap ( pointDocument .name , language , feature .getString ("mtb:name:" + language ), feature .getString ("name:" + language ), feature .getString ("name" ), feature .getString ("mtb:name" ));
284+ CoalesceIntoMap ( pointDocument .description , language , feature .getString ("description:" + language ), feature .getString ("description" ));
282285 }
283286 pointDocument .wikidata = feature .getString ("wikidata" );
284287 pointDocument .image = feature .getString ("image" );
@@ -334,8 +337,8 @@ private void processWaterwayFeature(SourceFeature sourceFeature, FeatureCollecto
334337
335338 var pointDocument = new PointDocument ();
336339 for (String language : supportedLanguages ) {
337- pointDocument .name . put ( language , Coalesce ( feature .getString ("name:" + language ), feature .getString ("name" ) ));
338- pointDocument .description . put ( language , Coalesce ( feature .getString ("description:" + language ), feature .getString ("description" ) ));
340+ CoalesceIntoMap ( pointDocument .name , language , feature .getString ("name:" + language ), feature .getString ("name" ));
341+ CoalesceIntoMap ( pointDocument .description , language , feature .getString ("description:" + language ), feature .getString ("description" ));
339342 }
340343 pointDocument .wikidata = feature .getString ("wikidata" );
341344 pointDocument .image = feature .getString ("image" );
@@ -390,8 +393,8 @@ private void processOtherSourceFeature(SourceFeature feature, FeatureCollector f
390393
391394 var pointDocument = new PointDocument ();
392395 for (String language : supportedLanguages ) {
393- pointDocument .name . put ( language , Coalesce ( feature .getString ("name:" + language ), feature .getString ("name" ) ));
394- pointDocument .description . put ( language , Coalesce ( feature .getString ("description:" + language ), feature .getString ("description" ) ));
396+ CoalesceIntoMap ( pointDocument .name , language , feature .getString ("name:" + language ), feature .getString ("name" ));
397+ CoalesceIntoMap ( pointDocument .description , language , feature .getString ("description:" + language ), feature .getString ("description" ));
395398 }
396399 pointDocument .wikidata = feature .getString ("wikidata" );
397400 pointDocument .image = feature .getString ("image" );
@@ -408,7 +411,7 @@ private void processOtherSourceFeature(SourceFeature feature, FeatureCollector f
408411
409412 insertPointToElasticsearch (pointDocument , docId );
410413
411- if (pointDocument .poiIcon == "icon-peak" && !isInterestingPoint (pointDocument )) {
414+ if (( pointDocument .poiIcon == "icon-peak" || pointDocument . poiIcon == "icon-waterfall" ) && !isInterestingPoint (pointDocument )) {
412415 return ;
413416 }
414417
@@ -444,7 +447,7 @@ private void insertBboxToElasticsearch(SourceFeature feature, String[] supported
444447
445448 bbox .setBBox (GeoUtils .toLatLonBoundsBounds (envelope ));
446449 for (String lang : supportedLanguages ) {
447- bbox .name . put ( lang , Coalesce ( feature .getString ("name:" + lang ), feature .getString ("name" ) ));
450+ CoalesceIntoMap ( bbox .name , lang , feature .getString ("name:" + lang ), feature .getString ("name" ));
448451 }
449452 esClient .index (i -> i
450453 .index (this .bboxIndexName )
@@ -463,7 +466,7 @@ private void insertBboxToElasticsearch(SourceFeature feature, String[] supported
463466 * @return the first point of the trail relation
464467 * @throws GeometryException
465468 */
466- private Point getFirstPointOfTrailRelation (MergedLinesHelper mergedLines ) throws GeometryException {
469+ private Point getFirstPointOfLineRelation (MergedLinesHelper mergedLines ) throws GeometryException {
467470 var firstMergedLineString = (LineString ) mergedLines .lineMerger .getMergedLineStrings ().iterator ().next ();
468471 var firstMergedLineCoordinate = firstMergedLineString .getCoordinate ();
469472 var lastMergedLineCoordinate = firstMergedLineString .getCoordinateN (firstMergedLineString .getNumPoints () - 1 );
@@ -486,7 +489,7 @@ private Point getFirstPointOfTrailRelation(MergedLinesHelper mergedLines) throws
486489 }
487490
488491 private boolean isInterestingPoint (PointDocument pointDocument ) {
489- return pointDocument .description .size () > 0 ||
492+ return ! pointDocument .description .isEmpty () ||
490493 pointDocument .wikidata != null ||
491494 pointDocument .image != null ;
492495 }
@@ -658,7 +661,7 @@ private void setIconColorCategory(PointDocument pointDocument, WithTags feature)
658661 }
659662 }
660663
661- if ("waterfall" .equals (feature .getString ("waterway" ))) {
664+ if ("waterfall" .equals (feature .getString ("waterway" )) || "waterway" . equals ( feature . getString ( "type" )) ) {
662665 pointDocument .poiIconColor = "blue" ;
663666 pointDocument .poiIcon = "icon-waterfall" ;
664667 pointDocument .poiCategory = "Water" ;
0 commit comments