pyvalhalla-git 3.5.1.post185__cp39-cp39-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. _valhalla.cp39-win_amd64.pyd +0 -0
  2. pyvalhalla_git-3.5.1.post185.data/platlib/.load-order-pyvalhalla_git-3.5.1.post185 +20 -0
  3. pyvalhalla_git-3.5.1.post185.data/platlib/Lerc-5492e53a634552d158814335bfd5508b.dll +0 -0
  4. pyvalhalla_git-3.5.1.post185.data/platlib/abseil_dll-1fc67c8668f83d1a5bea7b37c99ca6c3.dll +0 -0
  5. pyvalhalla_git-3.5.1.post185.data/platlib/gdal-ef87f613f24439573ac93245419c57fb.dll +0 -0
  6. pyvalhalla_git-3.5.1.post185.data/platlib/geos-6c521f6a54fa614211eebaea0a890f5e.dll +0 -0
  7. pyvalhalla_git-3.5.1.post185.data/platlib/geos_c-98a48e4eb33f944d74a394141acb7eaf.dll +0 -0
  8. pyvalhalla_git-3.5.1.post185.data/platlib/geotiff-e36440f3fa837002abf4656c8a82bee1.dll +0 -0
  9. pyvalhalla_git-3.5.1.post185.data/platlib/jpeg62-cdecd204dfd888a80dba8d7e15cb5b60.dll +0 -0
  10. pyvalhalla_git-3.5.1.post185.data/platlib/json-c-520fb69b2bfce9e17f4c6595040d996f.dll +0 -0
  11. pyvalhalla_git-3.5.1.post185.data/platlib/libcurl-39889826283c088f2b3897191ab7d21d.dll +0 -0
  12. pyvalhalla_git-3.5.1.post185.data/platlib/libexpat-0a3bbd6de9307d0020c69673bdb3d5f1.dll +0 -0
  13. pyvalhalla_git-3.5.1.post185.data/platlib/liblzma-953b7b97af894314faccc0606d85cede.dll +0 -0
  14. pyvalhalla_git-3.5.1.post185.data/platlib/libpng16-4a1fbc9b57e99b9c7881563565bfd72a.dll +0 -0
  15. pyvalhalla_git-3.5.1.post185.data/platlib/libprotobuf-lite-ad9267b70ceeab0c301d0a1ec48f2c07.dll +0 -0
  16. pyvalhalla_git-3.5.1.post185.data/platlib/lz4-77ac014ecbb0e1818a064a0c084142a3.dll +0 -0
  17. pyvalhalla_git-3.5.1.post185.data/platlib/msvcp140-73e7ea186a7d9ab676a764ffa64cf7e6.dll +0 -0
  18. pyvalhalla_git-3.5.1.post185.data/platlib/proj_9-0314b900bb5b081106b18666f0921a32.dll +0 -0
  19. pyvalhalla_git-3.5.1.post185.data/platlib/qhull_r-4c36dd0bc4600521ef29dec0973a8da6.dll +0 -0
  20. pyvalhalla_git-3.5.1.post185.data/platlib/sqlite3-9f887a0723821b9a01c3c1430763cead.dll +0 -0
  21. pyvalhalla_git-3.5.1.post185.data/platlib/tiff-2d8ce2b51dc79974e521d680e28b5a30.dll +0 -0
  22. pyvalhalla_git-3.5.1.post185.data/platlib/zlib1-882c7ca16198f8e2a6182b8f5d658a18.dll +0 -0
  23. pyvalhalla_git-3.5.1.post185.dist-info/DELVEWHEEL +2 -0
  24. pyvalhalla_git-3.5.1.post185.dist-info/METADATA +110 -0
  25. pyvalhalla_git-3.5.1.post185.dist-info/RECORD +36 -0
  26. pyvalhalla_git-3.5.1.post185.dist-info/WHEEL +5 -0
  27. pyvalhalla_git-3.5.1.post185.dist-info/licenses/AUTHORS +5 -0
  28. pyvalhalla_git-3.5.1.post185.dist-info/licenses/COPYING +22 -0
  29. pyvalhalla_git-3.5.1.post185.dist-info/licenses/LICENSE.md +1 -0
  30. pyvalhalla_git-3.5.1.post185.dist-info/top_level.txt +2 -0
  31. valhalla/__init__.py +38 -0
  32. valhalla/__version__.py +21 -0
  33. valhalla/actor.py +118 -0
  34. valhalla/config.py +45 -0
  35. valhalla/utils.py +62 -0
  36. valhalla/valhalla_build_config.py +760 -0
