remove plpython and python code for now. also removed mistaken installation of postgres_fdw in tests
This commit is contained in:
parent
aa807eb65b
commit
5e7bffae6a
5
Makefile
5
Makefile
@ -1,7 +1,6 @@
|
|||||||
include ./Makefile.global
|
include ./Makefile.global
|
||||||
|
|
||||||
EXT_DIR = src/pg
|
EXT_DIR = src/pg
|
||||||
PYP_DIR = src/python
|
|
||||||
|
|
||||||
.PHONY: install
|
.PHONY: install
|
||||||
.PHONY: run_tests
|
.PHONY: run_tests
|
||||||
@ -13,17 +12,14 @@ PYP_DIR = src/python
|
|||||||
# It requires sudo.
|
# It requires sudo.
|
||||||
install: ## Generate and install development version of the extension; requires sudo.
|
install: ## Generate and install development version of the extension; requires sudo.
|
||||||
$(MAKE) -C $(EXT_DIR) install
|
$(MAKE) -C $(EXT_DIR) install
|
||||||
$(MAKE) -C $(PYP_DIR) install
|
|
||||||
|
|
||||||
# Run the tests for the installed development extension.
|
# Run the tests for the installed development extension.
|
||||||
test: ## Run the tests for the development version of the extension
|
test: ## Run the tests for the development version of the extension
|
||||||
$(MAKE) -C $(EXT_DIR) test
|
$(MAKE) -C $(EXT_DIR) test
|
||||||
$(MAKE) -C $(PYP_DIR) test
|
|
||||||
|
|
||||||
# Generate a new release into release
|
# Generate a new release into release
|
||||||
release: ## Generate a new release of the extension. Only for release manager
|
release: ## Generate a new release of the extension. Only for release manager
|
||||||
$(MAKE) -C $(EXT_DIR) release
|
$(MAKE) -C $(EXT_DIR) release
|
||||||
$(MAKE) -C $(PYP_DIR) release
|
|
||||||
|
|
||||||
# Install the current release.
|
# Install the current release.
|
||||||
# It requires sudo.
|
# It requires sudo.
|
||||||
@ -31,7 +27,6 @@ release: ## Generate a new release of the extension. Only for release manager
|
|||||||
# sudo make deploy RELEASE_VERSION=1.0.0
|
# sudo make deploy RELEASE_VERSION=1.0.0
|
||||||
deploy: ## Deploy a released extension. Only for release manager. Requires sudo.
|
deploy: ## Deploy a released extension. Only for release manager. Requires sudo.
|
||||||
$(MAKE) -C $(EXT_DIR) deploy
|
$(MAKE) -C $(EXT_DIR) deploy
|
||||||
$(MAKE) -C $(PYP_DIR) deploy
|
|
||||||
|
|
||||||
# Cleanup development extension script files
|
# Cleanup development extension script files
|
||||||
clean-dev: ## clean up development extension script files
|
clean-dev: ## clean up development extension script files
|
||||||
|
1
NEWS.md
1
NEWS.md
@ -9,7 +9,6 @@ __API Changes__
|
|||||||
|
|
||||||
__Improvements__
|
__Improvements__
|
||||||
|
|
||||||
* Add support for PL/Python
|
|
||||||
* Generate fixtures from `obs_meta`
|
* Generate fixtures from `obs_meta`
|
||||||
* Remove unused table-level code
|
* Remove unused table-level code
|
||||||
* Refactor all augmentation and geometry functions to obtain data from
|
* Refactor all augmentation and geometry functions to obtain data from
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
comment = 'CartoDB Observatory backend extension'
|
comment = 'CartoDB Observatory backend extension'
|
||||||
default_version = '1.1.6'
|
default_version = '1.3.0'
|
||||||
requires = 'postgis, plpythonu'
|
requires = 'postgis'
|
||||||
superuser = true
|
superuser = true
|
||||||
schema = cdb_observatory
|
schema = cdb_observatory
|
||||||
|
@ -1,107 +0,0 @@
|
|||||||
CREATE OR REPLACE FUNCTION cdb_observatory._OBS_GetOverpass(
|
|
||||||
query text
|
|
||||||
) RETURNS TABLE (
|
|
||||||
geom TEXT,
|
|
||||||
"type" TEXT,
|
|
||||||
id TEXT,
|
|
||||||
properties TEXT
|
|
||||||
) AS $$
|
|
||||||
|
|
||||||
from observatory.osm import get_overpass
|
|
||||||
import plpy
|
|
||||||
import json
|
|
||||||
|
|
||||||
result = get_overpass(query)
|
|
||||||
|
|
||||||
return [{
|
|
||||||
'geom': json.dumps(feature['geometry']),
|
|
||||||
'type': feature['type'],
|
|
||||||
'id': str(feature['id']),
|
|
||||||
'properties': json.dumps(feature['properties'])
|
|
||||||
} for feature in result]
|
|
||||||
|
|
||||||
$$ LANGUAGE plpythonu;
|
|
||||||
|
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetOverpass(
|
|
||||||
query text
|
|
||||||
) RETURNS TABLE (
|
|
||||||
geom Geometry(Geometry, 4326),
|
|
||||||
"type" TEXT,
|
|
||||||
id TEXT,
|
|
||||||
properties JSON
|
|
||||||
) AS $$
|
|
||||||
BEGIN
|
|
||||||
RETURN QUERY
|
|
||||||
EXECUTE $string$
|
|
||||||
SELECT ST_GeomFromGeojson(geom) geom,
|
|
||||||
"type",
|
|
||||||
id,
|
|
||||||
properties::JSON
|
|
||||||
FROM cdb_observatory._OBS_GetOverPass($1)
|
|
||||||
$string$ USING query
|
|
||||||
RETURN;
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE plpgsql;
|
|
||||||
|
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetOverpassPOI(
|
|
||||||
within_geom Geometry(Geometry, 4326),
|
|
||||||
filters TEXT[] DEFAULT ARRAY[ 'pub', 'bar', 'restaurant', 'fast_food',
|
|
||||||
'cafe', 'food_court', 'ice_cream', 'college', 'kindergarten', 'library',
|
|
||||||
'school', 'music_school', 'driving_school', 'language_school', 'university',
|
|
||||||
'bicycle_rental', 'boat_sharing', 'car_rental', 'car_sharing', 'car_wash',
|
|
||||||
'ferry_terminal', 'fuel', 'bank', 'bureau_de_change', 'clinic', 'dentist',
|
|
||||||
'doctors', 'hospital', 'nursing_home', 'pharmacy', 'social_facility',
|
|
||||||
'veterinary', 'blood_donation', 'arts_centre', 'brothel', 'casino',
|
|
||||||
'community_centre', 'cinema', 'gambling', 'nightclub', 'planetarium',
|
|
||||||
'social_centre', 'stripclub', 'swingerclub', 'studio', 'theatre',
|
|
||||||
'animal_boarding', 'animal_shelter', 'courthouse', 'coworking_space',
|
|
||||||
'crematorium', 'dive_centre', 'dojo', 'embassy', 'fire_station',
|
|
||||||
'internet_cafe', 'marketplace', 'place_of_worship', 'police', 'post_office',
|
|
||||||
'prison', 'townhall', 'waste_transfer_station'
|
|
||||||
],
|
|
||||||
name TEXT DEFAULT NULL
|
|
||||||
) RETURNS TABLE (
|
|
||||||
geom Geometry(Geometry, 4326),
|
|
||||||
"type" TEXT,
|
|
||||||
id TEXT,
|
|
||||||
properties JSON
|
|
||||||
) AS $$
|
|
||||||
DECLARE
|
|
||||||
osm_bbox TEXT;
|
|
||||||
query TEXT;
|
|
||||||
BEGIN
|
|
||||||
osm_bbox := replace(replace(replace(regexp_replace(box2d(within_geom)::TEXT,
|
|
||||||
E'(\\-?\\d+\\.?\\d+) (\\-?\\d+\\.?\\d+)',
|
|
||||||
E'\\2 \\1', 'g'),
|
|
||||||
' ', ','),
|
|
||||||
'BOX(', ''),
|
|
||||||
')', '');
|
|
||||||
|
|
||||||
EXECUTE $string$
|
|
||||||
WITH filters AS (SELECT UNNEST($1) as filter)
|
|
||||||
SELECT ' ( '
|
|
||||||
'node ["name"]["amenity"~"' || String_Agg(filter, '|') || '"] (' || $2 || '); ' ||
|
|
||||||
'way ["name"]["amenity"~"' || String_Agg(filter, '|') || '"] (' || $2 || '); ' ||
|
|
||||||
'node ["name"][shop] (' || $2 || '); ' ||
|
|
||||||
'way ["name"][shop] (' || $2 || '); ' ||
|
|
||||||
'relation ["name"][shop] (' || $2 || ')) '
|
|
||||||
FROM filters
|
|
||||||
$string$
|
|
||||||
INTO query
|
|
||||||
USING filters, osm_bbox, name;
|
|
||||||
|
|
||||||
RAISE NOTICE '%', query;
|
|
||||||
RETURN QUERY
|
|
||||||
EXECUTE $string$
|
|
||||||
WITH results AS (SELECT ST_SetSRID(ST_GeomFromGeojson(geom), 4326) geom,
|
|
||||||
"type",
|
|
||||||
id,
|
|
||||||
properties::JSON
|
|
||||||
FROM cdb_observatory._OBS_GetOverPass($1))
|
|
||||||
SELECT * FROM results WHERE ST_Within(geom, $2)
|
|
||||||
$string$ USING query, within_geom
|
|
||||||
RETURN;
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE plpgsql;
|
|
@ -1,6 +1,4 @@
|
|||||||
-- Install dependencies
|
-- Install dependencies
|
||||||
CREATE EXTENSION postgis;
|
CREATE EXTENSION postgis;
|
||||||
CREATE EXTENSION postgres_fdw;
|
|
||||||
CREATE EXTENSION plpythonu;
|
|
||||||
-- Install the extension
|
-- Install the extension
|
||||||
CREATE EXTENSION observatory VERSION 'dev';
|
CREATE EXTENSION observatory VERSION 'dev';
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
-- Install dependencies
|
-- Install dependencies
|
||||||
CREATE EXTENSION postgis;
|
CREATE EXTENSION postgis;
|
||||||
CREATE EXTENSION postgres_fdw;
|
|
||||||
CREATE EXTENSION plpythonu;
|
|
||||||
|
|
||||||
-- Install the extension
|
-- Install the extension
|
||||||
CREATE EXTENSION observatory VERSION 'dev';
|
CREATE EXTENSION observatory VERSION 'dev';
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
include ../../Makefile.global
|
|
||||||
|
|
||||||
# Install the package locally for development
|
|
||||||
|
|
||||||
install:
|
|
||||||
pip install --upgrade ./observatory
|
|
||||||
|
|
||||||
test:
|
|
||||||
#TODO noop
|
|
@ -1,11 +0,0 @@
|
|||||||
from overpass import API
|
|
||||||
|
|
||||||
import json
|
|
||||||
|
|
||||||
def get_overpass(query):
|
|
||||||
'''
|
|
||||||
Return results of a raw overpass query.
|
|
||||||
'''
|
|
||||||
api = API()
|
|
||||||
response = api.Get(query)
|
|
||||||
return response['features']
|
|
@ -1 +0,0 @@
|
|||||||
overpass==0.5.6
|
|
@ -1,50 +0,0 @@
|
|||||||
"""
|
|
||||||
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'
|
|
||||||
)
|
|
Loading…
Reference in New Issue
Block a user