Skip to content

Commit

Permalink
First checkin for mapfart
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronr committed Mar 19, 2013
1 parent 88cb875 commit dfd0612
Show file tree
Hide file tree
Showing 79 changed files with 21,047 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*~
*.pyc
13 changes: 13 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
##MapFart -- Copyright 2013 Aaron Racicot

http://opensource.org/licenses/BSD-2-Clause

All rights reserved.

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

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
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.

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.

Empty file added __init__.py
Empty file.
13 changes: 13 additions & 0 deletions default.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#######################################
########APP Settings ##########
#######################################

# enable debug mode. Disable this in production!
DEBUG = False

TITLE = 'App Title'
SUBTITLE = 'Website'
AUTHOR = 'Aaron Racicot'
AUTHOR_EMAIL = '[email protected]'
KEYWORDS = 'z-pulley, gis, python'
DESCRIPTION = 'A simple site'
33 changes: 33 additions & 0 deletions examples/geojson.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{ "type": "FeatureCollection",
"features": [
{ "type": "Feature",
"geometry": {"type": "Point", "coordinates": [102.0, 0.5]},
"properties": {"prop0": "value0"}
},
{ "type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[102.0, 0.0], [103.0, 1.0], [104.0, 0.0], [105.0, 1.0]
]
},
"properties": {
"prop0": "value0",
"prop1": 0.0
}
},
{ "type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0],
[100.0, 1.0], [100.0, 0.0] ]
]
},
"properties": {
"prop0": "value0",
"prop1": {"this": "that"}
}
}
]
}
29 changes: 29 additions & 0 deletions examples/leaflet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{ "type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"name": "Coors Field",
"amenity": "Baseball Stadium",
"popupContent": "This is where the Rockies play!"
},
"geometry": {
"type": "Point",
"coordinates": [-104.99404, 39.75621]
}
},
{
"type": "Feature",
"properties": {"party": "Republican"},
"geometry": {
"type": "Polygon",
"coordinates": [[
[-104.05, 48.99],
[-97.22, 48.98],
[-96.58, 45.94],
[-104.03, 45.94],
[-104.05, 48.99]
]]
}
}
]}
13 changes: 13 additions & 0 deletions local.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#######################################
########APP Settings ##########
#######################################

# enable debug mode. Disable this in production!
DEBUG = True

TITLE = 'MapFart'
SUBTITLE = 'Quick map of your data...'
AUTHOR = 'Aaron Racicot'
AUTHOR_EMAIL = '[email protected]'
KEYWORDS = 'api, z-pulley, gis, python, aaron, racicot'
DESCRIPTION = 'Quick Mapping API'
2 changes: 2 additions & 0 deletions logs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
34 changes: 34 additions & 0 deletions mapfart.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<VirtualHost *:80>
ServerName www.mapfart.com
Redirect permanent / http://mapfart.com/
</VirtualHost>

<VirtualHost *:80>
ServerName mapfart.com
ServerAdmin [email protected]

LogLevel info
ErrorLog /home/projects/mapfart/logs/error.log
CustomLog /home/projects/mapfart/logs/access.log combined

#ErrorDocument 401 /Forbidden.html
#ErrorDocument 403 /Forbidden.html
#ErrorDocument 404 /FileNotFound.html
#ErrorDocument 500 /cgi-bin/ServerError.pl

DocumentRoot /home/projects/mapfart/www
<Directory /home/projects/mapfart/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>

WSGIDaemonProcess wsgi_mapfart threads=15 processes=15 \
display-name=wsgi_mapfart \
python-path=/home/projects/mapfart/venv/lib/python2.7/site-packages
WSGIProcessGroup wsgi_mapfart

WSGIScriptAlias / /home/projects/mapfart/mapfart.wsgi

</VirtualHost>
49 changes: 49 additions & 0 deletions mapfart.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# -*- coding: utf-8 -*-
from flask import Flask, request, jsonify
from flask import make_response, render_template
from flask import flash, redirect, url_for, session, escape, g

# General web serving
from mapfartapi.web import index, documentation, api_landing
# The good old fart generate code
from mapfartapi.api import fart, fart_srid, fart_srid_xy, fart_default
# The fart serve code
from mapfartapi.api import fart_serve
# Testing...
from mapfartapi.api import testcurl

app = Flask(__name__)

app.config.from_pyfile('default.cfg')
app.config.from_pyfile('local.cfg')

# URLs
# Landing Page
app.add_url_rule('/', 'index', index)
# Fart Serve
app.add_url_rule('/fart_<fart_id>', 'fart_serve', fart_serve, methods=['GET'])
# Building farts
# Default farts
app.add_url_rule('/api/fart', 'fart_default', fart_default, methods=['POST'])
# Reprojected farts
app.add_url_rule('/api/<int:srid>/fart', 'fart_srid', fart_srid, methods=['POST'])
# Reprojected farts of any size
app.add_url_rule('/api/<int:srid>/<int:xsize>/<int:ysize>/fart', 'fart_srid_xy', fart_srid_xy, methods=['POST'])

# Docs (in the future)
app.add_url_rule('/api', 'api', api_landing)
app.add_url_rule('/documentation', 'documentation', documentation)

# Testing
app.add_url_rule('/api/testcurl', 'testcurl', testcurl, methods=['POST'])

@app.errorhandler(500)
def page_not_found(e):
return "your farts stink... try again!\n", 500

@app.errorhandler(404)
def page_not_found(e):
return "Your fart request could not be served...\n", 404

if __name__ == "__main__":
app.run(debug=True,host='0.0.0.0')
6 changes: 6 additions & 0 deletions mapfart.wsgi
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import sys
sys.path.insert(0, "/home/projects/mapfart")
sys.path.insert(0, "/usr/local/lib/geom-0.2/bin")
sys.path.insert(0, "/usr/local/bin")

from mapfart import app as application
Empty file added mapfartapi/__init__.py
Empty file.
Loading

0 comments on commit dfd0612

Please sign in to comment.