haversigeo 0.1.0__tar.gz
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.
haversigeo-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026, james blessings
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: haversigeo
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A package for calculating distance between two places using haversine formula
|
|
5
|
+
License: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Author: james blessings
|
|
8
|
+
Requires-Python: >=3.12,<4.0
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
|
|
17
|
+
# haversigeo
|
|
18
|
+
|
|
19
|
+
A package for calculating distance between two places using haversine formula
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
$ pip install haversigeo
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
- TODO
|
|
30
|
+
|
|
31
|
+
## Contributing
|
|
32
|
+
|
|
33
|
+
Interested in contributing? Check out the contributing guidelines. Please note that this project is released with a Code of Conduct. By contributing to this project, you agree to abide by its terms.
|
|
34
|
+
|
|
35
|
+
## License
|
|
36
|
+
|
|
37
|
+
`haversigeo` was created by james blessings. It is licensed under the terms of the MIT license.
|
|
38
|
+
|
|
39
|
+
## Credits
|
|
40
|
+
|
|
41
|
+
`haversigeo` was created with [`cookiecutter`](https://cookiecutter.readthedocs.io/en/latest/) and the `py-pkgs-cookiecutter` [template](https://github.com/py-pkgs/py-pkgs-cookiecutter).
|
|
42
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# haversigeo
|
|
2
|
+
|
|
3
|
+
A package for calculating distance between two places using haversine formula
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
$ pip install haversigeo
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
- TODO
|
|
14
|
+
|
|
15
|
+
## Contributing
|
|
16
|
+
|
|
17
|
+
Interested in contributing? Check out the contributing guidelines. Please note that this project is released with a Code of Conduct. By contributing to this project, you agree to abide by its terms.
|
|
18
|
+
|
|
19
|
+
## License
|
|
20
|
+
|
|
21
|
+
`haversigeo` was created by james blessings. It is licensed under the terms of the MIT license.
|
|
22
|
+
|
|
23
|
+
## Credits
|
|
24
|
+
|
|
25
|
+
`haversigeo` was created with [`cookiecutter`](https://cookiecutter.readthedocs.io/en/latest/) and the `py-pkgs-cookiecutter` [template](https://github.com/py-pkgs/py-pkgs-cookiecutter).
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "haversigeo"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "A package for calculating distance between two places using haversine formula"
|
|
5
|
+
authors = ["james blessings"]
|
|
6
|
+
license = "MIT"
|
|
7
|
+
readme = "README.md"
|
|
8
|
+
|
|
9
|
+
[tool.poetry.dependencies]
|
|
10
|
+
python = "^3.12"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
[build-system]
|
|
14
|
+
requires = ["poetry-core>=1.0.0"]
|
|
15
|
+
build-backend = "poetry.core.masonry.api"
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import math
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def haversine_distance(origin, destination):
|
|
5
|
+
"""Calculate the great-circle distance between two points on Earth.
|
|
6
|
+
|
|
7
|
+
Uses the haversine formula to compute the shortest distance over the
|
|
8
|
+
Earth's surface between two points given as latitude/longitude pairs,
|
|
9
|
+
assuming a spherical Earth with a mean radius of 6,371,000 meters.
|
|
10
|
+
|
|
11
|
+
Args:
|
|
12
|
+
origin (tuple[float, float]): Starting point as ``(latitude, longitude)``
|
|
13
|
+
in decimal degrees.
|
|
14
|
+
destination (tuple[float, float]): End point as ``(latitude, longitude)``
|
|
15
|
+
in decimal degrees.
|
|
16
|
+
|
|
17
|
+
Returns:
|
|
18
|
+
float: The distance between the two points in meters.
|
|
19
|
+
|
|
20
|
+
Notes:
|
|
21
|
+
- Coordinates must be in ``(latitude, longitude)`` order. Many GIS
|
|
22
|
+
libraries use ``(longitude, latitude)``, so check the order of your
|
|
23
|
+
data before calling.
|
|
24
|
+
- Because the Earth is modelled as a perfect sphere, results can differ
|
|
25
|
+
from ellipsoidal (e.g. WGS84) geodesic distances by up to roughly 0.5%.
|
|
26
|
+
|
|
27
|
+
Examples:
|
|
28
|
+
>>> haversine_distance((0, 0), (0, 0))
|
|
29
|
+
0.0
|
|
30
|
+
>>> round(haversine_distance((0, 0), (1, 0)), 2)
|
|
31
|
+
111194.93
|
|
32
|
+
"""
|
|
33
|
+
lat1, lon1 = origin
|
|
34
|
+
lat2, lon2 = destination
|
|
35
|
+
radius = 6371000
|
|
36
|
+
dlat = math.radians(lat2-lat1)
|
|
37
|
+
dlon = math.radians(lon2-lon1)
|
|
38
|
+
a = math.sin(dlat/2) * math.sin(dlat/2) + math.cos(math.radians(lat1)) \
|
|
39
|
+
* math.cos(math.radians(lat2)) * math.sin(dlon/2) * math.sin(dlon/2)
|
|
40
|
+
c = 2 * math.atan2(math.sqrt(a), math.sqrt(1-a))
|
|
41
|
+
distance = radius * c
|
|
42
|
+
return distance
|