Library for creating MVT SQL query
Project description
## EOS vision tile query library
Vector tile query library create MVT tiles SQL query by XYZ.
## Architecture
Vision tile query library provide postgis MVT SQL query with special
abilities. Polygon simplification and geometries count simplification
according zoom level are main features. Reade more about postgis+MVT
https://postgis.net/docs/ST_AsMVT.html
### Installing
Use pip with project url
```text
pip install vision-tile-query
```
### Usage examples
Tile query library requires SQLalchemy table model for constructing SQL query
#### Flask
```text
from flask import Flask, render_template
from sqlalchemy import create_engine
from vision_tile_query import VisionBaseTileProcessor
from vision_tile_query import TableManager
app = Flask(__name__)
# Connect to DB
app.engine = create_engine('postgresql://postgres@localhost:5432/vision_db')
table_manager = TableManager(app.engine)
@app.route('/')
def map_page():
return render_template('main.html')
@app.route('/tile/<table>/<zoom>/<x_tile>/<y_tile>.pbf')
def get_tile(table, x_tile, y_tile, zoom):
tile = {'x': x_tile, 'y': y_tile, 'z': zoom}
# Define model
model = table_manager.get_table_model(
table, 'public')
tile_query = VisionBaseTileProcessor().get_tile(
tile, model=model.__table__)
# Exec query and get data
conn = app.engine.connect()
query = conn.execute(tile_query)
tile = query.fetchone()
conn.close()
# Make response object
response = app.make_response(bytes(tile[0]))
response.headers['Content-Type'] = 'application/x-protobuf'
response.headers['Access-Control-Allow-Origin'] = "*"
return response
if __name__ == '__main__':
app.run()
```
#### Aiohttp
Will be soon
### Requirements
- mercantile==0.10.0
- SQLAlchemy==1.1.11
- geoalchemy2==0.4.0
Vector tile query library create MVT tiles SQL query by XYZ.
## Architecture
Vision tile query library provide postgis MVT SQL query with special
abilities. Polygon simplification and geometries count simplification
according zoom level are main features. Reade more about postgis+MVT
https://postgis.net/docs/ST_AsMVT.html
### Installing
Use pip with project url
```text
pip install vision-tile-query
```
### Usage examples
Tile query library requires SQLalchemy table model for constructing SQL query
#### Flask
```text
from flask import Flask, render_template
from sqlalchemy import create_engine
from vision_tile_query import VisionBaseTileProcessor
from vision_tile_query import TableManager
app = Flask(__name__)
# Connect to DB
app.engine = create_engine('postgresql://postgres@localhost:5432/vision_db')
table_manager = TableManager(app.engine)
@app.route('/')
def map_page():
return render_template('main.html')
@app.route('/tile/<table>/<zoom>/<x_tile>/<y_tile>.pbf')
def get_tile(table, x_tile, y_tile, zoom):
tile = {'x': x_tile, 'y': y_tile, 'z': zoom}
# Define model
model = table_manager.get_table_model(
table, 'public')
tile_query = VisionBaseTileProcessor().get_tile(
tile, model=model.__table__)
# Exec query and get data
conn = app.engine.connect()
query = conn.execute(tile_query)
tile = query.fetchone()
conn.close()
# Make response object
response = app.make_response(bytes(tile[0]))
response.headers['Content-Type'] = 'application/x-protobuf'
response.headers['Access-Control-Allow-Origin'] = "*"
return response
if __name__ == '__main__':
app.run()
```
#### Aiohttp
Will be soon
### Requirements
- mercantile==0.10.0
- SQLAlchemy==1.1.11
- geoalchemy2==0.4.0
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for vision_tile_query-0.0.2.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e5e629894ecd4a581637515b89d1428cd7f000fa2affc31897e10efef73544b |
|
MD5 | c9b8b786cb0516293817f13d208de7a3 |
|
BLAKE2b-256 | e3adcdd0078eaa29b5f7fb44840714865e15fdf99c3485f000a2155ecb03445f |
Close
Hashes for vision_tile_query-0.0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5306cf67959ff172affee8a92474afa3b639d9f1fb2ee49c7a75c15c547a824e |
|
MD5 | 43d113c840ed4a71aa8315c4aa9f1feb |
|
BLAKE2b-256 | 0169b0054e95c85ff9a6b749f7024651e187e8241dfbd95988401173a7141ecc |