🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

snapr

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

snapr

Library enabling a flexible and frictionless way to render snapshots of maps with overlayed geometries.

0.5.0
PyPI
Maintainers
1

snapr.py

Snapr (/ˈsnæp ər/) is a library that enables a flexible and frictionless way to render snapshots of maps with overlayed geometries. The backing library is written in Rust, these are bindings to said library.

Example

from snapr import Geometry, Point, Snapr
import requests

def tile_fetcher(coords: list[tuple[int, int]], zoom: int) -> list[tuple[int, int, bytearray]]:
    tiles = []

    for x, y in coords:
        response = requests.get(
            f"https://a.tile.osm.org/{zoom}/{x}/{y}.png",
            headers={"User-Agent": "snapr.py"},
        )

        tiles.append((x, y, bytearray(response.content)))

    return tiles

snapr = Snapr(tile_fetcher=tile_fetcher, zoom=15)

geometries = [
    Geometry.Point(Point(latitude=41.703811459356196, longitude=-103.34835922605679)),
]

snapshot = snapr.generate_snapshot_from_geometries(geometries=geometries)

with open("example.png", "wb") as image:
    image.write(snapshot)

Example Output

License

Licensed under the MIT License found at the root of the repository.

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts