Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
trollefson committed Jun 17, 2019
0 parents commit 4c04658
Show file tree
Hide file tree
Showing 163 changed files with 35,231 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
docs/* linguist-vendored
sphinx/* linguist-vendored
19 changes: 19 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#### Code Sample, a copy-pastable example if possible

A "Minimal, Complete and Verifiable Example" will make it much easier for maintainers to help you:
http://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports

#### Problem description

[this should explain **why** the current behavior is a problem and why the expected output is a better solution.]

#### Expected Output

[expected output here]

#### Version Number

- djangorestframework-mvt
- Python
- Postgres
- PostGIS
5 changes: 5 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!-- Feel free to remove check-list items aren't relevant to your change -->

- [ ] Closes issue #xxxx
- [ ] Tests added
- [ ] Documentation updated (docstrings, README, setup.py, Sphinx docs)
22 changes: 22 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Compiled python modules.
*.pyc

# Setuptools distribution folder.
/dist/

# Python egg metadata, regenerated from source files by setuptools.
/*.egg-info

#environment stuff
/build/
/.idea/
/test-reports/

#reports
.coverage
coverage.xml

# Vim
*.swp
*.swo
/venv/
14 changes: 14 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[SIMILARITIES]
min-similarity-lines=10
# similarity because of https://github.com/PyCQA/pylint/issues/2019
ignore-imports=yes

[FORMATTING]
max-line-length=100

[MESSAGES CONTROL]
disable = too-few-public-methods,
missing-docstring,
bad-continuation,
dangerous-default-value,
protected-access,
18 changes: 18 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
dist: xenial
language: python
python:
- '3.7'
notifications:
email: false
before_install:
- sudo add-apt-repository -y ppa:ubuntugis/ppa
- sudo apt-get update -y
- sudo apt install -y gdal-bin python-gdal python3-gdal
install:
- pip install -e .[dev]
script:
- black --check --exclude venv .
- pylint rest_framework_mvt/
- pytest --cov=rest_framework_mvt/ test/
after_success:
- coveralls
54 changes: 54 additions & 0 deletions CODE_OF_CONDUCT.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
Contributor Covenant Code of Conduct
====================================

Our Pledge
----------

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.

Our Standards
-------------

Examples of behavior that contributes to creating a positive environment include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting

Our Responsibilities
--------------------

Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

Scope
-----

This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.

Enforcement
-----------

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at https://github.com/corteva/. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.

Attribution
-----------

This Code of Conduct is adapted from the Contributor Covenant_, version 1.4, available at version_.

.. _Contributor Covenant: http://contributor-covenant.org
.. _version: http://contributor-covenant.org/version/1/4/

53 changes: 53 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Contributing

Go [here](https://github.com/corteva/djangorestframework-mvt/issues) to create a new issue or view issues.

## Types of Contributions

- Bug Fixes
* Follow the [pull request requirements](#pull-request-requirements)
- Feature Implementations
* Follow the [pull request requirements](#pull-request-requirements)
- Documentation
* Sphinx compatibility required
- Bug Reports:
* Report [here](https://github.com/corteva/djangorestframework-mvt/issues)
* Operating system name and version required
* Database name and version required
* Python version required
* Steps to reproduce if possible

## Pull Request Requirements

Pull requests should at least include:
* Tests
* Documentation
* Python 3 compatible

## Development Workflow

Please use a fork and feature branch workflow when submitting merge requests to the project on GitHub.

## Development Setup

* Install From Source:
- `virtualenv venv -p python3`
- `source venv/bin/activate`
- `pip install -e .[dev]`
* Code Quality Checks:
- `pytest test/`
- `black --exclude venv .`
- `pylint rest_framework_mvt/`
* View Documentation Locally:
- `make html`
- `open docs/index.html`

## Releases

Releases will be managed by the core developers. Releases are NOT guaranteed to occur at regular intervals. All
releases will follow [semantic versioning](https://semver.org). Releases will push the newest version of the project
to PyPi.

## Misc

djangorestframework-mvt does not guarantee Python 2 functionality. The developers do not support Python 2.
13 changes: 13 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
BSD-3 License

Copyright (c) 2019 Corteva Agriscience™

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9 changes: 9 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
include CONTRIBUTING.md
include LICENSE.txt

recursive-include test *
recursive-exclude * __pycache__
recursive-exclude * *.py[co]

recursive-include sphinx *.rst conf.py Makefile make.bat *.jpg *.png *.gif
recursive-include docs *
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SOURCEDIR = sphinx
BUILDDIR = docs

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# [djangorestframework-mvt](https://corteva.github.io/djangorestframework-mvt)

A Django REST Framework extension for creating views that serialize model data to Google Protobuf encoded Map Box Vector Tiles via Postgres.

[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
[![Coverage Status](https://coveralls.io/repos/github/corteva/djangorestframework-mvt/badge.svg?branch=master)](https://coveralls.io/github/corteva/djangorestframework-mvt?branch=master)
[![Build Status](https://travis-ci.org/corteva/djangorestframework-mvt.svg?branch=master)](https://travis-ci.org/corteva/djangorestframework-mvt)
[![PyPI version](https://badge.fury.io/py/djangorestframework-mvt.svg)](https://badge.fury.io/py/djangorestframework-mvt)

## Documentation

https://corteva.github.io/djangorestframework-mvt
Empty file added docs/.nojekyll
Empty file.
Binary file added docs/doctrees/environment.pickle
Binary file not shown.
Binary file added docs/doctrees/index.doctree
Binary file not shown.
4 changes: 4 additions & 0 deletions docs/html/.buildinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 62069d5766600505106c1c97e28ee845
tags: 645f666f9bcd5a90fca523b33c5a78b7
85 changes: 85 additions & 0 deletions docs/html/_sources/index.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
Welcome to djangorestframework-mvt's documentation!
===================================================
.. toctree::
:maxdepth: 2
:caption: Contents:

System Requirements
===================
* `GDAL >= 2.1 <https://gdal.org>`_
* `Postgres >= 10 <https://www.postgresql.org/download/>`_
* `PostGIS >= 2.4.0 <http://postgis.net/install/>`_
* Python >= 3.0

Installation
============

.. code-block:: bash
pip install djangorestframework-mvt
Getting Started
===============
In a project's `models.py` file add a `MVTManager` to a model
to be served as Mapbox Vector Tiles. For example:

.. code-block:: python
from django.contrib.gis.db import models
from rest_framework_mvt.managers import MVTManager
class Example(models.Model):
geom = models.PointField()
my_column = models.CharField()
objects = models.Manager()
vector_tiles = MVTManager()
The `geo_col` keyword argument specifies the name of the PostGIS
geometry typed column.

In the project's `urls.py`, create a view linked to a model using
a `MVTManager` with the `mvt_view_factory` function. For example:

.. code-block:: python
from rest_framework_mvt.views import mvt_view_factory
urlpatterns = [
path("api/v1/data/example.mvt/", mvt_view_factory(Example)),
]
The following requests should now be enabled:

.. sourcecode:: http

GET api/v1/data/example.mvt?tile=1/0/0 HTTP/1.1

.. sourcecode:: http

GET api/v1/data/example.mvt?tile=1/0/0&my_column=foo HTTP/1.1

.. sourcecode:: http

GET api/v1/data/example.mvt?tile=1/0/0&my_column=foo&limit=10 HTTP/1.1

.. sourcecode:: http

GET api/v1/data/example.mvt?tile=1/0/0&my_column=foo&limit=10&offset=10 HTTP/1.1

References
==========
- `Mapbox Vector Tile Introduction <https://docs.mapbox.com/vector-tiles/reference/>`_
- `Mapbox Vector Tile v2.1 Specification <https://github.com/mapbox/vector-tile-spec/tree/master/2.1/>`_
- `Google Protocol Buffers <https://developers.google.com/protocol-buffers/>`_
- `PostGIS ST_AsMVT <https://postgis.net/docs/ST_AsMVT.html>`_
- If deploying to AWS RDS Postgres, version 10.5+ is required. See `here <https://forums.aws.amazon.com/thread.jspa?threadID=277371>`_ for more info.

Source Documentation
====================
.. automodule:: rest_framework_mvt.managers
:members:
.. automodule:: rest_framework_mvt.views
:members:
.. toctree::
:maxdepth: 2
:caption: Contents
Loading

0 comments on commit 4c04658

Please sign in to comment.