Name | datasette-haversine JSON |
Version |
0.2.1
JSON |
| download |
home_page | |
Summary | Datasette plugin that adds a custom SQL function for haversine distances |
upload_time | 2023-12-29 18:05:25 |
maintainer | |
docs_url | None |
author | Simon Willison |
requires_python | >=3.8 |
license | Apache License, Version 2.0 |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# datasette-haversine
[![PyPI](https://img.shields.io/pypi/v/datasette-haversine.svg)](https://pypi.org/project/datasette-haversine/)
[![Changelog](https://img.shields.io/github/v/release/simonw/datasette-haversine?include_prereleases&label=changelog)](https://github.com/simonw/datasette-haversine/releases)
[![Tests](https://github.com/simonw/datasette-haversine/workflows/Test/badge.svg)](https://github.com/simonw/datasette-haversine/actions?query=workflow%3ATest)
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/simonw/datasette-haversine/blob/main/LICENSE)
Datasette plugin that adds a custom SQL function for haversine distances
Install this plugin in the same environment as Datasette to enable the `haversine()` SQL function.
```bash
datasette install datasette-haversine
```
The plugin is built on top of the [haversine](https://github.com/mapado/haversine) library.
## haversine() to calculate distances
```sql
select haversine(lat1, lon1, lat2, lon2);
```
This will return the distance in kilometers between the point defined by `(lat1, lon1)` and the point defined by `(lat2, lon2)`.
## Demo
You can try this function [here using Datasette Lite](https://lite.datasette.io/?install=datasette-haversine#/content?sql=select+haversine%28%0A++40.7128%2C+-74.0060%2C+--+New+York%0A++37.7749%2C+-122.4194%2C+--+San+Francisco%0A++%27mi%27%0A%29+as+distance_in_miles%3B).
```sql
select haversine(
40.7128, -74.0060, -- New York
37.7749, -122.4194, -- San Francisco
'mi'
) as distance_in_miles;
```
## Custom units
By default `haversine()` returns results in km. You can pass an optional third argument to get results in a different unit:
- `ft` for feet
- `m` for meters
- `in` for inches
- `mi` for miles
- `nmi` for nautical miles
- `km` for kilometers (the default)
```sql
select haversine(lat1, lon1, lat2, lon2, 'mi');
```
Raw data
{
"_id": null,
"home_page": "",
"name": "datasette-haversine",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "",
"author": "Simon Willison",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/af/40/3ce30a6fe1d9b9df5c6a96d72f705514f392daf38318822c6f9beffba31c/datasette-haversine-0.2.1.tar.gz",
"platform": null,
"description": "# datasette-haversine\n\n[![PyPI](https://img.shields.io/pypi/v/datasette-haversine.svg)](https://pypi.org/project/datasette-haversine/)\n[![Changelog](https://img.shields.io/github/v/release/simonw/datasette-haversine?include_prereleases&label=changelog)](https://github.com/simonw/datasette-haversine/releases)\n[![Tests](https://github.com/simonw/datasette-haversine/workflows/Test/badge.svg)](https://github.com/simonw/datasette-haversine/actions?query=workflow%3ATest)\n[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/simonw/datasette-haversine/blob/main/LICENSE)\n\nDatasette plugin that adds a custom SQL function for haversine distances\n\nInstall this plugin in the same environment as Datasette to enable the `haversine()` SQL function.\n```bash\ndatasette install datasette-haversine\n```\nThe plugin is built on top of the [haversine](https://github.com/mapado/haversine) library.\n\n## haversine() to calculate distances\n\n```sql\nselect haversine(lat1, lon1, lat2, lon2);\n```\n\nThis will return the distance in kilometers between the point defined by `(lat1, lon1)` and the point defined by `(lat2, lon2)`.\n\n## Demo\n\nYou can try this function [here using Datasette Lite](https://lite.datasette.io/?install=datasette-haversine#/content?sql=select+haversine%28%0A++40.7128%2C+-74.0060%2C+--+New+York%0A++37.7749%2C+-122.4194%2C+--+San+Francisco%0A++%27mi%27%0A%29+as+distance_in_miles%3B).\n\n```sql\nselect haversine(\n 40.7128, -74.0060, -- New York\n 37.7749, -122.4194, -- San Francisco\n 'mi'\n) as distance_in_miles;\n```\n\n## Custom units\n\nBy default `haversine()` returns results in km. You can pass an optional third argument to get results in a different unit:\n\n- `ft` for feet\n- `m` for meters\n- `in` for inches\n- `mi` for miles\n- `nmi` for nautical miles\n- `km` for kilometers (the default)\n\n```sql\nselect haversine(lat1, lon1, lat2, lon2, 'mi');\n```\n",
"bugtrack_url": null,
"license": "Apache License, Version 2.0",
"summary": "Datasette plugin that adds a custom SQL function for haversine distances",
"version": "0.2.1",
"project_urls": {
"CI": "https://github.com/simonw/datasette-haversine/actions",
"Changelog": "https://github.com/simonw/datasette-haversine/releases",
"Homepage": "https://github.com/simonw/datasette-haversine",
"Issues": "https://github.com/simonw/datasette-haversine/issues"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "46f725a19af39c1a4e7827e316f41fae66b07352473be1b702844bdb7a4209f0",
"md5": "3959afbccdd3fdfad7ea434860113292",
"sha256": "6fd80f488d44cad5a868170f2db1b93c3b26d556ae70f9c690152b97a6bdd52c"
},
"downloads": -1,
"filename": "datasette_haversine-0.2.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3959afbccdd3fdfad7ea434860113292",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 6858,
"upload_time": "2023-12-29T18:05:24",
"upload_time_iso_8601": "2023-12-29T18:05:24.249982Z",
"url": "https://files.pythonhosted.org/packages/46/f7/25a19af39c1a4e7827e316f41fae66b07352473be1b702844bdb7a4209f0/datasette_haversine-0.2.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "af403ce30a6fe1d9b9df5c6a96d72f705514f392daf38318822c6f9beffba31c",
"md5": "ce170f14a0e08ed8de0dfa0bc13023a4",
"sha256": "7405fcb2aa6ca5c6c256ce34c96994d432259203af9fcd1a7b96534221d0357f"
},
"downloads": -1,
"filename": "datasette-haversine-0.2.1.tar.gz",
"has_sig": false,
"md5_digest": "ce170f14a0e08ed8de0dfa0bc13023a4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 6779,
"upload_time": "2023-12-29T18:05:25",
"upload_time_iso_8601": "2023-12-29T18:05:25.301839Z",
"url": "https://files.pythonhosted.org/packages/af/40/3ce30a6fe1d9b9df5c6a96d72f705514f392daf38318822c6f9beffba31c/datasette-haversine-0.2.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-29 18:05:25",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "simonw",
"github_project": "datasette-haversine",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "datasette-haversine"
}