first pass on overpass api, still getting an error with columns
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
comment = 'CartoDB Observatory backend extension'
|
||||
default_version = '1.1.6'
|
||||
requires = 'postgis, postgres_fdw'
|
||||
requires = 'postgis, postgres_fdw, plpythonu'
|
||||
superuser = true
|
||||
schema = cdb_observatory
|
||||
|
||||
7
src/pg/sql/60_observatory_providers.sql
Normal file
7
src/pg/sql/60_observatory_providers.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetOverpass(query text)
|
||||
RETURNS table (lat Numeric, lon Numeric, "type" TEXT, id Numeric, tags TEXT) as $$
|
||||
|
||||
from observatory.osm import get_overpass
|
||||
return get_overpass(query)
|
||||
|
||||
$$ LANGUAGE plpythonu;
|
||||
@@ -1,6 +1,7 @@
|
||||
-- Install dependencies
|
||||
CREATE EXTENSION postgis;
|
||||
CREATE EXTENSION postgres_fdw;
|
||||
CREATE EXTENSION plpythonu;
|
||||
|
||||
-- Install the extension
|
||||
CREATE EXTENSION observatory VERSION 'dev';
|
||||
|
||||
4
src/python/Makefile
Normal file
4
src/python/Makefile
Normal file
@@ -0,0 +1,4 @@
|
||||
# Install the package locally for development
|
||||
|
||||
install:
|
||||
pip install --upgrade ./crankshaft
|
||||
0
src/python/observatory/observatory/__init__.py
Normal file
0
src/python/observatory/observatory/__init__.py
Normal file
24
src/python/observatory/observatory/osm.py
Normal file
24
src/python/observatory/observatory/osm.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from overpass import API
|
||||
|
||||
import json
|
||||
|
||||
def get_overpass(query):
|
||||
'''
|
||||
Return results of a raw overpass query.
|
||||
'''
|
||||
|
||||
'''
|
||||
(node
|
||||
[amenity]
|
||||
(around:400,
|
||||
40.704301, -73.936658);
|
||||
way
|
||||
[amenity]
|
||||
(around:400,
|
||||
40.704301, -73.936658))
|
||||
'''
|
||||
|
||||
api = API()
|
||||
response = api.Get(query, responseformat='json')
|
||||
|
||||
return [(el['lat'], el['lon'], el['type'], el['id'], json.dumps(el['tags']), ) for el in response['elements'] if 'lat' in el]
|
||||
1
src/python/observatory/requirements.txt
Normal file
1
src/python/observatory/requirements.txt
Normal file
@@ -0,0 +1 @@
|
||||
overpass==0.5.6
|
||||
50
src/python/observatory/setup.py
Normal file
50
src/python/observatory/setup.py
Normal file
@@ -0,0 +1,50 @@
|
||||
"""
|
||||
CartoDB Spatial Analysis Python Library
|
||||
See:
|
||||
https://github.com/CartoDB/crankshaft
|
||||
"""
|
||||
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
setup(
|
||||
name='observatory',
|
||||
|
||||
version='0.0.1',
|
||||
|
||||
description='CARTO Observatory Python Library',
|
||||
|
||||
url='https://github.com/CartoDB/observatory-extension',
|
||||
|
||||
author='Research and Data - CARTO',
|
||||
author_email='john@carto.com',
|
||||
|
||||
license='MIT',
|
||||
|
||||
classifiers=[
|
||||
'Development Status :: 3 - Alpha',
|
||||
'Intended Audience :: Mapping comunity',
|
||||
'Topic :: Maps :: Mapping Tools',
|
||||
'License :: OSI Approved :: MIT License',
|
||||
'Programming Language :: Python :: 2.7',
|
||||
],
|
||||
|
||||
keywords='maps mapping tools spatial data',
|
||||
|
||||
packages=find_packages(exclude=['contrib', 'docs', 'tests']),
|
||||
|
||||
extras_require={
|
||||
'dev': ['unittest'],
|
||||
'test': ['unittest', 'nose', 'mock'],
|
||||
},
|
||||
|
||||
# The choice of component versions is dictated by what's
|
||||
# provisioned in the production servers.
|
||||
# IMPORTANT NOTE: please don't change this line. Instead issue a ticket to systems for evaluation.
|
||||
install_requires=[],
|
||||
#install_requires=['overpass==0.5.6'],
|
||||
|
||||
requires=[],
|
||||
#requires=['overpass'],
|
||||
|
||||
#test_suite='test'
|
||||
)
|
||||
Reference in New Issue
Block a user