Skip to content

Commit

Permalink
Merge pull request #2 from iannesbitt/bugfix-1-model_search-int
Browse files Browse the repository at this point in the history
Adding EPSG integer handling to `model_search`
  • Loading branch information
iannesbitt committed Nov 2, 2023
2 parents 6a5e988 + 5ffa8a4 commit 10016da
Show file tree
Hide file tree
Showing 12 changed files with 182 additions and 165 deletions.
2 changes: 1 addition & 1 deletion docs/defs.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@

<dl class="py data">
<dt class="sig sig-object py" id="pyegt.defs.MODEL_LIST">
<span class="sig-prename descclassname"><span class="pre">pyegt.defs.</span></span><span class="sig-name descname"><span class="pre">MODEL_LIST</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.11)"><span class="pre">list</span></a></em><a class="headerlink" href="#pyegt.defs.MODEL_LIST" title="Permalink to this definition"></a></dt>
<span class="sig-prename descclassname"><span class="pre">pyegt.defs.</span></span><span class="sig-name descname"><span class="pre">MODEL_LIST</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.12)"><span class="pre">list</span></a></em><a class="headerlink" href="#pyegt.defs.MODEL_LIST" title="Permalink to this definition"></a></dt>
<dd><p>The full list of models from NGS and VDatum APIs described here,
concatenated from <a class="reference internal" href="#pyegt.defs.NGS_MODELS" title="pyegt.defs.NGS_MODELS"><code class="xref py py-data docutils literal notranslate"><span class="pre">pyegt.defs.NGS_MODELS</span></code></a> and
<a class="reference internal" href="#pyegt.defs.VDATUM_MODELS" title="pyegt.defs.VDATUM_MODELS"><code class="xref py py-data docutils literal notranslate"><span class="pre">pyegt.defs.VDATUM_MODELS</span></code></a>:</p>
Expand Down
110 changes: 55 additions & 55 deletions docs/height.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/searchindex.js

Large diffs are not rendered by default.

53 changes: 28 additions & 25 deletions docs/utils.html

Large diffs are not rendered by default.

Binary file modified docsrc/_build/doctrees/environment.pickle
Binary file not shown.
Binary file modified docsrc/_build/doctrees/utils.doctree
Binary file not shown.
2 changes: 1 addition & 1 deletion docsrc/_build/html/defs.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@

<dl class="py data">
<dt class="sig sig-object py" id="pyegt.defs.MODEL_LIST">
<span class="sig-prename descclassname"><span class="pre">pyegt.defs.</span></span><span class="sig-name descname"><span class="pre">MODEL_LIST</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.11)"><span class="pre">list</span></a></em><a class="headerlink" href="#pyegt.defs.MODEL_LIST" title="Permalink to this definition"></a></dt>
<span class="sig-prename descclassname"><span class="pre">pyegt.defs.</span></span><span class="sig-name descname"><span class="pre">MODEL_LIST</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.12)"><span class="pre">list</span></a></em><a class="headerlink" href="#pyegt.defs.MODEL_LIST" title="Permalink to this definition"></a></dt>
<dd><p>The full list of models from NGS and VDatum APIs described here,
concatenated from <a class="reference internal" href="#pyegt.defs.NGS_MODELS" title="pyegt.defs.NGS_MODELS"><code class="xref py py-data docutils literal notranslate"><span class="pre">pyegt.defs.NGS_MODELS</span></code></a> and
<a class="reference internal" href="#pyegt.defs.VDATUM_MODELS" title="pyegt.defs.VDATUM_MODELS"><code class="xref py py-data docutils literal notranslate"><span class="pre">pyegt.defs.VDATUM_MODELS</span></code></a>:</p>
Expand Down
110 changes: 55 additions & 55 deletions docsrc/_build/html/height.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docsrc/_build/html/searchindex.js

Large diffs are not rendered by default.

53 changes: 28 additions & 25 deletions docsrc/_build/html/utils.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyegt/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.1.2'
__version__ = '0.1.3'
11 changes: 11 additions & 0 deletions pyegt/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import time
import requests
from typing import Union, Literal
from pyproj import CRS
from logging import getLogger

from . import defs

Expand All @@ -13,6 +15,9 @@ def model_search(vrs: str=None) -> Union[str, Literal[None]]:
>>> egm = "EGM2008 height"
>>> model_search(vrs=egm)
"EGM2008"
>>> egmi = 3855
>>> model_search(vrs=egmi)
"EGM2008"
>>> navd88 = "NAVD88 (US Survey Feet)"
>>> model_search(vrs=navd88)
"NAVD88"
Expand All @@ -24,6 +29,12 @@ def model_search(vrs: str=None) -> Union[str, Literal[None]]:
:return: A verified model name or ``None`` if none is found
:rtype: str or None
"""
L = getLogger(__name__)
L.debug(f"Input vrs={vrs} (Type: {type(vrs)})")
if isinstance(vrs, int):
L.debug("Integer vrs found, converting to namestring if possible...")
vrs = CRS.from_epsg(vrs).name
L.debug(f"Named vrs={vrs} (Type: {type(vrs)})")
for m in defs.MODEL_LIST:
if m in vrs:
# sometimes vrs from WKT will be formatted like "EGM2008 height" and this should catch that
Expand Down

0 comments on commit 10016da

Please sign in to comment.