forked from heldersepu/GMapCatcher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmapMark.py
55 lines (42 loc) · 1.53 KB
/
mapMark.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
## @package gmapcatcher.mapMark
# Read and Write the locations of the Markers
import os
import fileUtils
import widgets.mapPixbuf as mapPixbuf
from mapConst import *
class MyMarkers:
# coord = (lat, lng, zoom_level)
positions = {}
def refresh(self):
self.positions = {}
self.read_markers()
def read_markers(self):
self.positions = fileUtils.read_file('marker', self.markerPath)
def write_markers(self):
fileUtils.write_file('marker', self.markerPath, self.positions)
def append_marker(self, coord, strName=None, extraTag=False):
if strName is None:
strName = str(coord[0]) + '_' + str(coord[1])
fileUtils.append_file('marker', self.markerPath, coord, strName, extraTag)
def __init__(self, configpath=None):
localPath = os.path.expanduser(configpath or DEFAULT_PATH)
self.markerPath = os.path.join(localPath, 'markers')
if not os.path.isdir(localPath):
os.mkdir(localPath)
if (os.path.exists(self.markerPath)):
self.read_markers()
else:
self.write_markers()
def get_markers(self):
return self.positions
def get_pixDim(self, zl):
maxZoom = MAP_MAX_ZOOM_LEVEL - 2
if zl >= maxZoom:
return 56
elif zl <= 1:
return 256
else:
return 56 + int((maxZoom - zl) * 15)
def get_marker_pixbuf(self, zl, image='marker_s.png'):
pixDim = self.get_pixDim(zl)
return mapPixbuf.getImage(image, pixDim, pixDim)