resolve issues in build and with code, now returning geometries and data as expected from obs_getoverpass
This commit is contained in:
parent
ff50c5e2bf
commit
000a440417
5
Makefile
5
Makefile
@ -1,6 +1,7 @@
|
|||||||
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
|
||||||
@ -12,14 +13,17 @@ EXT_DIR = src/pg
|
|||||||
# 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.
|
||||||
@ -27,6 +31,7 @@ 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
|
||||||
|
@ -684,11 +684,13 @@ BEGIN
|
|||||||
Array_Cat(Array_Agg(geom_tablename),
|
Array_Cat(Array_Agg(geom_tablename),
|
||||||
Array_Agg(denom_tablename) FILTER (WHERE denom_tablename IS NOT NULL)))
|
Array_Agg(denom_tablename) FILTER (WHERE denom_tablename IS NOT NULL)))
|
||||||
)) tablename) bar) tablenames,
|
)) tablename) bar) tablenames,
|
||||||
|
|
||||||
String_Agg(numer_tablename || '.' || numer_geomref_colname || ' = ' ||
|
String_Agg(numer_tablename || '.' || numer_geomref_colname || ' = ' ||
|
||||||
geom_tablename || '.' || geom_geomref_colname ||
|
geom_tablename || '.' || geom_geomref_colname ||
|
||||||
Coalesce(' AND ' || numer_tablename || '.' || numer_geomref_colname || ' = ' ||
|
Coalesce(' AND ' || numer_tablename || '.' || numer_geomref_colname || ' = ' ||
|
||||||
denom_tablename || '.' || denom_geomref_colname, ''),
|
denom_tablename || '.' || denom_geomref_colname, ''),
|
||||||
' AND ') AS obs_wheres,
|
' AND ') AS obs_wheres,
|
||||||
|
|
||||||
String_Agg('ST_Intersects(' || geom_tablename || '.' || geom_colname
|
String_Agg('ST_Intersects(' || geom_tablename || '.' || geom_colname
|
||||||
|| ', _geoms.geom)', ' AND ')
|
|| ', _geoms.geom)', ' AND ')
|
||||||
AS user_wheres
|
AS user_wheres
|
||||||
|
@ -1,7 +1,44 @@
|
|||||||
CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetOverpass(query text)
|
CREATE OR REPLACE FUNCTION cdb_observatory._OBS_GetOverpass(
|
||||||
RETURNS table (lat Numeric, lon Numeric, "type" TEXT, id Numeric, tags TEXT) as $$
|
query text
|
||||||
|
) RETURNS TABLE (
|
||||||
|
geom TEXT,
|
||||||
|
"type" TEXT,
|
||||||
|
id TEXT,
|
||||||
|
properties TEXT
|
||||||
|
) AS $$
|
||||||
|
|
||||||
from observatory.osm import get_overpass
|
from observatory.osm import get_overpass
|
||||||
return get_overpass(query)
|
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;
|
$$ 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;
|
||||||
|
@ -1,4 +1,9 @@
|
|||||||
|
include ../../Makefile.global
|
||||||
|
|
||||||
# Install the package locally for development
|
# Install the package locally for development
|
||||||
|
|
||||||
install:
|
install:
|
||||||
pip install --upgrade ./crankshaft
|
pip install --upgrade ./observatory
|
||||||
|
|
||||||
|
test:
|
||||||
|
#TODO noop
|
||||||
|
@ -18,7 +18,20 @@ way
|
|||||||
40.704301, -73.936658))
|
40.704301, -73.936658))
|
||||||
'''
|
'''
|
||||||
|
|
||||||
api = API()
|
'''
|
||||||
response = api.Get(query, responseformat='json')
|
(node [amenity] (around:400, 40.704301, -73.936658); way [amenity] (around:400, 40.704301, -73.936658))
|
||||||
|
'''
|
||||||
|
|
||||||
return [(el['lat'], el['lon'], el['type'], el['id'], json.dumps(el['tags']), ) for el in response['elements'] if 'lat' in el]
|
api = API()
|
||||||
|
response = api.Get(query)
|
||||||
|
|
||||||
|
return response['features']
|
||||||
|
#return [(el['lat'], el['lon'], el['type'], el['id'], json.dumps(el['tags']) )
|
||||||
|
# for el in response['elements'] if 'lat' in el][0]
|
||||||
|
|
||||||
|
|
||||||
|
def get_overpass_poi(within_geom, geom, filters=None, name=None):
|
||||||
|
'''
|
||||||
|
Simplified access to overpass API
|
||||||
|
'''
|
||||||
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user