From 5e7bffae6ad555e33d035eb0f24f3d1f9bf4ed06 Mon Sep 17 00:00:00 2001 From: John Krauss Date: Wed, 25 Jan 2017 16:59:37 +0000 Subject: [PATCH] remove plpython and python code for now. also removed mistaken installation of postgres_fdw in tests --- Makefile | 5 - NEWS.md | 1 - src/pg/observatory.control | 4 +- src/pg/sql/60_observatory_providers.sql | 107 ------------------ src/pg/test/expected/01_install_test.out | 2 - src/pg/test/sql/01_install_test.sql | 2 - src/python/Makefile | 9 -- .../observatory/observatory/__init__.py | 0 src/python/observatory/observatory/osm.py | 11 -- src/python/observatory/requirements.txt | 1 - src/python/observatory/setup.py | 50 -------- 11 files changed, 2 insertions(+), 190 deletions(-) delete mode 100644 src/pg/sql/60_observatory_providers.sql delete mode 100644 src/python/Makefile delete mode 100644 src/python/observatory/observatory/__init__.py delete mode 100644 src/python/observatory/observatory/osm.py delete mode 100644 src/python/observatory/requirements.txt delete mode 100644 src/python/observatory/setup.py diff --git a/Makefile b/Makefile index a7b9715..1f613ad 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,6 @@ include ./Makefile.global EXT_DIR = src/pg -PYP_DIR = src/python .PHONY: install .PHONY: run_tests @@ -13,17 +12,14 @@ PYP_DIR = src/python # It requires sudo. install: ## Generate and install development version of the extension; requires sudo. $(MAKE) -C $(EXT_DIR) install - $(MAKE) -C $(PYP_DIR) install # Run the tests for the installed development extension. test: ## Run the tests for the development version of the extension $(MAKE) -C $(EXT_DIR) test - $(MAKE) -C $(PYP_DIR) test # Generate a new release into release release: ## Generate a new release of the extension. Only for release manager $(MAKE) -C $(EXT_DIR) release - $(MAKE) -C $(PYP_DIR) release # Install the current release. # 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 deploy: ## Deploy a released extension. Only for release manager. Requires sudo. $(MAKE) -C $(EXT_DIR) deploy - $(MAKE) -C $(PYP_DIR) deploy # Cleanup development extension script files clean-dev: ## clean up development extension script files diff --git a/NEWS.md b/NEWS.md index adb665f..2ed2022 100644 --- a/NEWS.md +++ b/NEWS.md @@ -9,7 +9,6 @@ __API Changes__ __Improvements__ -* Add support for PL/Python * Generate fixtures from `obs_meta` * Remove unused table-level code * Refactor all augmentation and geometry functions to obtain data from diff --git a/src/pg/observatory.control b/src/pg/observatory.control index b8a1e84..9c2bf9a 100644 --- a/src/pg/observatory.control +++ b/src/pg/observatory.control @@ -1,5 +1,5 @@ comment = 'CartoDB Observatory backend extension' -default_version = '1.1.6' -requires = 'postgis, plpythonu' +default_version = '1.3.0' +requires = 'postgis' superuser = true schema = cdb_observatory diff --git a/src/pg/sql/60_observatory_providers.sql b/src/pg/sql/60_observatory_providers.sql deleted file mode 100644 index e6b8632..0000000 --- a/src/pg/sql/60_observatory_providers.sql +++ /dev/null @@ -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; diff --git a/src/pg/test/expected/01_install_test.out b/src/pg/test/expected/01_install_test.out index 3520122..50dd883 100644 --- a/src/pg/test/expected/01_install_test.out +++ b/src/pg/test/expected/01_install_test.out @@ -1,6 +1,4 @@ -- Install dependencies CREATE EXTENSION postgis; -CREATE EXTENSION postgres_fdw; -CREATE EXTENSION plpythonu; -- Install the extension CREATE EXTENSION observatory VERSION 'dev'; diff --git a/src/pg/test/sql/01_install_test.sql b/src/pg/test/sql/01_install_test.sql index 1fa89c2..5092272 100644 --- a/src/pg/test/sql/01_install_test.sql +++ b/src/pg/test/sql/01_install_test.sql @@ -1,7 +1,5 @@ -- Install dependencies CREATE EXTENSION postgis; -CREATE EXTENSION postgres_fdw; -CREATE EXTENSION plpythonu; -- Install the extension CREATE EXTENSION observatory VERSION 'dev'; diff --git a/src/python/Makefile b/src/python/Makefile deleted file mode 100644 index 77bfcb7..0000000 --- a/src/python/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -include ../../Makefile.global - -# Install the package locally for development - -install: - pip install --upgrade ./observatory - -test: - #TODO noop diff --git a/src/python/observatory/observatory/__init__.py b/src/python/observatory/observatory/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/python/observatory/observatory/osm.py b/src/python/observatory/observatory/osm.py deleted file mode 100644 index e5ea70c..0000000 --- a/src/python/observatory/observatory/osm.py +++ /dev/null @@ -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'] diff --git a/src/python/observatory/requirements.txt b/src/python/observatory/requirements.txt deleted file mode 100644 index 01a8fab..0000000 --- a/src/python/observatory/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -overpass==0.5.6 diff --git a/src/python/observatory/setup.py b/src/python/observatory/setup.py deleted file mode 100644 index 23baf32..0000000 --- a/src/python/observatory/setup.py +++ /dev/null @@ -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' -)