Coverage for gws-app/gws/plugin/nominatim/finder.py: 0%

24 statements  

« prev     ^ index     » next       coverage.py v7.8.0, created at 2025-04-17 01:37 +0200

1"""Nominatim finder. 

2 

3http://wiki.openstreetmap.org/wiki/Nominatim 

4https://nominatim.org/release-docs/develop/api/Search/ 

5 

6""" 

7 

8from typing import Optional 

9 

10import gws 

11import gws.base.search 

12import gws.base.template 

13import gws.config.util 

14import gws.lib.net 

15 

16 

17gws.ext.new.finder('nominatim') 

18 

19_DEFAULT_TEMPLATES = [ 

20 gws.Config( 

21 subject='feature.teaser', 

22 type='html', 

23 text=''' 

24 <p class="head">{name|html}</p> 

25 <p>{osm_class}: {osm_type}</p> 

26 ''' 

27 ), 

28 gws.Config( 

29 subject='feature.description', 

30 type='html', 

31 text=''' 

32 <p class="head">{name|html}</p> 

33 <p class="head2">{osm_class}: {osm_type}</p> 

34 <p class="text2">{address_road} {address_building} 

35 <br>{address_postcode} {address_city} 

36 <br>{address_country} 

37 </p> 

38 ''' 

39 ), 

40] 

41 

42 

43class Config(gws.base.search.finder.Config): 

44 """Nominatim search""" 

45 

46 country: Optional[str] 

47 """country to limit the search""" 

48 language: Optional[str] 

49 """language to return the results in""" 

50 

51 

52class Object(gws.base.search.finder.Object): 

53 supportsKeywordSearch = True 

54 

55 def configure(self): 

56 self.configure_models() 

57 self.configure_templates() 

58 

59 def configure_templates(self): 

60 return gws.config.util.configure_templates_for(self, extra=_DEFAULT_TEMPLATES) 

61 

62 def configure_models(self): 

63 return gws.config.util.configure_models_for(self, with_default=True) 

64 

65 def create_model(self, cfg): 

66 return self.create_child( 

67 gws.ext.object.model, 

68 cfg, 

69 type=self.extType, 

70 country=self.cfg('country'), 

71 language=self.cfg('language') 

72 )