Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/metwork-framework/mapserverapi_python
tiny python library to invoke mapserver engine as a library
https://github.com/metwork-framework/mapserverapi_python
autoreadme github-actions integration-level-3 library mapserver python
Last synced: 1 day ago
JSON representation
tiny python library to invoke mapserver engine as a library
- Host: GitHub
- URL: https://github.com/metwork-framework/mapserverapi_python
- Owner: metwork-framework
- License: bsd-3-clause
- Created: 2018-10-30T11:10:46.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-10-07T09:18:38.000Z (3 months ago)
- Last Synced: 2024-11-11T12:14:20.286Z (2 months ago)
- Topics: autoreadme, github-actions, integration-level-3, library, mapserver, python
- Language: Python
- Homepage:
- Size: 190 KB
- Stars: 1
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# mapserverapi_python
[//]: # (automatically generated from https://github.com/metwork-framework/github_organization_management/blob/master/common_files/README.md)
**Status (master branch)**
[![GitHub CI](https://github.com/metwork-framework/mapserverapi_python/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/metwork-framework/mapserverapi_python/actions?query=workflow%3ACI+branch%3Amaster)
[![Maintenance](https://raw.githubusercontent.com/metwork-framework/resources/master/badges/maintained.svg)](https://github.com/metwork-framework/resources/blob/master/badges/maintained.svg)## What is it ?
This is a tiny python library to invoke [mapserver](http://www.mapserver.org) engine
as a simple library (with no daemon or CGI).## Why ?
We don't want to run "mapserver" as CGI or even as FastCGI, we already have our python
workers and we want to invoke "mapserver" features from them directly in Python.Moreover, we don't like the "mapscript" feature because there is always something you can't change with it.
## What is the point ?
The idea is to dynamically write two strings in your Python processes depending on the incoming request:
- the full content of the mapfile (from a jinja2 template for example)
- the "query string" for mapserver (which can be different from the incoming one)With that, you can "invoke" mapserver from your Python code as a library and get the output as a Python buffer or redirect the output into a file (which avoid to load in memory the full mapserver output).
## Example
```python
# With your logic, generate a mapfile content and load it (as a string)
# into mapfile_content
mapfile_content = [...]# With your logic, generate the query string for mapserver and put it into
# mapserver_qs variable (as a string)
mapserver_qs = "LAYERS=ocean&TRANSPARENT=true&FORMAT=image%2Fpng&SERVICE=WMS&" \
"VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc." \
"se_xml&SRS=EPSG%3A4326&BBOX=-180.0,-90.0,180.0,90.0&WIDTH=500&HEIGHT=250"
# (just an example)# Import the wrapper
import mapserverapi# Invoke mapserver and get the output
buf, content_type = mapserverapi.invoke(mapfile_content, mapserver_qs)# You have the content_type of the result and the output buffer (with probably
# a binary image inside)[...]
# Same idea but using a file instead of memory
content_type = mapserverapi.invoke_to_file(mapfile_content, mapserver_qs,
"/tmp/output.png")# You have the content_type of the result in content_type and the raw result
# in the given filepath
```## Contributing guide
See [CONTRIBUTING.md](CONTRIBUTING.md) file.
## Code of Conduct
See [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) file.
## Sponsors
*(If you are officially paid to work on MetWork Framework, please contact us to add your company logo here!)*
[![logo](https://raw.githubusercontent.com/metwork-framework/resources/master/sponsors/meteofrance-small.jpeg)](http://www.meteofrance.com)