コード例 #1
0
ファイル: handlers.py プロジェクト: geary/claslite
# -*- coding: utf-8 -*-
'''
	handlers.py for Earth Engine proxy
	
	By Michael Geary - http://mg.to/
	See UNLICENSE or http://unlicense.org/ for public domain notice.
'''

from main import fix_sys_path
fix_sys_path()

from tipfy import RequestHandler, Response

from tipfy.utils import json_encode

import cgi, re, urllib, urllib2

from earthengine import EarthEngine


class ProxyHandler(RequestHandler):
    '''
		Proxy an Earth Engine request
	'''
    def _getApiFromUrl(self):
        return re.sub(r'http(s)?://[^/]+/\w+/', '', self.request.url)

    def _proxy(self, allow, data=None):
        api = self._getApiFromUrl()

        test = api.startswith('test/')
コード例 #2
0
ファイル: handlers.py プロジェクト: geary/claslite
# -*- coding: utf-8 -*-
'''
	handlers.py for Fusion Table KML proxy
	
	By Michael Geary - http://mg.to/
	See UNLICENSE or http://unlicense.org/ for public domain notice.
'''

from main import fix_sys_path;  fix_sys_path()

from tipfy import RequestHandler, Response

import cgi, re, urllib, urllib2

import fusion

class FusionKmlHandler( RequestHandler ):
	'''
		Fetch a KML cell from a Fusion Table and make it available
		at its own URL.
	'''
	
	def get( self, tableId=None, rowId=None ):
		client = fusion.Client( self )
		selection = client.query(
			'SELECT geometry FROM ' + fusion.fixId(tableId) +
			' WHERE rowid = ' + fusion.fixId(rowId)
		)
		row = selection and selection[0]
		kml = row and row['geometry']
		response = Response( kml )
コード例 #3
0
ファイル: handlers.py プロジェクト: geary/claslite
# -*- coding: utf-8 -*-
"""
	rpc.handlers
	~~~~~~~~~~~~~~~~~~~~

	CLASlite JSON-RPC handlers

	:By Michael Geary - http://mg.to/
	:See UNLICENSE or http://unlicense.org/ for public domain notice.
"""

from main import fix_sys_path;  fix_sys_path()

from google.appengine.api import urlfetch, users
from google.appengine.ext import db

import logging
import ee
import datetime

from tipfy import RequestHandler, current_handler
from tipfy.ext.jsonrpc import JSONRPCMixin
from tipfy.utils import json_decode, json_encode

from models import Project

from earthengine import EarthEngine, EarthImage

import fusion

from beautifulsoup.BeautifulSoup import BeautifulStoneSoup, SoupStrainer