Skip to content

Commit

Permalink
reformat code.
Browse files Browse the repository at this point in the history
  • Loading branch information
achapkowski committed Aug 21, 2021
1 parent 7494416 commit 0d4b6b2
Show file tree
Hide file tree
Showing 9 changed files with 980 additions and 684 deletions.
3 changes: 2 additions & 1 deletion src/geopackage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
GeoPackage Initializer
"""
from ._geopackage import GeoPackage

__version__ = "1.0.0"
__all__ = ['GeoPackage']
__all__ = ["GeoPackage"]
24 changes: 14 additions & 10 deletions src/geopackage/_coord.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,24 @@
import json
import pandas as pd

__all__ = ['lookup_coordinate_system', 'info']
#----------------------------------------------------------------------
__all__ = ["lookup_coordinate_system", "info"]
# ----------------------------------------------------------------------
_lutbl = None
#----------------------------------------------------------------------
# ----------------------------------------------------------------------
def _load_data():
"""loads the coordinate information into memory"""

_fp = r"%s\prj.json" % os.path.dirname(__file__)
global _lutbl
if _lutbl is None:
with open(_fp, 'r') as reader:
with open(_fp, "r") as reader:
_lutbl = pd.DataFrame(json.loads(reader.read()))
_lutbl.columns = ['WKID', 'NAME', 'WKT']
_lutbl.columns = ["WKID", "NAME", "WKT"]
del reader
return _lutbl
#----------------------------------------------------------------------


# ----------------------------------------------------------------------
def lookup_coordinate_system(wkid):
"""
Looks up the wkt and name of the wkid coordinate system
Expand Down Expand Up @@ -51,15 +53,17 @@ def lookup_coordinate_system(wkid):
if _lutbl is None:
_load_data()
if isinstance(wkid, (int, float)):
q = _lutbl['WKID'] == int(wkid)
q = _lutbl["WKID"] == int(wkid)
elif isinstance(wkid, (list, tuple)):
q = _lutbl['WKID'].isin(wkid)
q = _lutbl["WKID"].isin(wkid)
else:
raise ValueError("Invalid wkid. Must be int or list.")
if len(_lutbl[q]) == 0:
raise ValueError("Invalid WKID")
return _lutbl[q].to_dict('records')
#----------------------------------------------------------------------
return _lutbl[q].to_dict("records")


# ----------------------------------------------------------------------
def info():
"""Returns all the support projections
Expand Down
Loading

0 comments on commit 0d4b6b2

Please sign in to comment.