@@ -109,6 +109,7 @@ public List<OsmRelationInfo> preprocessOsmRelation(OsmElement.Relation relation)
109109 pointDocument .name .put (language , Coalesce (relation .getString ("name:" + language ), relation .getString ("name" )));
110110 pointDocument .description .put (language , Coalesce (relation .getString ("description:" + language ), relation .getString ("description" )));
111111 }
112+ pointDocument .poiSource = "OSM" ;
112113 pointDocument .wikidata = relation .getString ("wikidata" );
113114 pointDocument .image = relation .getString ("image" );
114115 pointDocument .wikimedia_commons = relation .getString ("wikimedia_commons" );
@@ -147,6 +148,10 @@ public void preprocessOsmWay(OsmElement.Way way) {
147148
148149 @ Override
149150 public void processFeature (SourceFeature sourceFeature , FeatureCollector features ) {
151+ if (sourceFeature .getSource () == "external" ) {
152+ processExternalFeautre (sourceFeature , features );
153+ return ;
154+ }
150155 if (isBBoxFeature (sourceFeature , supportedLanguages )) {
151156 insertBboxToElasticsearch (sourceFeature , supportedLanguages );
152157 }
@@ -160,6 +165,43 @@ public void processFeature(SourceFeature sourceFeature, FeatureCollector feature
160165 }
161166 }
162167
168+ private void processExternalFeautre (SourceFeature sourceFeature , FeatureCollector features ) {
169+ var pointDocument = new PointDocument ();
170+ pointDocument .poiIcon = sourceFeature .getString ("poiIcon" );
171+ pointDocument .poiIconColor = sourceFeature .getString ("poiIconColor" );
172+ pointDocument .poiCategory = sourceFeature .getString ("poiCategory" );
173+ for (String language : supportedLanguages ) {
174+ pointDocument .name .put (language , Coalesce (sourceFeature .getString ("name:" + language ), sourceFeature .getString ("name" )));
175+ pointDocument .description .put (language , Coalesce (sourceFeature .getString ("description:" + language ), sourceFeature .getString ("description" )));
176+ }
177+ pointDocument .poiSource = sourceFeature .getString ("poiSource" );
178+ pointDocument .wikidata = sourceFeature .getString ("wikidata" );
179+ pointDocument .image = sourceFeature .getString ("image" );
180+ pointDocument .wikimedia_commons = sourceFeature .getString ("wikimedia_commons" );
181+ Point point ;
182+ var docId = pointDocument .poiSource + "_" + sourceFeature .getString ("identifier" );
183+ try {
184+ point = (Point )sourceFeature .centroidIfConvex ();
185+ } catch (GeometryException e ) {
186+ try {
187+ point = GeoUtils .point (sourceFeature .worldGeometry ().getCoordinate ());
188+ } catch (GeometryException e2 ) {
189+ LOGGER .warn ("Failed to process external feature: {}" , docId );
190+ return ;
191+ }
192+ }
193+ var lngLatPoint = GeoUtils .worldToLatLonCoords (point ).getCoordinate ();
194+ pointDocument .location = new double []{lngLatPoint .getX (), lngLatPoint .getY ()};
195+
196+ insertPointToElasticsearch (pointDocument , docId );
197+
198+ var tileFeature = features .geometry ("external" , point )
199+ .setAttr ("poiId" , docId )
200+ .setZoomRange (10 , 14 )
201+ .setId (sourceFeature .id ());
202+ setFeaturePropertiesFromPointDocument (tileFeature , pointDocument );
203+ }
204+
163205 private void processOsmRelationFeature (SourceFeature sourceFeature , FeatureCollector features ) {
164206 // get all the RouteRelationInfo instances we returned from preprocessOsmRelation that
165207 // this way belongs to
@@ -243,6 +285,7 @@ private void processMtbNameFeature(SourceFeature sourceFeature, FeatureCollector
243285 pointDocument .poiCategory = "Bicycle" ;
244286 pointDocument .poiIcon = "icon-bike" ;
245287 pointDocument .poiIconColor = "gray" ;
288+ pointDocument .poiSource = "OSM" ;
246289 var lngLatPoint = GeoUtils .worldToLatLonCoords (point ).getCoordinate ();
247290 pointDocument .location = new double []{lngLatPoint .getX (), lngLatPoint .getY ()};
248291
@@ -299,6 +342,7 @@ private void processWaterwayFeature(SourceFeature sourceFeature, FeatureCollecto
299342 pointDocument .poiCategory = "Water" ;
300343 pointDocument .poiIcon = "icon-waterfall" ;
301344 pointDocument .poiIconColor = "blue" ;
345+ pointDocument .poiSource = "OSM" ;
302346 var lngLatPoint = GeoUtils .worldToLatLonCoords (point ).getCoordinate ();
303347 pointDocument .location = new double []{lngLatPoint .getX (), lngLatPoint .getY ()};
304348
@@ -351,6 +395,7 @@ private void processOtherSourceFeature(SourceFeature feature, FeatureCollector f
351395 pointDocument .wikidata = feature .getString ("wikidata" );
352396 pointDocument .image = feature .getString ("image" );
353397 pointDocument .wikimedia_commons = feature .getString ("wikimedia_commons" );
398+ pointDocument .poiSource = "OSM" ;
354399 var lngLatPoint = GeoUtils .worldToLatLonCoords (point ).getCoordinate ();
355400 pointDocument .location = new double []{lngLatPoint .getX (), lngLatPoint .getY ()};
356401
@@ -444,7 +489,8 @@ private void setFeaturePropertiesFromPointDocument(Feature tileFeature, PointDoc
444489 .setAttr ("image" , pointDocument .image )
445490 .setAttr ("poiIcon" , pointDocument .poiIcon )
446491 .setAttr ("poiIconColor" , pointDocument .poiIconColor )
447- .setAttr ("poiCategory" , pointDocument .poiCategory );
492+ .setAttr ("poiCategory" , pointDocument .poiCategory )
493+ .setAttr ("poiSource" , pointDocument .poiSource );
448494 for (String lang : supportedLanguages ) {
449495 tileFeature .setAttr ("name:" + lang , pointDocument .name .get (lang ));
450496 tileFeature .setAttr ("description:" + lang , pointDocument .description .get (lang ));
0 commit comments