Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/iwpnd/starlite-tile38

Starlite application showcasing tile38
https://github.com/iwpnd/starlite-tile38

api crud pyle38 spatial starlite tile38

Last synced: about 2 months ago
JSON representation

Starlite application showcasing tile38

Awesome Lists containing this project

README

        




Starlite-Tile38


Showcase using Tile38 via pyle38 in a Starlite application.


Report Bug
·
Request Feature

Table of Contents




  1. About The Project



  2. Getting Started


  3. Usage

  4. License

  5. Contact

## About The Project

Showcase of using [Tile38](https://github.com/tidwall/tile38) with [Pyle38](https://github.com/iwpnd/pyle38) in a [Starlite](https://github.com/starlite-api/starlite)
application. Can be used as is, or be extended upon with other methods in the [pyle38 repertoire](https://github.com/iwpnd/pyle38#commands) of commands.

### Built With

- [Starlite](https://github.com/starlite-api/starlite)
- [Pyle38](https://github.com/iwpnd/pyle38)
- [Tile38](https://github.com/tidwall/tile38)

## Getting Started

### Installation

1. Clone and install
```sh
git clone https://github.com/iwpnd/starlite-tile38.git
poetry install
```
2. Setup environment
```sh
mv .env.dist .env
```
3. Start your local stack
```python
poe up
```
4. Test it!
```sh
poe test
```

## Usage

Once the application is started you can checkout and interact with it via on [localhost:8001/schema/redoc](http://localhost:8001/schema/redoc).

Or you can use it with [http](https://httpie.io/)/[curl](https://curl.se/):

### Create a vehicle

```sh
echo '{ "data": { "type": "Feature", "geometry": {"type": "Point", "coordinates": [13.37, 52.25]}, "properties": {"id": "truck"}}}' \
| http post http://localhost:8001/vehicles

> {data:"type":"Feature","geometry":{"type":"Point","coordinates":[13.37, 52.25]},"properties":{"id":"truck"}}
```

### Get vehicle by id
```sh
http get http://localhost:8001/vehicles/truck

> {data:"type":"Feature","geometry":{"type":"Point","coordinates":[13.37, 52.25]},"properties":{"id":"truck"}}
```

### Get all vehicles
```
http get http://localhost:8001/vehicles

> { data: ["type":"Feature","geometry":{"type": "Point", "coordinates": [13.37, 52.25]},"properties":{"id":"truck"}]}
```

### Get vehicles within radius
```
http get http://localhost:8001/search?lat=13.37&lon=52.25&radius=1000

> { data: ["type":"Feature","geometry":{"type": "Point", "coordinates": [13.37, 52.25]},"properties":{"id":"truck"}]}
```

Or you use it with [httpx](https://www.python-httpx.org/)/[requests](https://docs.python-requests.org/en/master/):

```python
import httpx

vehicle = {
"type": "Feature",
"geometry": {"type": "Point", "coordinates": [13.37, 52.25]},
"properties": {"id": "truck"},
}

# store a vehicle
r = httpx.post(
url="http://localhost:8001/vehicles",
json={"data": vehicle}
)

print(r.json())
> { data: ["type":"Feature","geometry":{"type": "Point", "coordinates": [13.37, 52.25]},"properties":{"id":"truck"}]}

# get a vehicle
r = httpx.get(
url="http://localhost:8001/vehicles/truck",
)

print(r.json())

> {"data": {"type":"Feature","geometry": {"coordinates": [13.37,52.25],"type": "Point"},"properties": {"id": "truck"}}}
```

You get the idea. And can use the rest.

## License

Distributed under the MIT License. See `LICENSE` for more information.

## Contact

Benjamin Ramser - [@imwithpanda](https://twitter.com/imwithpanda) - [email protected]
Project Link: [https://github.com/iwpnd/starlite-tile38](https://github.com/iwpnd/starlite-tile38)