1
|
|
|
# -*- coding: utf-8 -*- |
|
|
|
|
2
|
|
|
|
3
|
|
|
try: |
4
|
|
|
import logging |
5
|
|
|
import sys |
6
|
|
|
import os |
7
|
|
|
import json |
8
|
|
|
from osm_poi_matchmaker.libs.soup import save_downloaded_soup |
9
|
|
|
from osm_poi_matchmaker.libs.address import extract_street_housenumber_better_2, clean_city |
10
|
|
|
from osm_poi_matchmaker.libs.geo import check_hu_boundary |
11
|
|
|
from osm_poi_matchmaker.libs.osm_tag_sets import POS_HU_GEN, PAY_CASH |
12
|
|
|
from osm_poi_matchmaker.utils.data_provider import DataProvider |
13
|
|
|
from osm_poi_matchmaker.utils.enums import FileType |
14
|
|
|
except ImportError as err: |
15
|
|
|
logging.error('Error %s import module: %s', __name__, err) |
16
|
|
|
logging.exception('Exception occurred') |
17
|
|
|
|
18
|
|
|
sys.exit(128) |
19
|
|
|
|
20
|
|
|
POST_DATA = {'country': 'Magyarország', 'lat': '47.162494', |
21
|
|
|
'lng': '19.503304100000037', 'radius': 20} |
22
|
|
|
|
23
|
|
|
|
24
|
|
|
class hu_mol(DataProvider): |
|
|
|
|
25
|
|
|
|
26
|
|
View Code Duplication |
def constains(self): |
|
|
|
|
27
|
|
|
self.link = 'http://toltoallomaskereso.mol.hu/hu/portlet/routing/along_latlng.json' |
28
|
|
|
self.fuel = {'amenity': 'fuel', 'fuel:diesel': 'yes', 'fuel:octane_95': 'yes', 'air_conditioning': 'yes'} |
|
|
|
|
29
|
|
|
self.tags = {'brand': 'MOL', 'operator': 'MOL Nyrt.', |
30
|
|
|
'operator:addr': '1117 Budapest, Október huszonharmadika utca 18.', |
31
|
|
|
'ref:vatin:hu': '10625790-4-44', |
32
|
|
|
'contact:facebook': 'https://www.facebook.com/mol.magyarorszag/', |
33
|
|
|
'contact:youtube': 'https://www.youtube.com/user/molgrouptv', |
34
|
|
|
'contact:instagram': 'https://www.instagram.com/mol.magyarorszag/', |
35
|
|
|
'brand:wikipedia': 'hu:MOL Magyar Olaj- és Gázipari Nyrt.', 'brand:wikidata': 'Q549181', |
|
|
|
|
36
|
|
|
'ref:HU:company': '01-10-041683'} |
37
|
|
|
self.waterway_fuel = {'waterway': 'fuel'} |
38
|
|
|
self.filetype = FileType.json |
39
|
|
|
self.filename = '{}.{}'.format( |
40
|
|
|
self.__class__.__name__, self.filetype.name) |
41
|
|
|
|
42
|
|
|
def types(self): |
43
|
|
|
humolfu = self.tags.copy() |
44
|
|
|
humolfu.update(self.fuel) |
45
|
|
|
humolfu.update(POS_HU_GEN) |
46
|
|
|
humolfu.update(PAY_CASH) |
47
|
|
|
humolwfu = self.tags.copy() |
48
|
|
|
humolwfu.update(self.waterway_fuel) |
49
|
|
|
humolwfu.update(POS_HU_GEN) |
50
|
|
|
humolwfu.update(PAY_CASH) |
51
|
|
|
self.__types = [ |
52
|
|
|
{'poi_code': 'humolfu', 'poi_name': 'MOL', 'poi_type': 'fuel', |
53
|
|
|
'poi_tags': humolfu, 'poi_url_base': 'https://www.mol.hu', 'poi_search_name': 'mol', |
54
|
|
|
'osm_search_distance_perfect': 2000, |
55
|
|
|
'osm_search_distance_safe': 300, 'osm_search_distance_unsafe': 60}, |
56
|
|
|
{'poi_code': 'humolwfu', 'poi_name': 'MOL', 'poi_type': 'fuel', |
57
|
|
|
'poi_tags': humolwfu, 'poi_url_base': 'https://www.mol.hu', 'poi_search_name': 'mol', |
58
|
|
|
'osm_search_distance_perfect': 2000, |
59
|
|
|
'osm_search_distance_safe': 800, 'osm_search_distance_unsafe': 300}, ] |
60
|
|
|
return self.__types |
61
|
|
|
|
62
|
|
|
def process(self): |
63
|
|
|
try: |
64
|
|
|
soup = save_downloaded_soup('{}'.format(self.link), os.path.join(self.download_cache, self.filename), |
|
|
|
|
65
|
|
|
self.filetype, POST_DATA) |
66
|
|
|
if soup is not None: |
67
|
|
|
text = json.loads(soup) |
68
|
|
|
for poi_data in text: |
69
|
|
|
self.data.name = 'MOL' |
70
|
|
|
if " Sziget " in poi_data.get('name'): |
71
|
|
|
self.data.code = 'humolwfu' |
72
|
|
|
else: |
73
|
|
|
self.data.code = 'humolfu' |
74
|
|
|
self.data.postcode = poi_data.get('postcode').strip() |
75
|
|
|
self.data.city = clean_city(poi_data['city']) |
76
|
|
|
self.data.original = poi_data['address'] |
77
|
|
|
self.data.lat, self.data.lon = check_hu_boundary( |
78
|
|
|
poi_data['lat'], poi_data['lng']) |
79
|
|
|
self.data.street, self.data.housenumber, self.data.conscriptionnumber = extract_street_housenumber_better_2( |
|
|
|
|
80
|
|
|
poi_data['address']) |
81
|
|
|
self.data.public_holiday_open = True |
82
|
|
|
self.data.truck = True if 'kamion_parkolo' in poi_data.get( |
|
|
|
|
83
|
|
|
'servicesin') else False |
84
|
|
|
self.data.food = True if 'fresh_corner' in poi_data.get( |
|
|
|
|
85
|
|
|
'servicesin') else False |
86
|
|
|
self.data.rent_lpg_bottles = True if 'pb' in poi_data.get( |
|
|
|
|
87
|
|
|
'servicesin') else False |
88
|
|
|
self.data.fuel_adblue = True if 'adblue' in poi_data.get( |
|
|
|
|
89
|
|
|
'servicesin') else False |
90
|
|
|
self.data.fuel_lpg = True if 'lpg' in poi_data.get( |
|
|
|
|
91
|
|
|
'servicesin') else False |
92
|
|
|
self.data.fuel_octane_95 = True |
93
|
|
|
self.data.fuel_diesel = True |
94
|
|
|
self.data.fuel_octane_100 = True |
95
|
|
|
self.data.fuel_diesel_gtl = True |
96
|
|
|
self.data.compressed_air = True |
97
|
|
|
self.data.public_holiday_open = False |
98
|
|
|
self.data.add() |
99
|
|
|
except Exception as e: |
|
|
|
|
100
|
|
|
logging.exception('Exception occurred') |
101
|
|
|
|
102
|
|
|
logging.error(e) |
103
|
|
|
|