Skip to content

Commit

Permalink
Improve plotmap
Browse files Browse the repository at this point in the history
- Change the way of creating file path in plotmap to solve the error not reading local base map in some system environment.
- Expose the `read_imgsavepath` and `read_mapboxtoken` function
  • Loading branch information
ni1o1 committed Sep 10, 2022
1 parent a281e03 commit 624a5d9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/transbigdata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@
plot_map,
plotscale,
set_mapboxtoken,
set_imgsavepath
set_imgsavepath,
read_imgsavepath,
read_mapboxtoken
)
from .coordinates import (
gcj02tobd09,
Expand Down
15 changes: 9 additions & 6 deletions src/transbigdata/plotmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,12 @@ def savefig(filename, tile):
if filename in os.listdir(imgsavepath+'tileimg'): # pragma: no cover
pass # pragma: no cover
else:
tile.save(imgsavepath+'tileimg/' +
filename) # pragma: no cover

tile.save(os.path.join(imgsavepath+'tileimg',
filename)) # pragma: no cover
if printlog: # pragma: no cover
print('figsaved:'+imgsavepath+'tileimg/' +
filename) # pragma: no cover
print('figsaved:'+os.path.join(imgsavepath+'tileimg',
filename)) # pragma: no cover
else:
os.mkdir(imgsavepath+'tileimg')
except Exception as e:
Expand All @@ -263,14 +264,16 @@ def loadfig(filename):
if 'tileimg' in os.listdir(imgsavepath):
if filename in os.listdir(imgsavepath+'tileimg'): # pragma: no cover
tile = Image.open(
imgsavepath+'tileimg\\'+filename) # pragma: no cover
os.path.join(os.path.join(imgsavepath, 'tileimg'), filename)) # pragma: no cover
return tile # pragma: no cover
else:
return None # pragma: no cover
else:
os.mkdir(imgsavepath+'tileimg')
return None # pragma: no cover
except Exception:
except Exception as e:
if printlog: # pragma: no cover
print(e)
return None

tile = loadfig(filename)
Expand Down

0 comments on commit 624a5d9

Please sign in to comment.