Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

iwpnd/starlite-tile38

Repository files navigation


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 with Pyle38 in a Starlite application. Can be used as is, or be extended upon with other methods in the pyle38 repertoire of commands.

Built With

Getting Started

Installation

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

Usage

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

Or you can use it with http/curl:

Create a vehicle

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

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/requests:

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 - ahoi@iwpnd.pw
Project Link: https://github.com/iwpnd/starlite-tile38

Releases

No releases published

Packages

No packages published