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, clean_opening_hours, \ |
|
|
|
|
10
|
|
|
clean_phone_to_str |
11
|
|
|
from osm_poi_matchmaker.libs.geo import check_hu_boundary |
12
|
|
|
from osm_poi_matchmaker.libs.osm_tag_sets import POS_HU_GEN, PAY_CASH |
13
|
|
|
from osm_poi_matchmaker.utils.data_provider import DataProvider |
14
|
|
|
from osm_poi_matchmaker.utils.enums import FileType |
15
|
|
|
except ImportError as err: |
16
|
|
|
logging.error('Error %s import module: %s', __name__, err) |
17
|
|
|
logging.exception('Exception occurred') |
18
|
|
|
|
19
|
|
|
sys.exit(128) |
20
|
|
|
|
21
|
|
|
|
22
|
|
|
class hu_omv(DataProvider): |
|
|
|
|
23
|
|
|
|
24
|
|
|
def constains(self): |
25
|
|
|
self.link = 'https://app.wigeogis.com/kunden/omvpetrom/data/getresults.php' |
26
|
|
|
self.tags = {'amenity': 'fuel', 'name': 'OMV', 'brand': 'OMV', 'fuel:diesel': 'yes', |
27
|
|
|
'fuel:octane_95': 'yes', 'air_conditioning': 'yes', 'brand:wikidata': 'Q168238', |
|
|
|
|
28
|
|
|
'brand:wikipedia': 'en:OMV', 'operator': 'OMV Hungária Kft.', |
29
|
|
|
'operator:addr': '1117 Budapest, Október huszonharmadika utca 6-10 5. emelet 5/A.', |
|
|
|
|
30
|
|
|
'ref:vatin:hu': '10542925-2-44', 'ref:vatin': 'HU10542925', |
31
|
|
|
'ref:HU:company': '01-09-071584', 'contact:email': '[email protected]', |
32
|
|
|
'contact:facebook': 'https://www.facebook.com/omvmagyarorszag', |
33
|
|
|
'contact:fax': '+36 1 381 9899', 'contact:twitter': 'omv', |
34
|
|
|
'contact:linkedin': 'https://www.linkedin.com/company/omv', |
35
|
|
|
'contact:instagram': 'https://www.instagram.com/omv/', |
36
|
|
|
'contact:youtube': 'https://www.youtube.com/user/omvofficial'} |
37
|
|
|
self.post = {'BRAND': 'OMV', 'CTRISO': 'HUN', 'MODE': 'NEXTDOOR', 'ANZ': '5', |
38
|
|
|
'HASH': '23126a64295e2cf2a5e41f33fd4b0c416e09b0b8', 'TS': '1583951283'} |
39
|
|
|
self.filetype = FileType.json |
40
|
|
|
self.filename = '{}.{}'.format( |
41
|
|
|
self.__class__.__name__, self.filetype.name) |
42
|
|
|
|
43
|
|
|
def types(self): |
44
|
|
|
huomvfu = self.tags.copy() |
45
|
|
|
huomvfu.update(POS_HU_GEN) |
46
|
|
|
huomvfu.update(PAY_CASH) |
47
|
|
|
self.__types = [ |
48
|
|
|
{'poi_code': 'huomvfu', 'poi_name': 'OMV', 'poi_type': 'fuel', |
49
|
|
|
'poi_tags': huomvfu, 'poi_url_base': 'https://www.omv.hu', 'poi_search_name': '(omv|omw|ömv|ömw|ovm|owm)', |
|
|
|
|
50
|
|
|
'osm_search_distance_perfect': 2000, 'osm_search_distance_safe': 450, |
51
|
|
|
'osm_search_distance_unsafe': 60}, |
52
|
|
|
] |
53
|
|
|
return self.__types |
54
|
|
|
|
55
|
|
|
def process(self): |
56
|
|
|
try: |
|
|
|
|
57
|
|
|
soup = save_downloaded_soup('{}'.format(self.link), os.path.join(self.download_cache, self.filename), |
|
|
|
|
58
|
|
|
self.filetype, self.post) |
59
|
|
|
if soup is not None: |
60
|
|
|
text = json.loads(soup) |
61
|
|
|
for poi_data in text: |
62
|
|
|
try: |
63
|
|
|
self.data.name = 'OMV' |
64
|
|
|
self.data.code = 'huomvfu' |
65
|
|
|
if poi_data.get('postcode') is not None and poi_data.get('postcode') != '': |
66
|
|
|
self.data.postcode = poi_data.get( |
67
|
|
|
'postcode').strip() |
68
|
|
|
if poi_data.get('town_l') is not None and poi_data.get('town_l') != '': |
69
|
|
|
self.data.city = clean_city(poi_data.get('town_l')) |
70
|
|
|
if poi_data.get('open_hours') is not None: |
71
|
|
|
oho, ohc = clean_opening_hours( |
72
|
|
|
poi_data.get('open_hours')) |
73
|
|
|
if oho == '00:00' and ohc == '24:00': |
74
|
|
|
self.data.nonstop = True |
75
|
|
|
self.data.public_holiday_open = True |
76
|
|
|
oho, ohc = None, None |
77
|
|
|
else: |
78
|
|
|
self.data.public_holiday_open = False |
79
|
|
|
else: |
80
|
|
|
oho, ohc = None, None |
81
|
|
|
self.data.public_holiday_open = False |
82
|
|
|
for i in range(0, 7): |
83
|
|
|
self.data.day_open(i, oho) |
84
|
|
|
self.data.day_close(i, ohc) |
85
|
|
|
self.data.lat, self.data.lon = check_hu_boundary( |
86
|
|
|
poi_data.get('y'), poi_data.get('x')) |
87
|
|
|
if poi_data.get('address_l') is not None and poi_data.get('address_l') != '': |
|
|
|
|
88
|
|
|
self.data.original = poi_data.get('address_l') |
89
|
|
|
self.data.street, self.data.housenumber, self.data.conscriptionnumber = \ |
|
|
|
|
90
|
|
|
extract_street_housenumber_better_2( |
91
|
|
|
poi_data.get('address_l')) |
92
|
|
|
if poi_data.get('telnr') is not None and poi_data.get('telnr') != '': |
93
|
|
|
self.data.phone = clean_phone_to_str( |
94
|
|
|
poi_data.get('telnr')) |
95
|
|
|
self.data.fuel_octane_95 = True |
96
|
|
|
self.data.fuel_diesel = True |
97
|
|
|
self.data.fuel_octane_100 = True |
98
|
|
|
self.data.fuel_diesel_gtl = True |
99
|
|
|
self.data.compressed_air = True |
100
|
|
|
self.data.add() |
101
|
|
|
except Exception as e: |
|
|
|
|
102
|
|
|
logging.error(e) |
103
|
|
|
logging.error(poi_data) |
104
|
|
|
logging.exception('Exception occurred') |
105
|
|
|
|
106
|
|
|
except Exception as e: |
|
|
|
|
107
|
|
|
logging.error(e) |
108
|
|
|
logging.exception('Exception occurred') |
109
|
|
|
|