Skip to content

Commit

Permalink
added unit conversion as plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulworld committed Jul 8, 2018
1 parent 04eccda commit 72fee4d
Show file tree
Hide file tree
Showing 69 changed files with 1,724 additions and 78 deletions.
Binary file modified istsos/actions/__pycache__/action.cpython-36.pyc
Binary file not shown.
35 changes: 7 additions & 28 deletions istsos/actions/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ def __get_proxy(istsos_package, action_module, **kwargs):
state.config["loader"]["type"],
fileName
)
print('GET_Proxy')
print(istsos_package)
print(action_module)

istsos.debug("Importing %s.%s" % (module, action_module))
try:
Expand All @@ -256,36 +259,11 @@ def __get_proxy(istsos_package, action_module, **kwargs):
return m(**kwargs)
return m()

@asyncio.coroutine
def __get_plugin_proxy(istsos_package, action_module, **kwargs):
from istsos import setting
import importlib
state = yield from setting.get_state()
fileName = action_module[0].lower() + action_module[1:]
module = 'istsos.%s.%s.%s' % (
istsos_package,
state.config["loader"]["type"],
fileName
)

istsos.debug("Importing %s.%s" % (module, action_module))
try:
m = importlib.import_module(module)
except Exception:
module = 'istsos.%s.%s' % (
istsos_package,
fileName
)
m = importlib.import_module(module)

m = getattr(m, action_module)
if kwargs is not None:
return m(**kwargs)
return m()


@asyncio.coroutine
def get_plugin(plugin, name, **kwargs):
print('GET_PLUGIN')
print(plugin)
print(name)
import importlib
fileName = name[0].lower() + name[1:]
module = 'istsos.plugins.%s.%s.%s' % (
Expand All @@ -304,6 +282,7 @@ def get_plugin(plugin, name, **kwargs):
m = importlib.import_module(module)

m = getattr(m, name)
print(m)
if kwargs is not None:
return m(**kwargs)
return m()
Expand Down
Binary file not shown.
Binary file not shown.
49 changes: 0 additions & 49 deletions istsos/plugins/unit_con_post/postgresql_unit.py

This file was deleted.

4 changes: 4 additions & 0 deletions istsos/plugins/unit_con_post/retrievers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# istSOS3 - Retrievers

In this folder contains all the actions capable of storing the entities into
a database.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
46 changes: 46 additions & 0 deletions istsos/plugins/unit_con_post/retrievers/aiopg/featureOfInterest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# -*- coding: utf-8 -*-
# istSOS. See https://istsos.org/
# License: https://github.com/istSOS/istsos3/master/LICENSE.md
# Version: v3.0.0

import asyncio
from istsos.actions.retrievers.featureOfInterest import (
FeatureOfInterest
)


class FeatureOfInterest(FeatureOfInterest):
"""Return a single Feature of Interest based on identifier filter
"""

@asyncio.coroutine
def process(self, request):
"""Load all the featureOfInterest
"""
dbmanager = yield from self.init_connection()
cur = dbmanager.cur
identifier = request.get_filter(self._IDENTIFIER)

if identifier is not None:
yield from cur.execute("""
SELECT
row_to_json(t)
FROM (
SELECT
id,
description,
identifier,
foi_name as name,
foi_type as type,
(
ST_AsGeoJSON(ST_Force2D(geom))
)::json as shape
FROM
public.fois
WHERE
fois.identifier = %s
) t;
""", (identifier,))
rec = yield from cur.fetchone()
if rec is not None:
request['featureOfInterest'] = rec[0]
Loading

0 comments on commit 72fee4d

Please sign in to comment.