Binary file
@@ -0,0 +1,20 @@
1
+ geotiff-e36440f3fa837002abf4656c8a82bee1.dll
2
+ gdal-ef87f613f24439573ac93245419c57fb.dll
3
+ lz4-77ac014ecbb0e1818a064a0c084142a3.dll
4
+ proj_9-0314b900bb5b081106b18666f0921a32.dll
5
+ tiff-2d8ce2b51dc79974e521d680e28b5a30.dll
6
+ geos_c-98a48e4eb33f944d74a394141acb7eaf.dll
7
+ msvcp140-73e7ea186a7d9ab676a764ffa64cf7e6.dll
8
+ liblzma-953b7b97af894314faccc0606d85cede.dll
9
+ libcurl-39889826283c088f2b3897191ab7d21d.dll
10
+ jpeg62-cdecd204dfd888a80dba8d7e15cb5b60.dll
11
+ sqlite3-9f887a0723821b9a01c3c1430763cead.dll
12
+ zlib1-882c7ca16198f8e2a6182b8f5d658a18.dll
13
+ libexpat-0a3bbd6de9307d0020c69673bdb3d5f1.dll
14
+ libpng16-4a1fbc9b57e99b9c7881563565bfd72a.dll
15
+ libprotobuf-lite-ad9267b70ceeab0c301d0a1ec48f2c07.dll
16
+ abseil_dll-1fc67c8668f83d1a5bea7b37c99ca6c3.dll
17
+ geos-6c521f6a54fa614211eebaea0a890f5e.dll
18
+ Lerc-5492e53a634552d158814335bfd5508b.dll
19
+ json-c-520fb69b2bfce9e17f4c6595040d996f.dll
20
+ qhull_r-4c36dd0bc4600521ef29dec0973a8da6.dll
@@ -0,0 +1,2 @@
1
+ Version: 1.10.1
2
+ Arguments: ['C:\\hostedtoolcache\\windows\\Python\\3.9.13\\x64\\Scripts\\delvewheel', 'repair', '--add-path', 'build/vcpkg_installed/custom-x64-windows/bin', 'C:\\Users\\runneradmin\\AppData\\Local\\Temp\\cibw-run-0msw3pke\\cp39-win_amd64\\built_wheel\\pyvalhalla_git-3.5.1.post185-cp39-cp39-win_amd64.whl', '-w', 'C:\\Users\\runneradmin\\AppData\\Local\\Temp\\cibw-run-0msw3pke\\cp39-win_amd64\\repaired_wheel']
@@ -0,0 +1,110 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyvalhalla-git
3
+ Version: 3.5.1.post185
4
+ Summary: High-level bindings to the Valhalla C++ library
5
+ Home-page: https://github.com/valhalla/valhalla
6
+ Author: Nils Nolde
7
+ Author-email: nilsnolde+pyvalhalla@proton.me
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: Implementation :: CPython
11
+ Requires-Python: >=3.9.0
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE.md
14
+ License-File: COPYING
15
+ License-File: AUTHORS
16
+ Dynamic: author
17
+ Dynamic: author-email
18
+ Dynamic: classifier
19
+ Dynamic: description
20
+ Dynamic: description-content-type
21
+ Dynamic: home-page
22
+ Dynamic: license-file
23
+ Dynamic: requires-python
24
+ Dynamic: summary
25
+
26
+
27
+ ## Valhalla Python bindings
28
+
29
+ This package contains the Python bindings to [Valhalla routing engine](https://github.com/valhalla/valhalla).
30
+
31
+ > [!NOTE]
32
+ > `pyvalhalla(-git)` packages are currently only published for:
33
+ > - `linux-x86_x64`
34
+ > - `win-amd64`
35
+ > - `macos-arm64`
36
+
37
+ ### Installation
38
+
39
+ We distribute all currently maintained CPython versions as **binary wheels** for Win64, MacOS (`arm64`) and Linux (`x86_64`) distributions with `glibc>=2.28`. We **do not** offer a source distribution on PyPI.
40
+
41
+ `pip install pyvalhalla` to install the most recent Valhalla **release**.
42
+ `pip install pyvalhalla-git` to install the most recent Valhalla **master commit**.
43
+
44
+ ### Usage
45
+
46
+ Find a more extended notebook in `./examples`, e.g. how to [use the actor](./examples/actor_examples.ipynb).
47
+
48
+ Before using the Python bindings you need to have access to a routable Valhalla graph. Either install Valhalla from source and built the graph from OSM compatible data or use our [Valhalla docker image](https://github.com/gis-ops/docker-valhalla) for a painless experience, e.g. this will build the routing graph for Andorra in `./custom_files`:
49
+
50
+ ```shell
51
+ docker run --rm --name valhalla_gis-ops -p 8002:8002 -v $PWD/custom_files:/custom_files -e tile_urls=https://download.geofabrik.de/europe/andorra-latest.osm.pbf gisops/valhalla:latest
52
+ ```
53
+
54
+ Once you have created a graph locally, you can use it like this:
55
+
56
+ ```python
57
+ from valhalla import Actor, get_config, get_help
58
+
59
+ # generate configuration
60
+ config = get_config(tile_extract='./custom_files/valhalla_tiles.tar', verbose=True)
61
+
62
+ # print the help for specific config items (has the same structure as the output of get_config()
63
+ print(get_help()["service_limits"]["auto"]["max_distance"])
64
+
65
+ # instantiate Actor to load graph and call actions
66
+ actor = Actor(config)
67
+ route = actor.route({"locations": [...]})
68
+ ```
69
+
70
+ ### Building from source
71
+
72
+ #### Linux
73
+
74
+ To package arch-dependent Linux bindings we use a `manylinux` fork, where we install all dependencies into the `manylinux_2_28` image, based on AlmaLinux 8. This is necessary to have a broad `glibc` compatibility with many semi-recent Linux distros.
75
+
76
+ Either pull the `manylinux` image, or build it locally for testing:
77
+
78
+ ```shell
79
+ docker pull ghcr.io/valhalla/manylinux:2_28_valhalla_python
80
+
81
+ # or pull the image from ghcr.io
82
+ git clone https://github.com/valhalla/manylinux
83
+ cd manylinux
84
+ POLICY=manylinux_2_28 PLATFORM=x86_64 COMMIT_SHA=$(git rev-parse --verify HEAD) BUILDX_BUILDER=builder-docker-container ./build.sh
85
+ docker tag quay.io/pypa/manylinux_2_28_x86_64:$(git rev-parse --verify HEAD) ghcr.io/valhalla/manylinux:2_28_valhalla_python
86
+ ```
87
+
88
+ Once built, start a container to actually build Valhalla using AlmaLinux 8:
89
+
90
+ ```shell
91
+ cd valhalla
92
+ docker run -dt -v $PWD:/valhalla-py --name valhalla-py --workdir /valhalla-py ghcr.io/valhalla/manylinux:2_28_valhalla_python
93
+ docker exec -t valhalla-py /valhalla-py/src/bindings/python/build_linux.sh build_manylinux 3.12
94
+ ```
95
+
96
+ This will also build & install `libvalhalla` before building the bindings. At this point there should be a `wheelhouse` folder with the fixed python wheel, ready to be installed or distributed to arbitrary python 3.12 installations.
97
+
98
+ ### `cibuildwheel`
99
+
100
+ On our CI, this orchestrates the packaging of all `pyvalhalla` wheels for every supported, minor Python version and every platform. It can also be run locally (obviously only being able to build wheels for _your_ platform), e.g.
101
+
102
+ ```shell
103
+ # specifiers from https://cibuildwheel.pypa.io/en/stable/options/#build-skip
104
+ cibuildwheel --only cp313-manylinux_x86_64
105
+
106
+ # for windows you'll have to set an env var to the vcpkg win root
107
+ VCPKG_ARCH_ROOT="build/vcpkg_installed/custom-x64-windows" cibuildwheel --only cp313-manylinux_x86_64
108
+ ```
109
+
110
+ On Linux, this might download the `manylinux` docker image. In the end, you'll find the wheel in `./wheelhouse`.
@@ -0,0 +1,36 @@
1
+ _valhalla.cp39-win_amd64.pyd,sha256=R_giYOmQdETJ9CZr8aoN4Km08wvMsAO6YrFo_1huz8U,8123392
2
+ pyvalhalla_git-3.5.1.post185.data/platlib/.load-order-pyvalhalla_git-3.5.1.post185,sha256=jvUwJnatZM67VpJwtCTbaZE4lKRN8buoHOp_ocCoyyw,893
3
+ pyvalhalla_git-3.5.1.post185.data/platlib/abseil_dll-1fc67c8668f83d1a5bea7b37c99ca6c3.dll,sha256=JxC8gzXY3ULA4kzXVPmiGAH8pYggofnRKpuKI8RWs5Q,1887744
4
+ pyvalhalla_git-3.5.1.post185.data/platlib/gdal-ef87f613f24439573ac93245419c57fb.dll,sha256=1ShlE9E_IYmbSDJaq7KruNMv0w_hbJ7q-2X93ePtcas,18052096
5
+ pyvalhalla_git-3.5.1.post185.data/platlib/geos-6c521f6a54fa614211eebaea0a890f5e.dll,sha256=MRf-bLrP82WB92IKnuwkM6YMvd8gnIE9gp6S_B9kL-Y,2582016
6
+ pyvalhalla_git-3.5.1.post185.data/platlib/geos_c-98a48e4eb33f944d74a394141acb7eaf.dll,sha256=M4Tea5iyOgcuTHtAb6UxjC8TDYETx6EWrNCFcxjhq90,457728
7
+ pyvalhalla_git-3.5.1.post185.data/platlib/geotiff-e36440f3fa837002abf4656c8a82bee1.dll,sha256=OtzL5DG5Yi0MlvFQB-mgDiCkHtR98V8EGY9kAzWDEOc,161792
8
+ pyvalhalla_git-3.5.1.post185.data/platlib/jpeg62-cdecd204dfd888a80dba8d7e15cb5b60.dll,sha256=3Njm9u2ynTA5_AON3ui6APK5bExn3Nxci_IYMuE4XUE,683520
9
+ pyvalhalla_git-3.5.1.post185.data/platlib/json-c-520fb69b2bfce9e17f4c6595040d996f.dll,sha256=eSo-EsI3ISu3UGQcLEdRA4a84mOs_6PsWuNo7aW2Qfg,58880
10
+ pyvalhalla_git-3.5.1.post185.data/platlib/Lerc-5492e53a634552d158814335bfd5508b.dll,sha256=hi5fqms3kpEnvFhz1eJdYYq4omMI_1Ve7iAUU-2iUv4,526848
11
+ pyvalhalla_git-3.5.1.post185.data/platlib/libcurl-39889826283c088f2b3897191ab7d21d.dll,sha256=tf01uKIBv0LrQFBKzzhTuhnCANJLcKFMREepfIjbpDI,595456
12
+ pyvalhalla_git-3.5.1.post185.data/platlib/libexpat-0a3bbd6de9307d0020c69673bdb3d5f1.dll,sha256=YNDK4-_p_xUPZU_U9i2iUKSxzk5w6sT9_RUtbFnggYQ,159232
13
+ pyvalhalla_git-3.5.1.post185.data/platlib/liblzma-953b7b97af894314faccc0606d85cede.dll,sha256=v3x9ERcMQ_qQiLQoPeDBqEMIM4sdL14w9jjL7_WmqOc,185856
14
+ pyvalhalla_git-3.5.1.post185.data/platlib/libpng16-4a1fbc9b57e99b9c7881563565bfd72a.dll,sha256=jCssnGKi0ui84VBxahsYSZZxNocwdJcUyncZehtkcoU,201216
15
+ pyvalhalla_git-3.5.1.post185.data/platlib/libprotobuf-lite-ad9267b70ceeab0c301d0a1ec48f2c07.dll,sha256=3RbsupqD_7SrGoF7_zBSFthIDVFl7wRhoSuEhLi3Q2A,1502208
16
+ pyvalhalla_git-3.5.1.post185.data/platlib/lz4-77ac014ecbb0e1818a064a0c084142a3.dll,sha256=2tUogjKUHWJga91pezGBczrFXVBsCa63N86rAuLdapA,127488
17
+ pyvalhalla_git-3.5.1.post185.data/platlib/msvcp140-73e7ea186a7d9ab676a764ffa64cf7e6.dll,sha256=cDrXxV8uCWYH7Gp3qLX1LVNdvnH93wIel8vLvCP3SSo,576128
18
+ pyvalhalla_git-3.5.1.post185.data/platlib/proj_9-0314b900bb5b081106b18666f0921a32.dll,sha256=L01PdfyGtx3E3xgrYj8cph5zdVgUgukGX47WK7KJZkw,3414528
19
+ pyvalhalla_git-3.5.1.post185.data/platlib/qhull_r-4c36dd0bc4600521ef29dec0973a8da6.dll,sha256=2yVG47tZEHYsgZfdIUDfTrElFKNn94cQgx9iONqk34o,451072
20
+ pyvalhalla_git-3.5.1.post185.data/platlib/sqlite3-9f887a0723821b9a01c3c1430763cead.dll,sha256=gtLH4aBFxIb9cG1YzUfDpKOkE6B3rxcWKIA16kdhNBY,1118208
21
+ pyvalhalla_git-3.5.1.post185.data/platlib/tiff-2d8ce2b51dc79974e521d680e28b5a30.dll,sha256=0JvOzW9tXCUaTcNxVwbALYxb2ddgj-dFLUEFJ7AUXpc,468480
22
+ pyvalhalla_git-3.5.1.post185.data/platlib/zlib1-882c7ca16198f8e2a6182b8f5d658a18.dll,sha256=u74_0pDv2tbGlcORzlK00nsSnRUSKelODkN9ZgZ_CjM,90624
23
+ pyvalhalla_git-3.5.1.post185.dist-info/DELVEWHEEL,sha256=adas86Zdyo6kAydYUP7oiF6f-Lvcl4lEfC3EaeDxmrk,429
24
+ pyvalhalla_git-3.5.1.post185.dist-info/METADATA,sha256=ynQpTzm9qzUBSalHcSXqLLv0gOOG0p_Yo5Xljm1KKKY,4693
25
+ pyvalhalla_git-3.5.1.post185.dist-info/RECORD,,
26
+ pyvalhalla_git-3.5.1.post185.dist-info/top_level.txt,sha256=mU472JpF5fOfpVQ8UxZ_dwLmecLogajAMO5RmYsU1gw,19
27
+ pyvalhalla_git-3.5.1.post185.dist-info/WHEEL,sha256=XkFE14KmFh7mutkkb-qn_ueuH2lwfT8rLdfc5xpQ7wE,99
28
+ pyvalhalla_git-3.5.1.post185.dist-info/licenses/AUTHORS,sha256=zfqnWlS9zAHTcyIVTaquUA0hwOLARt8RbHyxV8ksIdo,176
29
+ pyvalhalla_git-3.5.1.post185.dist-info/licenses/COPYING,sha256=0-hXmYGEWqvizZa7uHZz_AefTiGcyE6O9mZH1e9Pf10,1157
30
+ pyvalhalla_git-3.5.1.post185.dist-info/licenses/LICENSE.md,sha256=TTSAvGrQ2khsitpI11WKnicjvEODZlalhi8PAzaRrV4,45
31
+ valhalla/actor.py,sha256=_A8eZpk7xk-7C6Xzz5nFE5Qp5GNInFjXurzjlh_ZmFA,4195
32
+ valhalla/config.py,sha256=LnxZ7uA42QOIB68ld_8VhRdTdsfs-sXQlu_AylLLFi4,1533
33
+ valhalla/utils.py,sha256=-hHjEDCftpOlRBib4CSZVDCLAZMqgtOtkX2V3-5bsJg,1985
34
+ valhalla/valhalla_build_config.py,sha256=xx8HY5RnP492PMP_DgJSgrum7OjkGWeUQAkZgag6LQM,43267
35
+ valhalla/__init__.py,sha256=etDcceS9RncpgO4bwZN2mvEaYu5n0n63-TgvDAnxE5k,1790
36
+ valhalla/__version__.py,sha256=NEZ8_VH-6rB5Hq0XCK288QS_i6stUqATL1XXhhGTsps,551
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: false
4
+ Tag: cp39-cp39-win_amd64
5
+
@@ -0,0 +1,5 @@
1
+ Duane Gearhart <duane@mapzen.com>
2
+ Greg Knisely <greg@mapzen.com>
3
+ Kevin Kreiser <kevinkreiser@gmail.com>
4
+ Kristen DiLuca <kristen@mapzen.com>
5
+ Dave Nesbitt <dave@mapzen.com>
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Valhalla contributors
4
+ Copyright (c) 2015-2017 Mapillary AB, Mapzen
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in
14
+ all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ THE SOFTWARE.
@@ -0,0 +1 @@
1
+ For license information see [here](COPYING)
@@ -0,0 +1,2 @@
1
+ _valhalla
2
+ valhalla
valhalla/__init__.py ADDED
@@ -0,0 +1,38 @@
1
+ """""" # start delvewheel patch
2
+ def _delvewheel_patch_1_10_1():
3
+ import ctypes
4
+ import os
5
+ import platform
6
+ import sys
7
+ libs_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, '.'))
8
+ is_conda_cpython = platform.python_implementation() == 'CPython' and (hasattr(ctypes.pythonapi, 'Anaconda_GetVersion') or 'packaged by conda-forge' in sys.version)
9
+ if sys.version_info[:2] >= (3, 8) and not is_conda_cpython or sys.version_info[:2] >= (3, 10):
10
+ if os.path.isdir(libs_dir):
11
+ os.add_dll_directory(libs_dir)
12
+ else:
13
+ load_order_filepath = os.path.join(libs_dir, '.load-order-pyvalhalla_git-3.5.1.post185')
14
+ if os.path.isfile(load_order_filepath):
15
+ import ctypes.wintypes
16
+ with open(os.path.join(libs_dir, '.load-order-pyvalhalla_git-3.5.1.post185')) as file:
17
+ load_order = file.read().split()
18
+ kernel32 = ctypes.WinDLL('kernel32', use_last_error=True)
19
+ kernel32.LoadLibraryExW.restype = ctypes.wintypes.HMODULE
20
+ kernel32.LoadLibraryExW.argtypes = ctypes.wintypes.LPCWSTR, ctypes.wintypes.HANDLE, ctypes.wintypes.DWORD
21
+ for lib in load_order:
22
+ lib_path = os.path.join(os.path.join(libs_dir, lib))
23
+ if os.path.isfile(lib_path) and not kernel32.LoadLibraryExW(lib_path, None, 8):
24
+ raise OSError('Error loading {}; {}'.format(lib, ctypes.FormatError(ctypes.get_last_error())))
25
+
26
+
27
+ _delvewheel_patch_1_10_1()
28
+ del _delvewheel_patch_1_10_1
29
+ # end delvewheel patch
30
+
31
+ try:
32
+ from ._valhalla import *
33
+ except ModuleNotFoundError:
34
+ from _valhalla import *
35
+
36
+ from .actor import Actor
37
+ from .config import get_config, get_help
38
+ from .__version__ import __version__
@@ -0,0 +1,21 @@
1
+ # file generated by setuptools-scm
2
+ # don't change, don't track in version control
3
+
4
+ __all__ = ["__version__", "__version_tuple__", "version", "version_tuple"]
5
+
6
+ TYPE_CHECKING = False
7
+ if TYPE_CHECKING:
8
+ from typing import Tuple
9
+ from typing import Union
10
+
11
+ VERSION_TUPLE = Tuple[Union[int, str], ...]
12
+ else:
13
+ VERSION_TUPLE = object
14
+
15
+ version: str
16
+ __version__: str
17
+ __version_tuple__: VERSION_TUPLE
18
+ version_tuple: VERSION_TUPLE
19
+
20
+ __version__ = version = '3.5.1.post185'
21
+ __version_tuple__ = version_tuple = (3, 5, 1, 'post185')
valhalla/actor.py ADDED
@@ -0,0 +1,118 @@
1
+ import json
2
+ import tempfile
3
+ from pathlib import Path
4
+ from typing import Union
5
+
6
+ try:
7
+ from ._valhalla import _Actor
8
+ except ModuleNotFoundError:
9
+ from _valhalla import _Actor
10
+
11
+
12
+ # TODO: wasteful for dict input/output; more reasonable would be to extend
13
+ # the Actor's action C++ interfaces with a JSON arg
14
+ def dict_or_str(func):
15
+ def wrapped(*args):
16
+ # /status doesn't take any parameters
17
+ if not len(args) > 1:
18
+ return func(*args)
19
+
20
+ if isinstance(args[1], dict):
21
+ return json.loads(func(args[0], json.dumps(args[1])))
22
+ elif not isinstance(args[1], str):
23
+ raise ValueError("Request must be either of type str or dict")
24
+ return func(*args)
25
+
26
+ return wrapped
27
+
28
+
29
+ class Actor(_Actor):
30
+ def __init__(self, config: Union[Path, str, dict]):
31
+ """
32
+ Valhalla's Actor class is used to call its actions, like route, isochrone, matrix etc.
33
+
34
+ Configuration passed in either by an existing configuration JSON file path or in `dict` form,
35
+ e.g. by calling valhalla.config.get_config(). In the latter case a temp file will be
36
+ created.
37
+
38
+ For details on parameters for each function consult Valhalla's documentation:
39
+ https://github.com/valhalla/valhalla/blob/master/docs/api
40
+ """
41
+ # make sure there's a valhalla.json file
42
+ if isinstance(config, dict):
43
+ with tempfile.NamedTemporaryFile(
44
+ "w", suffix=".json", prefix="valhalla_config_", delete=False
45
+ ) as f:
46
+ json.dump(config, f)
47
+ self._config_path = f.name
48
+ elif isinstance(config, str):
49
+ if not Path(config).is_file():
50
+ raise FileNotFoundError(f"Valhalla JSON config file doesn't exist: {config}")
51
+ self._config_path = config
52
+ elif isinstance(config, Path):
53
+ self._config_path = str(config.resolve())
54
+ else:
55
+ raise AttributeError(f"Valhalla JSON config can't be of type {type(config)}")
56
+
57
+ # test if there's an extract or tile_dir
58
+ with open(self._config_path) as f:
59
+ config = json.load(f)
60
+ tile_extract_fp = config.get("mjolnir", {}).get("tile_extract")
61
+ tile_dir = config.get("mjolnir", {}).get("tile_dir")
62
+
63
+ # raise if neither exists
64
+ if not tile_extract_fp and not tile_dir:
65
+ raise AttributeError(
66
+ "Valhalla config JSON is not valid: mjolnir.tile_extract and mjolnir.tile_dir are missing."
67
+ )
68
+ if not Path(config["mjolnir"]["tile_extract"]).is_file():
69
+ if not Path(config["mjolnir"]["tile_dir"]).is_dir():
70
+ raise FileNotFoundError(
71
+ f"Neither mjolnir.tile_extract ({Path(tile_extract_fp).resolve()}) nor mjolnir.tile_dir ({Path(tile_dir).resolve()}) exists. Can't load graph."
72
+ )
73
+
74
+ super(Actor, self).__init__(self._config_path)
75
+
76
+ @dict_or_str
77
+ def route(self, req: Union[str, dict]):
78
+ return super().route(req)
79
+
80
+ @dict_or_str
81
+ def locate(self, req: Union[str, dict]):
82
+ return super().locate(req)
83
+
84
+ @dict_or_str
85
+ def isochrone(self, req: Union[str, dict]):
86
+ return super().isochrone(req)
87
+
88
+ @dict_or_str
89
+ def matrix(self, req: Union[str, dict]):
90
+ return super().matrix(req)
91
+
92
+ @dict_or_str
93
+ def trace_route(self, req: Union[str, dict]):
94
+ return super().trace_route(req)
95
+
96
+ @dict_or_str
97
+ def trace_attributes(self, req: Union[str, dict]):
98
+ return super().trace_attributes(req)
99
+
100
+ @dict_or_str
101
+ def height(self, req: Union[str, dict]):
102
+ return super().height(req)
103
+
104
+ @dict_or_str
105
+ def transit_available(self, req: Union[str, dict]):
106
+ return super().transit_available(req)
107
+
108
+ @dict_or_str
109
+ def expansion(self, req: Union[str, dict]):
110
+ return super().expansion(req)
111
+
112
+ @dict_or_str
113
+ def centroid(self, req: Union[str, dict]):
114
+ return super().centroid(req)
115
+
116
+ @dict_or_str
117
+ def status(self, req: Union[str, dict] = ""):
118
+ return super().status(req)
valhalla/config.py ADDED
@@ -0,0 +1,45 @@
1
+ from pathlib import Path
2
+ from typing import Union, Dict
3
+
4
+ from .valhalla_build_config import config as default_config, Optional, help_text
5
+
6
+
7
+ def _sanitize_config(dict_: dict = None) -> dict:
8
+ """remove the "Optional" values from the config."""
9
+ int_dict_ = dict_.copy()
10
+ for k, v in int_dict_.items():
11
+ if isinstance(v, Optional):
12
+ del dict_[k]
13
+ elif isinstance(v, dict):
14
+ _sanitize_config(v)
15
+
16
+ return dict_
17
+
18
+
19
+ def get_help() -> Dict[str, Union[Dict[str, str], str]]:
20
+ """
21
+ Returns the help dictionary with the same keys as the config JSON.
22
+ """
23
+ return help_text
24
+
25
+
26
+ def get_config(
27
+ tile_extract: Union[str, Path] = "valhalla_tiles.tar",
28
+ tile_dir: Union[str, Path] = "valhalla_tiles",
29
+ verbose: bool = False,
30
+ ) -> dict:
31
+ """
32
+ Returns a default Valhalla configuration.
33
+
34
+ :param tile_extract: The file path (with .tar extension) of the tile extract (mjolnir.tile_extract), if present. Preferred over tile_dir.
35
+ :param tile_dir: The directory path where the graph tiles are stored (mjolnir.tile_dir), if present.
36
+ :param verbose: Whether you want to see Valhalla's logs on stdout (mjolnir.logging). Default False.
37
+ """
38
+
39
+ config = _sanitize_config(default_config.copy())
40
+
41
+ config["mjolnir"]["tile_dir"] = str(Path(tile_dir).resolve())
42
+ config["mjolnir"]["tile_extract"] = str(Path(tile_extract).resolve())
43
+ config["mjolnir"]["logging"]["type"] = "std_out" if verbose else ""
44
+
45
+ return config
valhalla/utils.py ADDED
@@ -0,0 +1,62 @@
1
+ from typing import List, Tuple
2
+
3
+
4
+ def decode_polyline(
5
+ polyline: str, precision: int = 6, order: str = "lnglat"
6
+ ) -> List[Tuple[float, float]]:
7
+ """Decodes an encoded ``polyline`` string with ``precision`` to a list of coordinate tuples.
8
+ The coordinate ``order`` of the output can be ``lnglat`` or ``latlng``."""
9
+
10
+ return _decode(polyline, precision=precision, order=order, is3d=False)
11
+
12
+
13
+ def _trans(value, index):
14
+ """
15
+ Copyright (c) 2014 Bruno M. Custódio
16
+ Copyright (c) 2016 Frederick Jansen
17
+ https://github.com/hicsail/polyline/commit/ddd12e85c53d394404952754e39c91f63a808656
18
+ """
19
+ byte, result, shift = None, 0, 0
20
+
21
+ while byte is None or byte >= 0x20:
22
+ byte = ord(value[index]) - 63
23
+ index += 1
24
+ result |= (byte & 0x1F) << shift
25
+ shift += 5
26
+ comp = result & 1
27
+
28
+ return ~(result >> 1) if comp else (result >> 1), index
29
+
30
+
31
+ def _decode(expression, precision=5, order="lnglat", is3d=False):
32
+ """
33
+ Copyright (c) 2014 Bruno M. Custódio
34
+ Copyright (c) 2016 Frederick Jansen
35
+ https://github.com/hicsail/polyline/commit/ddd12e85c53d394404952754e39c91f63a808656
36
+
37
+ Modified to be able to work with 3D polylines and a specified coordinate order.
38
+ """
39
+ coordinates, index, lat, lng, z, length, factor = (
40
+ [],
41
+ 0,
42
+ 0,
43
+ 0,
44
+ 0,
45
+ len(expression),
46
+ float(10**precision),
47
+ )
48
+
49
+ while index < length:
50
+ lat_change, index = _trans(expression, index)
51
+ lng_change, index = _trans(expression, index)
52
+ lat += lat_change
53
+ lng += lng_change
54
+ coord = (lat / factor, lng / factor) if order == "latlng" else (lng / factor, lat / factor)
55
+ if not is3d:
56
+ coordinates.append(coord)
57
+ else:
58
+ z_change, index = _trans(expression, index)
59
+ z += z_change
60
+ coordinates.append((*coord, z / 100))
61
+
62
+ return coordinates