diff --git a/.gitignore b/.gitignore index c17e1f1..2aedae2 100644 --- a/.gitignore +++ b/.gitignore @@ -11,9 +11,11 @@ Dockerfile.pg Dockerfile.pr Dockerfile.gs *.gdb +*.ags +*.sde ImportLog* -demo/arcgis/CIP-service/.backups/ -demo/arcgis/CIP-service/GpMessages/ -demo/arcgis/CIP-service/scratch/ -demo/arcgis/CIP-service/Index/ -/demo/jupyter/.ipynb_checkpoints +**/.backups/ +**/GpMessages/ +**/scratch/ +**/Index/ +**/jupyter/.ipynb_checkpoints diff --git a/admin/jupyter/notebooks/common.py b/admin/jupyter/notebooks/common.py index 86f0f92..26aea02 100644 --- a/admin/jupyter/notebooks/common.py +++ b/admin/jupyter/notebooks/common.py @@ -23,16 +23,6 @@ def pg_restore(host_name,host_port,database_name,user_name,database_password,dum return p.communicate(bytes('{}\n'.format(database_password),'utf-8')); -def ogr2ogr(cmdstring): - - command = 'ogr2ogr {0}'.format(cmdstring); - - command = shlex.split(command); - - p = Popen(command,shell=False,stdin=PIPE,stdout=PIPE,stderr=PIPE); - - return p.communicate(); - def ogr2ogr(cmdstring): command = 'ogr2ogr {0}'.format(cmdstring); diff --git a/admin/jupyter/notebooks/setup/git_checkout_cipsrv_engine.ipynb b/admin/jupyter/notebooks/setup/git_checkout_cipsrv_engine.ipynb index d584b55..38e49ed 100644 --- a/admin/jupyter/notebooks/setup/git_checkout_cipsrv_engine.ipynb +++ b/admin/jupyter/notebooks/setup/git_checkout_cipsrv_engine.ipynb @@ -18,6 +18,7 @@ "from IPython.display import display;\n", "parser = argparse.ArgumentParser();\n", "parser.add_argument(\"--override_branch\" ,required=False);\n", + "parser.add_argument(\"--use_existing_sql\",required=False);\n", "args, _ = parser.parse_known_args();\n", "\n", "sys.path.append(os.path.join(os.path.expanduser('~'),'notebooks'));\n", @@ -71,16 +72,23 @@ "metadata": {}, "outputs": [], "source": [ - "td = tempfile.TemporaryDirectory();\n", - "\n", - "repo = git.Repo.clone_from(\n", - " url = gith\n", - " ,branch = brnh\n", - " ,to_path = td.name \n", - " ,depth = 1\n", - ");\n", - "\n", - "print(\"checkout complete.\");" + "if args.use_existing_sql is not None:\n", + " trg = args.use_existing_sql;\n", + " print(\"using existing \" + trg);\n", + " \n", + "else:\n", + " td = tempfile.TemporaryDirectory();\n", + " \n", + " repo = git.Repo.clone_from(\n", + " url = gith\n", + " ,branch = brnh\n", + " ,to_path = td.name\n", + " ,depth = 1\n", + " );\n", + " \n", + " print(\"checkout of \" + td.name + \" complete.\");\n", + " trg = os.path.join(td.name,depf);\n", + " " ] }, { @@ -89,10 +97,8 @@ "metadata": {}, "outputs": [], "source": [ - "trg = os.path.join(td.name,depf);\n", - "\n", "if not os.path.exists(trg):\n", - " raise Exception(trg + ' file not found.');\n", + " raise Exception(trg + ' not found.');\n", " \n", "z = common.load_sqlfile(conn,trg,echo=True);\n" ] @@ -104,7 +110,9 @@ "outputs": [], "source": [ "conn.close();\n", - "td.cleanup();\n", + "\n", + "if args.use_existing_sql is None:\n", + " td.cleanup();\n", "\n", "print(\"logic load complete.\");" ] diff --git a/admin/jupyter/notebooks/setup/git_checkout_cipsrv_nhdplus_h.ipynb b/admin/jupyter/notebooks/setup/git_checkout_cipsrv_nhdplus_h.ipynb index 339fe00..7fe485e 100644 --- a/admin/jupyter/notebooks/setup/git_checkout_cipsrv_nhdplus_h.ipynb +++ b/admin/jupyter/notebooks/setup/git_checkout_cipsrv_nhdplus_h.ipynb @@ -18,6 +18,7 @@ "from IPython.display import display;\n", "parser = argparse.ArgumentParser();\n", "parser.add_argument(\"--override_branch\" ,required=False);\n", + "parser.add_argument(\"--use_existing_sql\",required=False);\n", "args, _ = parser.parse_known_args();\n", "\n", "sys.path.append(os.path.join(os.path.expanduser('~'),'notebooks'));\n", @@ -71,16 +72,23 @@ "metadata": {}, "outputs": [], "source": [ - "td = tempfile.TemporaryDirectory();\n", - "\n", - "repo = git.Repo.clone_from(\n", - " url = gith\n", - " ,branch = brnh\n", - " ,to_path = td.name \n", - " ,depth = 1\n", - ");\n", - "\n", - "print(\"checkout complete.\");" + "if args.use_existing_sql is not None:\n", + " trg = args.use_existing_sql;\n", + " print(\"using existing \" + trg);\n", + " \n", + "else:\n", + " td = tempfile.TemporaryDirectory();\n", + " \n", + " repo = git.Repo.clone_from(\n", + " url = gith\n", + " ,branch = brnh\n", + " ,to_path = td.name\n", + " ,depth = 1\n", + " );\n", + " \n", + " print(\"checkout of \" + td.name + \" complete.\");\n", + " trg = os.path.join(td.name,depf);\n", + " " ] }, { @@ -89,10 +97,8 @@ "metadata": {}, "outputs": [], "source": [ - "trg = os.path.join(td.name,depf);\n", - "\n", "if not os.path.exists(trg):\n", - " raise Exception(trg + ' file not found.');\n", + " raise Exception(trg + ' not found.');\n", " \n", "z = common.load_sqlfile(conn,trg,echo=True);\n" ] @@ -104,7 +110,9 @@ "outputs": [], "source": [ "conn.close();\n", - "td.cleanup();\n", + "\n", + "if args.use_existing_sql is None:\n", + " td.cleanup();\n", "\n", "print(\"logic load complete.\");" ] diff --git a/admin/jupyter/notebooks/setup/git_checkout_cipsrv_nhdplus_m.ipynb b/admin/jupyter/notebooks/setup/git_checkout_cipsrv_nhdplus_m.ipynb index 6c1f55e..d4ad0da 100644 --- a/admin/jupyter/notebooks/setup/git_checkout_cipsrv_nhdplus_m.ipynb +++ b/admin/jupyter/notebooks/setup/git_checkout_cipsrv_nhdplus_m.ipynb @@ -18,6 +18,7 @@ "from IPython.display import display;\n", "parser = argparse.ArgumentParser();\n", "parser.add_argument(\"--override_branch\" ,required=False);\n", + "parser.add_argument(\"--use_existing_sql\",required=False);\n", "args, _ = parser.parse_known_args();\n", "\n", "sys.path.append(os.path.join(os.path.expanduser('~'),'notebooks'));\n", @@ -71,16 +72,23 @@ "metadata": {}, "outputs": [], "source": [ - "td = tempfile.TemporaryDirectory();\n", - "\n", - "repo = git.Repo.clone_from(\n", - " url = gith\n", - " ,branch = brnh\n", - " ,to_path = td.name \n", - " ,depth = 1\n", - ");\n", - "\n", - "print(\"checkout complete.\");" + "if args.use_existing_sql is not None:\n", + " trg = args.use_existing_sql;\n", + " print(\"using existing \" + trg);\n", + " \n", + "else:\n", + " td = tempfile.TemporaryDirectory();\n", + " \n", + " repo = git.Repo.clone_from(\n", + " url = gith\n", + " ,branch = brnh\n", + " ,to_path = td.name\n", + " ,depth = 1\n", + " );\n", + " \n", + " print(\"checkout of \" + td.name + \" complete.\");\n", + " trg = os.path.join(td.name,depf);\n", + " " ] }, { @@ -89,10 +97,8 @@ "metadata": {}, "outputs": [], "source": [ - "trg = os.path.join(td.name,depf);\n", - "\n", "if not os.path.exists(trg):\n", - " raise Exception(trg + ' file not found.');\n", + " raise Exception(trg + ' not found.');\n", " \n", "z = common.load_sqlfile(conn,trg,echo=True);\n" ] @@ -104,7 +110,9 @@ "outputs": [], "source": [ "conn.close();\n", - "td.cleanup();\n", + "\n", + "if args.use_existing_sql is None:\n", + " td.cleanup();\n", "\n", "print(\"logic load complete.\");" ] diff --git a/admin/jupyter/notebooks/setup/git_checkout_cipsrv_owld.ipynb b/admin/jupyter/notebooks/setup/git_checkout_cipsrv_owld.ipynb new file mode 100644 index 0000000..dc09eca --- /dev/null +++ b/admin/jupyter/notebooks/setup/git_checkout_cipsrv_owld.ipynb @@ -0,0 +1,149 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## git_checkout cipsrv_owld" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import os,sys,git,tempfile,psycopg2,argparse;\n", + "from ipywidgets import IntProgress,HTML,VBox;\n", + "from IPython.display import display;\n", + "parser = argparse.ArgumentParser();\n", + "parser.add_argument(\"--override_branch\" ,required=False);\n", + "parser.add_argument(\"--use_existing_sql\",required=False);\n", + "args, _ = parser.parse_known_args();\n", + "\n", + "sys.path.append(os.path.join(os.path.expanduser('~'),'notebooks'));\n", + "import common;\n", + "\n", + "gith = os.environ['GITHUB_REPO_URL'];\n", + "# override: \"git@github.com:USEPA/CIPv2.git\"\n", + "if args.override_branch is not None:\n", + " brnh = args.override_branch;\n", + "else:\n", + " brnh = os.environ['GITHUB_DEFAULT_BRANCH'];\n", + "# override: \"mybranch\"\n", + "\n", + "dbse = os.environ['POSTGRESQL_DB'];\n", + "host = os.environ['POSTGRESQL_HOST'];\n", + "port = os.environ['POSTGRESQL_PORT'];\n", + "user = 'cipsrv';\n", + "pasw = os.environ['POSTGRESQL_CIP_PASS'];\n", + "\n", + "depf = os.path.join('src','database','cipsrv_owld','cipsrv_owld_deploy.sql');\n", + "\n", + "print(\"repo: \" + gith);\n", + "print(\"branch: \" + brnh);" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "cs = \"dbname=%s user=%s password=%s host=%s port=%s\" % (\n", + " dbse\n", + " ,user\n", + " ,pasw\n", + " ,host\n", + " ,port\n", + ");\n", + "\n", + "try:\n", + " conn = psycopg2.connect(cs);\n", + "except:\n", + " raise Exception(\"database connection error\");\n", + " \n", + "print(\"database is ready\");" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "if args.use_existing_sql is not None:\n", + " trg = args.use_existing_sql;\n", + " print(\"using existing \" + trg);\n", + " \n", + "else:\n", + " td = tempfile.TemporaryDirectory();\n", + " \n", + " repo = git.Repo.clone_from(\n", + " url = gith\n", + " ,branch = brnh\n", + " ,to_path = td.name\n", + " ,depth = 1\n", + " );\n", + " \n", + " print(\"checkout of \" + td.name + \" complete.\");\n", + " trg = os.path.join(td.name,depf);\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "if not os.path.exists(trg):\n", + " raise Exception(trg + ' not found.');\n", + " \n", + "z = common.load_sqlfile(conn,trg,echo=True);\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "conn.close();\n", + "\n", + "if args.use_existing_sql is None:\n", + " td.cleanup();\n", + "\n", + "print(\"logic load complete.\");" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.12.3" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/admin/jupyter/notebooks/setup/git_checkout_cipsrv_pgrest.ipynb b/admin/jupyter/notebooks/setup/git_checkout_cipsrv_pgrest.ipynb index a2bd6f3..5b11c76 100644 --- a/admin/jupyter/notebooks/setup/git_checkout_cipsrv_pgrest.ipynb +++ b/admin/jupyter/notebooks/setup/git_checkout_cipsrv_pgrest.ipynb @@ -18,6 +18,7 @@ "from IPython.display import display;\n", "parser = argparse.ArgumentParser();\n", "parser.add_argument(\"--override_branch\" ,required=False);\n", + "parser.add_argument(\"--use_existing_sql\",required=False);\n", "args, _ = parser.parse_known_args();\n", "\n", "sys.path.append(os.path.join(os.path.expanduser('~'),'notebooks'));\n", @@ -71,16 +72,23 @@ "metadata": {}, "outputs": [], "source": [ - "td = tempfile.TemporaryDirectory();\n", - "\n", - "repo = git.Repo.clone_from(\n", - " url = gith\n", - " ,branch = brnh\n", - " ,to_path = td.name \n", - " ,depth = 1\n", - ");\n", - "\n", - "print(\"checkout complete.\");" + "if args.use_existing_sql is not None:\n", + " trg = args.use_existing_sql;\n", + " print(\"using existing \" + trg);\n", + " \n", + "else:\n", + " td = tempfile.TemporaryDirectory();\n", + " \n", + " repo = git.Repo.clone_from(\n", + " url = gith\n", + " ,branch = brnh\n", + " ,to_path = td.name\n", + " ,depth = 1\n", + " );\n", + " \n", + " print(\"checkout of \" + td.name + \" complete.\");\n", + " trg = os.path.join(td.name,depf);\n", + " " ] }, { @@ -89,10 +97,8 @@ "metadata": {}, "outputs": [], "source": [ - "trg = os.path.join(td.name,depf);\n", - "\n", "if not os.path.exists(trg):\n", - " raise Exception(trg + ' file not found.');\n", + " raise Exception(trg + ' not found.');\n", " \n", "z = common.load_sqlfile(conn,trg,echo=True);\n" ] @@ -104,7 +110,9 @@ "outputs": [], "source": [ "conn.close();\n", - "td.cleanup();\n", + "\n", + "if args.use_existing_sql is None:\n", + " td.cleanup();\n", "\n", "print(\"logic load complete.\");" ] diff --git a/admin/jupyter/notebooks/setup/git_checkout_cipsrv_support.ipynb b/admin/jupyter/notebooks/setup/git_checkout_cipsrv_support.ipynb index 8afd605..86bb5f7 100644 --- a/admin/jupyter/notebooks/setup/git_checkout_cipsrv_support.ipynb +++ b/admin/jupyter/notebooks/setup/git_checkout_cipsrv_support.ipynb @@ -18,6 +18,7 @@ "from IPython.display import display;\n", "parser = argparse.ArgumentParser();\n", "parser.add_argument(\"--override_branch\" ,required=False);\n", + "parser.add_argument(\"--use_existing_sql\",required=False);\n", "args, _ = parser.parse_known_args();\n", "\n", "sys.path.append(os.path.join(os.path.expanduser('~'),'notebooks'));\n", @@ -71,16 +72,23 @@ "metadata": {}, "outputs": [], "source": [ - "td = tempfile.TemporaryDirectory();\n", - "\n", - "repo = git.Repo.clone_from(\n", - " url = gith\n", - " ,branch = brnh\n", - " ,to_path = td.name \n", - " ,depth = 1\n", - ");\n", - "\n", - "print(\"checkout complete.\");" + "if args.use_existing_sql is not None:\n", + " trg = args.use_existing_sql;\n", + " print(\"using existing \" + trg);\n", + " \n", + "else:\n", + " td = tempfile.TemporaryDirectory();\n", + " \n", + " repo = git.Repo.clone_from(\n", + " url = gith\n", + " ,branch = brnh\n", + " ,to_path = td.name\n", + " ,depth = 1\n", + " );\n", + " \n", + " print(\"checkout of \" + td.name + \" complete.\");\n", + " trg = os.path.join(td.name,depf);\n", + " " ] }, { @@ -89,10 +97,8 @@ "metadata": {}, "outputs": [], "source": [ - "trg = os.path.join(td.name,depf);\n", - "\n", "if not os.path.exists(trg):\n", - " raise Exception(trg + ' file not found.');\n", + " raise Exception(trg + ' not found.');\n", " \n", "z = common.load_sqlfile(conn,trg,echo=True);\n" ] @@ -104,7 +110,9 @@ "outputs": [], "source": [ "conn.close();\n", - "td.cleanup();\n", + "\n", + "if args.use_existing_sql is None:\n", + " td.cleanup();\n", "\n", "print(\"logic load complete.\");" ] diff --git a/admin/jupyter/notebooks/setup/pg_restore_cipsrv_owld.ipynb b/admin/jupyter/notebooks/setup/pg_restore_cipsrv_owld.ipynb new file mode 100644 index 0000000..e26903e --- /dev/null +++ b/admin/jupyter/notebooks/setup/pg_restore_cipsrv_owld.ipynb @@ -0,0 +1,192 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## pg_restore cipsrv_owld" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import os,sys,psycopg2,argparse;\n", + "from ipywidgets import IntProgress,HTML,VBox;\n", + "from IPython.display import display;\n", + "from contextlib import closing;\n", + "parser = argparse.ArgumentParser();\n", + "parser.add_argument(\"--owld_dumpfiles\" ,required=False);\n", + "parser.add_argument(\"--use_existing\" ,required=False,default=False,action=argparse.BooleanOptionalAction);\n", + "args, _ = parser.parse_known_args();\n", + "\n", + "sys.path.append(os.path.join(os.path.expanduser('~'),'notebooks'));\n", + "import common;\n", + "\n", + "s3bk = os.environ['S3_BUCKET'] + 'owld/';\n", + "# override: s3bk = 'https://edap-ow-data-commons.s3.amazonaws.com/data/cipsrv/owld/';\n", + "lddk = os.path.join(os.path.expanduser('~'),'loading_dock');\n", + "dbse = os.environ['POSTGRESQL_DB'];\n", + "host = os.environ['POSTGRESQL_HOST'];\n", + "port = os.environ['POSTGRESQL_PORT'];\n", + "user = 'cipsrv';\n", + "pswd = os.environ['POSTGRESQL_CIP_PASS'];\n", + "thds = 2;\n", + "\n", + "if args.owld_dumpfiles is None:\n", + " srcs = 'WQP:cipsrv_owld_wqp_20241006.dmp';\n", + "else:\n", + " srcs = args.owld_dumpfiles;\n", + "\n", + "ary_src = srcs.split(',');\n", + "for item in ary_src:\n", + " (pref,src)=item.split(':');\n", + " print(pref + \" source: \" + s3bk + src);\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for item in ary_src:\n", + " (pref,src)=item.split(':');\n", + " \n", + " if args.use_existing:\n", + " print(\"using existing \" + src);\n", + " \n", + " else:\n", + " z = common.download(\n", + " s3 = s3bk\n", + " ,src = src\n", + " ,ld = lddk\n", + " ,trg = src\n", + " );\n", + " \n", + " if not os.path.exists(os.path.join(lddk,src)):\n", + " raise Exception('failed to download dmp file');\n", + " \n", + " print(\"successfully downloaded \" + src);\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "cs = \"dbname=%s user=%s password=%s host=%s port=%s\" % (\n", + " dbse\n", + " ,user\n", + " ,pswd\n", + " ,host\n", + " ,port\n", + ");\n", + "\n", + "try:\n", + " conn = psycopg2.connect(cs);\n", + "except:\n", + " raise Exception(\"database connection error\");\n", + "\n", + "print(\"database is ready\");" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for item in ary_src:\n", + " (pref,src)=item.split(':');\n", + " \n", + " with closing(conn.cursor()) as cursor:\n", + " cursor.execute(\"DROP TABLE IF EXISTS cipsrv_owld.\" + pref + \"_attr CASCADE\");\n", + " cursor.execute(\"DROP TABLE IF EXISTS cipsrv_owld.\" + pref + \"_cip CASCADE\");\n", + " cursor.execute(\"DROP TABLE IF EXISTS cipsrv_owld.\" + pref + \"_cip_geo CASCADE\");\n", + " cursor.execute(\"DROP TABLE IF EXISTS cipsrv_owld.\" + pref + \"_huc12 CASCADE\");\n", + " cursor.execute(\"DROP TABLE IF EXISTS cipsrv_owld.\" + pref + \"_huc12_geo CASCADE\");\n", + " cursor.execute(\"DROP TABLE IF EXISTS cipsrv_owld.\" + pref + \"_rad_a CASCADE\");\n", + " cursor.execute(\"DROP TABLE IF EXISTS cipsrv_owld.\" + pref + \"_rad_evt2meta CASCADE\");\n", + " cursor.execute(\"DROP TABLE IF EXISTS cipsrv_owld.\" + pref + \"_rad_l CASCADE\");\n", + " cursor.execute(\"DROP TABLE IF EXISTS cipsrv_owld.\" + pref + \"_rad_metadata CASCADE\");\n", + " cursor.execute(\"DROP TABLE IF EXISTS cipsrv_owld.\" + pref + \"_rad_p CASCADE\");\n", + " cursor.execute(\"DROP TABLE IF EXISTS cipsrv_owld.\" + pref + \"_rad_srccit CASCADE\");\n", + " cursor.execute(\"DROP TABLE IF EXISTS cipsrv_owld.\" + pref + \"_sfid CASCADE\");\n", + " cursor.execute(\"DROP TABLE IF EXISTS cipsrv_owld.\" + pref + \"_src2cip CASCADE\");\n", + " cursor.execute(\"DROP TABLE IF EXISTS cipsrv_owld.\" + pref + \"_src_a CASCADE\");\n", + " cursor.execute(\"DROP TABLE IF EXISTS cipsrv_owld.\" + pref + \"_src_l CASCADE\");\n", + " cursor.execute(\"DROP TABLE IF EXISTS cipsrv_owld.\" + pref + \"_src_p CASCADE\");\n", + " conn.commit();\n", + " \n", + " print(\"preexisting \" + pref + \" data purged.\");" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for item in ary_src:\n", + " (pref,src)=item.split(':');\n", + " \n", + " z = common.pg_restore(\n", + " host\n", + " ,port\n", + " ,dbse\n", + " ,user\n", + " ,pswd\n", + " ,os.path.join(lddk,src)\n", + " ,thds\n", + " );\n", + " \n", + " print(\"pg_restore for \" + pref + \" complete.\");\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "if z[0] != b'':\n", + " print(str(z));\n", + " sys.exit(-10);\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.12.3" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/config/config-compose.py b/config/config-compose.py index 1202651..61eb1da 100644 --- a/config/config-compose.py +++ b/config/config-compose.py @@ -37,7 +37,7 @@ def main( outdir = templates; profiles = os.path.join(templates,"profiles"); - time_now = datetime.datetime.utcnow(); + time_now = datetime.datetime.now(datetime.timezone.utc); environment = jinja2.Environment(loader=jinja2.FileSystemLoader(templates)); diff --git a/config/quickconfig.py b/config/quickconfig.py index 5c16f9e..d7b59f8 100644 --- a/config/quickconfig.py +++ b/config/quickconfig.py @@ -42,6 +42,9 @@ parser.add_argument("--hrws_dumpfile" ,required=False,default=None); parser.add_argument("--hrws_dumpfile_copyin" ,required=False,default=None); +parser.add_argument("--owld_dumpfiles" ,required=False,default=None); +parser.add_argument("--owld_dumpfiles_copyin" ,required=False,default=None); + parser.add_argument("--support_dumpfile" ,required=False,default=None); parser.add_argument("--support_dumpfile_copyin" ,required=False,default=None); @@ -49,6 +52,7 @@ parser.add_argument("--override_demo_pgrst_host",required=False,default=None); parser.add_argument("--override_engine_profile" ,required=False,default=None); parser.add_argument("--override_git_branch" ,required=False,default=None); +parser.add_argument("--force_nogit_uselocal" ,required=False,default=False,action=argparse.BooleanOptionalAction); parser.add_argument("--down_volumes" ,required=False,default=False,action=argparse.BooleanOptionalAction); parser.add_argument("--build_nocache" ,required=False,default=False,action=argparse.BooleanOptionalAction); @@ -85,6 +89,9 @@ def main( ,hrws_dumpfile ,hrws_dumpfile_copyin + ,owld_dumpfiles + ,owld_dumpfiles_copyin + ,support_dumpfile ,support_dumpfile_copyin @@ -92,6 +99,7 @@ def main( ,override_demo_pgrst_host ,override_engine_profile ,override_git_branch + ,force_nogit_uselocal ,down_volumes ,build_nocache ): @@ -127,6 +135,7 @@ def cipld( ,dumpfile ,dumpfile_copyin ,dumpfile_parm + ,multi_flag = False ): cmd = [ "docker","compose","exec","cip_jp","jupyter" @@ -136,10 +145,28 @@ def cipld( dzproc(cmd); if dumpfile_copyin is not None: - mdf = os.path.basename(dumpfile_copyin); - print("Loading local " + ipnyb + " dumpfile " + mdf + " into container."); - cmd = ["docker","compose","cp",dumpfile_copyin,"cip_jp:/home/jovyan/loading_dock/" + mdf]; - dzproc(cmd); + + if multi_flag: + + mdf = ""; + for item in dumpfile_copyin.split(','): + (pref,file) = item.split(':'); + + mdf2 = os.path.basename(file); + print("Loading local " + item + " dumpfile " + file + " into container."); + cmd = ["docker","compose","cp",file,"cip_jp:/home/jovyan/loading_dock/" + mdf2]; + dzproc(cmd); + + mdf += pref + ":" + mdf2 + ","; + + mdf = mdf.rstrip(','); + + else: + mdf = os.path.basename(dumpfile_copyin); + print("Loading local " + ipnyb + " dumpfile " + mdf + " into container."); + cmd = ["docker","compose","cp",dumpfile_copyin,"cip_jp:/home/jovyan/loading_dock/" + mdf]; + dzproc(cmd); + cmd = ["docker","compose","exec","cip_jp","python3","/tmp/pg_restore_" + ipnyb + ".py","--use_existing",dumpfile_parm,mdf]; dzproc(cmd); @@ -153,21 +180,32 @@ def cipld( print("Downloading and importing " + dumpfile + " of " + ipnyb + " data."); cmd = ["docker","compose","exec","cip_jp","python3","/tmp/pg_restore_" + ipnyb + ".py",dumpfile_parm,dumpfile]; dzproc(cmd); - + ################################################################################## def cipgt( ipnyb - ,override_git_branch = None + ,override_git_branch = None + ,force_nogit_uselocal = False ): print("Fetching and loading " + ipnyb + " logic."); cmd = ["docker","compose","exec","cip_jp","jupyter","nbconvert","/home/jovyan/notebooks/setup/git_checkout_" + ipnyb + ".ipynb","--to","python","--output","/tmp/git_checkout_" + ipnyb + ".py"]; dzproc(cmd); - if override_git_branch is not None: - cmd = ["docker","compose","exec","cip_jp","python3","/tmp/git_checkout_" + ipnyb + ".py","--override_git_branch",override_git_branch]; + + if force_nogit_uselocal: + print("Loading " + ipnyb + "_deploy.sql into container."); + cmd = ["docker","compose","cp","../src/database/" + ipnyb + "/" + ipnyb + "_deploy.sql","cip_jp:/tmp/" + ipnyb + "_deploy.sql"]; + dzproc(cmd); + + cmd = ["docker","compose","exec","cip_jp","python3","/tmp/git_checkout_" + ipnyb + ".py","--use_existing_sql","/tmp/" + ipnyb + "_deploy.sql"]; + dzproc(cmd); + else: - cmd = ["docker","compose","exec","cip_jp","python3","/tmp/git_checkout_" + ipnyb + ".py"]; - dzproc(cmd); - + if override_git_branch is not None: + cmd = ["docker","compose","exec","cip_jp","python3","/tmp/git_checkout_" + ipnyb + ".py","--override_branch",override_git_branch]; + else: + cmd = ["docker","compose","exec","cip_jp","python3","/tmp/git_checkout_" + ipnyb + ".py"]; + + dzproc(cmd); ############################################################################### if mr_dumpfile_copyin is not None: @@ -217,7 +255,15 @@ def cipgt( if hrws_dumpfile_copyin is not None: if not os.path.exists(hrws_dumpfile_copyin): raise Exception("hrws_dumpfile_copyin not found - " + str(hrws_dumpfile_copyin)); + + if owld_dumpfiles_copyin is not None: + for item in owld_dumpfiles_copyin.split(','): + (pref,file) = item.split(':'); + if not os.path.exists(file): + raise Exception("owld_dumpfiles_copyin for " + pref + " not found - " + str(file)); + ############################################################################### + # set context to project directory ############################################################################### os.chdir(os.path.dirname(os.path.realpath(__file__))); @@ -260,8 +306,11 @@ def cipgt( dzproc(cmd); + ############################################################################### + # set context to config directory + ############################################################################### os.chdir('../config'); - + ############################################################################### if recipe is None: recipe = 'MRONLY'; @@ -310,9 +359,12 @@ def cipgt( ,bprofile = "default" ); + ############################################################################### + # set context to engine container ############################################################################### os.chdir('../engine'); - + ############################################################################### + if override_postgresql_port is not None: shutil.move('docker-compose.yml','docker-compose.yml.bak'); @@ -335,8 +387,11 @@ def cipgt( cmd = ["docker","compose","up","-d"]; dzproc(cmd); + ############################################################################### + # set context to demo container ############################################################################### os.chdir('../demo'); + ############################################################################### if override_demo_pgrst_host is not None: shutil.move('.env','.env.bak'); @@ -373,8 +428,13 @@ def cipgt( cmd = ["docker","compose","up","-d"]; dzproc(cmd); + ############################################################################### + # set context to admin container ############################################################################### os.chdir('../admin'); + ############################################################################### + + ############################################################################### print("Running compose build for admin containers."); cmd = ["docker","compose","build"]; if build_nocache: @@ -397,8 +457,9 @@ def cipgt( # Support Logic cipgt( - ipnyb = 'cipsrv_support' - ,override_git_branch = override_git_branch + ipnyb = 'cipsrv_support' + ,override_git_branch = override_git_branch + ,force_nogit_uselocal = force_nogit_uselocal ); z = 0; @@ -421,8 +482,9 @@ def cipgt( # NHDPlus MR Logic cipgt( - ipnyb = 'cipsrv_nhdplus_m' - ,override_git_branch = override_git_branch + ipnyb = 'cipsrv_nhdplus_m' + ,override_git_branch = override_git_branch + ,force_nogit_uselocal = force_nogit_uselocal ); z += 1; @@ -445,8 +507,9 @@ def cipgt( # HR Logic cipgt( - ipnyb = 'cipsrv_nhdplus_h' - ,override_git_branch = override_git_branch + ipnyb = 'cipsrv_nhdplus_h' + ,override_git_branch = override_git_branch + ,force_nogit_uselocal = force_nogit_uselocal ); z += 1; @@ -532,17 +595,53 @@ def cipgt( ,dumpfile_copyin = mrws_dumpfile_copyin ,dumpfile_parm = '--mrws_dumpfile' ); - + + ############################################################################### + # OWLD + ############################################################################### + if recipe in ['EXTENDED']: + # OWLD datasets + cipld( + ipnyb = 'cipsrv_owld' + ,dumpfile = owld_dumpfiles + ,dumpfile_copyin = owld_dumpfiles_copyin + ,dumpfile_parm = '--owld_dumpfiles' + ,multi_flag = True + ); + + cipgt( + ipnyb = 'cipsrv_owld' + ,override_git_branch = override_git_branch + ,force_nogit_uselocal = force_nogit_uselocal + ); + + ############################################################################### + # GIS + ############################################################################### + if recipe in ['EXTENDED']: + + cipgt( + ipnyb = 'cipsrv_gis' + ,override_git_branch = override_git_branch + ,force_nogit_uselocal = force_nogit_uselocal + ); + + ############################################################################### + # Engine ############################################################################### cipgt( - ipnyb = 'cipsrv_engine' - ,override_git_branch = override_git_branch + ipnyb = 'cipsrv_engine' + ,override_git_branch = override_git_branch + ,force_nogit_uselocal = force_nogit_uselocal ); + ############################################################################### + # PGRest ############################################################################### cipgt( - ipnyb = 'cipsrv_pgrest' - ,override_git_branch = override_git_branch + ipnyb = 'cipsrv_pgrest' + ,override_git_branch = override_git_branch + ,force_nogit_uselocal = force_nogit_uselocal ); ############################################################################### @@ -585,6 +684,9 @@ def cipgt( ,hrws_dumpfile = args.hrws_dumpfile ,hrws_dumpfile_copyin = args.hrws_dumpfile_copyin + ,owld_dumpfiles = args.owld_dumpfiles + ,owld_dumpfiles_copyin = args.owld_dumpfiles_copyin + ,support_dumpfile = args.support_dumpfile ,support_dumpfile_copyin = args.support_dumpfile_copyin @@ -592,6 +694,7 @@ def cipgt( ,override_demo_pgrst_host = args.override_demo_pgrst_host ,override_engine_profile = args.override_engine_profile ,override_git_branch = args.override_git_branch + ,force_nogit_uselocal = args.force_nogit_uselocal ,down_volumes = args.down_volumes ,build_nocache = args.build_nocache ); diff --git a/demo/Dockerfileng.j2 b/demo/Dockerfileng.j2 index 84e4662..35c0a39 100644 --- a/demo/Dockerfileng.j2 +++ b/demo/Dockerfileng.j2 @@ -2,6 +2,12 @@ FROM nginx:1.27.2 LABEL maintainer="Paul Dziemiela " +{%- if cip_pr_prot == 'env.POSTGREST_PROT' %} +{%- set postgrest_prot = '${ARG_POSTGREST_PROT}' %} +ARG ARG_POSTGREST_PROT +{%- else %} +{%- set postgrest_prot = cip_pr_prot %} +{%- endif %} {%- if cip_pr_host == 'env.POSTGREST_HOST' %} {%- set postgrest_host = '${ARG_POSTGREST_HOST}' %} ARG ARG_POSTGREST_HOST @@ -24,12 +30,14 @@ RUN apt-get update &&\ COPY ./nginx/html /usr/share/nginx/html COPY ./nginx/nginx.conf /etc/nginx/conf.d/default.conf +COPY --from=docs ./openapi.yml /usr/share/nginx/html/openapi.yml RUN printf "\ + const postgrest_prot = '{{ postgrest_prot }}';\n\ const postgrest_host = '{{ postgrest_host }}';\n\ const postgrest_port = '{{ postgrest_port }}';\n\ " > /usr/share/nginx/html/config.js - + EXPOSE 80 CMD ["nginx", "-g", "daemon off;"] diff --git a/demo/docker-compose.j2 b/demo/docker-compose.j2 index fcf8495..2dd98ff 100644 --- a/demo/docker-compose.j2 +++ b/demo/docker-compose.j2 @@ -33,8 +33,15 @@ services: cip_ng: build: context: . + additional_contexts: + docs: ../docs dockerfile: Dockerfile.ng args: +{%- if cip_pr_prot == "env.POSTGREST_PROT" %} + ARG_POSTGREST_PROT: ${POSTGREST_PROT:-http} +{%- else %} + ARG_POSTGREST_PROT: {{ cip_pr_prot }} +{%- endif %} {%- if cip_pr_host == "env.POSTGREST_HOST" %} ARG_POSTGREST_HOST: ${POSTGREST_HOST:-localhost} {%- else %} diff --git a/demo/env.example b/demo/env.example index 3ac981b..0dc16d4 100644 --- a/demo/env.example +++ b/demo/env.example @@ -1,13 +1,11 @@ # All profiles require an .env file to contain your project secrets # Use this template to fill out the needed double-quoted values # -# The demos run locally within a web browser and thus must "know" where the CIP API resides. In the most straightforward case that will be your localhost -# address where docker is running. If docker resides elsewhere or you are using an external engine API, then update this value to that location. -# Leave commented to use localhost. +# The demos run locally within a web browser and thus must "know" where the CIP-service API resides. In the most straightforward case that will be your http localhost +# address where docker is running on port 3000. If docker resides elsewhere or you are using an external engine API, then update these values to that location. +# Leave commented to use http localhost port 3000 defaults. +#POSTGREST_PROT=http #POSTGREST_HOST=localhost -# -# The demos run locally within a web browser and thus must "know" the port used by the CIP API. As the API uses PostgREST which uses port 3000 by default, -# leave this commented to use the default port 3000. #POSTGREST_PORT=3000 # # The demos run locally within a web browser against the Nginx server in the demo bundle. By default that server is exposed as port 8080. Uncomment and diff --git a/demo/nginx/html/openapi.html b/demo/nginx/html/openapi.html new file mode 100644 index 0000000..d63106e --- /dev/null +++ b/demo/nginx/html/openapi.html @@ -0,0 +1,57 @@ + + + + + + + CIP-service OpenAPI Documentation + + + +
+ + + + + + diff --git a/demo/nginx/html/upstreamdownstream.html b/demo/nginx/html/upstreamdownstream.html new file mode 100644 index 0000000..69ef05c --- /dev/null +++ b/demo/nginx/html/upstreamdownstream.html @@ -0,0 +1,1130 @@ + + + + + CIP Service Upstream/Downstream + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+
+
+
+
+
+

CIP Service Upstream/Downstream Test Harness

+ Add points to the map or enter GeoJSON text: +
+ +
+ +
+ NHDPlus Version:  + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Or enter NHDPlus identifiers and optional Measures
Start NHDPlusID: + + Stop NHDPlusID: + +
Start Perm Id: + + Stop Perm Id: + +
Start Reach Code: + + Stop Reach Code: + +
Start Hydro Seq: + + Stop Hydro Seq: + +
Start Measure: + + Stop Measure: + +
Start SourceFeatureID: + + Stop SourceFeatureID: + +
Start SourceFeatureID2: + + Stop SourceFeatureID2: + +
Start SourceOriginator: + + Stop SourceOriginator: + +
Start SourceSeries: + + Stop SourceSeries: + +
Start StartDate: + + Stop StartDate: + +
Start EndDate: + + Stop EndDate: + +
Start PermID JoinKey: + + Stop PermID JoinKey: + +
Start Source JoinKey: + + Stop Source JoinKey: + +
Start Cat JoinKey: + + Stop Cat JoinKey: + +
Start LinkedData Program: + + Stop LinkedData Program: + +
+ +  km +
+ Linked Data Search List: + +
+ Return Flowlines: + +     + Return Catchments: + +     + Return Linked Data CIP: + +
+ Return Linked Data HUC12: + +     + Return Linked Data SRC: + +     + Return Linked Data RAD: + +
+ Return Linked Data Attr: + +     + Remove Stop/Start SFIDs: + +     + Push SRC as RAD: + +
+
+   +   +
+
+
+
+
+ + + + + + diff --git a/demo/profiles/nginx_demo.yml b/demo/profiles/nginx_demo.yml index 7694c19..927c42d 100644 --- a/demo/profiles/nginx_demo.yml +++ b/demo/profiles/nginx_demo.yml @@ -4,7 +4,8 @@ profile_name: nginx_demo # last updated: 20221212 # -# Provide location of the CIP engine API +# Provide location of the CIP engine API +cip_pr_prot: env.POSTGREST_PROT cip_pr_host: env.POSTGREST_HOST cip_pr_port: env.POSTGREST_PORT # diff --git a/demo/profiles/nginx_demo_remote.yml b/demo/profiles/nginx_demo_remote.yml index f70a44d..c683dc7 100644 --- a/demo/profiles/nginx_demo_remote.yml +++ b/demo/profiles/nginx_demo_remote.yml @@ -5,8 +5,9 @@ profile_name: nginx_demo last updated: 20221212 # # Provide location of the CIP engine API -cip_pr_host: env.POSTGREST_HOST -cip_pr_port: env.POSTGREST_PORT +cip_pr_prot: env.POSTGREST_PROT +cip_pr_host: env.POSTGREST_HOST +cip_pr_port: env.POSTGREST_PORT # components: cip_ng: diff --git a/docs/openapi.yml b/docs/openapi.yml index 7887685..e44f4d0 100644 --- a/docs/openapi.yml +++ b/docs/openapi.yml @@ -1,7 +1,15 @@ openapi: 3.1.0 info: title: CIP-service Indexing API - description: The Catchment Index Processing Service provides the ability to associate hydrologic features with NHDPlus catchments. + description: CIP-service is a project of the US Environmental Protection Agency Office of Water providing containers, logic and data for the task of associating or _indexing_ hydrologic + features with NHDPlus features at multiple resolutions. CIP-service supports a variety of purposes indexing to catchments, reaches or navigating the NHDPlus network for discovery or flow analysis. + The majority of logic occurs within a containerized PostgreSQL database with additional containers providing support products such as an API, Jupyter Notebooks and sample demo applications. + All components of the provided container stack are open source. + termsOfService: https://www.epa.gov/web-policies-and-procedures/epa-disclaimers#geospatial + contact: + name: US EPA Office of Water + url: https://www.epa.gov/aboutepa/about-office-water + email: WATERS_SUPPORT@epa.gov license: name: Creative Commons Zero Public Domain Dedication url: https://edg.epa.gov/EPA_Data_License.html @@ -12,8 +20,8 @@ paths: /rpc/cipsrv_index: post: tags: - - 'CIP Services' - summary: CIP-service Indexing Endpoint + - 'CIP Indexing Services' + summary: CIP-service Indexing description: CIP-service Indexing Endpoint requestBody: required: true @@ -31,8 +39,8 @@ paths: /rpc/cipsrv_domains: get: tags: - - 'CIP Services' - summary: CIP-service Domains Endpoint + - 'CIP Indexing Services' + summary: CIP-service Domains description: CIP-service Domains Endpoint responses: '200': @@ -40,12 +48,12 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/cipsrv_domains' + $ref: '#/components/schemas/cipsrv_domains' /rpc/navigate: post: tags: - - 'Utility Services' - summary: CIP-service Navigation Endpoint + - 'Analysis Services' + summary: CIP-service Navigation description: CIP-service Navigation Endpoint requestBody: required: true @@ -63,8 +71,8 @@ paths: /rpc/delineate: post: tags: - - 'Utility Services' - summary: CIP-service Delineation Endpoint + - 'Analysis Services' + summary: CIP-service Delineation description: CIP-service Delineation Endpoint requestBody: required: true @@ -82,8 +90,8 @@ paths: /rpc/pointindexing: post: tags: - - 'Utility Services' - summary: CIP-service Point Indexing Endpoint + - 'Analysis Services' + summary: CIP-service Point Indexing description: CIP-service Point Indexing Endpoint requestBody: required: true @@ -93,11 +101,30 @@ paths: $ref: '#/components/schemas/pointindexing_rb' responses: 200: - description: CIP-service Point Catchment Reach Indexing Response + description: CIP-service Point Indexing Response content: application/json: schema: $ref: '#/components/schemas/pointindexing_resp' + /rpc/upstreamdownstream: + post: + tags: + - 'Analysis Services' + summary: CIP-service Upstream Downstream + description: CIP-service Upstream Downstream Endpoint + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/upstreamdownstream_rb' + responses: + 200: + description: CIP-service Upstream Downstream Response + content: + application/json: + schema: + $ref: '#/components/schemas/upstreamdownstream_resp' /rpc/randomcatchment: post: tags: @@ -203,36 +230,34 @@ components: oneOf: - $ref: '#/components/schemas/geojson_featurecollection' - $ref: '#/components/schemas/geojson_feature' - nullable: true + - type: 'null' lines: description: GeoJSON feature or feature collection of one or more line strings to index. oneOf: - $ref: '#/components/schemas/geojson_featurecollection' - $ref: '#/components/schemas/geojson_feature' - nullable: true + - type: 'null' areas: description: GeoJSON feature or feature collection of one or more polygons to index. oneOf: - $ref: '#/components/schemas/geojson_featurecollection' - $ref: '#/components/schemas/geojson_feature' - nullable: true + - type: 'null' geometry: description: GeoJSON geometry, feature or feature collection of one or more geometries to index. oneOf: - $ref: '#/components/schemas/geojson_featurecollection' - $ref: '#/components/schemas/geojson_feature' - $ref: '#/components/schemas/geojson_geometry' - nullable: true + - type: 'null' geometry_clip: description: array of clip items to apply to the incoming features. - type: array + type: ['array','null'] items: - type: string - nullable: true + type: 'string' geometry_clip_stage: description: flag to control whether to clip features before or after indexing. - type: string - nullable: true + type: ['string','null'] enum: - BEFORE - AFTER @@ -243,41 +268,36 @@ components: * USPS codes for the 50 states plus DC, PR, VI, AS, GU and MP. * Tribal keywords: ALLTRIBAL, PARTTRIBAL, NOTRIBAL or TRIBAL < X. For the TRIBAL < X keyword X is a decimal percentage that tribal percentage of the catchment must meet to be included. - type: array + type: ['array','null'] items: type: string - nullable: true nhdplus_version: + default: nhdplus_m $ref: '#/components/schemas/nhdplus_version' wbd_version: description: WBD version used in CIP indexing. Currently non-functional. - type: string - nullable: true + type: ['string','null'] default_point_indexing_method: description: Point indexing method to use when point features are received without expressly defining a point indexing method. - type: string - nullable: true + type: ['string','null'] enum: - point_simple default: point_simple default_line_indexing_method: description: Line indexing method to use when line features are received without expressly defining a line indexing method. - type: string - nullable: true + type: ['string','null'] enum: - line_simple - line_levelpath default: line_simple default_line_threshold: description: Linear threshold percentage (0 - 100) to use when linear features are received without expressly defining a linear threshold value. - type: number + type: ['number','null'] minimum: 0 maximum: 100 - nullable: true default_ring_indexing_method: description: Area indexing method to use when linear features that form a closed ring are received without expressly defining a ring indexing method. To preclude ring processing, set this value to **treat_as_lines**. - type: string - nullable: true + type: ['string','null'] enum: - area_simple - area_centroid @@ -286,20 +306,17 @@ components: default: treat_as_lines default_ring_areacat_threshold: description: Area catchment threshold percentage (0 - 100) to use when ring features are received without expressly defining a ring area catchment threshold value. - type: number + type: ['number','null'] minimum: 0 maximum: 100 - nullable: true default_ring_areaevt_threshold: description: Area event threshold percentage (0 - 100) to use when ring features are received without expressly defining a ring area event threshold value. - type: number + type: ['number','null'] minimum: 0 maximum: 100 - nullable: true default_area_indexing_method: description: Area indexing method to use when polygon features are received without expressly defining an area indexing method. - type: string - nullable: true + type: ['string','null'] enum: - area_simple - area_centroid @@ -307,68 +324,54 @@ components: default: area_simple default_areacat_threshold: description: Area catchment threshold percentage (0 - 100) to use when area features are received without expressly defining an area catchment threshold value. - type: number + type: ['number','null'] minimum: 0 maximum: 100 - nullable: true default_areaevt_threshold: description: Area event threshold percentage (0 - 100) to use when area features are received without expressly defining an area event threshold value. - type: number + type: ['number','null'] minimum: 0 maximum: 100 - nullable: true known_region: - description: > - Provided value to use to determine the proper spatial reference system to use in geometric analysis. - Providing an SRID value such as 5070 or a US state code such as MN will skip the sometimes expensive determination of the correct SRID for the feature. - However, if the feature does not actually apply to the provide known_region hint, then indexing may fail or return incorrect results. - If in doubt, leave this parameter blank. - type: string - nullable: true + oneOf: + - $ref: '#/components/schemas/known_region' + - type: 'null' return_indexing_summary: description: Flag as to whether to return a detailed summary of the indexing actions. Setting this false will slightly improve performance and throughput. - type: boolean - nullable: true + type: ['boolean','null'] default: true return_indexed_features: description: > Flag as to whether to return indexed features in the results payload. - Indexing may clip features creating a smaller, different geometry that users may wish to inspect. + Indexing may clip features creating a smaller, different geometry that users may wish to inspect. Setting this false will improve performance when large features are clipped to detailed political borders. - type: boolean - nullable: true + type: ['boolean','null'] default: true return_indexed_collection: description: > - Flag as to whether to return all indexed features as a single geometry collection. - This functionality is meant for users who just wish all the features back in a simple format for easy display purposes. - type: boolean - nullable: true + Flag as to whether to return all indexed features as a single geometry collection. + This functionality is meant for users who just wish all the features back in a simple format for easy display purposes. + type: ['boolean','null'] default: false return_catchment_geometry: - description: Flag as to whether to return the catchment geometry in the results payload. - type: boolean - nullable: true + description: Flag as to whether to return the catchment geometry in the results payload. + type: ['boolean','null'] default: true return_flowlines: - description: Flag as to whether to return a feature collection of flowlines associated with indexed catchments. - type: boolean - nullable: true + description: Flag as to whether to return a feature collection of flowlines associated with indexed catchments. + type: ['boolean','null'] default: true return_huc12s: - description: Flag as to whether to return a feature collection of HUC12s associated with indexed catchments. Currently non-functional. - type: boolean - nullable: true + description: Flag as to whether to return a feature collection of HUC12s associated with indexed catchments. Currently non-functional. + type: ['boolean','null'] default: false return_flowline_geometry: description: Flag as to return the flowline geometry when flowlines are returned in the results payload. - type: boolean - nullable: true + type: ['boolean','null'] default: true return_huc12_geometry: description: Flag as to return the HUC12 geometry when HUC12s are returned in the results payload. Currently non-functional. - type: boolean - nullable: true + type: ['boolean','null'] default: true required: - nhdplus_version @@ -403,130 +406,166 @@ components: return_code: $ref: '#/components/schemas/return_code' status_message: - type: string + $ref: '#/components/schemas/status_message' navigate_rb: type: object properties: nhdplus_version: + default: nhdplus_m $ref: '#/components/schemas/nhdplus_version' search_type: - description: | - Navigation methodolody for network discovery of events: - - UT = upstream with tributaries navigation - - UM = upstream mainstem navigation - - DM = downstream mainstem navigation - - DD = downstream with divergences navigation - - PP = point-to-point mainstem navigation - - PPALL = point-to-point mainstem navigation with all streams between - type: string - nullable: false - enum: - - UM - - UT - - DM - - DD - - PP - - PPALL - example: UT + $ref: '#/components/schemas/search_type' start_nhdplusid: - description: NHDPlus flowline NHDPlusID bigint value from which to begin the navigation. - type: integer - format: int64 - nullable: true + oneOf: + - $ref: '#/components/schemas/start_nhdplusid' + - type: 'null' start_permanent_identifier: - description: NHD flowline permanent identifier string value from which to begin the navigation. Permanent Identifiers may manifest as text forms of the NHDPlusID or as 40-byte guid values. - type: string - maxLength: 40 - nullable: true + oneOf: + - $ref: '#/components/schemas/start_permanent_identifier' + - type: 'null' start_reachcode: - description: NHD flowline 14-byte reach code value from which to begin the navigation. Provide a start measure to indicate a specific position on the reach. - type: string - minLength: 14 - maxLength: 14 - nullable: true + oneOf: + - $ref: '#/components/schemas/start_reachcode' + - type: 'null' start_hydroseq: - description: NHDPlus flowline hydro sequence bigint value from which to begin the navigation. - type: integer - format: int64 - nullable: true + oneOf: + - $ref: '#/components/schemas/start_hydroseq' + - type: 'null' start_measure: - description: NHD flowline measure from which to begin the navigation. - type: number - minimum: 0 - maximum: 100 - nullable: true + oneOf: + - $ref: '#/components/schemas/start_measure' + - type: 'null' stop_nhdplusid: - description: NHDPlus flowline NHDPlusID bigint value at which navigation will cease. Only used in point-to-point navigation. - type: integer - format: int64 - nullable: true + oneOf: + - $ref: '#/components/schemas/stop_nhdplusid' + - type: 'null' stop_permanent_identifier: - description: NHD flowline permanent identifier string value from which navigation will cease. Only used in point-to-point navigation. - type: string - maxLength: 40 - nullable: true + oneOf: + - $ref: '#/components/schemas/stop_permanent_identifier' + - type: 'null' stop_reachcode: - description: NHD flowline 14-byte reach code value from which navigation will cease. Only used in point-to-point navigation. - type: string - minLength: 14 - maxLength: 14 - nullable: true + oneOf: + - $ref: '#/components/schemas/stop_reachcode' + - type: 'null' stop_hydroseq: - description: NHDPlus flowline hydro sequence bigint value at which navigation will cease. Only used in point-to-point navigation. - type: integer - format: int64 - minimum: 0 - maximum: 100 - nullable: true + oneOf: + - $ref: '#/components/schemas/stop_hydroseq' + - type: 'null' stop_measure: - description: NHD flowline measure at which navigation will cease. Only used in point-to-point navigation. - type: number - nullable: true + oneOf: + - $ref: '#/components/schemas/stop_measure' + - type: 'null' max_distancekm: - description: Maximum distance traversed in kilometers for selecting features. - type: number - nullable: true + oneOf: + - $ref: '#/components/schemas/max_distancekm' + - type: 'null' max_flowtimeday: - description: Maximum flow time traversed in hours for selecting features. May not apply with all NHDPlus versions. - type: number - nullable: true + oneOf: + - $ref: '#/components/schemas/max_flowtimeday' + - type: 'null' return_flowline_details: - description: Switch whether to return flowline details with results. - type: boolean - nullable: true - default: true + oneOf: + - $ref: '#/components/schemas/return_flowline_details' + - type: 'null' return_flowline_geometry: - description: Switch whether to return flowline geometry information with results. - type: boolean - nullable: true - default: true + oneOf: + - $ref: '#/components/schemas/return_flowline_geometry' + - type: 'null' navigate_resp: type: object properties: flowlines: $ref: '#/components/schemas/geojson_featurecollection' flowline_count: - description: Total count of flowlines returned from navigation. - type: integer - format: int32 + $ref: '#/components/schemas/flowline_count' nhdplus_version: $ref: '#/components/schemas/nhdplus_version' return_code: $ref: '#/components/schemas/return_code' status_message: - description: Status message describing the results of processing. Null indicates success. - type: string - nullable: false + $ref: '#/components/schemas/status_message' delineate_rb: type: object properties: nhdplus_version: + default: nhdplus_m $ref: '#/components/schemas/nhdplus_version' + search_type: + $ref: '#/components/schemas/search_type' + start_nhdplusid: + oneOf: + - $ref: '#/components/schemas/start_nhdplusid' + - type: 'null' + start_permanent_identifier: + oneOf: + - $ref: '#/components/schemas/start_permanent_identifier' + - type: 'null' + start_reachcode: + oneOf: + - $ref: '#/components/schemas/start_reachcode' + - type: 'null' + start_hydroseq: + oneOf: + - $ref: '#/components/schemas/start_hydroseq' + - type: 'null' + start_measure: + oneOf: + - $ref: '#/components/schemas/start_measure' + - type: 'null' + stop_nhdplusid: + oneOf: + - $ref: '#/components/schemas/stop_nhdplusid' + - type: 'null' + stop_permanent_identifier: + oneOf: + - $ref: '#/components/schemas/stop_permanent_identifier' + - type: 'null' + stop_reachcode: + oneOf: + - $ref: '#/components/schemas/stop_reachcode' + - type: 'null' + stop_hydroseq: + oneOf: + - $ref: '#/components/schemas/stop_hydroseq' + - type: 'null' + stop_measure: + oneOf: + - $ref: '#/components/schemas/stop_measure' + - type: 'null' + max_distancekm: + oneOf: + - $ref: '#/components/schemas/max_distancekm' + - type: 'null' + max_flowtimeday: + oneOf: + - $ref: '#/components/schemas/max_flowtimeday' + - type: 'null' + return_flowline_details: + oneOf: + - $ref: '#/components/schemas/return_flowline_details' + - type: 'null' + return_flowline_geometry: + oneOf: + - $ref: '#/components/schemas/return_flowline_geometry' + - type: 'null' delineate_resp: type: object properties: flowlines: $ref: '#/components/schemas/geojson_featurecollection' + flowline_count: + $ref: '#/components/schemas/flowline_count' + nhdplus_version: + $ref: '#/components/schemas/nhdplus_version' + return_code: + $ref: '#/components/schemas/return_code' + status_message: + $ref: '#/components/schemas/status_message' + delineated_area: + $ref: '#/components/schemas/geojson_featurecollection' + aggregation_used: + description: aggregation logic used in delineation action. + type: string pointindexing_rb: type: object properties: @@ -535,45 +574,40 @@ components: - $ref: '#/components/schemas/geojson_featurecollection' - $ref: '#/components/schemas/geojson_feature' - $ref: '#/components/schemas/geojson_geometry' - nullable: false nhdplus_version: + default: nhdplus_m $ref: '#/components/schemas/nhdplus_version' return_snap_path: - type: boolean - nullable: true - default: false + oneOf: + - type: boolean + - type: 'null' known_region: - type: string - nullable: true + oneOf: + - $ref: '#/components/schemas/known_region' + - type: 'null' pointindexing_resp: type: object properties: nhdplusid: - type: integer - format: int64 - nullable: true + oneOf: + - $ref: '#/components/schemas/nhdplusid' + - type: 'null' hydroseq: - type: integer - format: int64 - nullable: true + $ref: '#/components/schemas/hydroseq' permanent_identifier: - type: string + type: ['integer','string'] maxLength: 40 - nullable: true reachcode: $ref: '#/components/schemas/reachcode' fcode: type: integer format: int32 - nullable: true isnavigable: type: boolean - nullable: true snap_measure: $ref: '#/components/schemas/measure' snap_distancekm: - type: number - nullable: true + type: ['number','null'] snap_point: $ref: '#/components/schemas/geojson_feature' snap_path: @@ -581,12 +615,473 @@ components: return_code: $ref: '#/components/schemas/return_code' status_message: + type: ['string','null'] + upstreamdownstream_rb: + type: object + properties: + nhdplus_version: + default: nhdplus_m + $ref: '#/components/schemas/nhdplus_version' + search_type: + $ref: '#/components/schemas/search_type' + start_nhdplusid: + oneOf: + - $ref: '#/components/schemas/start_nhdplusid' + - type: 'null' + start_permanent_identifier: + oneOf: + - $ref: '#/components/schemas/start_permanent_identifier' + - type: 'null' + start_reachcode: + oneOf: + - $ref: '#/components/schemas/start_reachcode' + - type: 'null' + start_hydroseq: + oneOf: + - $ref: '#/components/schemas/start_hydroseq' + - type: 'null' + start_measure: + oneOf: + - $ref: '#/components/schemas/start_measure' + - type: 'null' + start_source_featureid: + oneOf: + - type: string + - type: 'null' + start_source_featureid2: + oneOf: + - type: string + - type: 'null' + start_source_originator: + oneOf: + - type: string + - type: 'null' + start_source_series: + oneOf: + - type: string + - type: 'null' + start_start_date: + oneOf: + - type: string + format: date + - type: 'null' + start_end_date: + oneOf: + - type: string + format: date + - type: 'null' + start_permid_joinkey: + oneOf: + - type: string + - type: 'null' + start_source_joinkey: + oneOf: + - type: string + - type: 'null' + start_cat_joinkey: + oneOf: + - type: string + - type: 'null' + start_linked_data_program: + oneOf: + - type: string + - type: 'null' + start_search_precision: + oneOf: + - type: string + - type: 'null' + start_search_logic: + oneOf: + - type: string + - type: 'null' + stop_nhdplusid: + oneOf: + - $ref: '#/components/schemas/stop_nhdplusid' + - type: 'null' + stop_permanent_identifier: + oneOf: + - $ref: '#/components/schemas/stop_permanent_identifier' + - type: 'null' + stop_reachcode: + oneOf: + - $ref: '#/components/schemas/stop_reachcode' + - type: 'null' + stop_hydroseq: + oneOf: + - $ref: '#/components/schemas/stop_hydroseq' + - type: 'null' + stop_measure: + oneOf: + - $ref: '#/components/schemas/stop_measure' + - type: 'null' + stop_source_featureid: + oneOf: + - type: string + - type: 'null' + stop_source_featureid2: + oneOf: + - type: string + - type: 'null' + stop_source_originator: + oneOf: + - type: string + - type: 'null' + stop_source_series: + oneOf: + - type: string + - type: 'null' + stop_start_date: + oneOf: + - type: string + format: date + - type: 'null' + stop_end_date: + oneOf: + - type: string + format: date + - type: 'null' + stop_permid_joinkey: + oneOf: + - type: string + - type: 'null' + stop_source_joinkey: + oneOf: + - type: string + - type: 'null' + stop_cat_joinkey: + oneOf: + - type: string + - type: 'null' + stop_linked_data_program: + oneOf: + - type: string + - type: 'null' + stop_search_precision: + oneOf: + - type: string + - type: 'null' + stop_search_logic: + oneOf: + - type: string + - type: 'null' + max_distancekm: + oneOf: + - $ref: '#/components/schemas/max_distancekm' + - type: 'null' + max_flowtimeday: + oneOf: + - $ref: '#/components/schemas/max_flowtimeday' + - type: 'null' + linked_data_search_list: + type: array + items: + type: string + return_flowline_details: + oneOf: + - $ref: '#/components/schemas/return_flowline_details' + - type: 'null' + return_flowline_geometry: + oneOf: + - $ref: '#/components/schemas/return_flowline_geometry' + - type: 'null' + return_catchments: + oneOf: + - type: boolean + - type: 'null' + return_linked_data_cip: + oneOf: + - type: boolean + - type: 'null' + return_linked_data_huc12: + oneOf: + - type: boolean + - type: 'null' + return_linked_data_source: + oneOf: + - type: boolean + - type: 'null' + return_linked_data_rad: + oneOf: + - type: boolean + - type: 'null' + return_linked_data_attributes: + oneOf: + - type: boolean + - type: 'null' + remove_stop_start_sfids: + oneOf: + - type: boolean + - type: 'null' + push_source_geometry_as_rad: + oneOf: + - type: boolean + - type: 'null' + upstreamdownstream_resp: + type: object + properties: + flowlines: + $ref: '#/components/schemas/geojson_featurecollection' + catchments: + $ref: '#/components/schemas/geojson_featurecollection' + linked_data_sfid_found: + type: object + properties: + type: + type: string + rows: + type: array + items: + type: object + properties: + eventtype: + type: integer + source_originator: + type: string + source_featureid: + type: string + source_featureid2: + type: string + source_series: + type: string + source_subdivision: + type: string + source_joinkey: + type: string + start_date: + type: string + format: date + end_date: + type: string + format: date + sfiddetailurl: + type: string + src_event_count: + type: integer + rad_event_count: + type: integer + src_cat_joinkey_count: + type: integer + nearest_cip_distancekm_permid: + type: number + nearest_cip_distancekm_cat: + type: number + nearest_cip_network_distancekm: + type: number + nearest_rad_distancekm_permid: + type: string + nearest_rad_network_distancekm: + type: number + nearest_cip_flowtimeday_permid: + type: string + nearest_cip_flowtimeday_cat: + type: number + nearest_cip_network_flowtimeday: + type: number + nearest_rad_flowtimeday_permid: + type: string + nearest_rad_network_flowtimeday: + type: number + linked_data_cip_found: + type: object + properties: + type: + type: string + rows: + type: array + items: + type: object + properties: + eventtype: + type: integer + permid_joinkey: + type: string + source_originator: + type: string + source_featureid: + type: string + source_featureid2: + type: string + source_series: + type: string + source_subdivision: + type: string + source_joinkey: + type: string + start_date: + type: string + format: date + end_date: + type: string + format: date + cat_joinkey: + type: string + catchmentstatecode: + type: string + nhdplusid: + type: integer + format: int64 + xwalk_huc12: + type: string + network_distancekm: + type: number + network_flowtimeday: + type: number + linked_data_huc12_found: + type: object + properties: + type: + type: string + rows: + type: array + items: + type: object + properties: + eventtype: + type: integer + permid_joinkey: + type: string + source_originator: + type: string + source_featureid: + type: string + source_featureid2: + type: string + source_series: + type: string + source_subdivision: + type: string + source_joinkey: + type: string + start_date: + type: string + format: date + end_date: + type: string + format: date + xwalk_huc12: + type: string + network_distancekm: + type: number + network_flowtimeday: + type: number + linked_data_source_points: + $ref: '#/components/schemas/geojson_feature' + linked_data_source_lines: + $ref: '#/components/schemas/geojson_feature' + linked_data_source_areas: + $ref: '#/components/schemas/geojson_feature' + linked_data_reached_points: + $ref: '#/components/schemas/geojson_feature' + linked_data_reached_lines: + $ref: '#/components/schemas/geojson_feature' + linked_data_reached_areas: + $ref: '#/components/schemas/geojson_feature' + linked_data_attributes: + type: object + properties: + type: + type: string + rows: + type: array + items: + oneOf: + - $ref: '#/components/schemas/linked_data_wqp' + result_link_path: + $ref: '#/components/schemas/geojson_feature' + return_code: + $ref: '#/components/schemas/return_code' + status_message: + $ref: '#/components/schemas/status_message' + linked_data_wqp: + type: object + properties: + source_joinkey: + type: string + organizationidentifier: + type: string + organizationformalname: + type: string + monitoringlocationidentifier: + type: string + monitoringlocationname: + type: string + monitoringlocationtypename: + type: string + monitoringlocationdescription: + type: string + huceightdigitcode: + type: string + drainageareameasure_measureval: + type: number + drainageareameasure_measureunt: + type: string + contributingdrainageareameasva: + type: string + contributingdrainageareameasun: type: string - nullable: false + latitudemeasure: + type: number + longitudemeasure: + type: number + sourcemapscalenumeric: + type: number + horizontalaccuracymeasureval: + type: string + horizontalaccuracymeasureunit: + type: string + horizontalcollectionmethodname: + type: string + horizontalcoordinatereferences: + type: string + verticalmeasure_measurevalue: + type: string + verticalmeasure_measureunit: + type: string + verticalaccuracymeasurevalue: + type: string + verticalaccuracymeasureunit: + type: string + verticalcollectionmethodname: + type: string + verticalcoordinatereferencesys: + type: string + countrycode: + type: string + statecode: + type: string + countycode: + type: string + aquifername: + type: string + formationtypetext: + type: string + aquifertypename: + type: string + constructiondatetext: + type: string + welldepthmeasure_measurevalue: + type: string + welldepthmeasure_measureunit: + type: string + wellholedepthmeasure_measureva: + type: string + wellholedepthmeasure_measureun: + type: string + providername: + type: string + nearest_cip_network_distancekm: + type: number + nearest_cip_network_flowtimeday: + type: number + nearest_rad_network_distancekm: + type: number + nearest_rad_network_flowtimeday: + type: number randomcatchment_rb: type: object properties: nhdplus_version: + default: nhdplus_m $ref: '#/components/schemas/nhdplus_version' randomcatchment_resp: type: object @@ -597,6 +1092,7 @@ components: type: object properties: nhdplus_version: + default: nhdplus_m $ref: '#/components/schemas/nhdplus_version' randomhuc12_resp: type: object @@ -607,6 +1103,7 @@ components: type: object properties: nhdplus_version: + default: nhdplus_m $ref: '#/components/schemas/nhdplus_version' randomnav_resp: type: object @@ -617,6 +1114,7 @@ components: type: object properties: nhdplus_version: + default: nhdplus_m $ref: '#/components/schemas/nhdplus_version' randomppnav_resp: type: object @@ -629,12 +1127,13 @@ components: type: object properties: nhdplus_version: + default: nhdplus_m $ref: '#/components/schemas/nhdplus_version' randompoint_resp: type: object properties: point: - $ref: '#/components/schemas/geojson_feature' + $ref: '#/components/schemas/geojson_feature' cipsrv_domains: type: object properties: @@ -673,7 +1172,8 @@ components: ordinate: type: number title: GeoJSON Ordinate - example: -89.5327 + examples: + - -89.5327 coordinates1: type: array title: GeoJSON Coordinates 1 @@ -689,10 +1189,9 @@ components: title: GeoJSON Coordinates 3 items: "$ref": "#/components/schemas/coordinates2" - geojson_geometry: - type: object + geojson_geometry: + type: ['object','null'] title: GeoJSON Geometry - nullable: true externalDocs: url: http://geojson.org/geojson-spec.html#geometry-objects properties: @@ -723,9 +1222,8 @@ components: items: $ref: '#/components/schemas/ordinate' geojson_feature: - type: object + type: ['object','null'] title: GeoJSON Feature - nullable: true required: - type - geometry @@ -742,11 +1240,20 @@ components: properties: discriminator: propertyName: obj_type + mapping: + event_feature_properties: '#/components/schemas/event_feature_properties' + indexed_catchment_properties: '#/components/schemas/indexed_catchment_properties' + indexed_flowline_properties: '#/components/schemas/indexed_flowline_properties' + navigated_flowline_properties: '#/components/schemas/navigated_flowline_properties' + delineated_area_properties: '#/components/schemas/delineated_area_properties' + snap_point_properties: '#/components/schemas/snap_point_properties' + snap_path_properties: '#/components/schemas/snap_path_properties' oneOf: - "$ref": "#/components/schemas/event_feature_properties" - "$ref": "#/components/schemas/indexed_catchment_properties" - "$ref": "#/components/schemas/indexed_flowline_properties" - "$ref": "#/components/schemas/navigated_flowline_properties" + - "$ref": "#/components/schemas/delineated_area_properties" - "$ref": "#/components/schemas/snap_point_properties" - "$ref": "#/components/schemas/snap_path_properties" type: @@ -757,7 +1264,7 @@ components: type: object properties: globalid: - type: string + $ref: '#/components/schemas/globalid' lengthkm: type: number areasqkm: @@ -776,24 +1283,20 @@ components: type: object properties: nhdplusid: - type: integer - format: int64 + $ref: '#/components/schemas/nhdplusid' catchmentstatecode: type: string xwalk_huc12: - type: string + type: ['string','null'] minLength: 12 maxLength: 12 - nullable: true areasqkm: type: number indexed_flowline_properties: type: object properties: nhdplusid: - description: NHDPlus int64 flowline identifier - type: integer - format: int64 + $ref: '#/components/schemas/nhdplusid' gnis_id: description: NHD GNIS identifier type: string @@ -812,13 +1315,9 @@ components: type: object properties: nhdplusid: - description: NHDPlus int64 flowline identifier. - type: integer - format: int64 + $ref: '#/components/schemas/nhdplusid' hydroseq: - description: NHDPlus int64 hydro sequence identifier. - type: integer - format: int64 + $ref: '#/components/schemas/hydroseq' fmeasure: description: NHD flowline from measure. $ref: '#/components/schemas/measure' @@ -855,8 +1354,7 @@ components: type: number permanent_identifier: description: NHD permanent identifier of the navigated flowline. - type: string - nullable: true + type: ['string','null'] reachcode: description: NHD reach code of the navigated flowline $ref: '#/components/schemas/reachcode' @@ -896,6 +1394,18 @@ components: description: rough ordering key placing flowlines in navigated order type: integer format: int32 + delineated_area_properties: + type: object + properties: + areasqkm: + type: number + hydroseq: + $ref: '#/components/schemas/hydroseq' + sourcefc: + description: identifier of the delineation area source. + type: string + nhdplusid: + $ref: '#/components/schemas/nhdplusid' geojson_featurecollection: type: object title: GeoJSON Feature Collection @@ -952,19 +1462,150 @@ components: nhdplus_version: description: NHDPlus version used in CIP indexing. type: string - nullable: false enum: - nhdplus_m - nhdplus_h - default: nhdplus_m - example: nhdplus_m + examples: + - nhdplus_h + search_type: + description: | + Navigation methodolody for network discovery of events: + - UT = upstream with tributaries navigation + - UM = upstream mainstem navigation + - DM = downstream mainstem navigation + - DD = downstream with divergences navigation + - PP = point-to-point mainstem navigation + - PPALL = point-to-point mainstem navigation with all streams between + type: string + enum: + - UM + - UT + - DM + - DD + - PP + - PPALL + examples: + - UT + start_nhdplusid: + description: NHDPlus flowline NHDPlusID bigint value from which to begin the navigation. + type: integer + format: int64 + examples: + - 5000100000184 + start_permanent_identifier: + description: NHD flowline permanent identifier string value from which to begin the navigation. Permanent Identifiers may manifest as text forms of the NHDPlusID or as 40-byte guid values. + type: string + maxLength: 40 + examples: + - '{5DC9D377-46F7-41FB-A258-7A9AF8307610}' + start_reachcode: + description: NHD flowline 14-byte reach code value from which to begin the navigation. Provide a start measure to indicate a specific position on the reach. + type: string + minLength: 14 + maxLength: 14 + examples: + - '01010007002110' + start_hydroseq: + description: NHDPlus flowline hydro sequence bigint value from which to begin the navigation. + type: integer + format: int64 + examples: + - 5000100019676 + start_measure: + description: NHD flowline measure from which to begin the navigation. + type: number + minimum: 0 + maximum: 100 + examples: + - 50.0 + stop_nhdplusid: + description: NHDPlus flowline NHDPlusID bigint value at which navigation will cease. Only used in point-to-point navigation. + type: integer + format: int64 + examples: + - 5000100000184 + stop_permanent_identifier: + description: NHD flowline permanent identifier string value from which navigation will cease. Only used in point-to-point navigation. + type: string + maxLength: 40 + examples: + - '{46D7557F-A83A-4414-AE56-105167EE3502}' + stop_reachcode: + description: NHD flowline 14-byte reach code value from which navigation will cease. Only used in point-to-point navigation. + type: string + minLength: 14 + maxLength: 14 + examples: + - 188744699622 + stop_hydroseq: + description: NHDPlus flowline hydro sequence bigint value at which navigation will cease. Only used in point-to-point navigation. + type: integer + format: int64 + examples: + - 5000100000184 + stop_measure: + description: NHD flowline measure at which navigation will cease. Only used in point-to-point navigation. + type: number + examples: + - 45.23 + max_distancekm: + description: Maximum distance traversed in kilometers for selecting features. + type: number + examples: + - 15 + max_flowtimeday: + description: Maximum flow time traversed in hours for selecting features. May not apply with all NHDPlus versions. + type: number + examples: + - 1.2567 + return_flowline_details: + description: Switch whether to return flowline details with results. + type: boolean + default: true + examples: + - true + return_flowline_geometry: + description: Switch whether to return flowline geometry information with results. + type: boolean + default: true + examples: + - true return_code: description: Status code for results. Zero indicates success. type: integer format: int32 - nullable: false + examples: + - 0 measure: type: number minimum: 0 maximum: 100 - \ No newline at end of file + status_message: + description: Status message describing the results of processing. Null indicates success. + type: ['string','null'] + flowline_count: + description: Total count of flowlines returned from analysis. + type: integer + format: int32 + nhdplusid: + description: NHDPlus int64 nhdplus identifier. + type: integer + format: int64 + hydroseq: + description: NHDPlus int64 hydro sequence identifier. + type: integer + format: int64 + permanent_identifier: + description: NHD permanent identifier of the navigated flowline. + type: string + globalid: + type: string + examples: + - '{E374E06D-3A16-662D-E053-42DE4386FFB0}' + known_region: + description: > + Provided value to use to determine the proper spatial reference system to use in geometric analysis. + Providing an SRID value such as 5070 or a US state code such as MN will skip the sometimes expensive determination of the correct SRID for the feature. + However, if the feature does not actually apply to the provide known_region hint, then indexing may fail or return incorrect results. + If in doubt, leave this parameter blank. + type: string diff --git a/engine/postgresql/schema_config.sql b/engine/postgresql/schema_config.sql index af32f75..7cf962d 100644 --- a/engine/postgresql/schema_config.sql +++ b/engine/postgresql/schema_config.sql @@ -20,8 +20,6 @@ CREATE SCHEMA cipsrv_upload AUTHORIZATION cipsrv_upload; CREATE SCHEMA cipsrv_gis AUTHORIZATION cipsrv_gis; GRANT USAGE ON SCHEMA cipsrv_engine TO cipsrv_pgrest; -GRANT USAGE ON SCHEMA cipsrv_support TO cipsrv_pgrest; -GRANT USAGE ON SCHEMA cipsrv_owld TO cipsrv_pgrest; GRANT USAGE ON SCHEMA cipsrv_nhdplus_m TO cipsrv_pgrest; GRANT USAGE ON SCHEMA cipsrv_epageofab_m TO cipsrv_pgrest; GRANT USAGE ON SCHEMA cipsrv_nhdplusgrid_m TO cipsrv_pgrest; @@ -32,12 +30,12 @@ GRANT USAGE ON SCHEMA cipsrv_epageofab_h TO cipsrv_pgrest; GRANT USAGE ON SCHEMA cipsrv_nhdplusgrid_h TO cipsrv_pgrest; GRANT USAGE ON SCHEMA cipsrv_nhdplustopo_h TO cipsrv_pgrest; GRANT USAGE ON SCHEMA cipsrv_nhdpluswshd_h TO cipsrv_pgrest; +GRANT USAGE ON SCHEMA cipsrv_support TO cipsrv_pgrest; +GRANT USAGE ON SCHEMA cipsrv_owld TO cipsrv_pgrest; GRANT USAGE ON SCHEMA cipsrv_pgrest TO cipsrv; GRANT ALL ON SCHEMA cipsrv_gis TO cipsrv; GRANT USAGE ON SCHEMA cipsrv_upload TO cipsrv_upload; GRANT USAGE ON SCHEMA cipsrv_engine TO cipsrv_upload; -GRANT USAGE ON SCHEMA cipsrv_support TO cipsrv_upload; -GRANT USAGE ON SCHEMA cipsrv_owld TO cipsrv_upload; GRANT USAGE ON SCHEMA cipsrv_nhdplus_m TO cipsrv_upload; GRANT USAGE ON SCHEMA cipsrv_epageofab_m TO cipsrv_upload; GRANT USAGE ON SCHEMA cipsrv_nhdplusgrid_m TO cipsrv_upload; @@ -48,6 +46,8 @@ GRANT USAGE ON SCHEMA cipsrv_epageofab_h TO cipsrv_upload; GRANT USAGE ON SCHEMA cipsrv_nhdplusgrid_h TO cipsrv_upload; GRANT USAGE ON SCHEMA cipsrv_nhdplustopo_h TO cipsrv_upload; GRANT USAGE ON SCHEMA cipsrv_nhdpluswshd_h TO cipsrv_upload; +GRANT USAGE ON SCHEMA cipsrv_support TO cipsrv_upload; +GRANT USAGE ON SCHEMA cipsrv_owld TO cipsrv_upload; GRANT USAGE ON SCHEMA cipsrv_tap TO public; GRANT USAGE ON SCHEMA cipsrv_nhdplus_m TO cipsrv_gis; GRANT USAGE ON SCHEMA cipsrv_epageofab_m TO cipsrv_gis; diff --git a/gis/arcgis/epageofab_h.py b/gis/arcgis/epageofab_h.py new file mode 100644 index 0000000..d63c729 --- /dev/null +++ b/gis/arcgis/epageofab_h.py @@ -0,0 +1,162 @@ +import arcpy; +from arcpy import env; +import os,sys; + +spref = arcpy.SpatialReference(3857); + +############################################################################### +def auto_fm(source): + + sdeflds = ['objectid','shape','se_anno_cad_data','shape_length','shape_area','len','area','globalid']; + source_desc = arcpy.da.Describe(source); + + flds = [] + for item in source_desc["fields"]: + if item.name.lower() not in sdeflds: + flds.append(item); + + fms = arcpy.FieldMappings(); + + for i in range(len(flds)): + fm = arcpy.FieldMap(); + fm.addInputField(source,flds[i].name); + fd = fm.outputField; + fd.name = flds[i].name.lower() + #print(fd.name + ' ' + fd.type) + fd.type = flds[i].type + fd.length = flds[i].length; + fd.precision = flds[i].precision; + fd.scale = flds[i].scale; + fm.outputField = fd; + fms.addFieldMap(fm); + + return fms; + +############################################################################### +work_path = r"D:\Public\Data\pdziemie\gis"; +container_name = "epageofab_h.gdb"; +source_conn = r"D:\Public\Data\WatersGeoPro\watersdev_cipsrv_gis.sde"; +print("using " + source_conn + "..."); +############################################################################### +if not arcpy.Exists(work_path + os.sep + container_name): + arcpy.management.CreateFileGDB( + out_folder_path = work_path + ,out_name = container_name + ); + +print(" "); +print("purging existing data...",end="",flush=True); + +arcpy.env.preserveGlobalIds = True; + +item = work_path + os.sep + container_name + os.sep + "catchment_fabric" +if arcpy.Exists(item): + arcpy.Delete_management(item); + +item = work_path + os.sep + container_name + os.sep + "catchment_fabric_huc12" +if arcpy.Exists(item): + arcpy.Delete_management(item); + +print(" DONE."); +print(" "); + +############################################################################### +def tbexporter(source,outname,work_path,container_name): + + print("counting " + source + "....",end="",flush=True); + bef = arcpy.GetCount_management(source)[0]; + print(" " + str(bef) + "."); + print("exporting " + outname + "...",end="",flush=True); + target_nm = work_path + os.sep + container_name + os.sep + outname; + arcpy.conversion.ExportTable( + in_table = source + ,out_table = work_path + os.sep + container_name + os.sep + outname + ,field_mapping = auto_fm(source) + ); + print(" DONE."); + print("counting " + outname + "....",end="",flush=True); + aft = arcpy.GetCount_management(work_path + os.sep + container_name + os.sep + outname)[0]; + print(" " + str(aft) + "."); + if bef != aft: + raise Exception("export counts for " + outname + " do not match!"); + + arcpy.management.AddGlobalIDs(work_path + os.sep + container_name + os.sep + outname); + print(" DONE."); + +############################################################################### +def fcexporter(source,outname,work_path,container_name): + + print("counting " + source + "....",end="",flush=True); + bef = int(arcpy.GetCount_management(source)[0]); + print(" " + str(bef) + "."); + + arcpy.env.outputCoordinateSystem = spref; + + if bef == 0: + print("creating empty fc " + outname + "...",end="",flush=True); + arcpy.management.CreateFeatureclass( + out_path = work_path + os.sep + container_name + ,out_name = outname + ,geometry_type = geometry_type + ,template = source + ,has_m = 'DISABLED' + ,has_z = 'DISABLED' + ,spatial_reference = spref + ); + + else: + print("exporting " + outname + "...",end="",flush=True); + arcpy.conversion.ExportFeatures( + in_features = source + ,out_features = work_path + os.sep + container_name + os.sep + outname + ,field_mapping = auto_fm(source) + ); + + print(" DONE."); + print("counting " + outname + "....",end="",flush=True); + aft = int(arcpy.GetCount_management(work_path + os.sep + container_name + os.sep + outname)[0]); + print(" " + str(aft) + "."); + if bef != aft: + raise Exception("export counts for " + outname + " do not match!"); + + arcpy.management.AddGlobalIDs(work_path + os.sep + container_name + os.sep + outname); + print(" DONE."); + +############################################################################### +source = source_conn + r"/cipsrv_gis.epageofab_h_catchment_fabric_esri"; +outname = "catchment_fabric"; +target_nm = work_path + os.sep + container_name + os.sep + outname; +ret = fcexporter(source,outname,work_path,container_name); + +print("indexing " + outname + "...",end="",flush=True); +arcpy.management.AddIndex(target_nm,"catchmentstatecode" ,"idx01"); +arcpy.management.AddIndex(target_nm,"nhdplusid" ,"idx02"); +arcpy.management.AddIndex(target_nm,"istribal" ,"idx03"); +arcpy.management.AddIndex(target_nm,"xwalk_huc12" ,"idx04"); +arcpy.management.AddIndex(target_nm,"sourcefc" ,"idx05"); +arcpy.management.AddIndex(target_nm,"isnavigable" ,"idx06"); +arcpy.management.AddIndex(target_nm,"hasvaa" ,"idx07"); +arcpy.management.AddIndex(target_nm,"issink" ,"idx08"); +arcpy.management.AddIndex(target_nm,"isheadwater" ,"idx09"); +arcpy.management.AddIndex(target_nm,"iscoastal" ,"idx10"); +arcpy.management.AddIndex(target_nm,"isocean" ,"idx11"); +arcpy.management.AddIndex(target_nm,"isalaskan" ,"idx12"); +arcpy.management.AddIndex(target_nm,"h3hexagonaddr" ,"idx13"); +arcpy.management.AddIndex(target_nm,"state_count" ,"idx14"); +arcpy.management.AddIndex(target_nm,"vpuid" ,"idx15"); +print(" DONE."); +print(outname + " export complete."); +print(" "); + +############################################################################### +source = source_conn + r"/cipsrv_gis.epageofab_h_catchment_fabric_huc12_esri"; +outname = "catchment_fabric_huc12"; +target_nm = work_path + os.sep + container_name + os.sep + outname; +ret = fcexporter(source,outname,work_path,container_name); + +print("indexing " + outname + "...",end="",flush=True); +arcpy.management.AddIndex(target_nm,"xwalk_huc12" ,"idx01"); +print(" DONE."); +print(outname + " export complete."); +print(" "); + diff --git a/gis/arcgis/epageofab_h/epageofab_h.aprx b/gis/arcgis/epageofab_h/epageofab_h.aprx new file mode 100644 index 0000000..c946edf Binary files /dev/null and b/gis/arcgis/epageofab_h/epageofab_h.aprx differ diff --git a/gis/arcgis/epageofab_h/epageofab_h.atbx b/gis/arcgis/epageofab_h/epageofab_h.atbx new file mode 100644 index 0000000..8a10de0 Binary files /dev/null and b/gis/arcgis/epageofab_h/epageofab_h.atbx differ diff --git a/gis/arcgis/epageofab_m.py b/gis/arcgis/epageofab_m.py new file mode 100644 index 0000000..669466c --- /dev/null +++ b/gis/arcgis/epageofab_m.py @@ -0,0 +1,162 @@ +import arcpy; +from arcpy import env; +import os,sys; + +spref = arcpy.SpatialReference(3857); + +############################################################################### +def auto_fm(source): + + sdeflds = ['objectid','shape','se_anno_cad_data','shape_length','shape_area','len','area','globalid']; + source_desc = arcpy.da.Describe(source); + + flds = [] + for item in source_desc["fields"]: + if item.name.lower() not in sdeflds: + flds.append(item); + + fms = arcpy.FieldMappings(); + + for i in range(len(flds)): + fm = arcpy.FieldMap(); + fm.addInputField(source,flds[i].name); + fd = fm.outputField; + fd.name = flds[i].name.lower() + #print(fd.name + ' ' + fd.type) + fd.type = flds[i].type + fd.length = flds[i].length; + fd.precision = flds[i].precision; + fd.scale = flds[i].scale; + fm.outputField = fd; + fms.addFieldMap(fm); + + return fms; + +############################################################################### +work_path = r"D:\Public\Data\pdziemie\gis"; +container_name = "epageofab_m.gdb"; +source_conn = r"D:\Public\Data\WatersGeoPro\watersdev_cipsrv_gis.sde"; +print("using " + source_conn + "..."); +############################################################################### +if not arcpy.Exists(work_path + os.sep + container_name): + arcpy.management.CreateFileGDB( + out_folder_path = work_path + ,out_name = container_name + ); + +print(" "); +print("purging existing data...",end="",flush=True); + +arcpy.env.preserveGlobalIds = True; + +item = work_path + os.sep + container_name + os.sep + "catchment_fabric" +if arcpy.Exists(item): + arcpy.Delete_management(item); + +item = work_path + os.sep + container_name + os.sep + "catchment_fabric_huc12" +if arcpy.Exists(item): + arcpy.Delete_management(item); + +print(" DONE."); +print(" "); + +############################################################################### +def tbexporter(source,outname,work_path,container_name): + + print("counting " + source + "....",end="",flush=True); + bef = arcpy.GetCount_management(source)[0]; + print(" " + str(bef) + "."); + print("exporting " + outname + "...",end="",flush=True); + target_nm = work_path + os.sep + container_name + os.sep + outname; + arcpy.conversion.ExportTable( + in_table = source + ,out_table = work_path + os.sep + container_name + os.sep + outname + ,field_mapping = auto_fm(source) + ); + print(" DONE."); + print("counting " + outname + "....",end="",flush=True); + aft = arcpy.GetCount_management(work_path + os.sep + container_name + os.sep + outname)[0]; + print(" " + str(aft) + "."); + if bef != aft: + raise Exception("export counts for " + outname + " do not match!"); + + arcpy.management.AddGlobalIDs(work_path + os.sep + container_name + os.sep + outname); + print(" DONE."); + +############################################################################### +def fcexporter(source,outname,work_path,container_name): + + print("counting " + source + "....",end="",flush=True); + bef = int(arcpy.GetCount_management(source)[0]); + print(" " + str(bef) + "."); + + arcpy.env.outputCoordinateSystem = spref; + + if bef == 0: + print("creating empty fc " + outname + "...",end="",flush=True); + arcpy.management.CreateFeatureclass( + out_path = work_path + os.sep + container_name + ,out_name = outname + ,geometry_type = geometry_type + ,template = source + ,has_m = 'DISABLED' + ,has_z = 'DISABLED' + ,spatial_reference = spref + ); + + else: + print("exporting " + outname + "...",end="",flush=True); + arcpy.conversion.ExportFeatures( + in_features = source + ,out_features = work_path + os.sep + container_name + os.sep + outname + ,field_mapping = auto_fm(source) + ); + + print(" DONE."); + print("counting " + outname + "....",end="",flush=True); + aft = int(arcpy.GetCount_management(work_path + os.sep + container_name + os.sep + outname)[0]); + print(" " + str(aft) + "."); + if bef != aft: + raise Exception("export counts for " + outname + " do not match!"); + + arcpy.management.AddGlobalIDs(work_path + os.sep + container_name + os.sep + outname); + print(" DONE."); + +############################################################################### +source = source_conn + r"/cipsrv_gis.epageofab_m_catchment_fabric_esri"; +outname = "catchment_fabric"; +target_nm = work_path + os.sep + container_name + os.sep + outname; +ret = fcexporter(source,outname,work_path,container_name); + +print("indexing " + outname + "...",end="",flush=True); +arcpy.management.AddIndex(target_nm,"catchmentstatecode" ,"idx01"); +arcpy.management.AddIndex(target_nm,"nhdplusid" ,"idx02"); +arcpy.management.AddIndex(target_nm,"istribal" ,"idx03"); +arcpy.management.AddIndex(target_nm,"xwalk_huc12" ,"idx04"); +arcpy.management.AddIndex(target_nm,"sourcefc" ,"idx05"); +arcpy.management.AddIndex(target_nm,"isnavigable" ,"idx06"); +arcpy.management.AddIndex(target_nm,"hasvaa" ,"idx07"); +arcpy.management.AddIndex(target_nm,"issink" ,"idx08"); +arcpy.management.AddIndex(target_nm,"isheadwater" ,"idx09"); +arcpy.management.AddIndex(target_nm,"iscoastal" ,"idx10"); +arcpy.management.AddIndex(target_nm,"isocean" ,"idx11"); +arcpy.management.AddIndex(target_nm,"isalaskan" ,"idx12"); +arcpy.management.AddIndex(target_nm,"h3hexagonaddr" ,"idx13"); +arcpy.management.AddIndex(target_nm,"state_count" ,"idx14"); +arcpy.management.AddIndex(target_nm,"vpuid" ,"idx15"); +print(" DONE."); +print(outname + " export complete."); +print(" "); + +############################################################################### +source = source_conn + r"/cipsrv_gis.epageofab_m_catchment_fabric_huc12_esri"; +outname = "catchment_fabric_huc12"; +target_nm = work_path + os.sep + container_name + os.sep + outname; +ret = fcexporter(source,outname,work_path,container_name); + +print("indexing " + outname + "...",end="",flush=True); +arcpy.management.AddIndex(target_nm,"xwalk_huc12" ,"idx01"); +print(" DONE."); +print(outname + " export complete."); +print(" "); + diff --git a/gis/arcgis/epageofab_m/epageofab_m.aprx b/gis/arcgis/epageofab_m/epageofab_m.aprx new file mode 100644 index 0000000..c946edf Binary files /dev/null and b/gis/arcgis/epageofab_m/epageofab_m.aprx differ diff --git a/gis/arcgis/epageofab_m/epageofab_m.atbx b/gis/arcgis/epageofab_m/epageofab_m.atbx new file mode 100644 index 0000000..8a10de0 Binary files /dev/null and b/gis/arcgis/epageofab_m/epageofab_m.atbx differ diff --git a/gis/arcgis/nhdplus_h.py b/gis/arcgis/nhdplus_h.py new file mode 100644 index 0000000..020f29f --- /dev/null +++ b/gis/arcgis/nhdplus_h.py @@ -0,0 +1,371 @@ +import arcpy; +from arcpy import env; +import os,sys; + +spref = arcpy.SpatialReference(3857); + +############################################################################### +def auto_fm(source): + + sdeflds = ['objectid','shape','se_anno_cad_data','shape_length','shape_area','len','area','globalid']; + source_desc = arcpy.da.Describe(source); + + flds = [] + for item in source_desc["fields"]: + if item.name.lower() not in sdeflds: + flds.append(item); + + fms = arcpy.FieldMappings(); + + for i in range(len(flds)): + fm = arcpy.FieldMap(); + fm.addInputField(source,flds[i].name); + fd = fm.outputField; + fd.name = flds[i].name.lower() + #print(fd.name + ' ' + fd.type) + fd.type = flds[i].type + fd.length = flds[i].length; + fd.precision = flds[i].precision; + fd.scale = flds[i].scale; + fm.outputField = fd; + fms.addFieldMap(fm); + + return fms; + +############################################################################### +work_path = r"D:\Public\Data\pdziemie\gis"; +container_name = "nhdplus_h.gdb"; +source_conn = r"D:\Public\Data\WatersGeoPro\watersdev_cipsrv_gis.sde"; +print("using " + source_conn + "..."); +############################################################################### +if not arcpy.Exists(work_path + os.sep + container_name): + arcpy.management.CreateFileGDB( + out_folder_path = work_path + ,out_name = container_name + ); + +print(" "); +print("purging existing data...",end="",flush=True); + +arcpy.env.preserveGlobalIds = True; + +item = work_path + os.sep + container_name + os.sep + "flow_direction" +if arcpy.Exists(item): + arcpy.Delete_management(item); + +item = work_path + os.sep + container_name + os.sep + "nhdarea" +if arcpy.Exists(item): + arcpy.Delete_management(item); + +item = work_path + os.sep + container_name + os.sep + "nhdline" +if arcpy.Exists(item): + arcpy.Delete_management(item); + +item = work_path + os.sep + container_name + os.sep + "nhdpoint" +if arcpy.Exists(item): + arcpy.Delete_management(item); + +item = work_path + os.sep + container_name + os.sep + "nhdwaterbody" +if arcpy.Exists(item): + arcpy.Delete_management(item); + +item = work_path + os.sep + container_name + os.sep + "networknhdflowline" +if arcpy.Exists(item): + arcpy.Delete_management(item); + +item = work_path + os.sep + container_name + os.sep + "nonnetworknhdflowline" +if arcpy.Exists(item): + arcpy.Delete_management(item); + +item = work_path + os.sep + container_name + os.sep + "nhdplusflow" +if arcpy.Exists(item): + arcpy.Delete_management(item); + +item = work_path + os.sep + container_name + os.sep + "nhdpluscatchment" +if arcpy.Exists(item): + arcpy.Delete_management(item); + +item = work_path + os.sep + container_name + os.sep + "nhdplussink" +if arcpy.Exists(item): + arcpy.Delete_management(item); + +item = work_path + os.sep + container_name + os.sep + "nhdplusgage" +if arcpy.Exists(item): + arcpy.Delete_management(item); + +item = work_path + os.sep + container_name + os.sep + "wbdhu12" +if arcpy.Exists(item): + arcpy.Delete_management(item); + +print(" DONE."); +print(" "); + +############################################################################### +def tbexporter(source,outname,work_path,container_name): + + print("counting " + source + "....",end="",flush=True); + bef = arcpy.GetCount_management(source)[0]; + print(" " + str(bef) + "."); + print("exporting " + outname + "...",end="",flush=True); + target_nm = work_path + os.sep + container_name + os.sep + outname; + arcpy.conversion.ExportTable( + in_table = source + ,out_table = work_path + os.sep + container_name + os.sep + outname + ,field_mapping = auto_fm(source) + ); + print(" DONE."); + print("counting " + outname + "....",end="",flush=True); + aft = arcpy.GetCount_management(work_path + os.sep + container_name + os.sep + outname)[0]; + print(" " + str(aft) + "."); + if bef != aft: + raise Exception("export counts for " + outname + " do not match!"); + + arcpy.management.AddGlobalIDs(work_path + os.sep + container_name + os.sep + outname); + print(" DONE."); + +############################################################################### +def fcexporter(source,outname,work_path,container_name): + + print("counting " + source + "....",end="",flush=True); + bef = int(arcpy.GetCount_management(source)[0]); + print(" " + str(bef) + "."); + + arcpy.env.outputCoordinateSystem = spref; + + if bef == 0: + print("creating empty fc " + outname + "...",end="",flush=True); + arcpy.management.CreateFeatureclass( + out_path = work_path + os.sep + container_name + ,out_name = outname + ,geometry_type = geometry_type + ,template = source + ,has_m = 'DISABLED' + ,has_z = 'DISABLED' + ,spatial_reference = spref + ); + + else: + print("exporting " + outname + "...",end="",flush=True); + arcpy.conversion.ExportFeatures( + in_features = source + ,out_features = work_path + os.sep + container_name + os.sep + outname + ,field_mapping = auto_fm(source) + ); + + print(" DONE."); + print("counting " + outname + "....",end="",flush=True); + aft = int(arcpy.GetCount_management(work_path + os.sep + container_name + os.sep + outname)[0]); + print(" " + str(aft) + "."); + if bef != aft: + raise Exception("export counts for " + outname + " do not match!"); + + arcpy.management.AddGlobalIDs(work_path + os.sep + container_name + os.sep + outname); + print(" DONE."); + +############################################################################### +source = source_conn + r"/cipsrv_gis.nhdplus_h_flow_direction_esri"; +outname = "flow_direction"; +target_nm = work_path + os.sep + container_name + os.sep + outname; +ret = fcexporter(source,outname,work_path,container_name); + +print("indexing " + outname + "...",end="",flush=True); +arcpy.management.AddIndex(target_nm,"nhdplusid" ,"idx01"); +arcpy.management.AddIndex(target_nm,"permanent_identifier" ,"idx02"); +arcpy.management.AddIndex(target_nm,"ftype" ,"idx03"); +arcpy.management.AddIndex(target_nm,"fcode" ,"idx04"); +arcpy.management.AddIndex(target_nm,"visibilityfilter" ,"idx05"); +print(" DONE."); +print(outname + " export complete."); +print(" "); + +############################################################################### +source = source_conn + r"/cipsrv_gis.nhdplus_h_nhdarea_esri"; +outname = "nhdarea"; +target_nm = work_path + os.sep + container_name + os.sep + outname; +ret = fcexporter(source,outname,work_path,container_name); + +print("indexing " + outname + "...",end="",flush=True); +arcpy.management.AddIndex(target_nm,"nhdplusid" ,"idx01"); +arcpy.management.AddIndex(target_nm,"permanent_identifier" ,"idx02"); +arcpy.management.AddIndex(target_nm,"gnis_id" ,"idx03"); +arcpy.management.AddIndex(target_nm,"ftype" ,"idx04"); +arcpy.management.AddIndex(target_nm,"fcode" ,"idx05"); +arcpy.management.AddIndex(target_nm,"visibilityfilter" ,"idx06"); +arcpy.management.AddIndex(target_nm,"vpuid" ,"idx07"); +print(" DONE."); +print(outname + " export complete."); +print(" "); + +############################################################################### +source = source_conn + r"/cipsrv_gis.nhdplus_h_nhdline_esri"; +outname = "nhdline"; +target_nm = work_path + os.sep + container_name + os.sep + outname; +ret = fcexporter(source,outname,work_path,container_name); + +print("indexing " + outname + "...",end="",flush=True); +arcpy.management.AddIndex(target_nm,"nhdplusid" ,"idx01"); +arcpy.management.AddIndex(target_nm,"permanent_identifier" ,"idx02"); +arcpy.management.AddIndex(target_nm,"gnis_id" ,"idx03"); +arcpy.management.AddIndex(target_nm,"ftype" ,"idx04"); +arcpy.management.AddIndex(target_nm,"fcode" ,"idx05"); +arcpy.management.AddIndex(target_nm,"visibilityfilter" ,"idx06"); +arcpy.management.AddIndex(target_nm,"vpuid" ,"idx07"); +print(" DONE."); +print(outname + " export complete."); +print(" "); + +############################################################################### +source = source_conn + r"/cipsrv_gis.nhdplus_h_nhdpoint_esri"; +outname = "nhdpoint"; +target_nm = work_path + os.sep + container_name + os.sep + outname; +ret = fcexporter(source,outname,work_path,container_name); + +print("indexing " + outname + "...",end="",flush=True); +arcpy.management.AddIndex(target_nm,"nhdplusid" ,"idx01"); +arcpy.management.AddIndex(target_nm,"permanent_identifier" ,"idx02"); +arcpy.management.AddIndex(target_nm,"gnis_id" ,"idx03"); +arcpy.management.AddIndex(target_nm,"ftype" ,"idx04"); +arcpy.management.AddIndex(target_nm,"fcode" ,"idx05"); +arcpy.management.AddIndex(target_nm,"vpuid" ,"idx06"); +print(" DONE."); +print(outname + " export complete."); +print(" "); + +############################################################################### +source = source_conn + r"/cipsrv_gis.nhdplus_h_nhdwaterbody_esri"; +outname = "nhdwaterbody"; +target_nm = work_path + os.sep + container_name + os.sep + outname; +ret = fcexporter(source,outname,work_path,container_name); + +print("indexing " + outname + "...",end="",flush=True); +arcpy.management.AddIndex(target_nm,"nhdplusid" ,"idx01"); +arcpy.management.AddIndex(target_nm,"permanent_identifier" ,"idx02"); +arcpy.management.AddIndex(target_nm,"gnis_id" ,"idx03"); +arcpy.management.AddIndex(target_nm,"ftype" ,"idx04"); +arcpy.management.AddIndex(target_nm,"fcode" ,"idx05"); +arcpy.management.AddIndex(target_nm,"visibilityfilter" ,"idx06"); +arcpy.management.AddIndex(target_nm,"vpuid" ,"idx07"); +arcpy.management.AddIndex(target_nm,"reachcode" ,"idx08"); +print(" DONE."); +print(outname + " export complete."); +print(" "); + +############################################################################### +source = source_conn + r"/cipsrv_gis.nhdplus_h_networknhdflowline_esri"; +outname = "networknhdflowline"; +target_nm = work_path + os.sep + container_name + os.sep + outname; +ret = fcexporter(source,outname,work_path,container_name); + +print("indexing " + outname + "...",end="",flush=True); +arcpy.management.AddIndex(target_nm,"nhdplusid" ,"idx01"); +arcpy.management.AddIndex(target_nm,"permanent_identifier" ,"idx02"); +arcpy.management.AddIndex(target_nm,"gnis_id" ,"idx03"); +arcpy.management.AddIndex(target_nm,"ftype" ,"idx04"); +arcpy.management.AddIndex(target_nm,"fcode" ,"idx05"); +arcpy.management.AddIndex(target_nm,"visibilityfilter" ,"idx06"); +arcpy.management.AddIndex(target_nm,"vpuid" ,"idx07"); +arcpy.management.AddIndex(target_nm,"reachcode" ,"idx08"); +arcpy.management.AddIndex(target_nm,"wbarea_permanent_identifier" ,"idx09"); +arcpy.management.AddIndex(target_nm,"levelpathi" ,"idx10"); +arcpy.management.AddIndex(target_nm,"hydroseq" ,"idx11"); +arcpy.management.AddIndex(target_nm,"uphydroseq" ,"idx12"); +arcpy.management.AddIndex(target_nm,"dnhydroseq" ,"idx13"); +arcpy.management.AddIndex(target_nm,"terminalpa" ,"idx14"); +arcpy.management.AddIndex(target_nm,"uplevelpat" ,"idx15"); +arcpy.management.AddIndex(target_nm,"dnlevelpat" ,"idx16"); +print(" DONE."); +print(outname + " export complete."); +print(" "); + +############################################################################### +source = source_conn + r"/cipsrv_gis.nhdplus_h_nonnetworknhdflowline_esri"; +outname = "nonnetworknhdflowline"; +target_nm = work_path + os.sep + container_name + os.sep + outname; +ret = fcexporter(source,outname,work_path,container_name); + +print("indexing " + outname + "...",end="",flush=True); +arcpy.management.AddIndex(target_nm,"nhdplusid" ,"idx01"); +arcpy.management.AddIndex(target_nm,"permanent_identifier" ,"idx02"); +arcpy.management.AddIndex(target_nm,"gnis_id" ,"idx03"); +arcpy.management.AddIndex(target_nm,"ftype" ,"idx04"); +arcpy.management.AddIndex(target_nm,"fcode" ,"idx05"); +arcpy.management.AddIndex(target_nm,"visibilityfilter" ,"idx06"); +arcpy.management.AddIndex(target_nm,"vpuid" ,"idx07"); +arcpy.management.AddIndex(target_nm,"reachcode" ,"idx08"); +arcpy.management.AddIndex(target_nm,"wbarea_permanent_identifier" ,"idx09"); +print(" DONE."); +print(outname + " export complete."); +print(" "); + +############################################################################### +source = source_conn + r"/cipsrv_gis.nhdplus_h_nhdplusflow_esri"; +outname = "nhdplusflow"; +target_nm = work_path + os.sep + container_name + os.sep + outname; +ret = tbexporter(source,outname,work_path,container_name); + +print("indexing " + outname + "...",end="",flush=True); +arcpy.management.AddIndex(target_nm,"fromnhdpid" ,"idx01"); +arcpy.management.AddIndex(target_nm,"tonhdpid" ,"idx02"); +arcpy.management.AddIndex(target_nm,"nodenumber" ,"idx03"); +arcpy.management.AddIndex(target_nm,"direction" ,"idx04"); +arcpy.management.AddIndex(target_nm,"frompermid" ,"idx05"); +arcpy.management.AddIndex(target_nm,"topermid" ,"idx06"); +arcpy.management.AddIndex(target_nm,"fromhydroseq" ,"idx07"); +arcpy.management.AddIndex(target_nm,"tohydroseq" ,"idx08"); +print(" DONE."); +print(outname + " export complete."); +print(" "); + +############################################################################### +source = source_conn + r"/cipsrv_gis.nhdplus_h_nhdpluscatchment_esri"; +outname = "nhdpluscatchment"; +target_nm = work_path + os.sep + container_name + os.sep + outname; +ret = fcexporter(source,outname,work_path,container_name); + +print("indexing " + outname + "...",end="",flush=True); +arcpy.management.AddIndex(target_nm,"nhdplusid" ,"idx01"); +arcpy.management.AddIndex(target_nm,"sourcefc" ,"idx02"); +arcpy.management.AddIndex(target_nm,"vpuid" ,"idx03"); +print(" DONE."); +print(outname + " export complete."); +print(" "); + +############################################################################### +source = source_conn + r"/cipsrv_gis.nhdplus_h_nhdplussink_esri"; +outname = "nhdplussink"; +target_nm = work_path + os.sep + container_name + os.sep + outname; +ret = fcexporter(source,outname,work_path,container_name,'POINT'); + +print("indexing " + outname + "...",end="",flush=True); +arcpy.management.AddIndex(target_nm,"nhdplusid" ,"idx01"); +arcpy.management.AddIndex(target_nm,"featureid" ,"idx02"); +arcpy.management.AddIndex(target_nm,"vpuid" ,"idx03"); +print(" DONE."); +print(outname + " export complete."); +print(" "); + +############################################################################### +source = source_conn + r"/cipsrv_gis.nhdplus_h_nhdplusgage_esri"; +outname = "nhdplusgage"; +target_nm = work_path + os.sep + container_name + os.sep + outname; +ret = fcexporter(source,outname,work_path,container_name,'POINT'); + +print("indexing " + outname + "...",end="",flush=True); +arcpy.management.AddIndex(target_nm,"hydroaddressid" ,"idx01"); +print(" DONE."); +print(outname + " export complete."); +print(" "); + +############################################################################### +source = source_conn + r"/cipsrv_gis.nhdplus_h_wbdhu12_esri"; +outname = "wbdhu12"; +target_nm = work_path + os.sep + container_name + os.sep + outname; +ret = fcexporter(source,outname,work_path,container_name); + +print("indexing " + outname + "...",end="",flush=True); +arcpy.management.AddIndex(target_nm,"huc12" ,"idx01"); +arcpy.management.AddIndex(target_nm,"vpuid" ,"idx02"); +print(" DONE."); +print(outname + " export complete."); +print(" "); + diff --git a/gis/arcgis/nhdplus_h/nhdplus_h.aprx b/gis/arcgis/nhdplus_h/nhdplus_h.aprx new file mode 100644 index 0000000..c946edf Binary files /dev/null and b/gis/arcgis/nhdplus_h/nhdplus_h.aprx differ diff --git a/gis/arcgis/nhdplus_h/nhdplus_h.atbx b/gis/arcgis/nhdplus_h/nhdplus_h.atbx new file mode 100644 index 0000000..8a10de0 Binary files /dev/null and b/gis/arcgis/nhdplus_h/nhdplus_h.atbx differ diff --git a/gis/arcgis/nhdplus_m.py b/gis/arcgis/nhdplus_m.py new file mode 100644 index 0000000..0dae791 --- /dev/null +++ b/gis/arcgis/nhdplus_m.py @@ -0,0 +1,371 @@ +import arcpy; +from arcpy import env; +import os,sys; + +spref = arcpy.SpatialReference(3857); + +############################################################################### +def auto_fm(source): + + sdeflds = ['objectid','shape','se_anno_cad_data','shape_length','shape_area','len','area','globalid']; + source_desc = arcpy.da.Describe(source); + + flds = [] + for item in source_desc["fields"]: + if item.name.lower() not in sdeflds: + flds.append(item); + + fms = arcpy.FieldMappings(); + + for i in range(len(flds)): + fm = arcpy.FieldMap(); + fm.addInputField(source,flds[i].name); + fd = fm.outputField; + fd.name = flds[i].name.lower() + #print(fd.name + ' ' + fd.type) + fd.type = flds[i].type + fd.length = flds[i].length; + fd.precision = flds[i].precision; + fd.scale = flds[i].scale; + fm.outputField = fd; + fms.addFieldMap(fm); + + return fms; + +############################################################################### +work_path = r"D:\Public\Data\pdziemie\gis"; +container_name = "nhdplus_m.gdb"; +source_conn = r"D:\Public\Data\WatersGeoPro\watersdev_cipsrv_gis.sde"; +print("using " + source_conn + "..."); +############################################################################### +if not arcpy.Exists(work_path + os.sep + container_name): + arcpy.management.CreateFileGDB( + out_folder_path = work_path + ,out_name = container_name + ); + +print(" "); +print("purging existing data...",end="",flush=True); + +arcpy.env.preserveGlobalIds = True; + +item = work_path + os.sep + container_name + os.sep + "flow_direction" +if arcpy.Exists(item): + arcpy.Delete_management(item); + +item = work_path + os.sep + container_name + os.sep + "nhdarea" +if arcpy.Exists(item): + arcpy.Delete_management(item); + +item = work_path + os.sep + container_name + os.sep + "nhdline" +if arcpy.Exists(item): + arcpy.Delete_management(item); + +item = work_path + os.sep + container_name + os.sep + "nhdpoint" +if arcpy.Exists(item): + arcpy.Delete_management(item); + +item = work_path + os.sep + container_name + os.sep + "nhdwaterbody" +if arcpy.Exists(item): + arcpy.Delete_management(item); + +item = work_path + os.sep + container_name + os.sep + "networknhdflowline" +if arcpy.Exists(item): + arcpy.Delete_management(item); + +item = work_path + os.sep + container_name + os.sep + "nonnetworknhdflowline" +if arcpy.Exists(item): + arcpy.Delete_management(item); + +item = work_path + os.sep + container_name + os.sep + "nhdplusflow" +if arcpy.Exists(item): + arcpy.Delete_management(item); + +item = work_path + os.sep + container_name + os.sep + "nhdpluscatchment" +if arcpy.Exists(item): + arcpy.Delete_management(item); + +item = work_path + os.sep + container_name + os.sep + "nhdplussink" +if arcpy.Exists(item): + arcpy.Delete_management(item); + +item = work_path + os.sep + container_name + os.sep + "nhdplusgage" +if arcpy.Exists(item): + arcpy.Delete_management(item); + +item = work_path + os.sep + container_name + os.sep + "wbdhu12" +if arcpy.Exists(item): + arcpy.Delete_management(item); + +print(" DONE."); +print(" "); + +############################################################################### +def tbexporter(source,outname,work_path,container_name): + + print("counting " + source + "....",end="",flush=True); + bef = arcpy.GetCount_management(source)[0]; + print(" " + str(bef) + "."); + print("exporting " + outname + "...",end="",flush=True); + target_nm = work_path + os.sep + container_name + os.sep + outname; + arcpy.conversion.ExportTable( + in_table = source + ,out_table = work_path + os.sep + container_name + os.sep + outname + ,field_mapping = auto_fm(source) + ); + print(" DONE."); + print("counting " + outname + "....",end="",flush=True); + aft = arcpy.GetCount_management(work_path + os.sep + container_name + os.sep + outname)[0]; + print(" " + str(aft) + "."); + if bef != aft: + raise Exception("export counts for " + outname + " do not match!"); + + arcpy.management.AddGlobalIDs(work_path + os.sep + container_name + os.sep + outname); + print(" DONE."); + +############################################################################### +def fcexporter(source,outname,work_path,container_name): + + print("counting " + source + "....",end="",flush=True); + bef = int(arcpy.GetCount_management(source)[0]); + print(" " + str(bef) + "."); + + arcpy.env.outputCoordinateSystem = spref; + + if bef == 0: + print("creating empty fc " + outname + "...",end="",flush=True); + arcpy.management.CreateFeatureclass( + out_path = work_path + os.sep + container_name + ,out_name = outname + ,geometry_type = geometry_type + ,template = source + ,has_m = 'DISABLED' + ,has_z = 'DISABLED' + ,spatial_reference = spref + ); + + else: + print("exporting " + outname + "...",end="",flush=True); + arcpy.conversion.ExportFeatures( + in_features = source + ,out_features = work_path + os.sep + container_name + os.sep + outname + ,field_mapping = auto_fm(source) + ); + + print(" DONE."); + print("counting " + outname + "....",end="",flush=True); + aft = int(arcpy.GetCount_management(work_path + os.sep + container_name + os.sep + outname)[0]); + print(" " + str(aft) + "."); + if bef != aft: + raise Exception("export counts for " + outname + " do not match!"); + + arcpy.management.AddGlobalIDs(work_path + os.sep + container_name + os.sep + outname); + print(" DONE."); + +############################################################################### +source = source_conn + r"/cipsrv_gis.nhdplus_m_flow_direction_esri"; +outname = "flow_direction"; +target_nm = work_path + os.sep + container_name + os.sep + outname; +ret = fcexporter(source,outname,work_path,container_name); + +print("indexing " + outname + "...",end="",flush=True); +arcpy.management.AddIndex(target_nm,"nhdplusid" ,"idx01"); +arcpy.management.AddIndex(target_nm,"permanent_identifier" ,"idx02"); +arcpy.management.AddIndex(target_nm,"ftype" ,"idx03"); +arcpy.management.AddIndex(target_nm,"fcode" ,"idx04"); +arcpy.management.AddIndex(target_nm,"visibilityfilter" ,"idx05"); +print(" DONE."); +print(outname + " export complete."); +print(" "); + +############################################################################### +source = source_conn + r"/cipsrv_gis.nhdplus_m_nhdarea_esri"; +outname = "nhdarea"; +target_nm = work_path + os.sep + container_name + os.sep + outname; +ret = fcexporter(source,outname,work_path,container_name); + +print("indexing " + outname + "...",end="",flush=True); +arcpy.management.AddIndex(target_nm,"nhdplusid" ,"idx01"); +arcpy.management.AddIndex(target_nm,"permanent_identifier" ,"idx02"); +arcpy.management.AddIndex(target_nm,"gnis_id" ,"idx03"); +arcpy.management.AddIndex(target_nm,"ftype" ,"idx04"); +arcpy.management.AddIndex(target_nm,"fcode" ,"idx05"); +arcpy.management.AddIndex(target_nm,"visibilityfilter" ,"idx06"); +arcpy.management.AddIndex(target_nm,"vpuid" ,"idx07"); +print(" DONE."); +print(outname + " export complete."); +print(" "); + +############################################################################### +source = source_conn + r"/cipsrv_gis.nhdplus_m_nhdline_esri"; +outname = "nhdline"; +target_nm = work_path + os.sep + container_name + os.sep + outname; +ret = fcexporter(source,outname,work_path,container_name); + +print("indexing " + outname + "...",end="",flush=True); +arcpy.management.AddIndex(target_nm,"nhdplusid" ,"idx01"); +arcpy.management.AddIndex(target_nm,"permanent_identifier" ,"idx02"); +arcpy.management.AddIndex(target_nm,"gnis_id" ,"idx03"); +arcpy.management.AddIndex(target_nm,"ftype" ,"idx04"); +arcpy.management.AddIndex(target_nm,"fcode" ,"idx05"); +arcpy.management.AddIndex(target_nm,"visibilityfilter" ,"idx06"); +arcpy.management.AddIndex(target_nm,"vpuid" ,"idx07"); +print(" DONE."); +print(outname + " export complete."); +print(" "); + +############################################################################### +source = source_conn + r"/cipsrv_gis.nhdplus_m_nhdpoint_esri"; +outname = "nhdpoint"; +target_nm = work_path + os.sep + container_name + os.sep + outname; +ret = fcexporter(source,outname,work_path,container_name); + +print("indexing " + outname + "...",end="",flush=True); +arcpy.management.AddIndex(target_nm,"nhdplusid" ,"idx01"); +arcpy.management.AddIndex(target_nm,"permanent_identifier" ,"idx02"); +arcpy.management.AddIndex(target_nm,"gnis_id" ,"idx03"); +arcpy.management.AddIndex(target_nm,"ftype" ,"idx04"); +arcpy.management.AddIndex(target_nm,"fcode" ,"idx05"); +arcpy.management.AddIndex(target_nm,"vpuid" ,"idx06"); +print(" DONE."); +print(outname + " export complete."); +print(" "); + +############################################################################### +source = source_conn + r"/cipsrv_gis.nhdplus_m_nhdwaterbody_esri"; +outname = "nhdwaterbody"; +target_nm = work_path + os.sep + container_name + os.sep + outname; +ret = fcexporter(source,outname,work_path,container_name); + +print("indexing " + outname + "...",end="",flush=True); +arcpy.management.AddIndex(target_nm,"nhdplusid" ,"idx01"); +arcpy.management.AddIndex(target_nm,"permanent_identifier" ,"idx02"); +arcpy.management.AddIndex(target_nm,"gnis_id" ,"idx03"); +arcpy.management.AddIndex(target_nm,"ftype" ,"idx04"); +arcpy.management.AddIndex(target_nm,"fcode" ,"idx05"); +arcpy.management.AddIndex(target_nm,"visibilityfilter" ,"idx06"); +arcpy.management.AddIndex(target_nm,"vpuid" ,"idx07"); +arcpy.management.AddIndex(target_nm,"reachcode" ,"idx08"); +print(" DONE."); +print(outname + " export complete."); +print(" "); + +############################################################################### +source = source_conn + r"/cipsrv_gis.nhdplus_m_networknhdflowline_esri"; +outname = "networknhdflowline"; +target_nm = work_path + os.sep + container_name + os.sep + outname; +ret = fcexporter(source,outname,work_path,container_name); + +print("indexing " + outname + "...",end="",flush=True); +arcpy.management.AddIndex(target_nm,"nhdplusid" ,"idx01"); +arcpy.management.AddIndex(target_nm,"permanent_identifier" ,"idx02"); +arcpy.management.AddIndex(target_nm,"gnis_id" ,"idx03"); +arcpy.management.AddIndex(target_nm,"ftype" ,"idx04"); +arcpy.management.AddIndex(target_nm,"fcode" ,"idx05"); +arcpy.management.AddIndex(target_nm,"visibilityfilter" ,"idx06"); +arcpy.management.AddIndex(target_nm,"vpuid" ,"idx07"); +arcpy.management.AddIndex(target_nm,"reachcode" ,"idx08"); +arcpy.management.AddIndex(target_nm,"wbarea_permanent_identifier" ,"idx09"); +arcpy.management.AddIndex(target_nm,"levelpathi" ,"idx10"); +arcpy.management.AddIndex(target_nm,"hydroseq" ,"idx11"); +arcpy.management.AddIndex(target_nm,"uphydroseq" ,"idx12"); +arcpy.management.AddIndex(target_nm,"dnhydroseq" ,"idx13"); +arcpy.management.AddIndex(target_nm,"terminalpa" ,"idx14"); +arcpy.management.AddIndex(target_nm,"uplevelpat" ,"idx15"); +arcpy.management.AddIndex(target_nm,"dnlevelpat" ,"idx16"); +print(" DONE."); +print(outname + " export complete."); +print(" "); + +############################################################################### +source = source_conn + r"/cipsrv_gis.nhdplus_m_nonnetworknhdflowline_esri"; +outname = "nonnetworknhdflowline"; +target_nm = work_path + os.sep + container_name + os.sep + outname; +ret = fcexporter(source,outname,work_path,container_name); + +print("indexing " + outname + "...",end="",flush=True); +arcpy.management.AddIndex(target_nm,"nhdplusid" ,"idx01"); +arcpy.management.AddIndex(target_nm,"permanent_identifier" ,"idx02"); +arcpy.management.AddIndex(target_nm,"gnis_id" ,"idx03"); +arcpy.management.AddIndex(target_nm,"ftype" ,"idx04"); +arcpy.management.AddIndex(target_nm,"fcode" ,"idx05"); +arcpy.management.AddIndex(target_nm,"visibilityfilter" ,"idx06"); +arcpy.management.AddIndex(target_nm,"vpuid" ,"idx07"); +arcpy.management.AddIndex(target_nm,"reachcode" ,"idx08"); +arcpy.management.AddIndex(target_nm,"wbarea_permanent_identifier" ,"idx09"); +print(" DONE."); +print(outname + " export complete."); +print(" "); + +############################################################################### +source = source_conn + r"/cipsrv_gis.nhdplus_m_nhdplusflow_esri"; +outname = "nhdplusflow"; +target_nm = work_path + os.sep + container_name + os.sep + outname; +ret = tbexporter(source,outname,work_path,container_name); + +print("indexing " + outname + "...",end="",flush=True); +arcpy.management.AddIndex(target_nm,"fromnhdpid" ,"idx01"); +arcpy.management.AddIndex(target_nm,"tonhdpid" ,"idx02"); +arcpy.management.AddIndex(target_nm,"nodenumber" ,"idx03"); +arcpy.management.AddIndex(target_nm,"direction" ,"idx04"); +arcpy.management.AddIndex(target_nm,"frompermid" ,"idx05"); +arcpy.management.AddIndex(target_nm,"topermid" ,"idx06"); +arcpy.management.AddIndex(target_nm,"fromhydroseq" ,"idx07"); +arcpy.management.AddIndex(target_nm,"tohydroseq" ,"idx08"); +print(" DONE."); +print(outname + " export complete."); +print(" "); + +############################################################################### +source = source_conn + r"/cipsrv_gis.nhdplus_m_nhdpluscatchment_esri"; +outname = "nhdpluscatchment"; +target_nm = work_path + os.sep + container_name + os.sep + outname; +ret = fcexporter(source,outname,work_path,container_name); + +print("indexing " + outname + "...",end="",flush=True); +arcpy.management.AddIndex(target_nm,"nhdplusid" ,"idx01"); +arcpy.management.AddIndex(target_nm,"sourcefc" ,"idx02"); +arcpy.management.AddIndex(target_nm,"vpuid" ,"idx03"); +print(" DONE."); +print(outname + " export complete."); +print(" "); + +############################################################################### +source = source_conn + r"/cipsrv_gis.nhdplus_m_nhdplussink_esri"; +outname = "nhdplussink"; +target_nm = work_path + os.sep + container_name + os.sep + outname; +ret = fcexporter(source,outname,work_path,container_name,'POINT'); + +print("indexing " + outname + "...",end="",flush=True); +arcpy.management.AddIndex(target_nm,"nhdplusid" ,"idx01"); +arcpy.management.AddIndex(target_nm,"featureid" ,"idx02"); +arcpy.management.AddIndex(target_nm,"vpuid" ,"idx03"); +print(" DONE."); +print(outname + " export complete."); +print(" "); + +############################################################################### +source = source_conn + r"/cipsrv_gis.nhdplus_m_nhdplusgage_esri"; +outname = "nhdplusgage"; +target_nm = work_path + os.sep + container_name + os.sep + outname; +ret = fcexporter(source,outname,work_path,container_name,'POINT'); + +print("indexing " + outname + "...",end="",flush=True); +arcpy.management.AddIndex(target_nm,"hydroaddressid" ,"idx01"); +print(" DONE."); +print(outname + " export complete."); +print(" "); + +############################################################################### +source = source_conn + r"/cipsrv_gis.nhdplus_m_wbdhu12_esri"; +outname = "wbdhu12"; +target_nm = work_path + os.sep + container_name + os.sep + outname; +ret = fcexporter(source,outname,work_path,container_name); + +print("indexing " + outname + "...",end="",flush=True); +arcpy.management.AddIndex(target_nm,"huc12" ,"idx01"); +arcpy.management.AddIndex(target_nm,"vpuid" ,"idx02"); +print(" DONE."); +print(outname + " export complete."); +print(" "); + diff --git a/gis/arcgis/nhdplus_m/nhdplus_m.aprx b/gis/arcgis/nhdplus_m/nhdplus_m.aprx new file mode 100644 index 0000000..c946edf Binary files /dev/null and b/gis/arcgis/nhdplus_m/nhdplus_m.aprx differ diff --git a/gis/arcgis/nhdplus_m/nhdplus_m.atbx b/gis/arcgis/nhdplus_m/nhdplus_m.atbx new file mode 100644 index 0000000..8a10de0 Binary files /dev/null and b/gis/arcgis/nhdplus_m/nhdplus_m.atbx differ diff --git a/src/database/cipsrv_gis/cipsrv_gis_deploy.sql b/src/database/cipsrv_gis/cipsrv_gis_deploy.sql new file mode 100644 index 0000000..34bae5c --- /dev/null +++ b/src/database/cipsrv_gis/cipsrv_gis_deploy.sql @@ -0,0 +1,2930 @@ +--******************************-- +----- views/epageofab_h_catchment_fabric.sql + +CREATE OR REPLACE VIEW cipsrv_gis.epageofab_h_catchment_fabric +AS +SELECT + a.objectid +,a.catchmentstatecode +,a.nhdplusid +,a.istribal +,a.istribal_areasqkm +,a.xwalk_huc12 +,a.xwalk_method +,a.xwalk_huc12_version +,a.sourcefc +,a.gridcode +,a.areasqkm +,a.areasqkm_geo +,a.isnavigable +,a.hasvaa +,a.issink +,a.isheadwater +,a.iscoastal +,a.isocean +,a.isalaskan +,a.h3hexagonaddr +,a.state_count +,a.vpuid +,a.sourcedataset +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_epageofab_h.catchment_fabric a; + +ALTER TABLE cipsrv_gis.epageofab_h_catchment_fabric OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.epageofab_h_catchment_fabric TO public; +--******************************-- +----- views/epageofab_h_catchment_fabric_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.epageofab_h_catchment_fabric_esri +AS +SELECT + a.objectid +,a.catchmentstatecode +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.istribal +,a.istribal_areasqkm +,a.xwalk_huc12 +,a.xwalk_method +,a.xwalk_huc12_version +,a.sourcefc +,a.gridcode +,a.areasqkm +,a.areasqkm_geo +,a.isnavigable +,a.hasvaa +,a.issink +,a.isheadwater +,a.iscoastal +,a.isocean +,a.isalaskan +,a.h3hexagonaddr +,CAST(a.state_count AS SMALLINT) AS state_count +,a.vpuid +,a.sourcedataset +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_epageofab_h.catchment_fabric a; + +ALTER TABLE cipsrv_gis.epageofab_h_catchment_fabric_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.epageofab_h_catchment_fabric_esri TO public; +--******************************-- +----- views/epageofab_h_catchment_fabric_huc12.sql + +CREATE OR REPLACE VIEW cipsrv_gis.epageofab_m_catchment_fabric_huc12 +AS +SELECT + a.objectid +,a.xwalk_huc12 +,a.xwalk_huc12_version +,a.areasqkm +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_epageofab_m.catchment_fabric_huc12 a; + +ALTER TABLE cipsrv_gis.epageofab_m_catchment_fabric_huc12 OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.epageofab_m_catchment_fabric_huc12 TO public; +--******************************-- +----- views/epageofab_h_catchment_fabric_huc12_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.epageofab_h_catchment_fabric_huc12_esri +AS +SELECT + a.objectid +,a.xwalk_huc12 +,a.xwalk_huc12_version +,a.areasqkm +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_epageofab_h.catchment_fabric_huc12 a; + +ALTER TABLE cipsrv_gis.epageofab_h_catchment_fabric_huc12_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.epageofab_h_catchment_fabric_huc12_esri TO public; +--******************************-- +----- views/epageofab_m_catchment_fabric.sql + +CREATE OR REPLACE VIEW cipsrv_gis.epageofab_m_catchment_fabric +AS +SELECT + a.objectid +,a.catchmentstatecode +,a.nhdplusid +,a.istribal +,a.istribal_areasqkm +,a.xwalk_huc12 +,a.xwalk_method +,a.xwalk_huc12_version +,a.sourcefc +,a.gridcode +,a.areasqkm +,a.areasqkm_geo +,a.isnavigable +,a.hasvaa +,a.issink +,a.isheadwater +,a.iscoastal +,a.isocean +,a.isalaskan +,a.h3hexagonaddr +,a.state_count +,a.vpuid +,a.sourcedataset +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_epageofab_m.catchment_fabric a; + +ALTER TABLE cipsrv_gis.epageofab_m_catchment_fabric OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.epageofab_m_catchment_fabric TO public; +--******************************-- +----- views/epageofab_m_catchment_fabric_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.epageofab_m_catchment_fabric_esri +AS +SELECT + a.objectid +,a.catchmentstatecode +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.istribal +,a.istribal_areasqkm +,a.xwalk_huc12 +,a.xwalk_method +,a.xwalk_huc12_version +,a.sourcefc +,a.gridcode +,a.areasqkm +,a.areasqkm_geo +,a.isnavigable +,a.hasvaa +,a.issink +,a.isheadwater +,a.iscoastal +,a.isocean +,a.isalaskan +,a.h3hexagonaddr +,CAST(a.state_count AS SMALLINT) AS state_count +,a.vpuid +,a.sourcedataset +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_epageofab_m.catchment_fabric a; + +ALTER TABLE cipsrv_gis.epageofab_m_catchment_fabric_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.epageofab_m_catchment_fabric_esri TO public; +--******************************-- +----- views/epageofab_m_catchment_fabric_huc12.sql + +CREATE OR REPLACE VIEW cipsrv_gis.epageofab_m_catchment_fabric_huc12 +AS +SELECT + a.objectid +,a.xwalk_huc12 +,a.xwalk_huc12_version +,a.areasqkm +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_epageofab_m.catchment_fabric_huc12 a; + +ALTER TABLE cipsrv_gis.epageofab_m_catchment_fabric_huc12 OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.epageofab_m_catchment_fabric_huc12 TO public; +--******************************-- +----- views/epageofab_m_catchment_fabric_huc12_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.epageofab_m_catchment_fabric_huc12_esri +AS +SELECT + a.objectid +,a.xwalk_huc12 +,a.xwalk_huc12_version +,a.areasqkm +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_epageofab_m.catchment_fabric_huc12 a; + +ALTER TABLE cipsrv_gis.epageofab_m_catchment_fabric_huc12_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.epageofab_m_catchment_fabric_huc12_esri TO public; +--******************************-- +----- views/nhdplus_h_flow_direction.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_flow_direction +AS +SELECT + a.objectid +,a.permanent_identifier +,CAST(DEGREES( + ST_Azimuth( + a.penul_point + ,a.final_point + ) + ) AS NUMERIC) AS angle_direction +,CAST(ROUND(DEGREES( + ST_Azimuth( + a.penul_point + ,a.final_point + ) + ) / 5 ) * 5 AS NUMERIC ) AS angle_rounded +,a.ftype +,a.fcode +,a.visibilityfilter +,a.nhdplusid +,ST_Transform(a.final_point,3857) AS shape +FROM ( + SELECT + aa.objectid + ,aa.permanent_identifier + ,aa.ftype + ,aa.fcode + ,aa.visibilityfilter + ,aa.nhdplusid + ,ST_PointN(aa.shape,-2) AS penul_point + ,ST_PointN(aa.shape,-1) AS final_point + FROM ( + SELECT + aaa.objectid + ,aaa.permanent_identifier + ,aaa.ftype + ,aaa.fcode + ,aaa.visibilityfilter + ,aaa.nhdplusid + ,ST_Force2D(aaa.shape) AS shape + FROM + cipsrv_nhdplus_h.networknhdflowline aaa + ) aa +) a; + +ALTER TABLE cipsrv_gis.nhdplus_h_flow_direction OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_flow_direction TO public; +--******************************-- +----- views/nhdplus_h_flow_direction_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_flow_direction_esri +AS +SELECT + a.objectid +,a.permanent_identifier +,CAST(DEGREES( + ST_Azimuth( + a.penul_point + ,a.final_point + ) + ) AS NUMERIC) AS angle_direction +,CAST(ROUND(DEGREES( + ST_Azimuth( + a.penul_point + ,a.final_point + ) + ) / 5 ) * 5 AS NUMERIC ) AS angle_rounded +,CAST(a.ftype AS INTEGER) AS ftype +,CAST(a.fcode AS INTEGER) AS fcode +,a.visibilityfilter +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,ST_Transform(a.final_point,3857) AS shape +FROM ( + SELECT + aa.objectid + ,aa.permanent_identifier + ,aa.ftype + ,aa.fcode + ,aa.visibilityfilter + ,aa.nhdplusid + ,ST_PointN(aa.shape,-2) AS penul_point + ,ST_PointN(aa.shape,-1) AS final_point + FROM ( + SELECT + aaa.objectid + ,aaa.permanent_identifier + ,aaa.ftype + ,aaa.fcode + ,aaa.visibilityfilter + ,aaa.nhdplusid + ,ST_Force2D(aaa.shape) AS shape + FROM + cipsrv_nhdplus_h.networknhdflowline aaa + ) aa +) a; + +ALTER TABLE cipsrv_gis.nhdplus_h_flow_direction_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_flow_direction_esri TO public; +--******************************-- +----- views/nhdplus_h_networknhdflowline.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_networknhdflowline +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.lengthkm +,a.totma +,a.reachcode +,a.flowdir +,a.wbarea_permanent_identifier +,a.ftype +,a.fcode +,a.mainpath +,a.innetwork +,a.visibilityfilter +,a.nhdplusid +,a.vpuid +,a.streamleve +,a.streamorde +,a.streamcalc +,a.fromnode +,a.tonode +,a.hydroseq +,a.levelpathi +,a.pathlength +,a.pathtimema +,a.terminalpa +,a.arbolatesu +,a.divergence +,a.startflag +,a.terminalfl +,a.uplevelpat +,a.uphydroseq +,a.dnlevel +,a.dnlevelpat +,a.dnhydroseq +,a.dnminorhyd +,a.dndraincou +,a.frommeas +,a.tomeas +,a.rtndiv +,a.thinner +,a.vpuin +,a.vpuout +,a.areasqkm +,a.totdasqkm +,a.divdasqkm +,a.maxelevraw +,a.minelevraw +,a.maxelevsmo +,a.minelevsmo +,a.slope +,a.slopelenkm +,a.elevfixed +,a.hwtype +,a.hwnodesqkm +,a.statusflag +,a.qama +,a.vama +,a.qincrama +,a.qbma +,a.vbma +,a.qincrbma +,a.qcma +,a.vcma +,a.qincrcma +,a.qdma +,a.vdma +,a.qincrdma +,a.qema +,a.vema +,a.qincrema +,a.qfma +,a.qincrfma +,a.arqnavma +,a.petma +,a.qlossma +,a.qgadjma +,a.qgnavma +,a.gageadjma +,a.avgqadjma +,a.gageidma +,a.gageqma +,a.globalid +,ST_Transform(ST_Force2D(a.shape),3857) AS shape +FROM +cipsrv_nhdplus_h.networknhdflowline a; + +ALTER TABLE cipsrv_gis.nhdplus_h_networknhdflowline OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_networknhdflowline TO public; +--******************************-- +----- views/nhdplus_h_networknhdflowline_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_networknhdflowline_esri +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.lengthkm +,a.totma +,a.reachcode +,a.flowdir +,a.wbarea_permanent_identifier +,CAST(a.ftype AS INTEGER) AS ftype +,CAST(a.fcode AS INTEGER) AS fcode +,a.mainpath +,CAST(a.innetwork AS SMALLINT) AS innetwork +,a.visibilityfilter +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.vpuid +,CAST(a.streamleve AS SMALLINT) AS streamleve +,CAST(a.streamorde AS SMALLINT) AS streamorde +,CAST(a.streamcalc AS SMALLINT) AS streamcalc +,CAST(a.fromnode AS NUMERIC) AS fromnode +,CAST(a.tonode AS NUMERIC) AS tonode +,CAST(a.hydroseq AS NUMERIC) AS hydroseq +,CAST(a.levelpathi AS NUMERIC) AS levelpathi +,a.pathlength +,a.pathtimema +,CAST(a.terminalpa AS NUMERIC) AS terminalpa +,a.arbolatesu +,CAST(a.divergence AS SMALLINT) AS divergence +,CAST(a.startflag AS SMALLINT) AS startflag +,CAST(a.terminalfl AS SMALLINT) AS terminalfl +,CAST(a.uplevelpat AS NUMERIC) AS uplevelpat +,CAST(a.uphydroseq AS NUMERIC) AS uphydroseq +,CAST(a.dnlevel AS SMALLINT) AS dnlevel +,CAST(a.dnlevelpat AS NUMERIC) AS dnlevelpat +,CAST(a.dnhydroseq AS NUMERIC) AS dnhydroseq +,CAST(a.dnminorhyd AS NUMERIC) AS dnminorhyd +,CAST(a.dndraincou AS SMALLINT) AS dndraincou +,a.frommeas +,a.tomeas +,CAST(a.rtndiv AS SMALLINT) AS rtndiv +,CAST(a.thinner AS SMALLINT) AS thinner +,CAST(a.vpuin AS SMALLINT) AS vpuin +,CAST(a.vpuout AS SMALLINT) AS vpuout +,a.areasqkm +,a.totdasqkm +,a.divdasqkm +,a.maxelevraw +,a.minelevraw +,a.maxelevsmo +,a.minelevsmo +,a.slope +,a.slopelenkm +,CAST(a.elevfixed AS SMALLINT) AS elevfixed +,CAST(a.hwtype AS SMALLINT) AS hwtype +,a.hwnodesqkm +,a.statusflag +,a.qama +,a.vama +,a.qincrama +,a.qbma +,a.vbma +,a.qincrbma +,a.qcma +,a.vcma +,a.qincrcma +,a.qdma +,a.vdma +,a.qincrdma +,a.qema +,a.vema +,a.qincrema +,a.qfma +,a.qincrfma +,a.arqnavma +,a.petma +,a.qlossma +,a.qgadjma +,a.qgnavma +,CAST(a.gageadjma AS SMALLINT) AS gageadjma +,a.avgqadjma +,a.gageidma +,a.gageqma +,a.globalid +,ST_Transform(ST_Force2D(a.shape),3857) AS shape +FROM +cipsrv_nhdplus_h.networknhdflowline a; + +ALTER TABLE cipsrv_gis.nhdplus_h_networknhdflowline_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_networknhdflowline_esri TO public; +--******************************-- +----- views/nhdplus_h_nhdarea.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_nhdarea +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.areasqkm +,a.elevation +,a.ftype +,a.fcode +,a.visibilityfilter +,a.nhdplusid +,a.vpuid +,a.onoffnet +,a.purpcode +,a.burn +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_h.nhdarea a; + +ALTER TABLE cipsrv_gis.nhdplus_h_nhdarea OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_nhdarea TO public; +--******************************-- +----- views/nhdplus_h_nhdarea_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_nhdarea_esri +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.areasqkm +,a.elevation +,CAST(a.ftype AS INTEGER) AS ftype +,CAST(a.fcode AS INTEGER) AS fcode +,a.visibilityfilter +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.vpuid +,a.onoffnet +,a.purpcode +,a.burn +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_h.nhdarea a; + +ALTER TABLE cipsrv_gis.nhdplus_h_nhdarea_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_nhdarea_esri TO public; +--******************************-- +----- views/nhdplus_h_nhdline.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_nhdline +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.lengthkm +,a.ftype +,a.fcode +,a.visibilityfilter +,a.nhdplusid +,a.vpuid +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_h.nhdline a; + +ALTER TABLE cipsrv_gis.nhdplus_h_nhdline OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_nhdline TO public; +--******************************-- +----- views/nhdplus_h_nhdline_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_nhdline_esri +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.lengthkm +,CAST(a.ftype AS INTEGER) AS ftype +,CAST(a.fcode AS INTEGER) AS fcode +,a.visibilityfilter +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.vpuid +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_h.nhdline a; + +ALTER TABLE cipsrv_gis.nhdplus_h_nhdline_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_nhdline_esri TO public; +--******************************-- +----- views/nhdplus_h_nhdpluscatchment.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_nhdpluscatchment +AS +SELECT + a.objectid +,a.nhdplusid +,a.sourcefc +,a.gridcode +,a.areasqkm +,a.vpuid +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_h.nhdpluscatchment a; + +ALTER TABLE cipsrv_gis.nhdplus_h_nhdpluscatchment OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_nhdpluscatchment TO public; +--******************************-- +----- views/nhdplus_h_nhdpluscatchment_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_nhdpluscatchment_esri +AS +SELECT + a.objectid +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.sourcefc +,a.gridcode +,a.areasqkm +,a.vpuid +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_h.nhdpluscatchment a; + +ALTER TABLE cipsrv_gis.nhdplus_h_nhdpluscatchment_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_nhdpluscatchment_esri TO public; +--******************************-- +----- views/nhdplus_h_nhdplusflow.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_nhdplusflow +AS +SELECT + a.objectid +,a.fromnhdpid +,a.tonhdpid +,a.nodenumber +,a.deltalevel +,a.direction +,a.gapdistkm +,a.hasgeo +,a.fromvpuid +,a.tovpuid +,a.frompermid +,a.topermid +,a.fromhydroseq +,a.tohydroseq +,a.globalid +FROM +cipsrv_nhdplus_h.nhdplusflow a; + +ALTER TABLE cipsrv_gis.nhdplus_h_nhdplusflow OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_nhdplusflow TO public; +--******************************-- +----- views/nhdplus_h_nhdplusflow_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_nhdplusflow_esri +AS +SELECT + a.objectid +,CAST(a.fromnhdpid AS NUMERIC) AS fromnhdpid +,CAST(a.tonhdpid AS NUMERIC) AS tonhdpid +,CAST(a.nodenumber AS NUMERIC) AS nodenumber +,CAST(a.deltalevel AS SMALLINT) AS deltalevel +,CAST(a.direction AS SMALLINT) AS direction +,a.gapdistkm +,CAST(a.hasgeo AS SMALLINT) AS hasgeo +,a.fromvpuid +,a.tovpuid +,a.frompermid +,a.topermid +,CAST(a.fromhydroseq AS NUMERIC) AS fromhydroseq +,CAST(a.tohydroseq AS NUMERIC) AS tohydroseq +,a.globalid +FROM +cipsrv_nhdplus_h.nhdplusflow a; + +ALTER TABLE cipsrv_gis.nhdplus_h_nhdplusflow_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_nhdplusflow_esri TO public; +--******************************-- +----- views/nhdplus_h_nhdplusgage.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_nhdplusgage +AS +SELECT + a.objectid +,a.hydroaddressid +,a.addressdate +,a.featuretype +,a.onnetwork +,a.sourceid +,a.sourceagency +,a.sourcedataset +,a.sourcefeatureurl +,a.catchment +,a.hu +,a.reachcode +,a.measure +,a.reachsmdate +,a.nhdplusid +,a.vpuid +,a.station_nm +,a.state_cd +,a.state +,a.latsite +,a.lonsite +,a.dasqmi +,a.referencegage +,a.class +,a.classmod +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_h.nhdplusgage a; + +ALTER TABLE cipsrv_gis.nhdplus_h_nhdplusgage OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_nhdplusgage TO public; +--******************************-- +----- views/nhdplus_h_nhdplusgage_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_nhdplusgage_esri +AS +SELECT + a.objectid +,a.hydroaddressid +,a.addressdate +,a.featuretype +,a.onnetwork +,a.sourceid +,a.sourceagency +,a.sourcedataset +,a.sourcefeatureurl +,CAST(a.catchment AS NUMERIC) AS catchment +,a.hu +,a.reachcode +,a.measure +,a.reachsmdate +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.vpuid +,a.station_nm +,a.state_cd +,a.state +,a.latsite +,a.lonsite +,a.dasqmi +,a.referencegage +,a.class +,a.classmod +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_h.nhdplusgage a; + +ALTER TABLE cipsrv_gis.nhdplus_h_nhdplusgage_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_nhdplusgage_esri TO public; +--******************************-- +----- views/nhdplus_h_nhdplussink.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_nhdplussink +AS +SELECT + a.objectid +,a.nhdplusid +,a.gridcode +,a.purpcode +,a.featureid +,a.sourcefc +,a.rpuid +,a.statusflag +,a.catchment +,a.burn +,a.vpuid +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_h.nhdplussink a; + +ALTER TABLE cipsrv_gis.nhdplus_h_nhdplussink OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_nhdplussink TO public; +--******************************-- +----- views/nhdplus_h_nhdplussink_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_nhdplussink_esri +AS +SELECT + a.objectid +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.gridcode +,a.purpcode +,CAST(a.featureid AS NUMERIC) AS featureid +,a.sourcefc +,a.rpuid +,a.statusflag +,CAST(a.catchment AS SMALLINT) AS catchment +,CAST(a.burn AS SMALLINT) AS burn +,a.vpuid +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_h.nhdplussink a; + +ALTER TABLE cipsrv_gis.nhdplus_h_nhdplussink_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_nhdplussink_esri TO public; +--******************************-- +----- views/nhdplus_h_nhdpoint.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_nhdpoint +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.reachcode +,a.ftype +,a.fcode +,a.nhdplusid +,a.vpuid +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_h.nhdpoint a; + +ALTER TABLE cipsrv_gis.nhdplus_h_nhdpoint OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_nhdpoint TO public; +--******************************-- +----- views/nhdplus_h_nhdpoint_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_nhdpoint_esri +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.reachcode +,CAST(a.ftype AS INTEGER) AS ftype +,CAST(a.fcode AS INTEGER) AS fcode +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.vpuid +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_h.nhdpoint a; + +ALTER TABLE cipsrv_gis.nhdplus_h_nhdpoint_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_nhdpoint_esri TO public; +--******************************-- +----- views/nhdplus_h_nhdwaterbody.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_nhdwaterbody +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.areasqkm +,a.elevation +,a.reachcode +,a.ftype +,a.fcode +,a.visibilityfilter +,a.nhdplusid +,a.vpuid +,a.onoffnet +,a.purpcode +,a.burn +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_m.nhdwaterbody a; + +ALTER TABLE cipsrv_gis.nhdplus_m_nhdwaterbody OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_nhdwaterbody TO public; +--******************************-- +----- views/nhdplus_h_nhdwaterbody_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_nhdwaterbody_esri +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.areasqkm +,a.elevation +,a.reachcode +,CAST(a.ftype AS INTEGER) AS ftype +,CAST(a.fcode AS INTEGER) AS fcode +,a.visibilityfilter +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.vpuid +,a.onoffnet +,a.purpcode +,a.burn +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_h.nhdwaterbody a; + +ALTER TABLE cipsrv_gis.nhdplus_h_nhdwaterbody_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_nhdwaterbody_esri TO public; +--******************************-- +----- views/nhdplus_h_nonnetworknhdflowline.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_nonnetworknhdflowline +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.lengthkm +,a.reachcode +,a.flowdir +,a.wbarea_permanent_identifier +,a.ftype +,a.fcode +,a.mainpath +,a.innetwork +,a.visibilityfilter +,a.nhdplusid +,a.vpuid +,a.globalid +,ST_Transform(ST_Force2D(a.shape),3857) AS shape +FROM +cipsrv_nhdplus_h.nonnetworknhdflowline a; + +ALTER TABLE cipsrv_gis.nhdplus_h_nonnetworknhdflowline OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_nonnetworknhdflowline TO public; +--******************************-- +----- views/nhdplus_h_nonnetworknhdflowline_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_nonnetworknhdflowline_esri +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.lengthkm +,a.reachcode +,a.flowdir +,a.wbarea_permanent_identifier +,CAST(a.ftype AS INTEGER) AS ftype +,CAST(a.fcode AS INTEGER) AS fcode +,a.mainpath +,CAST(a.innetwork AS SMALLINT) AS innetwork +,a.visibilityfilter +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.vpuid +,a.globalid +,ST_Transform(ST_Force2D(a.shape),3857) AS shape +FROM +cipsrv_nhdplus_h.nonnetworknhdflowline a; + +ALTER TABLE cipsrv_gis.nhdplus_h_nonnetworknhdflowline_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_nonnetworknhdflowline_esri TO public; +--******************************-- +----- views/nhdplus_h_wbdhu12.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_wbdhu12 +AS +SELECT + a.objectid +,a.tnmid +,a.metasourceid +,a.sourcedatadesc +,a.sourceoriginator +,a.sourcefeatureid +,a.loaddate +,a.referencegnis_ids +,a.areaacres +,a.areasqkm +,a.states +,a.huc12 +,a.name +,a.hutype +,a.humod +,a.tohuc +,a.noncontributingareaacres +,a.noncontributingareasqkm +,a.nhdplusid +,a.vpuid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_h.wbdhu12 a; + +ALTER TABLE cipsrv_gis.nhdplus_h_wbdhu12 OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_wbdhu12 TO public; +--******************************-- +----- views/nhdplus_h_wbdhu12_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_wbdhu12_esri +AS +SELECT + a.objectid +,a.tnmid +,a.metasourceid +,a.sourcedatadesc +,a.sourceoriginator +,a.sourcefeatureid +,a.loaddate +,a.referencegnis_ids +,a.areaacres +,a.areasqkm +,a.states +,a.huc12 +,a.name +,a.hutype +,a.humod +,a.tohuc +,a.noncontributingareaacres +,a.noncontributingareasqkm +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.vpuid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_h.wbdhu12 a; + +ALTER TABLE cipsrv_gis.nhdplus_h_wbdhu12_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_wbdhu12_esri TO public; +--******************************-- +----- views/nhdplus_m_flow_direction.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_flow_direction +AS +SELECT + a.objectid +,a.permanent_identifier +,CAST(DEGREES( + ST_Azimuth( + a.penul_point + ,a.final_point + ) + ) AS NUMERIC) AS angle_direction +,CAST(ROUND(DEGREES( + ST_Azimuth( + a.penul_point + ,a.final_point + ) + ) / 5 ) * 5 AS NUMERIC ) AS angle_rounded +,a.ftype +,a.fcode +,a.visibilityfilter +,a.nhdplusid +,ST_Transform(a.final_point,3857) AS shape +FROM ( + SELECT + aa.objectid + ,aa.permanent_identifier + ,aa.ftype + ,aa.fcode + ,aa.visibilityfilter + ,aa.nhdplusid + ,ST_PointN(aa.shape,-2) AS penul_point + ,ST_PointN(aa.shape,-1) AS final_point + FROM ( + SELECT + aaa.objectid + ,aaa.permanent_identifier + ,aaa.ftype + ,aaa.fcode + ,aaa.visibilityfilter + ,aaa.nhdplusid + ,ST_Force2D(aaa.shape) AS shape + FROM + cipsrv_nhdplus_m.networknhdflowline aaa + ) aa +) a; + +ALTER TABLE cipsrv_gis.nhdplus_m_flow_direction OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_flow_direction TO public; +--******************************-- +----- views/nhdplus_m_flow_direction_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_flow_direction_esri +AS +SELECT + a.objectid +,a.permanent_identifier +,CAST(DEGREES( + ST_Azimuth( + a.penul_point + ,a.final_point + ) + ) AS NUMERIC) AS angle_direction +,CAST(ROUND(DEGREES( + ST_Azimuth( + a.penul_point + ,a.final_point + ) + ) / 5 ) * 5 AS NUMERIC ) AS angle_rounded +,CAST(a.ftype AS INTEGER) AS ftype +,CAST(a.fcode AS INTEGER) AS fcode +,a.visibilityfilter +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,ST_Transform(a.final_point,3857) AS shape +FROM ( + SELECT + aa.objectid + ,aa.permanent_identifier + ,aa.ftype + ,aa.fcode + ,aa.visibilityfilter + ,aa.nhdplusid + ,ST_PointN(aa.shape,-2) AS penul_point + ,ST_PointN(aa.shape,-1) AS final_point + FROM ( + SELECT + aaa.objectid + ,aaa.permanent_identifier + ,aaa.ftype + ,aaa.fcode + ,aaa.visibilityfilter + ,aaa.nhdplusid + ,ST_Force2D(aaa.shape) AS shape + FROM + cipsrv_nhdplus_m.networknhdflowline aaa + ) aa +) a; + +ALTER TABLE cipsrv_gis.nhdplus_m_flow_direction_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_flow_direction_esri TO public; +--******************************-- +----- views/nhdplus_m_networknhdflowline.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_networknhdflowline +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.lengthkm +,a.totma +,a.reachcode +,a.flowdir +,a.wbarea_permanent_identifier +,a.ftype +,a.fcode +,a.mainpath +,a.innetwork +,a.visibilityfilter +,a.nhdplusid +,a.vpuid +,a.streamleve +,a.streamorde +,a.streamcalc +,a.fromnode +,a.tonode +,a.hydroseq +,a.levelpathi +,a.pathlength +,a.pathtimema +,a.terminalpa +,a.arbolatesu +,a.divergence +,a.startflag +,a.terminalfl +,a.uplevelpat +,a.uphydroseq +,a.dnlevel +,a.dnlevelpat +,a.dnhydroseq +,a.dnminorhyd +,a.dndraincou +,a.frommeas +,a.tomeas +,a.rtndiv +,a.thinner +,a.vpuin +,a.vpuout +,a.areasqkm +,a.totdasqkm +,a.divdasqkm +,a.maxelevraw +,a.minelevraw +,a.maxelevsmo +,a.minelevsmo +,a.slope +,a.slopelenkm +,a.elevfixed +,a.hwtype +,a.hwnodesqkm +,a.statusflag +,a.qama +,a.vama +,a.qincrama +,a.qbma +,a.vbma +,a.qincrbma +,a.qcma +,a.vcma +,a.qincrcma +,a.qdma +,a.vdma +,a.qincrdma +,a.qema +,a.vema +,a.qincrema +,a.qfma +,a.qincrfma +,a.arqnavma +,a.petma +,a.qlossma +,a.qgadjma +,a.qgnavma +,a.gageadjma +,a.avgqadjma +,a.gageidma +,a.gageqma +,a.globalid +,ST_Transform(ST_Force2D(a.shape),3857) AS shape +FROM +cipsrv_nhdplus_m.networknhdflowline a; + +ALTER TABLE cipsrv_gis.nhdplus_m_networknhdflowline OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_networknhdflowline TO public; +--******************************-- +----- views/nhdplus_m_networknhdflowline_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_networknhdflowline_esri +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.lengthkm +,a.totma +,a.reachcode +,a.flowdir +,a.wbarea_permanent_identifier +,CAST(a.ftype AS INTEGER) AS ftype +,CAST(a.fcode AS INTEGER) AS fcode +,a.mainpath +,CAST(a.innetwork AS SMALLINT) AS innetwork +,a.visibilityfilter +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.vpuid +,CAST(a.streamleve AS SMALLINT) AS streamleve +,CAST(a.streamorde AS SMALLINT) AS streamorde +,CAST(a.streamcalc AS SMALLINT) AS streamcalc +,CAST(a.fromnode AS NUMERIC) AS fromnode +,CAST(a.tonode AS NUMERIC) AS tonode +,CAST(a.hydroseq AS NUMERIC) AS hydroseq +,CAST(a.levelpathi AS NUMERIC) AS levelpathi +,a.pathlength +,a.pathtimema +,CAST(a.terminalpa AS NUMERIC) AS terminalpa +,a.arbolatesu +,CAST(a.divergence AS SMALLINT) AS divergence +,CAST(a.startflag AS SMALLINT) AS startflag +,CAST(a.terminalfl AS SMALLINT) AS terminalfl +,CAST(a.uplevelpat AS NUMERIC) AS uplevelpat +,CAST(a.uphydroseq AS NUMERIC) AS uphydroseq +,CAST(a.dnlevel AS SMALLINT) AS dnlevel +,CAST(a.dnlevelpat AS NUMERIC) AS dnlevelpat +,CAST(a.dnhydroseq AS NUMERIC) AS dnhydroseq +,CAST(a.dnminorhyd AS NUMERIC) AS dnminorhyd +,CAST(a.dndraincou AS SMALLINT) AS dndraincou +,a.frommeas +,a.tomeas +,CAST(a.rtndiv AS SMALLINT) AS rtndiv +,CAST(a.thinner AS SMALLINT) AS thinner +,CAST(a.vpuin AS SMALLINT) AS vpuin +,CAST(a.vpuout AS SMALLINT) AS vpuout +,a.areasqkm +,a.totdasqkm +,a.divdasqkm +,a.maxelevraw +,a.minelevraw +,a.maxelevsmo +,a.minelevsmo +,a.slope +,a.slopelenkm +,CAST(a.elevfixed AS SMALLINT) AS elevfixed +,CAST(a.hwtype AS SMALLINT) AS hwtype +,a.hwnodesqkm +,a.statusflag +,a.qama +,a.vama +,a.qincrama +,a.qbma +,a.vbma +,a.qincrbma +,a.qcma +,a.vcma +,a.qincrcma +,a.qdma +,a.vdma +,a.qincrdma +,a.qema +,a.vema +,a.qincrema +,a.qfma +,a.qincrfma +,a.arqnavma +,a.petma +,a.qlossma +,a.qgadjma +,a.qgnavma +,CAST(a.gageadjma AS SMALLINT) AS gageadjma +,a.avgqadjma +,a.gageidma +,a.gageqma +,a.globalid +,ST_Transform(ST_Force2D(a.shape),3857) AS shape +FROM +cipsrv_nhdplus_m.networknhdflowline a; + +ALTER TABLE cipsrv_gis.nhdplus_m_networknhdflowline_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_networknhdflowline_esri TO public; +--******************************-- +----- views/nhdplus_m_nhdarea.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_nhdarea +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.areasqkm +,a.elevation +,a.ftype +,a.fcode +,a.visibilityfilter +,a.nhdplusid +,a.vpuid +,a.onoffnet +,a.purpcode +,a.burn +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_m.nhdarea a; + +ALTER TABLE cipsrv_gis.nhdplus_m_nhdarea OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_nhdarea TO public; +--******************************-- +----- views/nhdplus_m_nhdarea_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_nhdarea_esri +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.areasqkm +,a.elevation +,CAST(a.ftype AS INTEGER) AS ftype +,CAST(a.fcode AS INTEGER) AS fcode +,a.visibilityfilter +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.vpuid +,a.onoffnet +,a.purpcode +,a.burn +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_m.nhdarea a; + +ALTER TABLE cipsrv_gis.nhdplus_m_nhdarea_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_nhdarea_esri TO public; +--******************************-- +----- views/nhdplus_m_nhdline.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_nhdline +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.areasqkm +,a.elevation +,a.ftype +,a.fcode +,a.visibilityfilter +,a.nhdplusid +,a.vpuid +,a.onoffnet +,a.purpcode +,a.burn +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_m.nhdarea a; + +ALTER TABLE cipsrv_gis.nhdplus_m_nhdarea OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_nhdarea TO public; +--******************************-- +----- views/nhdplus_m_nhdline_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_nhdline_esri +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.lengthkm +,CAST(a.ftype AS INTEGER) AS ftype +,CAST(a.fcode AS INTEGER) AS fcode +,a.visibilityfilter +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.vpuid +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_m.nhdline a; + +ALTER TABLE cipsrv_gis.nhdplus_m_nhdline_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_nhdline_esri TO public; +--******************************-- +----- views/nhdplus_m_nhdpluscatchment.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_nhdpluscatchment +AS +SELECT + a.objectid +,a.nhdplusid +,a.sourcefc +,a.gridcode +,a.areasqkm +,a.vpuid +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_m.nhdpluscatchment a; + +ALTER TABLE cipsrv_gis.nhdplus_m_nhdpluscatchment OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_nhdpluscatchment TO public; +--******************************-- +----- views/nhdplus_m_nhdpluscatchment_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_nhdpluscatchment_esri +AS +SELECT + a.objectid +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.sourcefc +,a.gridcode +,a.areasqkm +,a.vpuid +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_m.nhdpluscatchment a; + +ALTER TABLE cipsrv_gis.nhdplus_m_nhdpluscatchment_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_nhdpluscatchment_esri TO public; +--******************************-- +----- views/nhdplus_m_nhdplusflow.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_nhdplusflow +AS +SELECT + a.objectid +,a.fromnhdpid +,a.tonhdpid +,a.nodenumber +,a.deltalevel +,a.direction +,a.gapdistkm +,a.hasgeo +,a.fromvpuid +,a.tovpuid +,a.frompermid +,a.topermid +,a.fromhydroseq +,a.tohydroseq +,a.globalid +FROM +cipsrv_nhdplus_m.nhdplusflow a; + +ALTER TABLE cipsrv_gis.nhdplus_m_nhdplusflow OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_nhdplusflow TO public; +--******************************-- +----- views/nhdplus_m_nhdplusflow_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_nhdplusflow_esri +AS +SELECT + a.objectid +,CAST(a.fromnhdpid AS NUMERIC) AS fromnhdpid +,CAST(a.tonhdpid AS NUMERIC) AS tonhdpid +,CAST(a.nodenumber AS NUMERIC) AS nodenumber +,CAST(a.deltalevel AS SMALLINT) AS deltalevel +,CAST(a.direction AS SMALLINT) AS direction +,a.gapdistkm +,CAST(a.hasgeo AS SMALLINT) AS hasgeo +,a.fromvpuid +,a.tovpuid +,a.frompermid +,a.topermid +,CAST(a.fromhydroseq AS NUMERIC) AS fromhydroseq +,CAST(a.tohydroseq AS NUMERIC) AS tohydroseq +,a.globalid +FROM +cipsrv_nhdplus_m.nhdplusflow a; + +ALTER TABLE cipsrv_gis.nhdplus_m_nhdplusflow_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_nhdplusflow_esri TO public; +--******************************-- +----- views/nhdplus_m_nhdplusgage.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_nhdplusgage +AS +SELECT + a.objectid +,a.hydroaddressid +,a.addressdate +,a.featuretype +,a.onnetwork +,a.sourceid +,a.sourceagency +,a.sourcedataset +,a.sourcefeatureurl +,a.catchment +,a.hu +,a.reachcode +,a.measure +,a.reachsmdate +,a.nhdplusid +,a.vpuid +,a.station_nm +,a.state_cd +,a.state +,a.latsite +,a.lonsite +,a.dasqmi +,a.referencegage +,a.class +,a.classmod +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_m.nhdplusgage a; + +ALTER TABLE cipsrv_gis.nhdplus_m_nhdplusgage OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_nhdplusgage TO public; +--******************************-- +----- views/nhdplus_m_nhdplusgage_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_nhdplusgage_esri +AS +SELECT + a.objectid +,a.hydroaddressid +,a.addressdate +,a.featuretype +,a.onnetwork +,a.sourceid +,a.sourceagency +,a.sourcedataset +,a.sourcefeatureurl +,CAST(a.catchment AS NUMERIC) AS catchment +,a.hu +,a.reachcode +,a.measure +,a.reachsmdate +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.vpuid +,a.station_nm +,a.state_cd +,a.state +,a.latsite +,a.lonsite +,a.dasqmi +,a.referencegage +,a.class +,a.classmod +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_m.nhdplusgage a; + +ALTER TABLE cipsrv_gis.nhdplus_m_nhdplusgage_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_nhdplusgage_esri TO public; +--******************************-- +----- views/nhdplus_m_nhdplussink.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_nhdplussink +AS +SELECT + a.objectid +,a.nhdplusid +,a.gridcode +,a.purpcode +,a.featureid +,a.sourcefc +,a.rpuid +,a.statusflag +,a.catchment +,a.burn +,a.vpuid +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_m.nhdplussink a; + +ALTER TABLE cipsrv_gis.nhdplus_m_nhdplussink OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_nhdplussink TO public; +--******************************-- +----- views/nhdplus_m_nhdplussink_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_nhdplussink_esri +AS +SELECT + a.objectid +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.gridcode +,a.purpcode +,CAST(a.featureid AS NUMERIC) AS featureid +,a.sourcefc +,a.rpuid +,a.statusflag +,CAST(a.catchment AS SMALLINT) AS catchment +,CAST(a.burn AS SMALLINT) AS burn +,a.vpuid +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_m.nhdplussink a; + +ALTER TABLE cipsrv_gis.nhdplus_m_nhdplussink_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_nhdplussink_esri TO public; +--******************************-- +----- views/nhdplus_m_nhdpoint.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_nhdpoint +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.reachcode +,a.ftype +,a.fcode +,a.nhdplusid +,a.vpuid +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_m.nhdpoint a; + +ALTER TABLE cipsrv_gis.nhdplus_m_nhdpoint OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_nhdpoint TO public; +--******************************-- +----- views/nhdplus_m_nhdpoint_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_nhdpoint_esri +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.reachcode +,CAST(a.ftype AS INTEGER) AS ftype +,CAST(a.fcode AS INTEGER) AS fcode +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.vpuid +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_m.nhdpoint a; + +ALTER TABLE cipsrv_gis.nhdplus_m_nhdpoint_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_nhdpoint_esri TO public; +--******************************-- +----- views/nhdplus_m_nhdwaterbody.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_nhdwaterbody +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.areasqkm +,a.elevation +,a.reachcode +,a.ftype +,a.fcode +,a.visibilityfilter +,a.nhdplusid +,a.vpuid +,a.onoffnet +,a.purpcode +,a.burn +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_m.nhdwaterbody a; + +ALTER TABLE cipsrv_gis.nhdplus_m_nhdwaterbody OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_nhdwaterbody TO public; +--******************************-- +----- views/nhdplus_m_nhdwaterbody_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_nhdwaterbody_esri +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.areasqkm +,a.elevation +,a.reachcode +,CAST(a.ftype AS INTEGER) AS ftype +,CAST(a.fcode AS INTEGER) AS fcode +,a.visibilityfilter +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.vpuid +,a.onoffnet +,a.purpcode +,a.burn +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_m.nhdwaterbody a; + +ALTER TABLE cipsrv_gis.nhdplus_m_nhdwaterbody_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_nhdwaterbody_esri TO public; +--******************************-- +----- views/nhdplus_m_nonnetworknhdflowline.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_nonnetworknhdflowline +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.lengthkm +,a.reachcode +,a.flowdir +,a.wbarea_permanent_identifier +,a.ftype +,a.fcode +,a.mainpath +,a.innetwork +,a.visibilityfilter +,a.nhdplusid +,a.vpuid +,a.globalid +,ST_Transform(ST_Force2D(a.shape),3857) AS shape +FROM +cipsrv_nhdplus_m.nonnetworknhdflowline a; + +ALTER TABLE cipsrv_gis.nhdplus_m_nonnetworknhdflowline OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_nonnetworknhdflowline TO public; +--******************************-- +----- views/nhdplus_m_nonnetworknhdflowline_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_nonnetworknhdflowline_esri +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.lengthkm +,a.reachcode +,a.flowdir +,a.wbarea_permanent_identifier +,CAST(a.ftype AS INTEGER) AS ftype +,CAST(a.fcode AS INTEGER) AS fcode +,a.mainpath +,CAST(a.innetwork AS SMALLINT) AS innetwork +,a.visibilityfilter +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.vpuid +,a.globalid +,ST_Transform(ST_Force2D(a.shape),3857) AS shape +FROM +cipsrv_nhdplus_m.nonnetworknhdflowline a; + +ALTER TABLE cipsrv_gis.nhdplus_m_nonnetworknhdflowline_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_nonnetworknhdflowline_esri TO public; +--******************************-- +----- views/nhdplus_m_wbdhu12.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_wbdhu12 +AS +SELECT + a.objectid +,a.tnmid +,a.metasourceid +,a.sourcedatadesc +,a.sourceoriginator +,a.sourcefeatureid +,a.loaddate +,a.referencegnis_ids +,a.areaacres +,a.areasqkm +,a.states +,a.huc12 +,a.name +,a.hutype +,a.humod +,a.tohuc +,a.noncontributingareaacres +,a.noncontributingareasqkm +,a.nhdplusid +,a.vpuid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_m.wbdhu12 a; + +ALTER TABLE cipsrv_gis.nhdplus_m_wbdhu12 OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_wbdhu12 TO public; +--******************************-- +----- views/nhdplus_m_wbdhu12_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_wbdhu12_esri +AS +SELECT + a.objectid +,a.tnmid +,a.metasourceid +,a.sourcedatadesc +,a.sourceoriginator +,a.sourcefeatureid +,a.loaddate +,a.referencegnis_ids +,a.areaacres +,a.areasqkm +,a.states +,a.huc12 +,a.name +,a.hutype +,a.humod +,a.tohuc +,a.noncontributingareaacres +,a.noncontributingareasqkm +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.vpuid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_m.wbdhu12 a; + +ALTER TABLE cipsrv_gis.nhdplus_m_wbdhu12_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_wbdhu12_esri TO public; +--******************************-- +----- views/owld_wqp_attr.sql + +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_attr +AS +SELECT + a.objectid +,a.source_joinkey +,a.organizationidentifier +,a.organizationformalname +,a.monitoringlocationidentifier +,a.monitoringlocationname +,a.monitoringlocationtypename +,a.monitoringlocationdescription +,a.huceightdigitcode +,a.drainageareameasure_measureval +,a.drainageareameasure_measureunt +,a.contributingdrainageareameasva +,a.contributingdrainageareameasun +,a.latitudemeasure +,a.longitudemeasure +,a.sourcemapscalenumeric +,a.horizontalaccuracymeasureval +,a.horizontalaccuracymeasureunit +,a.horizontalcollectionmethodname +,a.horizontalcoordinatereferences +,a.verticalmeasure_measurevalue +,a.verticalmeasure_measureunit +,a.verticalaccuracymeasurevalue +,a.verticalaccuracymeasureunit +,a.verticalcollectionmethodname +,a.verticalcoordinatereferencesys +,a.countrycode +,a.statecode +,a.countycode +,a.aquifername +,a.formationtypetext +,a.aquifertypename +,a.localaqfrname +,a.constructiondatetext +,a.welldepthmeasure_measurevalue +,a.welldepthmeasure_measureunit +,a.wellholedepthmeasure_measureva +,a.wellholedepthmeasure_measureun +,a.providername +,a.globalid +FROM +cipsrv_owld.wqp_attr a; + +ALTER TABLE cipsrv_gis.owld_wqp_attr OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_attr TO public; +--******************************-- +----- views/owld_wqp_attr_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_attr_esri +AS +SELECT + a.objectid +,a.source_joinkey +,a.organizationidentifier +,a.organizationformalname +,a.monitoringlocationidentifier +,a.monitoringlocationname +,a.monitoringlocationtypename +,a.monitoringlocationdescription +,a.huceightdigitcode +,a.drainageareameasure_measureval +,a.drainageareameasure_measureunt +,a.contributingdrainageareameasva +,a.contributingdrainageareameasun +,a.latitudemeasure +,a.longitudemeasure +,a.sourcemapscalenumeric +,a.horizontalaccuracymeasureval +,a.horizontalaccuracymeasureunit +,a.horizontalcollectionmethodname +,a.horizontalcoordinatereferences +,a.verticalmeasure_measurevalue +,a.verticalmeasure_measureunit +,a.verticalaccuracymeasurevalue +,a.verticalaccuracymeasureunit +,a.verticalcollectionmethodname +,a.verticalcoordinatereferencesys +,a.countrycode +,a.statecode +,a.countycode +,a.aquifername +,a.formationtypetext +,a.aquifertypename +,a.localaqfrname +,a.constructiondatetext +,a.welldepthmeasure_measurevalue +,a.welldepthmeasure_measureunit +,a.wellholedepthmeasure_measureva +,a.wellholedepthmeasure_measureun +,a.providername +,a.globalid +FROM +cipsrv_owld.wqp_attr a; + +ALTER TABLE cipsrv_gis.owld_wqp_attr_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_attr_esri TO public; +--******************************-- +----- views/owld_wqp_cip.sql + +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_cip +AS +SELECT + a.objectid +,a.cip_joinkey +,a.permid_joinkey +,a.source_originator +,a.source_featureid +,a.source_featureid2 +,a.source_series +,a.source_subdivision +,a.source_joinkey +,a.start_date +,a.end_date +,a.cat_joinkey +,a.catchmentstatecode +,a.nhdplusid +,a.istribal +,a.istribal_areasqkm +,a.catchmentresolution +,a.catchmentareasqkm +,a.xwalk_huc12 +,a.xwalk_method +,a.xwalk_huc12_version +,a.isnavigable +,a.hasvaa +,a.issink +,a.isheadwater +,a.iscoastal +,a.isocean +,a.isalaskan +,a.h3hexagonaddr +,a.globalid +FROM +cipsrv_owld.wqp_cip a; + +ALTER TABLE cipsrv_gis.owld_wqp_cip OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_cip TO public; +--******************************-- +----- views/owld_wqp_cip_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_cip_esri +AS +SELECT + a.objectid +,a.cip_joinkey +,a.permid_joinkey +,a.source_originator +,a.source_featureid +,a.source_featureid2 +,a.source_series +,a.source_subdivision +,a.source_joinkey +,a.start_date +,a.end_date +,a.cat_joinkey +,a.catchmentstatecode +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.istribal +,a.istribal_areasqkm +,a.catchmentresolution +,a.catchmentareasqkm +,a.xwalk_huc12 +,a.xwalk_method +,a.xwalk_huc12_version +,a.isnavigable +,a.hasvaa +,a.issink +,a.isheadwater +,a.iscoastal +,a.isocean +,a.isalaskan +,a.h3hexagonaddr +,a.globalid +FROM +cipsrv_owld.wqp_cip a; + +ALTER TABLE cipsrv_gis.owld_wqp_cip_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_cip_esri TO public; +--******************************-- +----- views/owld_wqp_cip_geo.sql + +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_cip_geo +AS +SELECT + a.objectid +,a.cat_joinkey +,a.catchmentstatecode +,a.nhdplusid +,a.catchmentresolution +,a.catchmentareasqkm +,a.xwalk_huc12 +,a.xwalk_method +,a.xwalk_huc12_version +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_owld.wqp_cip_geo a; + +ALTER TABLE cipsrv_gis.owld_wqp_cip_geo OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_cip_geo TO public; +--******************************-- +----- views/owld_wqp_cip_geo_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_cip_geo_esri +AS +SELECT + a.objectid +,a.cat_joinkey +,a.catchmentstatecode +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.catchmentresolution +,a.catchmentareasqkm +,a.xwalk_huc12 +,a.xwalk_method +,a.xwalk_huc12_version +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_owld.wqp_cip_geo a; + +ALTER TABLE cipsrv_gis.owld_wqp_cip_geo_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_cip_geo_esri TO public; +--******************************-- +----- views/owld_wqp_huc12.sql + +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_huc12 +AS +SELECT + a.objectid +,a.source_originator +,a.source_featureid +,a.source_featureid2 +,a.source_series +,a.source_subdivision +,a.source_joinkey +,a.permid_joinkey +,a.start_date +,a.end_date +,a.xwalk_huc12 +,a.xwalk_catresolution +,a.xwalk_huc12_version +,a.xwalk_huc12_areasqkm +,a.globalid +FROM +cipsrv_owld.wqp_huc12 a; + +ALTER TABLE cipsrv_gis.owld_wqp_huc12 OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_huc12 TO public; +--******************************-- +----- views/owld_wqp_huc12_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_huc12_esri +AS +SELECT + a.objectid +,a.source_originator +,a.source_featureid +,a.source_featureid2 +,a.source_series +,a.source_subdivision +,a.source_joinkey +,a.permid_joinkey +,a.start_date +,a.end_date +,a.xwalk_huc12 +,a.xwalk_catresolution +,a.xwalk_huc12_version +,a.xwalk_huc12_areasqkm +,a.globalid +FROM +cipsrv_owld.wqp_huc12 a; + +ALTER TABLE cipsrv_gis.owld_wqp_huc12_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_huc12_esri TO public; +--******************************-- +----- views/owld_wqp_huc12_geo.sql + +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_huc12_geo +AS +SELECT + a.objectid +,a.xwalk_huc12 +,a.xwalk_catresolution +,a.xwalk_huc12_version +,a.xwalk_huc12_areasqkm +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_owld.wqp_huc12_geo a; + +ALTER TABLE cipsrv_gis.owld_wqp_huc12_geo OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_huc12_geo TO public; +--******************************-- +----- views/owld_wqp_huc12_geo_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_huc12_geo_esri +AS +SELECT + a.objectid +,a.xwalk_huc12 +,a.xwalk_catresolution +,a.xwalk_huc12_version +,a.xwalk_huc12_areasqkm +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_owld.wqp_huc12_geo a; + +ALTER TABLE cipsrv_gis.owld_wqp_huc12_geo_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_huc12_geo_esri TO public; +--******************************-- +----- views/owld_wqp_rad_a.sql + +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_rad_a +AS +SELECT + a.objectid +,a.permanent_identifier +,a.eventdate +,a.reachcode +,a.reachsmdate +,a.reachresolution +,a.feature_permanent_identifier +,a.featureclassref +,a.source_originator +,a.source_featureid +,a.source_featureid2 +,a.source_datadesc +,a.source_series +,a.source_subdivision +,a.source_joinkey +,a.permid_joinkey +,a.start_date +,a.end_date +,a.featuredetailurl +,a.eventtype +,a.event_areasqkm +,a.geogstate +,a.xwalk_huc12 +,a.xwalk_method +,a.xwalk_huc12_version +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_owld.wqp_rad_a a; + +ALTER TABLE cipsrv_gis.owld_wqp_rad_a OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_rad_a TO public; +--******************************-- +----- views/owld_wqp_rad_a_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_rad_a_esri +AS +SELECT + a.objectid +,a.permanent_identifier +,a.eventdate +,a.reachcode +,a.reachsmdate +,a.reachresolution +,a.feature_permanent_identifier +,a.featureclassref +,a.source_originator +,a.source_featureid +,a.source_featureid2 +,a.source_datadesc +,a.source_series +,a.source_subdivision +,a.source_joinkey +,a.permid_joinkey +,a.start_date +,a.end_date +,a.featuredetailurl +,a.eventtype +,a.event_areasqkm +,a.geogstate +,a.xwalk_huc12 +,a.xwalk_method +,a.xwalk_huc12_version +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_owld.wqp_rad_a a; + +ALTER TABLE cipsrv_gis.owld_wqp_rad_a_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_rad_a_esri TO public; +--******************************-- +----- views/owld_wqp_rad_evt2meta.sql + +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_rad_evt2meta +AS +SELECT + a.objectid +,a.permanent_identifier +,a.meta_processid +,a.globalid +FROM +cipsrv_owld.wqp_rad_evt2meta a; + +ALTER TABLE cipsrv_gis.owld_wqp_rad_evt2meta OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_rad_evt2meta TO public; +--******************************-- +----- views/owld_wqp_rad_evt2meta_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_rad_evt2meta_esri +AS +SELECT + a.objectid +,a.permanent_identifier +,a.meta_processid +,a.globalid +FROM +cipsrv_owld.wqp_rad_evt2meta a; + +ALTER TABLE cipsrv_gis.owld_wqp_rad_evt2meta_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_rad_evt2meta_esri TO public; +--******************************-- +----- views/owld_wqp_rad_l.sql + +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_rad_l +AS +SELECT + a.objectid +,a.permanent_identifier +,a.eventdate +,a.reachcode +,a.reachsmdate +,a.reachresolution +,a.feature_permanent_identifier +,a.featureclassref +,a.source_originator +,a.source_featureid +,a.source_featureid2 +,a.source_datadesc +,a.source_series +,a.source_subdivision +,a.source_joinkey +,a.permid_joinkey +,a.start_date +,a.end_date +,a.featuredetailurl +,a.fmeasure +,a.tmeasure +,a.eventtype +,a.eventoffset +,a.event_lengthkm +,a.geogstate +,a.xwalk_huc12 +,a.xwalk_method +,a.xwalk_huc12_version +,a.isnavigable +,a.hasvaa +,a.issink +,a.isheadwater +,a.iscoastal +,a.isocean +,a.isalaskan +,a.h3hexagonaddr +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_owld.wqp_rad_l a; + +ALTER TABLE cipsrv_gis.owld_wqp_rad_l OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_rad_l TO public; +--******************************-- +----- views/owld_wqp_rad_l_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_rad_l_esri +AS +SELECT + a.objectid +,a.permanent_identifier +,a.eventdate +,a.reachcode +,a.reachsmdate +,a.reachresolution +,a.feature_permanent_identifier +,a.featureclassref +,a.source_originator +,a.source_featureid +,a.source_featureid2 +,a.source_datadesc +,a.source_series +,a.source_subdivision +,a.source_joinkey +,a.permid_joinkey +,a.start_date +,a.end_date +,a.featuredetailurl +,a.fmeasure +,a.tmeasure +,a.eventtype +,a.eventoffset +,a.event_lengthkm +,a.geogstate +,a.xwalk_huc12 +,a.xwalk_method +,a.xwalk_huc12_version +,a.isnavigable +,a.hasvaa +,a.issink +,a.isheadwater +,a.iscoastal +,a.isocean +,a.isalaskan +,a.h3hexagonaddr +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_owld.wqp_rad_l a; + +ALTER TABLE cipsrv_gis.owld_wqp_rad_l_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_rad_l_esri TO public; +--******************************-- +----- views/owld_wqp_rad_metadata.sql + +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_rad_metadata +AS +SELECT + a.objectid +,a.meta_processid +,a.processdescription +,a.processdate +,a.attributeaccuracyreport +,a.logicalconsistencyreport +,a.completenessreport +,a.horizpositionalaccuracyreport +,a.vertpositionalaccuracyreport +,a.metadatastandardname +,a.metadatastandardversion +,a.metadatadate +,a.datasetcredit +,a.contactorganization +,a.addresstype +,a.address +,a.city +,a.stateorprovince +,a.postalcode +,a.contactvoicetelephone +,a.contactinstructions +,a.contactemailaddress +,a.globalid +FROM +cipsrv_owld.wqp_rad_metadata a; + +ALTER TABLE cipsrv_gis.owld_wqp_rad_metadata OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_rad_metadata TO public; +--******************************-- +----- views/owld_wqp_rad_metadata_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_rad_metadata_esri +AS +SELECT + a.objectid +,a.meta_processid +,a.processdescription +,a.processdate +,a.attributeaccuracyreport +,a.logicalconsistencyreport +,a.completenessreport +,a.horizpositionalaccuracyreport +,a.vertpositionalaccuracyreport +,a.metadatastandardname +,a.metadatastandardversion +,a.metadatadate +,a.datasetcredit +,a.contactorganization +,a.addresstype +,a.address +,a.city +,a.stateorprovince +,a.postalcode +,a.contactvoicetelephone +,a.contactinstructions +,a.contactemailaddress +,a.globalid +FROM +cipsrv_owld.wqp_rad_metadata a; + +ALTER TABLE cipsrv_gis.owld_wqp_rad_metadata_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_rad_metadata_esri TO public; +--******************************-- +----- views/owld_wqp_rad_p.sql + +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_rad_p +AS +SELECT + a.objectid +,a.permanent_identifier +,a.eventdate +,a.reachcode +,a.reachsmdate +,a.reachresolution +,a.feature_permanent_identifier +,a.featureclassref +,a.source_originator +,a.source_featureid +,a.source_featureid2 +,a.source_datadesc +,a.source_series +,a.source_subdivision +,a.source_joinkey +,a.permid_joinkey +,a.start_date +,a.end_date +,a.featuredetailurl +,a.measure +,a.eventtype +,a.eventoffset +,a.geogstate +,a.xwalk_huc12 +,a.xwalk_method +,a.xwalk_huc12_version +,a.isnavigable +,a.hasvaa +,a.issink +,a.isheadwater +,a.iscoastal +,a.isocean +,a.isalaskan +,a.h3hexagonaddr +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_owld.wqp_rad_p a; + +ALTER TABLE cipsrv_gis.owld_wqp_rad_p OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_rad_p TO public; +--******************************-- +----- views/owld_wqp_rad_p_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_rad_p_esri +AS +SELECT + a.objectid +,a.permanent_identifier +,a.eventdate +,a.reachcode +,a.reachsmdate +,a.reachresolution +,a.feature_permanent_identifier +,a.featureclassref +,a.source_originator +,a.source_featureid +,a.source_featureid2 +,a.source_datadesc +,a.source_series +,a.source_subdivision +,a.source_joinkey +,a.permid_joinkey +,a.start_date +,a.end_date +,a.featuredetailurl +,a.measure +,a.eventtype +,a.eventoffset +,a.geogstate +,a.xwalk_huc12 +,a.xwalk_method +,a.xwalk_huc12_version +,a.isnavigable +,a.hasvaa +,a.issink +,a.isheadwater +,a.iscoastal +,a.isocean +,a.isalaskan +,a.h3hexagonaddr +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_owld.wqp_rad_p a; + +ALTER TABLE cipsrv_gis.owld_wqp_rad_p_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_rad_p_esri TO public; +--******************************-- +----- views/owld_wqp_rad_srccit.sql + +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_rad_srccit +AS +SELECT + a.objectid +,a.title +,a.source_datasetid +,a.sourcecitationabbreviation +,a.originator +,a.publicationdate +,a.beginningdate +,a.endingdate +,a.sourcecontribution +,a.sourcescaledenominator +,a.typeofsourcemedia +,a.calendardate +,a.sourcecurrentnessreference +,a.meta_processid +,a.globalid +FROM +cipsrv_owld.wqp_rad_srccit a; + +ALTER TABLE cipsrv_gis.owld_wqp_rad_srccit OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_rad_srccit TO public; +--******************************-- +----- views/owld_wqp_rad_srccit_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_rad_srccit_esri +AS +SELECT + a.objectid +,a.title +,a.source_datasetid +,a.sourcecitationabbreviation +,a.originator +,a.publicationdate +,a.beginningdate +,a.endingdate +,a.sourcecontribution +,a.sourcescaledenominator +,a.typeofsourcemedia +,a.calendardate +,a.sourcecurrentnessreference +,a.meta_processid +,a.globalid +FROM +cipsrv_owld.wqp_rad_srccit a; + +ALTER TABLE cipsrv_gis.owld_wqp_rad_srccit_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_rad_srccit_esri TO public; +--******************************-- +----- views/owld_wqp_sfid.sql + +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_sfid +AS +SELECT + a.objectid +,a.source_originator +,a.source_featureid +,a.source_featureid2 +,a.source_series +,a.source_subdivision +,a.source_joinkey +,a.start_date +,a.end_date +,a.sfiddetailurl +,a.load_id +,a.load_date +,a.src_event_count +,a.src_point_count +,a.src_line_count +,a.src_area_count +,a.cat_mr_count +,a.cat_hr_count +,a.xwalk_huc12_mr_count +,a.rad_mr_event_count +,a.rad_hr_event_count +,a.rad_mr_point_count +,a.rad_hr_point_count +,a.rad_mr_line_count +,a.rad_hr_line_count +,a.rad_mr_area_count +,a.rad_hr_area_count +,a.globalid +FROM +cipsrv_owld.wqp_sfid a; + +ALTER TABLE cipsrv_gis.owld_wqp_sfid OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_sfid TO public; +--******************************-- +----- views/owld_wqp_sfid_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_sfid_esri +AS +SELECT + a.objectid +,a.source_originator +,a.source_featureid +,a.source_featureid2 +,a.source_series +,a.source_subdivision +,a.source_joinkey +,a.start_date +,a.end_date +,a.sfiddetailurl +,a.load_id +,a.load_date +,a.src_event_count +,a.src_point_count +,a.src_line_count +,a.src_area_count +,a.cat_mr_count +,a.cat_hr_count +,a.xwalk_huc12_mr_count +,a.rad_mr_event_count +,a.rad_hr_event_count +,a.rad_mr_point_count +,a.rad_hr_point_count +,a.rad_mr_line_count +,a.rad_hr_line_count +,a.rad_mr_area_count +,a.rad_hr_area_count +,a.globalid +FROM +cipsrv_owld.wqp_sfid a; + +ALTER TABLE cipsrv_gis.owld_wqp_sfid_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_sfid_esri TO public; +--******************************-- +----- views/owld_wqp_src2cip.sql + +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_src2cip +AS +SELECT + a.objectid +,a.src2cip_joinkey +,a.cip_joinkey +,a.source_joinkey +,a.permid_joinkey +,a.cat_joinkey +,a.catchmentstatecode +,a.nhdplusid +,a.catchmentresolution +,a.cip_action +,a.overlap_measure +,a.cip_method +,a.cip_parms +,a.cip_date +,a.cip_version +,a.globalid +FROM +cipsrv_owld.wqp_src2cip a; + +ALTER TABLE cipsrv_gis.owld_wqp_src2cip OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_src2cip TO public; +--******************************-- +----- views/owld_wqp_src2cip_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_src2cip_esri +AS +SELECT + a.objectid +,a.src2cip_joinkey +,a.cip_joinkey +,a.source_joinkey +,a.permid_joinkey +,a.cat_joinkey +,a.catchmentstatecode +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.catchmentresolution +,a.cip_action +,a.overlap_measure +,a.cip_method +,a.cip_parms +,a.cip_date +,a.cip_version +,a.globalid +FROM +cipsrv_owld.wqp_src2cip a; + +ALTER TABLE cipsrv_gis.owld_wqp_src2cip_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_src2cip_esri TO public; +--******************************-- +----- views/owld_wqp_src_a.sql + +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_src_a +AS +SELECT + a.objectid +,a.permid_joinkey +,a.source_originator +,a.source_featureid +,a.source_featureid2 +,a.source_series +,a.source_subdivision +,a.source_joinkey +,a.start_date +,a.end_date +,a.featuredetailurl +,a.areasqkm +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_owld.wqp_src_a a; + +ALTER TABLE cipsrv_gis.owld_wqp_src_a OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_src_a TO public; +--******************************-- +----- views/owld_wqp_src_a_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_src_a_esri +AS +SELECT + a.objectid +,a.permid_joinkey +,a.source_originator +,a.source_featureid +,a.source_featureid2 +,a.source_series +,a.source_subdivision +,a.source_joinkey +,a.start_date +,a.end_date +,a.featuredetailurl +,a.areasqkm +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_owld.wqp_src_a a; + +ALTER TABLE cipsrv_gis.owld_wqp_src_a_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_src_a_esri TO public; +--******************************-- +----- views/owld_wqp_src_l.sql + +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_src_l +AS +SELECT + a.objectid +,a.permid_joinkey +,a.source_originator +,a.source_featureid +,a.source_featureid2 +,a.source_series +,a.source_subdivision +,a.source_joinkey +,a.start_date +,a.end_date +,a.featuredetailurl +,a.lengthkm +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_owld.wqp_src_l a; + +ALTER TABLE cipsrv_gis.owld_wqp_src_l OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_src_l TO public; +--******************************-- +----- views/owld_wqp_src_l_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_src_l_esri +AS +SELECT + a.objectid +,a.permid_joinkey +,a.source_originator +,a.source_featureid +,a.source_featureid2 +,a.source_series +,a.source_subdivision +,a.source_joinkey +,a.start_date +,a.end_date +,a.featuredetailurl +,a.lengthkm +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_owld.wqp_src_l a; + +ALTER TABLE cipsrv_gis.owld_wqp_src_l_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_src_l_esri TO public; +--******************************-- +----- views/owld_wqp_src_p.sql + +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_src_p +AS +SELECT + a.objectid +,a.permid_joinkey +,a.source_originator +,a.source_featureid +,a.source_featureid2 +,a.source_series +,a.source_subdivision +,a.source_joinkey +,a.start_date +,a.end_date +,a.featuredetailurl +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_owld.wqp_src_p a; + +ALTER TABLE cipsrv_gis.owld_wqp_src_p OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_src_p TO public; +--******************************-- +----- views/owld_wqp_src_p_esri.sql + +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_src_p_esri +AS +SELECT + a.objectid +,a.permid_joinkey +,a.source_originator +,a.source_featureid +,a.source_featureid2 +,a.source_series +,a.source_subdivision +,a.source_joinkey +,a.start_date +,a.end_date +,a.featuredetailurl +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_owld.wqp_src_p a; + +ALTER TABLE cipsrv_gis.owld_wqp_src_p_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_src_p_esri TO public; diff --git a/src/database/cipsrv_gis/manifest.json b/src/database/cipsrv_gis/manifest.json new file mode 100644 index 0000000..ab6bad7 --- /dev/null +++ b/src/database/cipsrv_gis/manifest.json @@ -0,0 +1,148 @@ +{ + "constants": [ + { + "key": "GITRELEASE" + ,"cmd": "git describe --tags" + } + ,{ + "key": "GITCOMMIT" + ,"cmd": "git rev-parse HEAD" + } + ,{ + "key": "GITCOMMITDATE" + ,"cmd": "git show -s --format=%cd" + } + ,{ + "key": "GITCOMMITAUTH" + ,"cmd": "git show -s --format=%an" + } + ] + ,"tasks": [ + { + "id": "concatenate" + ,"output": "cipsrv_gis_deploy.sql" + ,"includes": [ + "views/epageofab_h_catchment_fabric.sql" + ,"views/epageofab_h_catchment_fabric_esri.sql" + ,"views/epageofab_h_catchment_fabric_huc12.sql" + ,"views/epageofab_h_catchment_fabric_huc12_esri.sql" + ,"views/epageofab_m_catchment_fabric.sql" + ,"views/epageofab_m_catchment_fabric_esri.sql" + ,"views/epageofab_m_catchment_fabric_huc12.sql" + ,"views/epageofab_m_catchment_fabric_huc12_esri.sql" + ,"views/nhdplus_h_flow_direction.sql" + ,"views/nhdplus_h_flow_direction_esri.sql" + ,"views/nhdplus_h_networknhdflowline.sql" + ,"views/nhdplus_h_networknhdflowline_esri.sql" + ,"views/nhdplus_h_nhdarea.sql" + ,"views/nhdplus_h_nhdarea_esri.sql" + ,"views/nhdplus_h_nhdline.sql" + ,"views/nhdplus_h_nhdline_esri.sql" + ,"views/nhdplus_h_nhdpluscatchment.sql" + ,"views/nhdplus_h_nhdpluscatchment_esri.sql" + ,"views/nhdplus_h_nhdplusflow.sql" + ,"views/nhdplus_h_nhdplusflow_esri.sql" + ,"views/nhdplus_h_nhdplusgage.sql" + ,"views/nhdplus_h_nhdplusgage_esri.sql" + ,"views/nhdplus_h_nhdplussink.sql" + ,"views/nhdplus_h_nhdplussink_esri.sql" + ,"views/nhdplus_h_nhdpoint.sql" + ,"views/nhdplus_h_nhdpoint_esri.sql" + ,"views/nhdplus_h_nhdwaterbody.sql" + ,"views/nhdplus_h_nhdwaterbody_esri.sql" + ,"views/nhdplus_h_nonnetworknhdflowline.sql" + ,"views/nhdplus_h_nonnetworknhdflowline_esri.sql" + ,"views/nhdplus_h_wbdhu12.sql" + ,"views/nhdplus_h_wbdhu12_esri.sql" + ,"views/nhdplus_m_flow_direction.sql" + ,"views/nhdplus_m_flow_direction_esri.sql" + ,"views/nhdplus_m_networknhdflowline.sql" + ,"views/nhdplus_m_networknhdflowline_esri.sql" + ,"views/nhdplus_m_nhdarea.sql" + ,"views/nhdplus_m_nhdarea_esri.sql" + ,"views/nhdplus_m_nhdline.sql" + ,"views/nhdplus_m_nhdline_esri.sql" + ,"views/nhdplus_m_nhdpluscatchment.sql" + ,"views/nhdplus_m_nhdpluscatchment_esri.sql" + ,"views/nhdplus_m_nhdplusflow.sql" + ,"views/nhdplus_m_nhdplusflow_esri.sql" + ,"views/nhdplus_m_nhdplusgage.sql" + ,"views/nhdplus_m_nhdplusgage_esri.sql" + ,"views/nhdplus_m_nhdplussink.sql" + ,"views/nhdplus_m_nhdplussink_esri.sql" + ,"views/nhdplus_m_nhdpoint.sql" + ,"views/nhdplus_m_nhdpoint_esri.sql" + ,"views/nhdplus_m_nhdwaterbody.sql" + ,"views/nhdplus_m_nhdwaterbody_esri.sql" + ,"views/nhdplus_m_nonnetworknhdflowline.sql" + ,"views/nhdplus_m_nonnetworknhdflowline_esri.sql" + ,"views/nhdplus_m_wbdhu12.sql" + ,"views/nhdplus_m_wbdhu12_esri.sql" + ,"views/owld_wqp_attr.sql" + ,"views/owld_wqp_attr_esri.sql" + ,"views/owld_wqp_cip.sql" + ,"views/owld_wqp_cip_esri.sql" + ,"views/owld_wqp_cip_geo.sql" + ,"views/owld_wqp_cip_geo_esri.sql" + ,"views/owld_wqp_huc12.sql" + ,"views/owld_wqp_huc12_esri.sql" + ,"views/owld_wqp_huc12_geo.sql" + ,"views/owld_wqp_huc12_geo_esri.sql" + ,"views/owld_wqp_rad_a.sql" + ,"views/owld_wqp_rad_a_esri.sql" + ,"views/owld_wqp_rad_evt2meta.sql" + ,"views/owld_wqp_rad_evt2meta_esri.sql" + ,"views/owld_wqp_rad_l.sql" + ,"views/owld_wqp_rad_l_esri.sql" + ,"views/owld_wqp_rad_metadata.sql" + ,"views/owld_wqp_rad_metadata_esri.sql" + ,"views/owld_wqp_rad_p.sql" + ,"views/owld_wqp_rad_p_esri.sql" + ,"views/owld_wqp_rad_srccit.sql" + ,"views/owld_wqp_rad_srccit_esri.sql" + ,"views/owld_wqp_sfid.sql" + ,"views/owld_wqp_sfid_esri.sql" + ,"views/owld_wqp_src2cip.sql" + ,"views/owld_wqp_src2cip_esri.sql" + ,"views/owld_wqp_src_a.sql" + ,"views/owld_wqp_src_a_esri.sql" + ,"views/owld_wqp_src_l.sql" + ,"views/owld_wqp_src_l_esri.sql" + ,"views/owld_wqp_src_p.sql" + ,"views/owld_wqp_src_p_esri.sql" + ] + ,"separator": "--******************************--\n----- %%FILENAME%% \n\n" + ,"configurations": [ + { + "id": 1 + ,"file": "*/*.sql" + ,"replacements": [ + { + "string": "c_gitrelease CONSTANT VARCHAR(255) := 'NULL';" + ,"value": "c_gitrelease CONSTANT VARCHAR(255) := '%GITRELEASE%';" + } + ,{ + "string": "c_gitcommit CONSTANT VARCHAR(255) := 'NULL';" + ,"value": "c_gitcommit CONSTANT VARCHAR(255) := '%GITCOMMIT%';" + } + ,{ + "string": "c_gitcommitdate CONSTANT VARCHAR(255) := 'NULL';" + ,"value": "c_gitcommitdate CONSTANT VARCHAR(255) := '%GITCOMMITDATE%';" + } + ,{ + "string": "c_gitcommitauth CONSTANT VARCHAR(255) := 'NULL';" + ,"value": "c_gitcommitauth CONSTANT VARCHAR(255) := '%GITCOMMITAUTH%';" + } + ] + } + ] + } + ,{ + "id": "artifacts" + ,"targets": [ + "cipsrv_gis_deploy.sql" + ] + } + ] +} + diff --git a/src/database/cipsrv_gis/views/epageofab_h_catchment_fabric.sql b/src/database/cipsrv_gis/views/epageofab_h_catchment_fabric.sql new file mode 100644 index 0000000..b7eb194 --- /dev/null +++ b/src/database/cipsrv_gis/views/epageofab_h_catchment_fabric.sql @@ -0,0 +1,33 @@ +CREATE OR REPLACE VIEW cipsrv_gis.epageofab_h_catchment_fabric +AS +SELECT + a.objectid +,a.catchmentstatecode +,a.nhdplusid +,a.istribal +,a.istribal_areasqkm +,a.xwalk_huc12 +,a.xwalk_method +,a.xwalk_huc12_version +,a.sourcefc +,a.gridcode +,a.areasqkm +,a.areasqkm_geo +,a.isnavigable +,a.hasvaa +,a.issink +,a.isheadwater +,a.iscoastal +,a.isocean +,a.isalaskan +,a.h3hexagonaddr +,a.state_count +,a.vpuid +,a.sourcedataset +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_epageofab_h.catchment_fabric a; + +ALTER TABLE cipsrv_gis.epageofab_h_catchment_fabric OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.epageofab_h_catchment_fabric TO public; diff --git a/src/database/cipsrv_gis/views/epageofab_h_catchment_fabric_esri.sql b/src/database/cipsrv_gis/views/epageofab_h_catchment_fabric_esri.sql new file mode 100644 index 0000000..e238bdd --- /dev/null +++ b/src/database/cipsrv_gis/views/epageofab_h_catchment_fabric_esri.sql @@ -0,0 +1,33 @@ +CREATE OR REPLACE VIEW cipsrv_gis.epageofab_h_catchment_fabric_esri +AS +SELECT + a.objectid +,a.catchmentstatecode +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.istribal +,a.istribal_areasqkm +,a.xwalk_huc12 +,a.xwalk_method +,a.xwalk_huc12_version +,a.sourcefc +,a.gridcode +,a.areasqkm +,a.areasqkm_geo +,a.isnavigable +,a.hasvaa +,a.issink +,a.isheadwater +,a.iscoastal +,a.isocean +,a.isalaskan +,a.h3hexagonaddr +,CAST(a.state_count AS SMALLINT) AS state_count +,a.vpuid +,a.sourcedataset +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_epageofab_h.catchment_fabric a; + +ALTER TABLE cipsrv_gis.epageofab_h_catchment_fabric_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.epageofab_h_catchment_fabric_esri TO public; diff --git a/src/database/cipsrv_gis/views/epageofab_h_catchment_fabric_huc12.sql b/src/database/cipsrv_gis/views/epageofab_h_catchment_fabric_huc12.sql new file mode 100644 index 0000000..9963d38 --- /dev/null +++ b/src/database/cipsrv_gis/views/epageofab_h_catchment_fabric_huc12.sql @@ -0,0 +1,14 @@ +CREATE OR REPLACE VIEW cipsrv_gis.epageofab_m_catchment_fabric_huc12 +AS +SELECT + a.objectid +,a.xwalk_huc12 +,a.xwalk_huc12_version +,a.areasqkm +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_epageofab_m.catchment_fabric_huc12 a; + +ALTER TABLE cipsrv_gis.epageofab_m_catchment_fabric_huc12 OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.epageofab_m_catchment_fabric_huc12 TO public; diff --git a/src/database/cipsrv_gis/views/epageofab_h_catchment_fabric_huc12_esri.sql b/src/database/cipsrv_gis/views/epageofab_h_catchment_fabric_huc12_esri.sql new file mode 100644 index 0000000..77d2672 --- /dev/null +++ b/src/database/cipsrv_gis/views/epageofab_h_catchment_fabric_huc12_esri.sql @@ -0,0 +1,14 @@ +CREATE OR REPLACE VIEW cipsrv_gis.epageofab_h_catchment_fabric_huc12_esri +AS +SELECT + a.objectid +,a.xwalk_huc12 +,a.xwalk_huc12_version +,a.areasqkm +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_epageofab_h.catchment_fabric_huc12 a; + +ALTER TABLE cipsrv_gis.epageofab_h_catchment_fabric_huc12_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.epageofab_h_catchment_fabric_huc12_esri TO public; diff --git a/src/database/cipsrv_gis/views/epageofab_m_catchment_fabric.sql b/src/database/cipsrv_gis/views/epageofab_m_catchment_fabric.sql new file mode 100644 index 0000000..e98f7f8 --- /dev/null +++ b/src/database/cipsrv_gis/views/epageofab_m_catchment_fabric.sql @@ -0,0 +1,33 @@ +CREATE OR REPLACE VIEW cipsrv_gis.epageofab_m_catchment_fabric +AS +SELECT + a.objectid +,a.catchmentstatecode +,a.nhdplusid +,a.istribal +,a.istribal_areasqkm +,a.xwalk_huc12 +,a.xwalk_method +,a.xwalk_huc12_version +,a.sourcefc +,a.gridcode +,a.areasqkm +,a.areasqkm_geo +,a.isnavigable +,a.hasvaa +,a.issink +,a.isheadwater +,a.iscoastal +,a.isocean +,a.isalaskan +,a.h3hexagonaddr +,a.state_count +,a.vpuid +,a.sourcedataset +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_epageofab_m.catchment_fabric a; + +ALTER TABLE cipsrv_gis.epageofab_m_catchment_fabric OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.epageofab_m_catchment_fabric TO public; diff --git a/src/database/cipsrv_gis/views/epageofab_m_catchment_fabric_esri.sql b/src/database/cipsrv_gis/views/epageofab_m_catchment_fabric_esri.sql new file mode 100644 index 0000000..3d7c63d --- /dev/null +++ b/src/database/cipsrv_gis/views/epageofab_m_catchment_fabric_esri.sql @@ -0,0 +1,33 @@ +CREATE OR REPLACE VIEW cipsrv_gis.epageofab_m_catchment_fabric_esri +AS +SELECT + a.objectid +,a.catchmentstatecode +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.istribal +,a.istribal_areasqkm +,a.xwalk_huc12 +,a.xwalk_method +,a.xwalk_huc12_version +,a.sourcefc +,a.gridcode +,a.areasqkm +,a.areasqkm_geo +,a.isnavigable +,a.hasvaa +,a.issink +,a.isheadwater +,a.iscoastal +,a.isocean +,a.isalaskan +,a.h3hexagonaddr +,CAST(a.state_count AS SMALLINT) AS state_count +,a.vpuid +,a.sourcedataset +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_epageofab_m.catchment_fabric a; + +ALTER TABLE cipsrv_gis.epageofab_m_catchment_fabric_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.epageofab_m_catchment_fabric_esri TO public; diff --git a/src/database/cipsrv_gis/views/epageofab_m_catchment_fabric_huc12.sql b/src/database/cipsrv_gis/views/epageofab_m_catchment_fabric_huc12.sql new file mode 100644 index 0000000..9963d38 --- /dev/null +++ b/src/database/cipsrv_gis/views/epageofab_m_catchment_fabric_huc12.sql @@ -0,0 +1,14 @@ +CREATE OR REPLACE VIEW cipsrv_gis.epageofab_m_catchment_fabric_huc12 +AS +SELECT + a.objectid +,a.xwalk_huc12 +,a.xwalk_huc12_version +,a.areasqkm +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_epageofab_m.catchment_fabric_huc12 a; + +ALTER TABLE cipsrv_gis.epageofab_m_catchment_fabric_huc12 OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.epageofab_m_catchment_fabric_huc12 TO public; diff --git a/src/database/cipsrv_gis/views/epageofab_m_catchment_fabric_huc12_esri.sql b/src/database/cipsrv_gis/views/epageofab_m_catchment_fabric_huc12_esri.sql new file mode 100644 index 0000000..e685d6b --- /dev/null +++ b/src/database/cipsrv_gis/views/epageofab_m_catchment_fabric_huc12_esri.sql @@ -0,0 +1,14 @@ +CREATE OR REPLACE VIEW cipsrv_gis.epageofab_m_catchment_fabric_huc12_esri +AS +SELECT + a.objectid +,a.xwalk_huc12 +,a.xwalk_huc12_version +,a.areasqkm +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_epageofab_m.catchment_fabric_huc12 a; + +ALTER TABLE cipsrv_gis.epageofab_m_catchment_fabric_huc12_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.epageofab_m_catchment_fabric_huc12_esri TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_h_flow_direction.sql b/src/database/cipsrv_gis/views/nhdplus_h_flow_direction.sql new file mode 100644 index 0000000..66ab29b --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_h_flow_direction.sql @@ -0,0 +1,48 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_flow_direction +AS +SELECT + a.objectid +,a.permanent_identifier +,CAST(DEGREES( + ST_Azimuth( + a.penul_point + ,a.final_point + ) + ) AS NUMERIC) AS angle_direction +,CAST(ROUND(DEGREES( + ST_Azimuth( + a.penul_point + ,a.final_point + ) + ) / 5 ) * 5 AS NUMERIC ) AS angle_rounded +,a.ftype +,a.fcode +,a.visibilityfilter +,a.nhdplusid +,ST_Transform(a.final_point,3857) AS shape +FROM ( + SELECT + aa.objectid + ,aa.permanent_identifier + ,aa.ftype + ,aa.fcode + ,aa.visibilityfilter + ,aa.nhdplusid + ,ST_PointN(aa.shape,-2) AS penul_point + ,ST_PointN(aa.shape,-1) AS final_point + FROM ( + SELECT + aaa.objectid + ,aaa.permanent_identifier + ,aaa.ftype + ,aaa.fcode + ,aaa.visibilityfilter + ,aaa.nhdplusid + ,ST_Force2D(aaa.shape) AS shape + FROM + cipsrv_nhdplus_h.networknhdflowline aaa + ) aa +) a; + +ALTER TABLE cipsrv_gis.nhdplus_h_flow_direction OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_flow_direction TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_h_flow_direction_esri.sql b/src/database/cipsrv_gis/views/nhdplus_h_flow_direction_esri.sql new file mode 100644 index 0000000..04efb4a --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_h_flow_direction_esri.sql @@ -0,0 +1,48 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_flow_direction_esri +AS +SELECT + a.objectid +,a.permanent_identifier +,CAST(DEGREES( + ST_Azimuth( + a.penul_point + ,a.final_point + ) + ) AS NUMERIC) AS angle_direction +,CAST(ROUND(DEGREES( + ST_Azimuth( + a.penul_point + ,a.final_point + ) + ) / 5 ) * 5 AS NUMERIC ) AS angle_rounded +,CAST(a.ftype AS INTEGER) AS ftype +,CAST(a.fcode AS INTEGER) AS fcode +,a.visibilityfilter +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,ST_Transform(a.final_point,3857) AS shape +FROM ( + SELECT + aa.objectid + ,aa.permanent_identifier + ,aa.ftype + ,aa.fcode + ,aa.visibilityfilter + ,aa.nhdplusid + ,ST_PointN(aa.shape,-2) AS penul_point + ,ST_PointN(aa.shape,-1) AS final_point + FROM ( + SELECT + aaa.objectid + ,aaa.permanent_identifier + ,aaa.ftype + ,aaa.fcode + ,aaa.visibilityfilter + ,aaa.nhdplusid + ,ST_Force2D(aaa.shape) AS shape + FROM + cipsrv_nhdplus_h.networknhdflowline aaa + ) aa +) a; + +ALTER TABLE cipsrv_gis.nhdplus_h_flow_direction_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_flow_direction_esri TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_h_networknhdflowline.sql b/src/database/cipsrv_gis/views/nhdplus_h_networknhdflowline.sql new file mode 100644 index 0000000..20cec39 --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_h_networknhdflowline.sql @@ -0,0 +1,94 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_networknhdflowline +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.lengthkm +,a.totma +,a.reachcode +,a.flowdir +,a.wbarea_permanent_identifier +,a.ftype +,a.fcode +,a.mainpath +,a.innetwork +,a.visibilityfilter +,a.nhdplusid +,a.vpuid +,a.streamleve +,a.streamorde +,a.streamcalc +,a.fromnode +,a.tonode +,a.hydroseq +,a.levelpathi +,a.pathlength +,a.pathtimema +,a.terminalpa +,a.arbolatesu +,a.divergence +,a.startflag +,a.terminalfl +,a.uplevelpat +,a.uphydroseq +,a.dnlevel +,a.dnlevelpat +,a.dnhydroseq +,a.dnminorhyd +,a.dndraincou +,a.frommeas +,a.tomeas +,a.rtndiv +,a.thinner +,a.vpuin +,a.vpuout +,a.areasqkm +,a.totdasqkm +,a.divdasqkm +,a.maxelevraw +,a.minelevraw +,a.maxelevsmo +,a.minelevsmo +,a.slope +,a.slopelenkm +,a.elevfixed +,a.hwtype +,a.hwnodesqkm +,a.statusflag +,a.qama +,a.vama +,a.qincrama +,a.qbma +,a.vbma +,a.qincrbma +,a.qcma +,a.vcma +,a.qincrcma +,a.qdma +,a.vdma +,a.qincrdma +,a.qema +,a.vema +,a.qincrema +,a.qfma +,a.qincrfma +,a.arqnavma +,a.petma +,a.qlossma +,a.qgadjma +,a.qgnavma +,a.gageadjma +,a.avgqadjma +,a.gageidma +,a.gageqma +,a.globalid +,ST_Transform(ST_Force2D(a.shape),3857) AS shape +FROM +cipsrv_nhdplus_h.networknhdflowline a; + +ALTER TABLE cipsrv_gis.nhdplus_h_networknhdflowline OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_networknhdflowline TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_h_networknhdflowline_esri.sql b/src/database/cipsrv_gis/views/nhdplus_h_networknhdflowline_esri.sql new file mode 100644 index 0000000..2e94c79 --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_h_networknhdflowline_esri.sql @@ -0,0 +1,94 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_networknhdflowline_esri +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.lengthkm +,a.totma +,a.reachcode +,a.flowdir +,a.wbarea_permanent_identifier +,CAST(a.ftype AS INTEGER) AS ftype +,CAST(a.fcode AS INTEGER) AS fcode +,a.mainpath +,CAST(a.innetwork AS SMALLINT) AS innetwork +,a.visibilityfilter +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.vpuid +,CAST(a.streamleve AS SMALLINT) AS streamleve +,CAST(a.streamorde AS SMALLINT) AS streamorde +,CAST(a.streamcalc AS SMALLINT) AS streamcalc +,CAST(a.fromnode AS NUMERIC) AS fromnode +,CAST(a.tonode AS NUMERIC) AS tonode +,CAST(a.hydroseq AS NUMERIC) AS hydroseq +,CAST(a.levelpathi AS NUMERIC) AS levelpathi +,a.pathlength +,a.pathtimema +,CAST(a.terminalpa AS NUMERIC) AS terminalpa +,a.arbolatesu +,CAST(a.divergence AS SMALLINT) AS divergence +,CAST(a.startflag AS SMALLINT) AS startflag +,CAST(a.terminalfl AS SMALLINT) AS terminalfl +,CAST(a.uplevelpat AS NUMERIC) AS uplevelpat +,CAST(a.uphydroseq AS NUMERIC) AS uphydroseq +,CAST(a.dnlevel AS SMALLINT) AS dnlevel +,CAST(a.dnlevelpat AS NUMERIC) AS dnlevelpat +,CAST(a.dnhydroseq AS NUMERIC) AS dnhydroseq +,CAST(a.dnminorhyd AS NUMERIC) AS dnminorhyd +,CAST(a.dndraincou AS SMALLINT) AS dndraincou +,a.frommeas +,a.tomeas +,CAST(a.rtndiv AS SMALLINT) AS rtndiv +,CAST(a.thinner AS SMALLINT) AS thinner +,CAST(a.vpuin AS SMALLINT) AS vpuin +,CAST(a.vpuout AS SMALLINT) AS vpuout +,a.areasqkm +,a.totdasqkm +,a.divdasqkm +,a.maxelevraw +,a.minelevraw +,a.maxelevsmo +,a.minelevsmo +,a.slope +,a.slopelenkm +,CAST(a.elevfixed AS SMALLINT) AS elevfixed +,CAST(a.hwtype AS SMALLINT) AS hwtype +,a.hwnodesqkm +,a.statusflag +,a.qama +,a.vama +,a.qincrama +,a.qbma +,a.vbma +,a.qincrbma +,a.qcma +,a.vcma +,a.qincrcma +,a.qdma +,a.vdma +,a.qincrdma +,a.qema +,a.vema +,a.qincrema +,a.qfma +,a.qincrfma +,a.arqnavma +,a.petma +,a.qlossma +,a.qgadjma +,a.qgnavma +,CAST(a.gageadjma AS SMALLINT) AS gageadjma +,a.avgqadjma +,a.gageidma +,a.gageqma +,a.globalid +,ST_Transform(ST_Force2D(a.shape),3857) AS shape +FROM +cipsrv_nhdplus_h.networknhdflowline a; + +ALTER TABLE cipsrv_gis.nhdplus_h_networknhdflowline_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_networknhdflowline_esri TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_h_nhdarea.sql b/src/database/cipsrv_gis/views/nhdplus_h_nhdarea.sql new file mode 100644 index 0000000..95d689c --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_h_nhdarea.sql @@ -0,0 +1,26 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_nhdarea +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.areasqkm +,a.elevation +,a.ftype +,a.fcode +,a.visibilityfilter +,a.nhdplusid +,a.vpuid +,a.onoffnet +,a.purpcode +,a.burn +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_h.nhdarea a; + +ALTER TABLE cipsrv_gis.nhdplus_h_nhdarea OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_nhdarea TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_h_nhdarea_esri.sql b/src/database/cipsrv_gis/views/nhdplus_h_nhdarea_esri.sql new file mode 100644 index 0000000..69d763e --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_h_nhdarea_esri.sql @@ -0,0 +1,26 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_nhdarea_esri +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.areasqkm +,a.elevation +,CAST(a.ftype AS INTEGER) AS ftype +,CAST(a.fcode AS INTEGER) AS fcode +,a.visibilityfilter +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.vpuid +,a.onoffnet +,a.purpcode +,a.burn +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_h.nhdarea a; + +ALTER TABLE cipsrv_gis.nhdplus_h_nhdarea_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_nhdarea_esri TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_h_nhdline.sql b/src/database/cipsrv_gis/views/nhdplus_h_nhdline.sql new file mode 100644 index 0000000..ff03666 --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_h_nhdline.sql @@ -0,0 +1,22 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_nhdline +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.lengthkm +,a.ftype +,a.fcode +,a.visibilityfilter +,a.nhdplusid +,a.vpuid +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_h.nhdline a; + +ALTER TABLE cipsrv_gis.nhdplus_h_nhdline OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_nhdline TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_h_nhdline_esri.sql b/src/database/cipsrv_gis/views/nhdplus_h_nhdline_esri.sql new file mode 100644 index 0000000..863ae76 --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_h_nhdline_esri.sql @@ -0,0 +1,22 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_nhdline_esri +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.lengthkm +,CAST(a.ftype AS INTEGER) AS ftype +,CAST(a.fcode AS INTEGER) AS fcode +,a.visibilityfilter +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.vpuid +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_h.nhdline a; + +ALTER TABLE cipsrv_gis.nhdplus_h_nhdline_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_nhdline_esri TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_h_nhdpluscatchment.sql b/src/database/cipsrv_gis/views/nhdplus_h_nhdpluscatchment.sql new file mode 100644 index 0000000..042a5f3 --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_h_nhdpluscatchment.sql @@ -0,0 +1,16 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_nhdpluscatchment +AS +SELECT + a.objectid +,a.nhdplusid +,a.sourcefc +,a.gridcode +,a.areasqkm +,a.vpuid +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_h.nhdpluscatchment a; + +ALTER TABLE cipsrv_gis.nhdplus_h_nhdpluscatchment OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_nhdpluscatchment TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_h_nhdpluscatchment_esri.sql b/src/database/cipsrv_gis/views/nhdplus_h_nhdpluscatchment_esri.sql new file mode 100644 index 0000000..9c93bb6 --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_h_nhdpluscatchment_esri.sql @@ -0,0 +1,16 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_nhdpluscatchment_esri +AS +SELECT + a.objectid +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.sourcefc +,a.gridcode +,a.areasqkm +,a.vpuid +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_h.nhdpluscatchment a; + +ALTER TABLE cipsrv_gis.nhdplus_h_nhdpluscatchment_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_nhdpluscatchment_esri TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_h_nhdplusflow.sql b/src/database/cipsrv_gis/views/nhdplus_h_nhdplusflow.sql new file mode 100644 index 0000000..e854d0e --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_h_nhdplusflow.sql @@ -0,0 +1,23 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_nhdplusflow +AS +SELECT + a.objectid +,a.fromnhdpid +,a.tonhdpid +,a.nodenumber +,a.deltalevel +,a.direction +,a.gapdistkm +,a.hasgeo +,a.fromvpuid +,a.tovpuid +,a.frompermid +,a.topermid +,a.fromhydroseq +,a.tohydroseq +,a.globalid +FROM +cipsrv_nhdplus_h.nhdplusflow a; + +ALTER TABLE cipsrv_gis.nhdplus_h_nhdplusflow OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_nhdplusflow TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_h_nhdplusflow_esri.sql b/src/database/cipsrv_gis/views/nhdplus_h_nhdplusflow_esri.sql new file mode 100644 index 0000000..2ce0b9f --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_h_nhdplusflow_esri.sql @@ -0,0 +1,23 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_nhdplusflow_esri +AS +SELECT + a.objectid +,CAST(a.fromnhdpid AS NUMERIC) AS fromnhdpid +,CAST(a.tonhdpid AS NUMERIC) AS tonhdpid +,CAST(a.nodenumber AS NUMERIC) AS nodenumber +,CAST(a.deltalevel AS SMALLINT) AS deltalevel +,CAST(a.direction AS SMALLINT) AS direction +,a.gapdistkm +,CAST(a.hasgeo AS SMALLINT) AS hasgeo +,a.fromvpuid +,a.tovpuid +,a.frompermid +,a.topermid +,CAST(a.fromhydroseq AS NUMERIC) AS fromhydroseq +,CAST(a.tohydroseq AS NUMERIC) AS tohydroseq +,a.globalid +FROM +cipsrv_nhdplus_h.nhdplusflow a; + +ALTER TABLE cipsrv_gis.nhdplus_h_nhdplusflow_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_nhdplusflow_esri TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_h_nhdplusgage.sql b/src/database/cipsrv_gis/views/nhdplus_h_nhdplusgage.sql new file mode 100644 index 0000000..9f697cc --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_h_nhdplusgage.sql @@ -0,0 +1,35 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_nhdplusgage +AS +SELECT + a.objectid +,a.hydroaddressid +,a.addressdate +,a.featuretype +,a.onnetwork +,a.sourceid +,a.sourceagency +,a.sourcedataset +,a.sourcefeatureurl +,a.catchment +,a.hu +,a.reachcode +,a.measure +,a.reachsmdate +,a.nhdplusid +,a.vpuid +,a.station_nm +,a.state_cd +,a.state +,a.latsite +,a.lonsite +,a.dasqmi +,a.referencegage +,a.class +,a.classmod +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_h.nhdplusgage a; + +ALTER TABLE cipsrv_gis.nhdplus_h_nhdplusgage OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_nhdplusgage TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_h_nhdplusgage_esri.sql b/src/database/cipsrv_gis/views/nhdplus_h_nhdplusgage_esri.sql new file mode 100644 index 0000000..5379001 --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_h_nhdplusgage_esri.sql @@ -0,0 +1,35 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_nhdplusgage_esri +AS +SELECT + a.objectid +,a.hydroaddressid +,a.addressdate +,a.featuretype +,a.onnetwork +,a.sourceid +,a.sourceagency +,a.sourcedataset +,a.sourcefeatureurl +,CAST(a.catchment AS NUMERIC) AS catchment +,a.hu +,a.reachcode +,a.measure +,a.reachsmdate +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.vpuid +,a.station_nm +,a.state_cd +,a.state +,a.latsite +,a.lonsite +,a.dasqmi +,a.referencegage +,a.class +,a.classmod +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_h.nhdplusgage a; + +ALTER TABLE cipsrv_gis.nhdplus_h_nhdplusgage_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_nhdplusgage_esri TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_h_nhdplussink.sql b/src/database/cipsrv_gis/views/nhdplus_h_nhdplussink.sql new file mode 100644 index 0000000..fec9254 --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_h_nhdplussink.sql @@ -0,0 +1,21 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_nhdplussink +AS +SELECT + a.objectid +,a.nhdplusid +,a.gridcode +,a.purpcode +,a.featureid +,a.sourcefc +,a.rpuid +,a.statusflag +,a.catchment +,a.burn +,a.vpuid +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_h.nhdplussink a; + +ALTER TABLE cipsrv_gis.nhdplus_h_nhdplussink OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_nhdplussink TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_h_nhdplussink_esri.sql b/src/database/cipsrv_gis/views/nhdplus_h_nhdplussink_esri.sql new file mode 100644 index 0000000..1d7eb88 --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_h_nhdplussink_esri.sql @@ -0,0 +1,21 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_nhdplussink_esri +AS +SELECT + a.objectid +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.gridcode +,a.purpcode +,CAST(a.featureid AS NUMERIC) AS featureid +,a.sourcefc +,a.rpuid +,a.statusflag +,CAST(a.catchment AS SMALLINT) AS catchment +,CAST(a.burn AS SMALLINT) AS burn +,a.vpuid +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_h.nhdplussink a; + +ALTER TABLE cipsrv_gis.nhdplus_h_nhdplussink_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_nhdplussink_esri TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_h_nhdpoint.sql b/src/database/cipsrv_gis/views/nhdplus_h_nhdpoint.sql new file mode 100644 index 0000000..f6eb554 --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_h_nhdpoint.sql @@ -0,0 +1,21 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_nhdpoint +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.reachcode +,a.ftype +,a.fcode +,a.nhdplusid +,a.vpuid +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_h.nhdpoint a; + +ALTER TABLE cipsrv_gis.nhdplus_h_nhdpoint OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_nhdpoint TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_h_nhdpoint_esri.sql b/src/database/cipsrv_gis/views/nhdplus_h_nhdpoint_esri.sql new file mode 100644 index 0000000..e786860 --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_h_nhdpoint_esri.sql @@ -0,0 +1,21 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_nhdpoint_esri +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.reachcode +,CAST(a.ftype AS INTEGER) AS ftype +,CAST(a.fcode AS INTEGER) AS fcode +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.vpuid +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_h.nhdpoint a; + +ALTER TABLE cipsrv_gis.nhdplus_h_nhdpoint_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_nhdpoint_esri TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_h_nhdwaterbody.sql b/src/database/cipsrv_gis/views/nhdplus_h_nhdwaterbody.sql new file mode 100644 index 0000000..30e999f --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_h_nhdwaterbody.sql @@ -0,0 +1,27 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_nhdwaterbody +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.areasqkm +,a.elevation +,a.reachcode +,a.ftype +,a.fcode +,a.visibilityfilter +,a.nhdplusid +,a.vpuid +,a.onoffnet +,a.purpcode +,a.burn +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_m.nhdwaterbody a; + +ALTER TABLE cipsrv_gis.nhdplus_m_nhdwaterbody OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_nhdwaterbody TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_h_nhdwaterbody_esri.sql b/src/database/cipsrv_gis/views/nhdplus_h_nhdwaterbody_esri.sql new file mode 100644 index 0000000..3b22e38 --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_h_nhdwaterbody_esri.sql @@ -0,0 +1,27 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_nhdwaterbody_esri +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.areasqkm +,a.elevation +,a.reachcode +,CAST(a.ftype AS INTEGER) AS ftype +,CAST(a.fcode AS INTEGER) AS fcode +,a.visibilityfilter +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.vpuid +,a.onoffnet +,a.purpcode +,a.burn +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_h.nhdwaterbody a; + +ALTER TABLE cipsrv_gis.nhdplus_h_nhdwaterbody_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_nhdwaterbody_esri TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_h_nonnetworknhdflowline.sql b/src/database/cipsrv_gis/views/nhdplus_h_nonnetworknhdflowline.sql new file mode 100644 index 0000000..1c6336e --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_h_nonnetworknhdflowline.sql @@ -0,0 +1,27 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_nonnetworknhdflowline +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.lengthkm +,a.reachcode +,a.flowdir +,a.wbarea_permanent_identifier +,a.ftype +,a.fcode +,a.mainpath +,a.innetwork +,a.visibilityfilter +,a.nhdplusid +,a.vpuid +,a.globalid +,ST_Transform(ST_Force2D(a.shape),3857) AS shape +FROM +cipsrv_nhdplus_h.nonnetworknhdflowline a; + +ALTER TABLE cipsrv_gis.nhdplus_h_nonnetworknhdflowline OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_nonnetworknhdflowline TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_h_nonnetworknhdflowline_esri.sql b/src/database/cipsrv_gis/views/nhdplus_h_nonnetworknhdflowline_esri.sql new file mode 100644 index 0000000..8d89cda --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_h_nonnetworknhdflowline_esri.sql @@ -0,0 +1,27 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_nonnetworknhdflowline_esri +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.lengthkm +,a.reachcode +,a.flowdir +,a.wbarea_permanent_identifier +,CAST(a.ftype AS INTEGER) AS ftype +,CAST(a.fcode AS INTEGER) AS fcode +,a.mainpath +,CAST(a.innetwork AS SMALLINT) AS innetwork +,a.visibilityfilter +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.vpuid +,a.globalid +,ST_Transform(ST_Force2D(a.shape),3857) AS shape +FROM +cipsrv_nhdplus_h.nonnetworknhdflowline a; + +ALTER TABLE cipsrv_gis.nhdplus_h_nonnetworknhdflowline_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_nonnetworknhdflowline_esri TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_h_wbdhu12.sql b/src/database/cipsrv_gis/views/nhdplus_h_wbdhu12.sql new file mode 100644 index 0000000..95b469f --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_h_wbdhu12.sql @@ -0,0 +1,29 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_wbdhu12 +AS +SELECT + a.objectid +,a.tnmid +,a.metasourceid +,a.sourcedatadesc +,a.sourceoriginator +,a.sourcefeatureid +,a.loaddate +,a.referencegnis_ids +,a.areaacres +,a.areasqkm +,a.states +,a.huc12 +,a.name +,a.hutype +,a.humod +,a.tohuc +,a.noncontributingareaacres +,a.noncontributingareasqkm +,a.nhdplusid +,a.vpuid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_h.wbdhu12 a; + +ALTER TABLE cipsrv_gis.nhdplus_h_wbdhu12 OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_wbdhu12 TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_h_wbdhu12_esri.sql b/src/database/cipsrv_gis/views/nhdplus_h_wbdhu12_esri.sql new file mode 100644 index 0000000..d32b9a6 --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_h_wbdhu12_esri.sql @@ -0,0 +1,29 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_h_wbdhu12_esri +AS +SELECT + a.objectid +,a.tnmid +,a.metasourceid +,a.sourcedatadesc +,a.sourceoriginator +,a.sourcefeatureid +,a.loaddate +,a.referencegnis_ids +,a.areaacres +,a.areasqkm +,a.states +,a.huc12 +,a.name +,a.hutype +,a.humod +,a.tohuc +,a.noncontributingareaacres +,a.noncontributingareasqkm +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.vpuid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_h.wbdhu12 a; + +ALTER TABLE cipsrv_gis.nhdplus_h_wbdhu12_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_h_wbdhu12_esri TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_m_flow_direction.sql b/src/database/cipsrv_gis/views/nhdplus_m_flow_direction.sql new file mode 100644 index 0000000..ec0ff62 --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_m_flow_direction.sql @@ -0,0 +1,48 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_flow_direction +AS +SELECT + a.objectid +,a.permanent_identifier +,CAST(DEGREES( + ST_Azimuth( + a.penul_point + ,a.final_point + ) + ) AS NUMERIC) AS angle_direction +,CAST(ROUND(DEGREES( + ST_Azimuth( + a.penul_point + ,a.final_point + ) + ) / 5 ) * 5 AS NUMERIC ) AS angle_rounded +,a.ftype +,a.fcode +,a.visibilityfilter +,a.nhdplusid +,ST_Transform(a.final_point,3857) AS shape +FROM ( + SELECT + aa.objectid + ,aa.permanent_identifier + ,aa.ftype + ,aa.fcode + ,aa.visibilityfilter + ,aa.nhdplusid + ,ST_PointN(aa.shape,-2) AS penul_point + ,ST_PointN(aa.shape,-1) AS final_point + FROM ( + SELECT + aaa.objectid + ,aaa.permanent_identifier + ,aaa.ftype + ,aaa.fcode + ,aaa.visibilityfilter + ,aaa.nhdplusid + ,ST_Force2D(aaa.shape) AS shape + FROM + cipsrv_nhdplus_m.networknhdflowline aaa + ) aa +) a; + +ALTER TABLE cipsrv_gis.nhdplus_m_flow_direction OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_flow_direction TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_m_flow_direction_esri.sql b/src/database/cipsrv_gis/views/nhdplus_m_flow_direction_esri.sql new file mode 100644 index 0000000..7db28d0 --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_m_flow_direction_esri.sql @@ -0,0 +1,48 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_flow_direction_esri +AS +SELECT + a.objectid +,a.permanent_identifier +,CAST(DEGREES( + ST_Azimuth( + a.penul_point + ,a.final_point + ) + ) AS NUMERIC) AS angle_direction +,CAST(ROUND(DEGREES( + ST_Azimuth( + a.penul_point + ,a.final_point + ) + ) / 5 ) * 5 AS NUMERIC ) AS angle_rounded +,CAST(a.ftype AS INTEGER) AS ftype +,CAST(a.fcode AS INTEGER) AS fcode +,a.visibilityfilter +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,ST_Transform(a.final_point,3857) AS shape +FROM ( + SELECT + aa.objectid + ,aa.permanent_identifier + ,aa.ftype + ,aa.fcode + ,aa.visibilityfilter + ,aa.nhdplusid + ,ST_PointN(aa.shape,-2) AS penul_point + ,ST_PointN(aa.shape,-1) AS final_point + FROM ( + SELECT + aaa.objectid + ,aaa.permanent_identifier + ,aaa.ftype + ,aaa.fcode + ,aaa.visibilityfilter + ,aaa.nhdplusid + ,ST_Force2D(aaa.shape) AS shape + FROM + cipsrv_nhdplus_m.networknhdflowline aaa + ) aa +) a; + +ALTER TABLE cipsrv_gis.nhdplus_m_flow_direction_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_flow_direction_esri TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_m_networknhdflowline.sql b/src/database/cipsrv_gis/views/nhdplus_m_networknhdflowline.sql new file mode 100644 index 0000000..35626c1 --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_m_networknhdflowline.sql @@ -0,0 +1,94 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_networknhdflowline +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.lengthkm +,a.totma +,a.reachcode +,a.flowdir +,a.wbarea_permanent_identifier +,a.ftype +,a.fcode +,a.mainpath +,a.innetwork +,a.visibilityfilter +,a.nhdplusid +,a.vpuid +,a.streamleve +,a.streamorde +,a.streamcalc +,a.fromnode +,a.tonode +,a.hydroseq +,a.levelpathi +,a.pathlength +,a.pathtimema +,a.terminalpa +,a.arbolatesu +,a.divergence +,a.startflag +,a.terminalfl +,a.uplevelpat +,a.uphydroseq +,a.dnlevel +,a.dnlevelpat +,a.dnhydroseq +,a.dnminorhyd +,a.dndraincou +,a.frommeas +,a.tomeas +,a.rtndiv +,a.thinner +,a.vpuin +,a.vpuout +,a.areasqkm +,a.totdasqkm +,a.divdasqkm +,a.maxelevraw +,a.minelevraw +,a.maxelevsmo +,a.minelevsmo +,a.slope +,a.slopelenkm +,a.elevfixed +,a.hwtype +,a.hwnodesqkm +,a.statusflag +,a.qama +,a.vama +,a.qincrama +,a.qbma +,a.vbma +,a.qincrbma +,a.qcma +,a.vcma +,a.qincrcma +,a.qdma +,a.vdma +,a.qincrdma +,a.qema +,a.vema +,a.qincrema +,a.qfma +,a.qincrfma +,a.arqnavma +,a.petma +,a.qlossma +,a.qgadjma +,a.qgnavma +,a.gageadjma +,a.avgqadjma +,a.gageidma +,a.gageqma +,a.globalid +,ST_Transform(ST_Force2D(a.shape),3857) AS shape +FROM +cipsrv_nhdplus_m.networknhdflowline a; + +ALTER TABLE cipsrv_gis.nhdplus_m_networknhdflowline OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_networknhdflowline TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_m_networknhdflowline_esri.sql b/src/database/cipsrv_gis/views/nhdplus_m_networknhdflowline_esri.sql new file mode 100644 index 0000000..32e534a --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_m_networknhdflowline_esri.sql @@ -0,0 +1,94 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_networknhdflowline_esri +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.lengthkm +,a.totma +,a.reachcode +,a.flowdir +,a.wbarea_permanent_identifier +,CAST(a.ftype AS INTEGER) AS ftype +,CAST(a.fcode AS INTEGER) AS fcode +,a.mainpath +,CAST(a.innetwork AS SMALLINT) AS innetwork +,a.visibilityfilter +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.vpuid +,CAST(a.streamleve AS SMALLINT) AS streamleve +,CAST(a.streamorde AS SMALLINT) AS streamorde +,CAST(a.streamcalc AS SMALLINT) AS streamcalc +,CAST(a.fromnode AS NUMERIC) AS fromnode +,CAST(a.tonode AS NUMERIC) AS tonode +,CAST(a.hydroseq AS NUMERIC) AS hydroseq +,CAST(a.levelpathi AS NUMERIC) AS levelpathi +,a.pathlength +,a.pathtimema +,CAST(a.terminalpa AS NUMERIC) AS terminalpa +,a.arbolatesu +,CAST(a.divergence AS SMALLINT) AS divergence +,CAST(a.startflag AS SMALLINT) AS startflag +,CAST(a.terminalfl AS SMALLINT) AS terminalfl +,CAST(a.uplevelpat AS NUMERIC) AS uplevelpat +,CAST(a.uphydroseq AS NUMERIC) AS uphydroseq +,CAST(a.dnlevel AS SMALLINT) AS dnlevel +,CAST(a.dnlevelpat AS NUMERIC) AS dnlevelpat +,CAST(a.dnhydroseq AS NUMERIC) AS dnhydroseq +,CAST(a.dnminorhyd AS NUMERIC) AS dnminorhyd +,CAST(a.dndraincou AS SMALLINT) AS dndraincou +,a.frommeas +,a.tomeas +,CAST(a.rtndiv AS SMALLINT) AS rtndiv +,CAST(a.thinner AS SMALLINT) AS thinner +,CAST(a.vpuin AS SMALLINT) AS vpuin +,CAST(a.vpuout AS SMALLINT) AS vpuout +,a.areasqkm +,a.totdasqkm +,a.divdasqkm +,a.maxelevraw +,a.minelevraw +,a.maxelevsmo +,a.minelevsmo +,a.slope +,a.slopelenkm +,CAST(a.elevfixed AS SMALLINT) AS elevfixed +,CAST(a.hwtype AS SMALLINT) AS hwtype +,a.hwnodesqkm +,a.statusflag +,a.qama +,a.vama +,a.qincrama +,a.qbma +,a.vbma +,a.qincrbma +,a.qcma +,a.vcma +,a.qincrcma +,a.qdma +,a.vdma +,a.qincrdma +,a.qema +,a.vema +,a.qincrema +,a.qfma +,a.qincrfma +,a.arqnavma +,a.petma +,a.qlossma +,a.qgadjma +,a.qgnavma +,CAST(a.gageadjma AS SMALLINT) AS gageadjma +,a.avgqadjma +,a.gageidma +,a.gageqma +,a.globalid +,ST_Transform(ST_Force2D(a.shape),3857) AS shape +FROM +cipsrv_nhdplus_m.networknhdflowline a; + +ALTER TABLE cipsrv_gis.nhdplus_m_networknhdflowline_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_networknhdflowline_esri TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_m_nhdarea.sql b/src/database/cipsrv_gis/views/nhdplus_m_nhdarea.sql new file mode 100644 index 0000000..221c0e6 --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_m_nhdarea.sql @@ -0,0 +1,26 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_nhdarea +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.areasqkm +,a.elevation +,a.ftype +,a.fcode +,a.visibilityfilter +,a.nhdplusid +,a.vpuid +,a.onoffnet +,a.purpcode +,a.burn +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_m.nhdarea a; + +ALTER TABLE cipsrv_gis.nhdplus_m_nhdarea OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_nhdarea TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_m_nhdarea_esri.sql b/src/database/cipsrv_gis/views/nhdplus_m_nhdarea_esri.sql new file mode 100644 index 0000000..6c65f38 --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_m_nhdarea_esri.sql @@ -0,0 +1,26 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_nhdarea_esri +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.areasqkm +,a.elevation +,CAST(a.ftype AS INTEGER) AS ftype +,CAST(a.fcode AS INTEGER) AS fcode +,a.visibilityfilter +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.vpuid +,a.onoffnet +,a.purpcode +,a.burn +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_m.nhdarea a; + +ALTER TABLE cipsrv_gis.nhdplus_m_nhdarea_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_nhdarea_esri TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_m_nhdline.sql b/src/database/cipsrv_gis/views/nhdplus_m_nhdline.sql new file mode 100644 index 0000000..8d59cef --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_m_nhdline.sql @@ -0,0 +1,26 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_nhdline +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.areasqkm +,a.elevation +,a.ftype +,a.fcode +,a.visibilityfilter +,a.nhdplusid +,a.vpuid +,a.onoffnet +,a.purpcode +,a.burn +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_m.nhdarea a; + +ALTER TABLE cipsrv_gis.nhdplus_m_nhdarea OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_nhdarea TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_m_nhdline_esri.sql b/src/database/cipsrv_gis/views/nhdplus_m_nhdline_esri.sql new file mode 100644 index 0000000..ca3f7b7 --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_m_nhdline_esri.sql @@ -0,0 +1,22 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_nhdline_esri +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.lengthkm +,CAST(a.ftype AS INTEGER) AS ftype +,CAST(a.fcode AS INTEGER) AS fcode +,a.visibilityfilter +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.vpuid +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_m.nhdline a; + +ALTER TABLE cipsrv_gis.nhdplus_m_nhdline_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_nhdline_esri TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_m_nhdpluscatchment.sql b/src/database/cipsrv_gis/views/nhdplus_m_nhdpluscatchment.sql new file mode 100644 index 0000000..ad41dc0 --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_m_nhdpluscatchment.sql @@ -0,0 +1,16 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_nhdpluscatchment +AS +SELECT + a.objectid +,a.nhdplusid +,a.sourcefc +,a.gridcode +,a.areasqkm +,a.vpuid +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_m.nhdpluscatchment a; + +ALTER TABLE cipsrv_gis.nhdplus_m_nhdpluscatchment OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_nhdpluscatchment TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_m_nhdpluscatchment_esri.sql b/src/database/cipsrv_gis/views/nhdplus_m_nhdpluscatchment_esri.sql new file mode 100644 index 0000000..61b5ba0 --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_m_nhdpluscatchment_esri.sql @@ -0,0 +1,16 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_nhdpluscatchment_esri +AS +SELECT + a.objectid +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.sourcefc +,a.gridcode +,a.areasqkm +,a.vpuid +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_m.nhdpluscatchment a; + +ALTER TABLE cipsrv_gis.nhdplus_m_nhdpluscatchment_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_nhdpluscatchment_esri TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_m_nhdplusflow.sql b/src/database/cipsrv_gis/views/nhdplus_m_nhdplusflow.sql new file mode 100644 index 0000000..0d80388 --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_m_nhdplusflow.sql @@ -0,0 +1,23 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_nhdplusflow +AS +SELECT + a.objectid +,a.fromnhdpid +,a.tonhdpid +,a.nodenumber +,a.deltalevel +,a.direction +,a.gapdistkm +,a.hasgeo +,a.fromvpuid +,a.tovpuid +,a.frompermid +,a.topermid +,a.fromhydroseq +,a.tohydroseq +,a.globalid +FROM +cipsrv_nhdplus_m.nhdplusflow a; + +ALTER TABLE cipsrv_gis.nhdplus_m_nhdplusflow OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_nhdplusflow TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_m_nhdplusflow_esri.sql b/src/database/cipsrv_gis/views/nhdplus_m_nhdplusflow_esri.sql new file mode 100644 index 0000000..900909d --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_m_nhdplusflow_esri.sql @@ -0,0 +1,23 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_nhdplusflow_esri +AS +SELECT + a.objectid +,CAST(a.fromnhdpid AS NUMERIC) AS fromnhdpid +,CAST(a.tonhdpid AS NUMERIC) AS tonhdpid +,CAST(a.nodenumber AS NUMERIC) AS nodenumber +,CAST(a.deltalevel AS SMALLINT) AS deltalevel +,CAST(a.direction AS SMALLINT) AS direction +,a.gapdistkm +,CAST(a.hasgeo AS SMALLINT) AS hasgeo +,a.fromvpuid +,a.tovpuid +,a.frompermid +,a.topermid +,CAST(a.fromhydroseq AS NUMERIC) AS fromhydroseq +,CAST(a.tohydroseq AS NUMERIC) AS tohydroseq +,a.globalid +FROM +cipsrv_nhdplus_m.nhdplusflow a; + +ALTER TABLE cipsrv_gis.nhdplus_m_nhdplusflow_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_nhdplusflow_esri TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_m_nhdplusgage.sql b/src/database/cipsrv_gis/views/nhdplus_m_nhdplusgage.sql new file mode 100644 index 0000000..d9d737c --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_m_nhdplusgage.sql @@ -0,0 +1,35 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_nhdplusgage +AS +SELECT + a.objectid +,a.hydroaddressid +,a.addressdate +,a.featuretype +,a.onnetwork +,a.sourceid +,a.sourceagency +,a.sourcedataset +,a.sourcefeatureurl +,a.catchment +,a.hu +,a.reachcode +,a.measure +,a.reachsmdate +,a.nhdplusid +,a.vpuid +,a.station_nm +,a.state_cd +,a.state +,a.latsite +,a.lonsite +,a.dasqmi +,a.referencegage +,a.class +,a.classmod +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_m.nhdplusgage a; + +ALTER TABLE cipsrv_gis.nhdplus_m_nhdplusgage OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_nhdplusgage TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_m_nhdplusgage_esri.sql b/src/database/cipsrv_gis/views/nhdplus_m_nhdplusgage_esri.sql new file mode 100644 index 0000000..faac326 --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_m_nhdplusgage_esri.sql @@ -0,0 +1,35 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_nhdplusgage_esri +AS +SELECT + a.objectid +,a.hydroaddressid +,a.addressdate +,a.featuretype +,a.onnetwork +,a.sourceid +,a.sourceagency +,a.sourcedataset +,a.sourcefeatureurl +,CAST(a.catchment AS NUMERIC) AS catchment +,a.hu +,a.reachcode +,a.measure +,a.reachsmdate +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.vpuid +,a.station_nm +,a.state_cd +,a.state +,a.latsite +,a.lonsite +,a.dasqmi +,a.referencegage +,a.class +,a.classmod +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_m.nhdplusgage a; + +ALTER TABLE cipsrv_gis.nhdplus_m_nhdplusgage_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_nhdplusgage_esri TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_m_nhdplussink.sql b/src/database/cipsrv_gis/views/nhdplus_m_nhdplussink.sql new file mode 100644 index 0000000..fd6fee5 --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_m_nhdplussink.sql @@ -0,0 +1,21 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_nhdplussink +AS +SELECT + a.objectid +,a.nhdplusid +,a.gridcode +,a.purpcode +,a.featureid +,a.sourcefc +,a.rpuid +,a.statusflag +,a.catchment +,a.burn +,a.vpuid +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_m.nhdplussink a; + +ALTER TABLE cipsrv_gis.nhdplus_m_nhdplussink OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_nhdplussink TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_m_nhdplussink_esri.sql b/src/database/cipsrv_gis/views/nhdplus_m_nhdplussink_esri.sql new file mode 100644 index 0000000..3c48058 --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_m_nhdplussink_esri.sql @@ -0,0 +1,21 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_nhdplussink_esri +AS +SELECT + a.objectid +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.gridcode +,a.purpcode +,CAST(a.featureid AS NUMERIC) AS featureid +,a.sourcefc +,a.rpuid +,a.statusflag +,CAST(a.catchment AS SMALLINT) AS catchment +,CAST(a.burn AS SMALLINT) AS burn +,a.vpuid +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_m.nhdplussink a; + +ALTER TABLE cipsrv_gis.nhdplus_m_nhdplussink_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_nhdplussink_esri TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_m_nhdpoint.sql b/src/database/cipsrv_gis/views/nhdplus_m_nhdpoint.sql new file mode 100644 index 0000000..50807ea --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_m_nhdpoint.sql @@ -0,0 +1,21 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_nhdpoint +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.reachcode +,a.ftype +,a.fcode +,a.nhdplusid +,a.vpuid +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_m.nhdpoint a; + +ALTER TABLE cipsrv_gis.nhdplus_m_nhdpoint OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_nhdpoint TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_m_nhdpoint_esri.sql b/src/database/cipsrv_gis/views/nhdplus_m_nhdpoint_esri.sql new file mode 100644 index 0000000..6452d9e --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_m_nhdpoint_esri.sql @@ -0,0 +1,21 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_nhdpoint_esri +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.reachcode +,CAST(a.ftype AS INTEGER) AS ftype +,CAST(a.fcode AS INTEGER) AS fcode +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.vpuid +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_m.nhdpoint a; + +ALTER TABLE cipsrv_gis.nhdplus_m_nhdpoint_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_nhdpoint_esri TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_m_nhdwaterbody.sql b/src/database/cipsrv_gis/views/nhdplus_m_nhdwaterbody.sql new file mode 100644 index 0000000..30e999f --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_m_nhdwaterbody.sql @@ -0,0 +1,27 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_nhdwaterbody +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.areasqkm +,a.elevation +,a.reachcode +,a.ftype +,a.fcode +,a.visibilityfilter +,a.nhdplusid +,a.vpuid +,a.onoffnet +,a.purpcode +,a.burn +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_m.nhdwaterbody a; + +ALTER TABLE cipsrv_gis.nhdplus_m_nhdwaterbody OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_nhdwaterbody TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_m_nhdwaterbody_esri.sql b/src/database/cipsrv_gis/views/nhdplus_m_nhdwaterbody_esri.sql new file mode 100644 index 0000000..4d3220f --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_m_nhdwaterbody_esri.sql @@ -0,0 +1,27 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_nhdwaterbody_esri +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.areasqkm +,a.elevation +,a.reachcode +,CAST(a.ftype AS INTEGER) AS ftype +,CAST(a.fcode AS INTEGER) AS fcode +,a.visibilityfilter +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.vpuid +,a.onoffnet +,a.purpcode +,a.burn +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_m.nhdwaterbody a; + +ALTER TABLE cipsrv_gis.nhdplus_m_nhdwaterbody_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_nhdwaterbody_esri TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_m_nonnetworknhdflowline.sql b/src/database/cipsrv_gis/views/nhdplus_m_nonnetworknhdflowline.sql new file mode 100644 index 0000000..fa4f051 --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_m_nonnetworknhdflowline.sql @@ -0,0 +1,27 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_nonnetworknhdflowline +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.lengthkm +,a.reachcode +,a.flowdir +,a.wbarea_permanent_identifier +,a.ftype +,a.fcode +,a.mainpath +,a.innetwork +,a.visibilityfilter +,a.nhdplusid +,a.vpuid +,a.globalid +,ST_Transform(ST_Force2D(a.shape),3857) AS shape +FROM +cipsrv_nhdplus_m.nonnetworknhdflowline a; + +ALTER TABLE cipsrv_gis.nhdplus_m_nonnetworknhdflowline OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_nonnetworknhdflowline TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_m_nonnetworknhdflowline_esri.sql b/src/database/cipsrv_gis/views/nhdplus_m_nonnetworknhdflowline_esri.sql new file mode 100644 index 0000000..de0dc6d --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_m_nonnetworknhdflowline_esri.sql @@ -0,0 +1,27 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_nonnetworknhdflowline_esri +AS +SELECT + a.objectid +,a.permanent_identifier +,a.fdate +,a.resolution +,a.gnis_id +,a.gnis_name +,a.lengthkm +,a.reachcode +,a.flowdir +,a.wbarea_permanent_identifier +,CAST(a.ftype AS INTEGER) AS ftype +,CAST(a.fcode AS INTEGER) AS fcode +,a.mainpath +,CAST(a.innetwork AS SMALLINT) AS innetwork +,a.visibilityfilter +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.vpuid +,a.globalid +,ST_Transform(ST_Force2D(a.shape),3857) AS shape +FROM +cipsrv_nhdplus_m.nonnetworknhdflowline a; + +ALTER TABLE cipsrv_gis.nhdplus_m_nonnetworknhdflowline_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_nonnetworknhdflowline_esri TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_m_wbdhu12.sql b/src/database/cipsrv_gis/views/nhdplus_m_wbdhu12.sql new file mode 100644 index 0000000..efc9f4c --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_m_wbdhu12.sql @@ -0,0 +1,29 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_wbdhu12 +AS +SELECT + a.objectid +,a.tnmid +,a.metasourceid +,a.sourcedatadesc +,a.sourceoriginator +,a.sourcefeatureid +,a.loaddate +,a.referencegnis_ids +,a.areaacres +,a.areasqkm +,a.states +,a.huc12 +,a.name +,a.hutype +,a.humod +,a.tohuc +,a.noncontributingareaacres +,a.noncontributingareasqkm +,a.nhdplusid +,a.vpuid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_m.wbdhu12 a; + +ALTER TABLE cipsrv_gis.nhdplus_m_wbdhu12 OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_wbdhu12 TO public; diff --git a/src/database/cipsrv_gis/views/nhdplus_m_wbdhu12_esri.sql b/src/database/cipsrv_gis/views/nhdplus_m_wbdhu12_esri.sql new file mode 100644 index 0000000..468e1cc --- /dev/null +++ b/src/database/cipsrv_gis/views/nhdplus_m_wbdhu12_esri.sql @@ -0,0 +1,29 @@ +CREATE OR REPLACE VIEW cipsrv_gis.nhdplus_m_wbdhu12_esri +AS +SELECT + a.objectid +,a.tnmid +,a.metasourceid +,a.sourcedatadesc +,a.sourceoriginator +,a.sourcefeatureid +,a.loaddate +,a.referencegnis_ids +,a.areaacres +,a.areasqkm +,a.states +,a.huc12 +,a.name +,a.hutype +,a.humod +,a.tohuc +,a.noncontributingareaacres +,a.noncontributingareasqkm +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.vpuid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_nhdplus_m.wbdhu12 a; + +ALTER TABLE cipsrv_gis.nhdplus_m_wbdhu12_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.nhdplus_m_wbdhu12_esri TO public; diff --git a/src/database/cipsrv_gis/views/owld_wqp_attr.sql b/src/database/cipsrv_gis/views/owld_wqp_attr.sql new file mode 100644 index 0000000..97c461b --- /dev/null +++ b/src/database/cipsrv_gis/views/owld_wqp_attr.sql @@ -0,0 +1,48 @@ +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_attr +AS +SELECT + a.objectid +,a.source_joinkey +,a.organizationidentifier +,a.organizationformalname +,a.monitoringlocationidentifier +,a.monitoringlocationname +,a.monitoringlocationtypename +,a.monitoringlocationdescription +,a.huceightdigitcode +,a.drainageareameasure_measureval +,a.drainageareameasure_measureunt +,a.contributingdrainageareameasva +,a.contributingdrainageareameasun +,a.latitudemeasure +,a.longitudemeasure +,a.sourcemapscalenumeric +,a.horizontalaccuracymeasureval +,a.horizontalaccuracymeasureunit +,a.horizontalcollectionmethodname +,a.horizontalcoordinatereferences +,a.verticalmeasure_measurevalue +,a.verticalmeasure_measureunit +,a.verticalaccuracymeasurevalue +,a.verticalaccuracymeasureunit +,a.verticalcollectionmethodname +,a.verticalcoordinatereferencesys +,a.countrycode +,a.statecode +,a.countycode +,a.aquifername +,a.formationtypetext +,a.aquifertypename +,a.localaqfrname +,a.constructiondatetext +,a.welldepthmeasure_measurevalue +,a.welldepthmeasure_measureunit +,a.wellholedepthmeasure_measureva +,a.wellholedepthmeasure_measureun +,a.providername +,a.globalid +FROM +cipsrv_owld.wqp_attr a; + +ALTER TABLE cipsrv_gis.owld_wqp_attr OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_attr TO public; diff --git a/src/database/cipsrv_gis/views/owld_wqp_attr_esri.sql b/src/database/cipsrv_gis/views/owld_wqp_attr_esri.sql new file mode 100644 index 0000000..7cc8322 --- /dev/null +++ b/src/database/cipsrv_gis/views/owld_wqp_attr_esri.sql @@ -0,0 +1,48 @@ +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_attr_esri +AS +SELECT + a.objectid +,a.source_joinkey +,a.organizationidentifier +,a.organizationformalname +,a.monitoringlocationidentifier +,a.monitoringlocationname +,a.monitoringlocationtypename +,a.monitoringlocationdescription +,a.huceightdigitcode +,a.drainageareameasure_measureval +,a.drainageareameasure_measureunt +,a.contributingdrainageareameasva +,a.contributingdrainageareameasun +,a.latitudemeasure +,a.longitudemeasure +,a.sourcemapscalenumeric +,a.horizontalaccuracymeasureval +,a.horizontalaccuracymeasureunit +,a.horizontalcollectionmethodname +,a.horizontalcoordinatereferences +,a.verticalmeasure_measurevalue +,a.verticalmeasure_measureunit +,a.verticalaccuracymeasurevalue +,a.verticalaccuracymeasureunit +,a.verticalcollectionmethodname +,a.verticalcoordinatereferencesys +,a.countrycode +,a.statecode +,a.countycode +,a.aquifername +,a.formationtypetext +,a.aquifertypename +,a.localaqfrname +,a.constructiondatetext +,a.welldepthmeasure_measurevalue +,a.welldepthmeasure_measureunit +,a.wellholedepthmeasure_measureva +,a.wellholedepthmeasure_measureun +,a.providername +,a.globalid +FROM +cipsrv_owld.wqp_attr a; + +ALTER TABLE cipsrv_gis.owld_wqp_attr_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_attr_esri TO public; diff --git a/src/database/cipsrv_gis/views/owld_wqp_cip.sql b/src/database/cipsrv_gis/views/owld_wqp_cip.sql new file mode 100644 index 0000000..459c588 --- /dev/null +++ b/src/database/cipsrv_gis/views/owld_wqp_cip.sql @@ -0,0 +1,38 @@ +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_cip +AS +SELECT + a.objectid +,a.cip_joinkey +,a.permid_joinkey +,a.source_originator +,a.source_featureid +,a.source_featureid2 +,a.source_series +,a.source_subdivision +,a.source_joinkey +,a.start_date +,a.end_date +,a.cat_joinkey +,a.catchmentstatecode +,a.nhdplusid +,a.istribal +,a.istribal_areasqkm +,a.catchmentresolution +,a.catchmentareasqkm +,a.xwalk_huc12 +,a.xwalk_method +,a.xwalk_huc12_version +,a.isnavigable +,a.hasvaa +,a.issink +,a.isheadwater +,a.iscoastal +,a.isocean +,a.isalaskan +,a.h3hexagonaddr +,a.globalid +FROM +cipsrv_owld.wqp_cip a; + +ALTER TABLE cipsrv_gis.owld_wqp_cip OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_cip TO public; diff --git a/src/database/cipsrv_gis/views/owld_wqp_cip_esri.sql b/src/database/cipsrv_gis/views/owld_wqp_cip_esri.sql new file mode 100644 index 0000000..dba4785 --- /dev/null +++ b/src/database/cipsrv_gis/views/owld_wqp_cip_esri.sql @@ -0,0 +1,38 @@ +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_cip_esri +AS +SELECT + a.objectid +,a.cip_joinkey +,a.permid_joinkey +,a.source_originator +,a.source_featureid +,a.source_featureid2 +,a.source_series +,a.source_subdivision +,a.source_joinkey +,a.start_date +,a.end_date +,a.cat_joinkey +,a.catchmentstatecode +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.istribal +,a.istribal_areasqkm +,a.catchmentresolution +,a.catchmentareasqkm +,a.xwalk_huc12 +,a.xwalk_method +,a.xwalk_huc12_version +,a.isnavigable +,a.hasvaa +,a.issink +,a.isheadwater +,a.iscoastal +,a.isocean +,a.isalaskan +,a.h3hexagonaddr +,a.globalid +FROM +cipsrv_owld.wqp_cip a; + +ALTER TABLE cipsrv_gis.owld_wqp_cip_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_cip_esri TO public; diff --git a/src/database/cipsrv_gis/views/owld_wqp_cip_geo.sql b/src/database/cipsrv_gis/views/owld_wqp_cip_geo.sql new file mode 100644 index 0000000..c4edf97 --- /dev/null +++ b/src/database/cipsrv_gis/views/owld_wqp_cip_geo.sql @@ -0,0 +1,19 @@ +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_cip_geo +AS +SELECT + a.objectid +,a.cat_joinkey +,a.catchmentstatecode +,a.nhdplusid +,a.catchmentresolution +,a.catchmentareasqkm +,a.xwalk_huc12 +,a.xwalk_method +,a.xwalk_huc12_version +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_owld.wqp_cip_geo a; + +ALTER TABLE cipsrv_gis.owld_wqp_cip_geo OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_cip_geo TO public; diff --git a/src/database/cipsrv_gis/views/owld_wqp_cip_geo_esri.sql b/src/database/cipsrv_gis/views/owld_wqp_cip_geo_esri.sql new file mode 100644 index 0000000..cadd77a --- /dev/null +++ b/src/database/cipsrv_gis/views/owld_wqp_cip_geo_esri.sql @@ -0,0 +1,19 @@ +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_cip_geo_esri +AS +SELECT + a.objectid +,a.cat_joinkey +,a.catchmentstatecode +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.catchmentresolution +,a.catchmentareasqkm +,a.xwalk_huc12 +,a.xwalk_method +,a.xwalk_huc12_version +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_owld.wqp_cip_geo a; + +ALTER TABLE cipsrv_gis.owld_wqp_cip_geo_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_cip_geo_esri TO public; diff --git a/src/database/cipsrv_gis/views/owld_wqp_huc12.sql b/src/database/cipsrv_gis/views/owld_wqp_huc12.sql new file mode 100644 index 0000000..ce43610 --- /dev/null +++ b/src/database/cipsrv_gis/views/owld_wqp_huc12.sql @@ -0,0 +1,23 @@ +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_huc12 +AS +SELECT + a.objectid +,a.source_originator +,a.source_featureid +,a.source_featureid2 +,a.source_series +,a.source_subdivision +,a.source_joinkey +,a.permid_joinkey +,a.start_date +,a.end_date +,a.xwalk_huc12 +,a.xwalk_catresolution +,a.xwalk_huc12_version +,a.xwalk_huc12_areasqkm +,a.globalid +FROM +cipsrv_owld.wqp_huc12 a; + +ALTER TABLE cipsrv_gis.owld_wqp_huc12 OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_huc12 TO public; diff --git a/src/database/cipsrv_gis/views/owld_wqp_huc12_esri.sql b/src/database/cipsrv_gis/views/owld_wqp_huc12_esri.sql new file mode 100644 index 0000000..ea431a9 --- /dev/null +++ b/src/database/cipsrv_gis/views/owld_wqp_huc12_esri.sql @@ -0,0 +1,23 @@ +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_huc12_esri +AS +SELECT + a.objectid +,a.source_originator +,a.source_featureid +,a.source_featureid2 +,a.source_series +,a.source_subdivision +,a.source_joinkey +,a.permid_joinkey +,a.start_date +,a.end_date +,a.xwalk_huc12 +,a.xwalk_catresolution +,a.xwalk_huc12_version +,a.xwalk_huc12_areasqkm +,a.globalid +FROM +cipsrv_owld.wqp_huc12 a; + +ALTER TABLE cipsrv_gis.owld_wqp_huc12_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_huc12_esri TO public; diff --git a/src/database/cipsrv_gis/views/owld_wqp_huc12_geo.sql b/src/database/cipsrv_gis/views/owld_wqp_huc12_geo.sql new file mode 100644 index 0000000..3239b1f --- /dev/null +++ b/src/database/cipsrv_gis/views/owld_wqp_huc12_geo.sql @@ -0,0 +1,15 @@ +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_huc12_geo +AS +SELECT + a.objectid +,a.xwalk_huc12 +,a.xwalk_catresolution +,a.xwalk_huc12_version +,a.xwalk_huc12_areasqkm +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_owld.wqp_huc12_geo a; + +ALTER TABLE cipsrv_gis.owld_wqp_huc12_geo OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_huc12_geo TO public; diff --git a/src/database/cipsrv_gis/views/owld_wqp_huc12_geo_esri.sql b/src/database/cipsrv_gis/views/owld_wqp_huc12_geo_esri.sql new file mode 100644 index 0000000..cd386bc --- /dev/null +++ b/src/database/cipsrv_gis/views/owld_wqp_huc12_geo_esri.sql @@ -0,0 +1,15 @@ +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_huc12_geo_esri +AS +SELECT + a.objectid +,a.xwalk_huc12 +,a.xwalk_catresolution +,a.xwalk_huc12_version +,a.xwalk_huc12_areasqkm +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_owld.wqp_huc12_geo a; + +ALTER TABLE cipsrv_gis.owld_wqp_huc12_geo_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_huc12_geo_esri TO public; diff --git a/src/database/cipsrv_gis/views/owld_wqp_rad_a.sql b/src/database/cipsrv_gis/views/owld_wqp_rad_a.sql new file mode 100644 index 0000000..0a3c3d3 --- /dev/null +++ b/src/database/cipsrv_gis/views/owld_wqp_rad_a.sql @@ -0,0 +1,35 @@ +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_rad_a +AS +SELECT + a.objectid +,a.permanent_identifier +,a.eventdate +,a.reachcode +,a.reachsmdate +,a.reachresolution +,a.feature_permanent_identifier +,a.featureclassref +,a.source_originator +,a.source_featureid +,a.source_featureid2 +,a.source_datadesc +,a.source_series +,a.source_subdivision +,a.source_joinkey +,a.permid_joinkey +,a.start_date +,a.end_date +,a.featuredetailurl +,a.eventtype +,a.event_areasqkm +,a.geogstate +,a.xwalk_huc12 +,a.xwalk_method +,a.xwalk_huc12_version +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_owld.wqp_rad_a a; + +ALTER TABLE cipsrv_gis.owld_wqp_rad_a OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_rad_a TO public; diff --git a/src/database/cipsrv_gis/views/owld_wqp_rad_a_esri.sql b/src/database/cipsrv_gis/views/owld_wqp_rad_a_esri.sql new file mode 100644 index 0000000..ee70461 --- /dev/null +++ b/src/database/cipsrv_gis/views/owld_wqp_rad_a_esri.sql @@ -0,0 +1,35 @@ +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_rad_a_esri +AS +SELECT + a.objectid +,a.permanent_identifier +,a.eventdate +,a.reachcode +,a.reachsmdate +,a.reachresolution +,a.feature_permanent_identifier +,a.featureclassref +,a.source_originator +,a.source_featureid +,a.source_featureid2 +,a.source_datadesc +,a.source_series +,a.source_subdivision +,a.source_joinkey +,a.permid_joinkey +,a.start_date +,a.end_date +,a.featuredetailurl +,a.eventtype +,a.event_areasqkm +,a.geogstate +,a.xwalk_huc12 +,a.xwalk_method +,a.xwalk_huc12_version +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_owld.wqp_rad_a a; + +ALTER TABLE cipsrv_gis.owld_wqp_rad_a_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_rad_a_esri TO public; diff --git a/src/database/cipsrv_gis/views/owld_wqp_rad_evt2meta.sql b/src/database/cipsrv_gis/views/owld_wqp_rad_evt2meta.sql new file mode 100644 index 0000000..293c468 --- /dev/null +++ b/src/database/cipsrv_gis/views/owld_wqp_rad_evt2meta.sql @@ -0,0 +1,12 @@ +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_rad_evt2meta +AS +SELECT + a.objectid +,a.permanent_identifier +,a.meta_processid +,a.globalid +FROM +cipsrv_owld.wqp_rad_evt2meta a; + +ALTER TABLE cipsrv_gis.owld_wqp_rad_evt2meta OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_rad_evt2meta TO public; diff --git a/src/database/cipsrv_gis/views/owld_wqp_rad_evt2meta_esri.sql b/src/database/cipsrv_gis/views/owld_wqp_rad_evt2meta_esri.sql new file mode 100644 index 0000000..ca112e9 --- /dev/null +++ b/src/database/cipsrv_gis/views/owld_wqp_rad_evt2meta_esri.sql @@ -0,0 +1,12 @@ +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_rad_evt2meta_esri +AS +SELECT + a.objectid +,a.permanent_identifier +,a.meta_processid +,a.globalid +FROM +cipsrv_owld.wqp_rad_evt2meta a; + +ALTER TABLE cipsrv_gis.owld_wqp_rad_evt2meta_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_rad_evt2meta_esri TO public; diff --git a/src/database/cipsrv_gis/views/owld_wqp_rad_l.sql b/src/database/cipsrv_gis/views/owld_wqp_rad_l.sql new file mode 100644 index 0000000..d5b85a7 --- /dev/null +++ b/src/database/cipsrv_gis/views/owld_wqp_rad_l.sql @@ -0,0 +1,46 @@ +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_rad_l +AS +SELECT + a.objectid +,a.permanent_identifier +,a.eventdate +,a.reachcode +,a.reachsmdate +,a.reachresolution +,a.feature_permanent_identifier +,a.featureclassref +,a.source_originator +,a.source_featureid +,a.source_featureid2 +,a.source_datadesc +,a.source_series +,a.source_subdivision +,a.source_joinkey +,a.permid_joinkey +,a.start_date +,a.end_date +,a.featuredetailurl +,a.fmeasure +,a.tmeasure +,a.eventtype +,a.eventoffset +,a.event_lengthkm +,a.geogstate +,a.xwalk_huc12 +,a.xwalk_method +,a.xwalk_huc12_version +,a.isnavigable +,a.hasvaa +,a.issink +,a.isheadwater +,a.iscoastal +,a.isocean +,a.isalaskan +,a.h3hexagonaddr +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_owld.wqp_rad_l a; + +ALTER TABLE cipsrv_gis.owld_wqp_rad_l OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_rad_l TO public; diff --git a/src/database/cipsrv_gis/views/owld_wqp_rad_l_esri.sql b/src/database/cipsrv_gis/views/owld_wqp_rad_l_esri.sql new file mode 100644 index 0000000..d6777a7 --- /dev/null +++ b/src/database/cipsrv_gis/views/owld_wqp_rad_l_esri.sql @@ -0,0 +1,46 @@ +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_rad_l_esri +AS +SELECT + a.objectid +,a.permanent_identifier +,a.eventdate +,a.reachcode +,a.reachsmdate +,a.reachresolution +,a.feature_permanent_identifier +,a.featureclassref +,a.source_originator +,a.source_featureid +,a.source_featureid2 +,a.source_datadesc +,a.source_series +,a.source_subdivision +,a.source_joinkey +,a.permid_joinkey +,a.start_date +,a.end_date +,a.featuredetailurl +,a.fmeasure +,a.tmeasure +,a.eventtype +,a.eventoffset +,a.event_lengthkm +,a.geogstate +,a.xwalk_huc12 +,a.xwalk_method +,a.xwalk_huc12_version +,a.isnavigable +,a.hasvaa +,a.issink +,a.isheadwater +,a.iscoastal +,a.isocean +,a.isalaskan +,a.h3hexagonaddr +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_owld.wqp_rad_l a; + +ALTER TABLE cipsrv_gis.owld_wqp_rad_l_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_rad_l_esri TO public; diff --git a/src/database/cipsrv_gis/views/owld_wqp_rad_metadata.sql b/src/database/cipsrv_gis/views/owld_wqp_rad_metadata.sql new file mode 100644 index 0000000..9555645 --- /dev/null +++ b/src/database/cipsrv_gis/views/owld_wqp_rad_metadata.sql @@ -0,0 +1,31 @@ +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_rad_metadata +AS +SELECT + a.objectid +,a.meta_processid +,a.processdescription +,a.processdate +,a.attributeaccuracyreport +,a.logicalconsistencyreport +,a.completenessreport +,a.horizpositionalaccuracyreport +,a.vertpositionalaccuracyreport +,a.metadatastandardname +,a.metadatastandardversion +,a.metadatadate +,a.datasetcredit +,a.contactorganization +,a.addresstype +,a.address +,a.city +,a.stateorprovince +,a.postalcode +,a.contactvoicetelephone +,a.contactinstructions +,a.contactemailaddress +,a.globalid +FROM +cipsrv_owld.wqp_rad_metadata a; + +ALTER TABLE cipsrv_gis.owld_wqp_rad_metadata OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_rad_metadata TO public; diff --git a/src/database/cipsrv_gis/views/owld_wqp_rad_metadata_esri.sql b/src/database/cipsrv_gis/views/owld_wqp_rad_metadata_esri.sql new file mode 100644 index 0000000..8d588e2 --- /dev/null +++ b/src/database/cipsrv_gis/views/owld_wqp_rad_metadata_esri.sql @@ -0,0 +1,31 @@ +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_rad_metadata_esri +AS +SELECT + a.objectid +,a.meta_processid +,a.processdescription +,a.processdate +,a.attributeaccuracyreport +,a.logicalconsistencyreport +,a.completenessreport +,a.horizpositionalaccuracyreport +,a.vertpositionalaccuracyreport +,a.metadatastandardname +,a.metadatastandardversion +,a.metadatadate +,a.datasetcredit +,a.contactorganization +,a.addresstype +,a.address +,a.city +,a.stateorprovince +,a.postalcode +,a.contactvoicetelephone +,a.contactinstructions +,a.contactemailaddress +,a.globalid +FROM +cipsrv_owld.wqp_rad_metadata a; + +ALTER TABLE cipsrv_gis.owld_wqp_rad_metadata_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_rad_metadata_esri TO public; diff --git a/src/database/cipsrv_gis/views/owld_wqp_rad_p.sql b/src/database/cipsrv_gis/views/owld_wqp_rad_p.sql new file mode 100644 index 0000000..f41afaf --- /dev/null +++ b/src/database/cipsrv_gis/views/owld_wqp_rad_p.sql @@ -0,0 +1,44 @@ +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_rad_p +AS +SELECT + a.objectid +,a.permanent_identifier +,a.eventdate +,a.reachcode +,a.reachsmdate +,a.reachresolution +,a.feature_permanent_identifier +,a.featureclassref +,a.source_originator +,a.source_featureid +,a.source_featureid2 +,a.source_datadesc +,a.source_series +,a.source_subdivision +,a.source_joinkey +,a.permid_joinkey +,a.start_date +,a.end_date +,a.featuredetailurl +,a.measure +,a.eventtype +,a.eventoffset +,a.geogstate +,a.xwalk_huc12 +,a.xwalk_method +,a.xwalk_huc12_version +,a.isnavigable +,a.hasvaa +,a.issink +,a.isheadwater +,a.iscoastal +,a.isocean +,a.isalaskan +,a.h3hexagonaddr +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_owld.wqp_rad_p a; + +ALTER TABLE cipsrv_gis.owld_wqp_rad_p OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_rad_p TO public; diff --git a/src/database/cipsrv_gis/views/owld_wqp_rad_p_esri.sql b/src/database/cipsrv_gis/views/owld_wqp_rad_p_esri.sql new file mode 100644 index 0000000..76d7287 --- /dev/null +++ b/src/database/cipsrv_gis/views/owld_wqp_rad_p_esri.sql @@ -0,0 +1,44 @@ +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_rad_p_esri +AS +SELECT + a.objectid +,a.permanent_identifier +,a.eventdate +,a.reachcode +,a.reachsmdate +,a.reachresolution +,a.feature_permanent_identifier +,a.featureclassref +,a.source_originator +,a.source_featureid +,a.source_featureid2 +,a.source_datadesc +,a.source_series +,a.source_subdivision +,a.source_joinkey +,a.permid_joinkey +,a.start_date +,a.end_date +,a.featuredetailurl +,a.measure +,a.eventtype +,a.eventoffset +,a.geogstate +,a.xwalk_huc12 +,a.xwalk_method +,a.xwalk_huc12_version +,a.isnavigable +,a.hasvaa +,a.issink +,a.isheadwater +,a.iscoastal +,a.isocean +,a.isalaskan +,a.h3hexagonaddr +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_owld.wqp_rad_p a; + +ALTER TABLE cipsrv_gis.owld_wqp_rad_p_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_rad_p_esri TO public; diff --git a/src/database/cipsrv_gis/views/owld_wqp_rad_srccit.sql b/src/database/cipsrv_gis/views/owld_wqp_rad_srccit.sql new file mode 100644 index 0000000..e8e96e2 --- /dev/null +++ b/src/database/cipsrv_gis/views/owld_wqp_rad_srccit.sql @@ -0,0 +1,23 @@ +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_rad_srccit +AS +SELECT + a.objectid +,a.title +,a.source_datasetid +,a.sourcecitationabbreviation +,a.originator +,a.publicationdate +,a.beginningdate +,a.endingdate +,a.sourcecontribution +,a.sourcescaledenominator +,a.typeofsourcemedia +,a.calendardate +,a.sourcecurrentnessreference +,a.meta_processid +,a.globalid +FROM +cipsrv_owld.wqp_rad_srccit a; + +ALTER TABLE cipsrv_gis.owld_wqp_rad_srccit OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_rad_srccit TO public; diff --git a/src/database/cipsrv_gis/views/owld_wqp_rad_srccit_esri.sql b/src/database/cipsrv_gis/views/owld_wqp_rad_srccit_esri.sql new file mode 100644 index 0000000..5754c45 --- /dev/null +++ b/src/database/cipsrv_gis/views/owld_wqp_rad_srccit_esri.sql @@ -0,0 +1,23 @@ +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_rad_srccit_esri +AS +SELECT + a.objectid +,a.title +,a.source_datasetid +,a.sourcecitationabbreviation +,a.originator +,a.publicationdate +,a.beginningdate +,a.endingdate +,a.sourcecontribution +,a.sourcescaledenominator +,a.typeofsourcemedia +,a.calendardate +,a.sourcecurrentnessreference +,a.meta_processid +,a.globalid +FROM +cipsrv_owld.wqp_rad_srccit a; + +ALTER TABLE cipsrv_gis.owld_wqp_rad_srccit_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_rad_srccit_esri TO public; diff --git a/src/database/cipsrv_gis/views/owld_wqp_sfid.sql b/src/database/cipsrv_gis/views/owld_wqp_sfid.sql new file mode 100644 index 0000000..f672714 --- /dev/null +++ b/src/database/cipsrv_gis/views/owld_wqp_sfid.sql @@ -0,0 +1,36 @@ +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_sfid +AS +SELECT + a.objectid +,a.source_originator +,a.source_featureid +,a.source_featureid2 +,a.source_series +,a.source_subdivision +,a.source_joinkey +,a.start_date +,a.end_date +,a.sfiddetailurl +,a.load_id +,a.load_date +,a.src_event_count +,a.src_point_count +,a.src_line_count +,a.src_area_count +,a.cat_mr_count +,a.cat_hr_count +,a.xwalk_huc12_mr_count +,a.rad_mr_event_count +,a.rad_hr_event_count +,a.rad_mr_point_count +,a.rad_hr_point_count +,a.rad_mr_line_count +,a.rad_hr_line_count +,a.rad_mr_area_count +,a.rad_hr_area_count +,a.globalid +FROM +cipsrv_owld.wqp_sfid a; + +ALTER TABLE cipsrv_gis.owld_wqp_sfid OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_sfid TO public; diff --git a/src/database/cipsrv_gis/views/owld_wqp_sfid_esri.sql b/src/database/cipsrv_gis/views/owld_wqp_sfid_esri.sql new file mode 100644 index 0000000..9c8248e --- /dev/null +++ b/src/database/cipsrv_gis/views/owld_wqp_sfid_esri.sql @@ -0,0 +1,36 @@ +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_sfid_esri +AS +SELECT + a.objectid +,a.source_originator +,a.source_featureid +,a.source_featureid2 +,a.source_series +,a.source_subdivision +,a.source_joinkey +,a.start_date +,a.end_date +,a.sfiddetailurl +,a.load_id +,a.load_date +,a.src_event_count +,a.src_point_count +,a.src_line_count +,a.src_area_count +,a.cat_mr_count +,a.cat_hr_count +,a.xwalk_huc12_mr_count +,a.rad_mr_event_count +,a.rad_hr_event_count +,a.rad_mr_point_count +,a.rad_hr_point_count +,a.rad_mr_line_count +,a.rad_hr_line_count +,a.rad_mr_area_count +,a.rad_hr_area_count +,a.globalid +FROM +cipsrv_owld.wqp_sfid a; + +ALTER TABLE cipsrv_gis.owld_wqp_sfid_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_sfid_esri TO public; diff --git a/src/database/cipsrv_gis/views/owld_wqp_src2cip.sql b/src/database/cipsrv_gis/views/owld_wqp_src2cip.sql new file mode 100644 index 0000000..9e2201f --- /dev/null +++ b/src/database/cipsrv_gis/views/owld_wqp_src2cip.sql @@ -0,0 +1,24 @@ +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_src2cip +AS +SELECT + a.objectid +,a.src2cip_joinkey +,a.cip_joinkey +,a.source_joinkey +,a.permid_joinkey +,a.cat_joinkey +,a.catchmentstatecode +,a.nhdplusid +,a.catchmentresolution +,a.cip_action +,a.overlap_measure +,a.cip_method +,a.cip_parms +,a.cip_date +,a.cip_version +,a.globalid +FROM +cipsrv_owld.wqp_src2cip a; + +ALTER TABLE cipsrv_gis.owld_wqp_src2cip OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_src2cip TO public; diff --git a/src/database/cipsrv_gis/views/owld_wqp_src2cip_esri.sql b/src/database/cipsrv_gis/views/owld_wqp_src2cip_esri.sql new file mode 100644 index 0000000..0553822 --- /dev/null +++ b/src/database/cipsrv_gis/views/owld_wqp_src2cip_esri.sql @@ -0,0 +1,24 @@ +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_src2cip_esri +AS +SELECT + a.objectid +,a.src2cip_joinkey +,a.cip_joinkey +,a.source_joinkey +,a.permid_joinkey +,a.cat_joinkey +,a.catchmentstatecode +,CAST(a.nhdplusid AS NUMERIC) AS nhdplusid +,a.catchmentresolution +,a.cip_action +,a.overlap_measure +,a.cip_method +,a.cip_parms +,a.cip_date +,a.cip_version +,a.globalid +FROM +cipsrv_owld.wqp_src2cip a; + +ALTER TABLE cipsrv_gis.owld_wqp_src2cip_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_src2cip_esri TO public; diff --git a/src/database/cipsrv_gis/views/owld_wqp_src_a.sql b/src/database/cipsrv_gis/views/owld_wqp_src_a.sql new file mode 100644 index 0000000..a339a7e --- /dev/null +++ b/src/database/cipsrv_gis/views/owld_wqp_src_a.sql @@ -0,0 +1,22 @@ +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_src_a +AS +SELECT + a.objectid +,a.permid_joinkey +,a.source_originator +,a.source_featureid +,a.source_featureid2 +,a.source_series +,a.source_subdivision +,a.source_joinkey +,a.start_date +,a.end_date +,a.featuredetailurl +,a.areasqkm +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_owld.wqp_src_a a; + +ALTER TABLE cipsrv_gis.owld_wqp_src_a OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_src_a TO public; diff --git a/src/database/cipsrv_gis/views/owld_wqp_src_a_esri.sql b/src/database/cipsrv_gis/views/owld_wqp_src_a_esri.sql new file mode 100644 index 0000000..f67688f --- /dev/null +++ b/src/database/cipsrv_gis/views/owld_wqp_src_a_esri.sql @@ -0,0 +1,22 @@ +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_src_a_esri +AS +SELECT + a.objectid +,a.permid_joinkey +,a.source_originator +,a.source_featureid +,a.source_featureid2 +,a.source_series +,a.source_subdivision +,a.source_joinkey +,a.start_date +,a.end_date +,a.featuredetailurl +,a.areasqkm +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_owld.wqp_src_a a; + +ALTER TABLE cipsrv_gis.owld_wqp_src_a_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_src_a_esri TO public; diff --git a/src/database/cipsrv_gis/views/owld_wqp_src_l.sql b/src/database/cipsrv_gis/views/owld_wqp_src_l.sql new file mode 100644 index 0000000..b0be5ab --- /dev/null +++ b/src/database/cipsrv_gis/views/owld_wqp_src_l.sql @@ -0,0 +1,22 @@ +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_src_l +AS +SELECT + a.objectid +,a.permid_joinkey +,a.source_originator +,a.source_featureid +,a.source_featureid2 +,a.source_series +,a.source_subdivision +,a.source_joinkey +,a.start_date +,a.end_date +,a.featuredetailurl +,a.lengthkm +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_owld.wqp_src_l a; + +ALTER TABLE cipsrv_gis.owld_wqp_src_l OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_src_l TO public; diff --git a/src/database/cipsrv_gis/views/owld_wqp_src_l_esri.sql b/src/database/cipsrv_gis/views/owld_wqp_src_l_esri.sql new file mode 100644 index 0000000..c5a350e --- /dev/null +++ b/src/database/cipsrv_gis/views/owld_wqp_src_l_esri.sql @@ -0,0 +1,22 @@ +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_src_l_esri +AS +SELECT + a.objectid +,a.permid_joinkey +,a.source_originator +,a.source_featureid +,a.source_featureid2 +,a.source_series +,a.source_subdivision +,a.source_joinkey +,a.start_date +,a.end_date +,a.featuredetailurl +,a.lengthkm +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_owld.wqp_src_l a; + +ALTER TABLE cipsrv_gis.owld_wqp_src_l_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_src_l_esri TO public; diff --git a/src/database/cipsrv_gis/views/owld_wqp_src_p.sql b/src/database/cipsrv_gis/views/owld_wqp_src_p.sql new file mode 100644 index 0000000..602b601 --- /dev/null +++ b/src/database/cipsrv_gis/views/owld_wqp_src_p.sql @@ -0,0 +1,21 @@ +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_src_p +AS +SELECT + a.objectid +,a.permid_joinkey +,a.source_originator +,a.source_featureid +,a.source_featureid2 +,a.source_series +,a.source_subdivision +,a.source_joinkey +,a.start_date +,a.end_date +,a.featuredetailurl +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_owld.wqp_src_p a; + +ALTER TABLE cipsrv_gis.owld_wqp_src_p OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_src_p TO public; diff --git a/src/database/cipsrv_gis/views/owld_wqp_src_p_esri.sql b/src/database/cipsrv_gis/views/owld_wqp_src_p_esri.sql new file mode 100644 index 0000000..ba68913 --- /dev/null +++ b/src/database/cipsrv_gis/views/owld_wqp_src_p_esri.sql @@ -0,0 +1,21 @@ +CREATE OR REPLACE VIEW cipsrv_gis.owld_wqp_src_p_esri +AS +SELECT + a.objectid +,a.permid_joinkey +,a.source_originator +,a.source_featureid +,a.source_featureid2 +,a.source_series +,a.source_subdivision +,a.source_joinkey +,a.start_date +,a.end_date +,a.featuredetailurl +,a.globalid +,ST_Transform(a.shape,3857) AS shape +FROM +cipsrv_owld.wqp_src_p a; + +ALTER TABLE cipsrv_gis.owld_wqp_src_p_esri OWNER TO cipsrv_gis; +GRANT SELECT ON cipsrv_gis.owld_wqp_src_p_esri TO public; diff --git a/src/database/cipsrv_owld/cipsrv_owld_deploy.sql b/src/database/cipsrv_owld/cipsrv_owld_deploy.sql new file mode 100644 index 0000000..a1bb8d4 --- /dev/null +++ b/src/database/cipsrv_owld/cipsrv_owld_deploy.sql @@ -0,0 +1,208 @@ +--******************************-- +----- functions/upstreamdownstream.sql + +DO $$DECLARE + a VARCHAR;b VARCHAR; +BEGIN + SELECT p.oid::regproc,pg_get_function_identity_arguments(p.oid) + INTO a,b FROM pg_catalog.pg_proc p LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace + WHERE p.oid::regproc::text = 'cipsrv_owld.upstreamdownstream'; + IF b IS NOT NULL THEN + EXECUTE FORMAT('DROP FUNCTION IF EXISTS %s(%s)',a,b);ELSE + IF a IS NOT NULL THEN EXECUTE FORMAT('DROP FUNCTION IF EXISTS %s',a);END IF;END IF; +END$$; + +CREATE OR REPLACE FUNCTION cipsrv_owld.upstreamdownstream( + IN p_nhdplus_version VARCHAR + ,IN p_search_type VARCHAR + + ,IN p_start_nhdplusid BIGINT + ,IN p_start_permanent_identifier VARCHAR + ,IN p_start_reachcode VARCHAR + ,IN p_start_hydroseq BIGINT + ,IN p_start_measure NUMERIC + ,IN p_start_source_featureid VARCHAR + ,IN p_start_source_featureid2 VARCHAR + ,IN p_start_source_originator VARCHAR + ,IN p_start_source_series VARCHAR + ,IN p_start_start_date DATE + ,IN p_start_end_date DATE + ,IN p_start_permid_joinkey VARCHAR + ,IN p_start_source_joinkey VARCHAR + ,IN p_start_cat_joinkey VARCHAR + ,IN p_start_linked_data_program VARCHAR + ,IN p_start_search_precision VARCHAR + ,IN p_start_search_logic VARCHAR + + ,IN p_stop_nhdplusid BIGINT + ,IN p_stop_permanent_identifier VARCHAR + ,IN p_stop_reachcode VARCHAR + ,IN p_stop_hydroseq BIGINT + ,IN p_stop_measure NUMERIC + ,IN p_stop_source_featureid VARCHAR + ,IN p_stop_source_featureid2 VARCHAR + ,IN p_stop_source_originator VARCHAR + ,IN p_stop_source_series VARCHAR + ,IN p_stop_start_date DATE + ,IN p_stop_end_date DATE + ,IN p_stop_permid_joinkey VARCHAR + ,IN p_stop_source_joinkey VARCHAR + ,IN p_stop_cat_joinkey VARCHAR + ,IN p_stop_linked_data_program VARCHAR + ,IN p_stop_search_precision VARCHAR + ,IN p_stop_search_logic VARCHAR + + ,IN p_max_distancekm NUMERIC + ,IN p_max_flowtimeday NUMERIC + ,IN p_linked_data_search_list VARCHAR[] + + ,IN p_return_flowlines BOOLEAN + ,IN p_return_flowline_details BOOLEAN + ,IN p_return_flowline_geometry BOOLEAN + ,IN p_return_catchments BOOLEAN + ,IN p_return_linked_data_cip BOOLEAN + ,IN p_return_linked_data_huc12 BOOLEAN + ,IN p_return_linked_data_source BOOLEAN + ,IN p_return_linked_data_rad BOOLEAN + ,IN p_return_linked_data_attributes BOOLEAN + ,IN p_remove_stop_start_sfids BOOLEAN + ,IN p_push_source_geometry_as_rad BOOLEAN + + ,IN p_known_region VARCHAR DEFAULT NULL + + ,OUT out_start_nhdplusid BIGINT + ,OUT out_start_permanent_identifier VARCHAR + ,OUT out_start_measure NUMERIC + ,OUT out_grid_srid INTEGER + ,OUT out_stop_nhdplusid BIGINT + ,OUT out_stop_measure NUMERIC + ,OUT out_flowline_count INTEGER + ,OUT out_return_flowlines BOOLEAN + ,OUT out_return_code NUMERIC + ,OUT out_status_message VARCHAR +) +VOLATILE +AS $BODY$ +DECLARE + +BEGIN + + out_return_code := cipsrv_engine.create_navigation_temp_tables(); + + ---------------------------------------------------------------------------- + -- Step 10 + -- Check over incoming parameters + ---------------------------------------------------------------------------- + out_return_code := 0; + +END; +$BODY$ +LANGUAGE plpgsql; + +ALTER FUNCTION cipsrv_owld.upstreamdownstream( + VARCHAR + ,VARCHAR + ,BIGINT + ,VARCHAR + ,VARCHAR + ,BIGINT + ,NUMERIC + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,DATE + ,DATE + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,BIGINT + ,VARCHAR + ,VARCHAR + ,BIGINT + ,NUMERIC + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,DATE + ,DATE + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,NUMERIC + ,NUMERIC + ,VARCHAR[] + ,BOOLEAN + ,BOOLEAN + ,BOOLEAN + ,BOOLEAN + ,BOOLEAN + ,BOOLEAN + ,BOOLEAN + ,BOOLEAN + ,BOOLEAN + ,BOOLEAN + ,BOOLEAN + ,VARCHAR +) OWNER TO cipsrv; + +GRANT EXECUTE ON FUNCTION cipsrv_owld.upstreamdownstream( + VARCHAR + ,VARCHAR + ,BIGINT + ,VARCHAR + ,VARCHAR + ,BIGINT + ,NUMERIC + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,DATE + ,DATE + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,BIGINT + ,VARCHAR + ,VARCHAR + ,BIGINT + ,NUMERIC + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,DATE + ,DATE + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,NUMERIC + ,NUMERIC + ,VARCHAR[] + ,BOOLEAN + ,BOOLEAN + ,BOOLEAN + ,BOOLEAN + ,BOOLEAN + ,BOOLEAN + ,BOOLEAN + ,BOOLEAN + ,BOOLEAN + ,BOOLEAN + ,BOOLEAN + ,VARCHAR +) TO PUBLIC; diff --git a/src/database/cipsrv_owld/functions/upstreamdownstream.sql b/src/database/cipsrv_owld/functions/upstreamdownstream.sql new file mode 100644 index 0000000..ff4e373 --- /dev/null +++ b/src/database/cipsrv_owld/functions/upstreamdownstream.sql @@ -0,0 +1,205 @@ +DO $$DECLARE + a VARCHAR;b VARCHAR; +BEGIN + SELECT p.oid::regproc,pg_get_function_identity_arguments(p.oid) + INTO a,b FROM pg_catalog.pg_proc p LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace + WHERE p.oid::regproc::text = 'cipsrv_owld.upstreamdownstream'; + IF b IS NOT NULL THEN + EXECUTE FORMAT('DROP FUNCTION IF EXISTS %s(%s)',a,b);ELSE + IF a IS NOT NULL THEN EXECUTE FORMAT('DROP FUNCTION IF EXISTS %s',a);END IF;END IF; +END$$; + +CREATE OR REPLACE FUNCTION cipsrv_owld.upstreamdownstream( + IN p_nhdplus_version VARCHAR + ,IN p_search_type VARCHAR + + ,IN p_start_nhdplusid BIGINT + ,IN p_start_permanent_identifier VARCHAR + ,IN p_start_reachcode VARCHAR + ,IN p_start_hydroseq BIGINT + ,IN p_start_measure NUMERIC + ,IN p_start_source_featureid VARCHAR + ,IN p_start_source_featureid2 VARCHAR + ,IN p_start_source_originator VARCHAR + ,IN p_start_source_series VARCHAR + ,IN p_start_start_date DATE + ,IN p_start_end_date DATE + ,IN p_start_permid_joinkey VARCHAR + ,IN p_start_source_joinkey VARCHAR + ,IN p_start_cat_joinkey VARCHAR + ,IN p_start_linked_data_program VARCHAR + ,IN p_start_search_precision VARCHAR + ,IN p_start_search_logic VARCHAR + + ,IN p_stop_nhdplusid BIGINT + ,IN p_stop_permanent_identifier VARCHAR + ,IN p_stop_reachcode VARCHAR + ,IN p_stop_hydroseq BIGINT + ,IN p_stop_measure NUMERIC + ,IN p_stop_source_featureid VARCHAR + ,IN p_stop_source_featureid2 VARCHAR + ,IN p_stop_source_originator VARCHAR + ,IN p_stop_source_series VARCHAR + ,IN p_stop_start_date DATE + ,IN p_stop_end_date DATE + ,IN p_stop_permid_joinkey VARCHAR + ,IN p_stop_source_joinkey VARCHAR + ,IN p_stop_cat_joinkey VARCHAR + ,IN p_stop_linked_data_program VARCHAR + ,IN p_stop_search_precision VARCHAR + ,IN p_stop_search_logic VARCHAR + + ,IN p_max_distancekm NUMERIC + ,IN p_max_flowtimeday NUMERIC + ,IN p_linked_data_search_list VARCHAR[] + + ,IN p_return_flowlines BOOLEAN + ,IN p_return_flowline_details BOOLEAN + ,IN p_return_flowline_geometry BOOLEAN + ,IN p_return_catchments BOOLEAN + ,IN p_return_linked_data_cip BOOLEAN + ,IN p_return_linked_data_huc12 BOOLEAN + ,IN p_return_linked_data_source BOOLEAN + ,IN p_return_linked_data_rad BOOLEAN + ,IN p_return_linked_data_attributes BOOLEAN + ,IN p_remove_stop_start_sfids BOOLEAN + ,IN p_push_source_geometry_as_rad BOOLEAN + + ,IN p_known_region VARCHAR DEFAULT NULL + + ,OUT out_start_nhdplusid BIGINT + ,OUT out_start_permanent_identifier VARCHAR + ,OUT out_start_measure NUMERIC + ,OUT out_grid_srid INTEGER + ,OUT out_stop_nhdplusid BIGINT + ,OUT out_stop_measure NUMERIC + ,OUT out_flowline_count INTEGER + ,OUT out_return_flowlines BOOLEAN + ,OUT out_return_code NUMERIC + ,OUT out_status_message VARCHAR +) +VOLATILE +AS $BODY$ +DECLARE + +BEGIN + + out_return_code := cipsrv_engine.create_navigation_temp_tables(); + + ---------------------------------------------------------------------------- + -- Step 10 + -- Check over incoming parameters + ---------------------------------------------------------------------------- + out_return_code := 0; + +END; +$BODY$ +LANGUAGE plpgsql; + +ALTER FUNCTION cipsrv_owld.upstreamdownstream( + VARCHAR + ,VARCHAR + ,BIGINT + ,VARCHAR + ,VARCHAR + ,BIGINT + ,NUMERIC + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,DATE + ,DATE + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,BIGINT + ,VARCHAR + ,VARCHAR + ,BIGINT + ,NUMERIC + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,DATE + ,DATE + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,NUMERIC + ,NUMERIC + ,VARCHAR[] + ,BOOLEAN + ,BOOLEAN + ,BOOLEAN + ,BOOLEAN + ,BOOLEAN + ,BOOLEAN + ,BOOLEAN + ,BOOLEAN + ,BOOLEAN + ,BOOLEAN + ,BOOLEAN + ,VARCHAR +) OWNER TO cipsrv; + +GRANT EXECUTE ON FUNCTION cipsrv_owld.upstreamdownstream( + VARCHAR + ,VARCHAR + ,BIGINT + ,VARCHAR + ,VARCHAR + ,BIGINT + ,NUMERIC + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,DATE + ,DATE + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,BIGINT + ,VARCHAR + ,VARCHAR + ,BIGINT + ,NUMERIC + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,DATE + ,DATE + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,VARCHAR + ,NUMERIC + ,NUMERIC + ,VARCHAR[] + ,BOOLEAN + ,BOOLEAN + ,BOOLEAN + ,BOOLEAN + ,BOOLEAN + ,BOOLEAN + ,BOOLEAN + ,BOOLEAN + ,BOOLEAN + ,BOOLEAN + ,BOOLEAN + ,VARCHAR +) TO PUBLIC; diff --git a/src/database/cipsrv_owld/manifest.json b/src/database/cipsrv_owld/manifest.json new file mode 100644 index 0000000..8b31dd3 --- /dev/null +++ b/src/database/cipsrv_owld/manifest.json @@ -0,0 +1,61 @@ +{ + "constants": [ + { + "key": "GITRELEASE" + ,"cmd": "git describe --tags" + } + ,{ + "key": "GITCOMMIT" + ,"cmd": "git rev-parse HEAD" + } + ,{ + "key": "GITCOMMITDATE" + ,"cmd": "git show -s --format=%cd" + } + ,{ + "key": "GITCOMMITAUTH" + ,"cmd": "git show -s --format=%an" + } + ] + ,"tasks": [ + { + "id": "concatenate" + ,"output": "cipsrv_owld_deploy.sql" + ,"includes": [ + "functions/upstreamdownstream.sql" + ] + ,"separator": "--******************************--\n----- %%FILENAME%% \n\n" + ,"configurations": [ + { + "id": 1 + ,"file": "*/*.sql" + ,"replacements": [ + { + "string": "c_gitrelease CONSTANT VARCHAR(255) := 'NULL';" + ,"value": "c_gitrelease CONSTANT VARCHAR(255) := '%GITRELEASE%';" + } + ,{ + "string": "c_gitcommit CONSTANT VARCHAR(255) := 'NULL';" + ,"value": "c_gitcommit CONSTANT VARCHAR(255) := '%GITCOMMIT%';" + } + ,{ + "string": "c_gitcommitdate CONSTANT VARCHAR(255) := 'NULL';" + ,"value": "c_gitcommitdate CONSTANT VARCHAR(255) := '%GITCOMMITDATE%';" + } + ,{ + "string": "c_gitcommitauth CONSTANT VARCHAR(255) := 'NULL';" + ,"value": "c_gitcommitauth CONSTANT VARCHAR(255) := '%GITCOMMITAUTH%';" + } + ] + } + ] + } + ,{ + "id": "artifacts" + ,"targets": [ + "cipsrv_owld_deploy.sql" + ] + } + ] +} + diff --git a/src/database/cipsrv_pgrest/cipsrv_pgrest_deploy.sql b/src/database/cipsrv_pgrest/cipsrv_pgrest_deploy.sql index 2eaec15..71e7d8d 100644 --- a/src/database/cipsrv_pgrest/cipsrv_pgrest_deploy.sql +++ b/src/database/cipsrv_pgrest/cipsrv_pgrest_deploy.sql @@ -2095,6 +2095,454 @@ GRANT EXECUTE ON FUNCTION cipsrv_pgrest.pointindexing( JSONB ) TO PUBLIC; +--******************************-- +----- functions/upstreamdownstream.sql + +DO $$DECLARE + a VARCHAR;b VARCHAR; +BEGIN + SELECT p.oid::regproc,pg_get_function_identity_arguments(p.oid) + INTO a,b FROM pg_catalog.pg_proc p LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace + WHERE p.oid::regproc::text = 'cipsrv_pgrest.upstreamdownstream'; + IF b IS NOT NULL THEN + EXECUTE FORMAT('DROP FUNCTION IF EXISTS %s(%s)',a,b);ELSE + IF a IS NOT NULL THEN EXECUTE FORMAT('DROP FUNCTION IF EXISTS %s',a);END IF;END IF; +END$$; + +CREATE OR REPLACE FUNCTION cipsrv_pgrest.upstreamdownstream( + JSONB +) RETURNS JSONB +VOLATILE +AS +$BODY$ +DECLARE + rec RECORD; + json_input JSONB := $1; + str_search_type VARCHAR(5); + str_nhdplus_version VARCHAR(50); + + int_start_nhdplusid BIGINT; + str_start_permanent_identifier VARCHAR(40); + str_start_reachcode VARCHAR(14); + int_start_hydroseq BIGINT; + num_start_measure NUMERIC; + str_start_source_featureid VARCHAR; + str_start_source_featureid2 VARCHAR; + str_start_source_originator VARCHAR; + str_start_source_series VARCHAR; + dat_start_start_date DATE; + dat_start_end_date DATE; + str_start_permid_joinkey VARCHAR; + str_start_source_joinkey VARCHAR; + str_start_cat_joinkey VARCHAR; + str_start_linked_data_program VARCHAR; + str_start_search_precision VARCHAR; + str_start_search_logic VARCHAR; + + int_stop_nhdplusid BIGINT; + str_stop_permanent_identifier VARCHAR(40); + str_stop_reachcode VARCHAR(14); + int_stop_hydroseq BIGINT; + num_stop_measure NUMERIC; + str_stop_source_featureid VARCHAR; + str_stop_source_featureid2 VARCHAR; + str_stop_source_originator VARCHAR; + str_stop_source_series VARCHAR; + dat_stop_start_date DATE; + dat_stop_end_date DATE; + str_stop_permid_joinkey VARCHAR; + str_stop_source_joinkey VARCHAR; + str_stop_cat_joinkey VARCHAR; + str_stop_linked_data_program VARCHAR; + str_stop_search_precision VARCHAR; + str_stop_search_logic VARCHAR; + + num_max_distancekm NUMERIC; + num_max_flowtimeday NUMERIC; + ary_linked_data_search_list VARCHAR[]; + + boo_return_flowlines BOOLEAN; + boo_return_flowline_details BOOLEAN; + boo_return_flowline_geometry BOOLEAN; + boo_return_catchments BOOLEAN; + boo_return_linked_data_cip BOOLEAN; + boo_return_linked_data_huc12 BOOLEAN; + boo_return_linked_data_source BOOLEAN; + boo_return_linked_data_rad BOOLEAN; + boo_return_linked_data_attributes BOOLEAN; + boo_remove_stop_start_sfids BOOLEAN; + boo_push_source_geometry_as_rad BOOLEAN; + + int_grid_srid INTEGER; + int_flowline_count INTEGER; + int_return_code INTEGER; + str_status_message VARCHAR; + + json_flowlines JSONB; + str_known_region VARCHAR; + +BEGIN + + int_return_code := 0; + + ---------------------------------------------------------------------------- + -- Step 10 + -- Check over incoming parameters + ---------------------------------------------------------------------------- + IF JSONB_PATH_EXISTS(json_input,'$.nhdplus_version') + AND json_input->>'nhdplus_version' IS NOT NULL + AND json_input->>'nhdplus_version' != '' + THEN + str_nhdplus_version := json_input->>'nhdplus_version'; + + ELSE + RETURN JSONB_BUILD_OBJECT( + 'flowlines' , NULL + ,'catchments' , NULL + ,'linked_data_sfid_found' , NULL + ,'linked_data_cip_found' , NULL + ,'linked_data_huc12_found' , NULL + ,'linked_data_source_points' , NULL + ,'linked_data_source_lines' , NULL + ,'linked_data_source_areas' , NULL + ,'linked_data_reached_points', NULL + ,'linked_data_reached_lines' , NULL + ,'linked_data_reached_areas' , NULL + ,'linked_data_attributes' , NULL + ,'result_link_path' , NULL + ,'return_code' , -100 + ,'status_message' , 'nhdplus version parameter is required' + ); + + END IF; + + IF JSONB_PATH_EXISTS(json_input,'$.search_type') + AND json_input->>'search_type' IS NOT NULL + AND json_input->>'search_type' != '' + THEN + + str_search_type := json_input->>'search_type'; + + END IF; + + IF JSONB_PATH_EXISTS(json_input,'$.start_nhdplusid') + AND json_input->'start_nhdplusid' IS NOT NULL + AND json_input->>'start_nhdplusid' != '' + THEN + int_start_nhdplusid := cipsrv_engine.json2bigint(json_input->'start_nhdplusid'); + + END IF; + + IF JSONB_PATH_EXISTS(json_input,'$.start_permanent_identifier') + AND json_input->>'start_permanent_identifier' IS NOT NULL + AND json_input->>'start_permanent_identifier' != '' + THEN + str_start_permanent_identifier := json_input->>'start_permanent_identifier'; + + END IF; + + IF JSONB_PATH_EXISTS(json_input,'$.start_reachcode') + AND json_input->>'start_reachcode' IS NOT NULL + AND json_input->>'start_reachcode' != '' + THEN + str_start_reachcode := json_input->>'start_reachcode'; + + END IF; + + IF JSONB_PATH_EXISTS(json_input,'$.start_hydroseq') + AND json_input->'start_hydroseq' IS NOT NULL + AND json_input->>'start_hydroseq' != '' + THEN + int_start_hydroseq := cipsrv_engine.json2numeric(json_input->'start_hydroseq'); + + END IF; + + IF JSONB_PATH_EXISTS(json_input,'$.start_measure') + AND json_input->'start_measure' IS NOT NULL + AND json_input->>'start_measure' != '' + THEN + num_start_measure := cipsrv_engine.json2numeric(json_input->'start_measure'); + + END IF; + + IF JSONB_PATH_EXISTS(json_input,'$.stop_nhdplusid') + AND json_input->'stop_nhdplusid' IS NOT NULL + AND json_input->>'stop_nhdplusid' != '' + THEN + int_stop_nhdplusid := cipsrv_engine.json2bigint(json_input->'stop_nhdplusid'); + + END IF; + + IF JSONB_PATH_EXISTS(json_input,'$.stop_permanent_identifier') + AND json_input->>'stop_permanent_identifier' IS NOT NULL + AND json_input->>'stop_permanent_identifier' != '' + THEN + str_stop_permanent_identifier := json_input->>'stop_permanent_identifier'; + + END IF; + + IF JSONB_PATH_EXISTS(json_input,'$.stop_reachcode') + AND json_input->>'stop_reachcode' IS NOT NULL + AND json_input->>'stop_reachcode' != '' + THEN + str_stop_reachcode := json_input->>'stop_reachcode'; + + END IF; + + IF JSONB_PATH_EXISTS(json_input,'$.stop_hydroseq') + AND json_input->'stop_hydroseq' IS NOT NULL + AND json_input->>'stop_hydroseq' != '' + THEN + int_stop_hydroseq := cipsrv_engine.json2bigint(json_input->'stop_hydroseq'); + + END IF; + + IF JSONB_PATH_EXISTS(json_input,'$.stop_measure') + AND json_input->'stop_measure' IS NOT NULL + AND json_input->>'stop_measure' != '' + THEN + num_stop_measure := cipsrv_engine.json2numeric(json_input->'stop_measure'); + + END IF; + + IF JSONB_PATH_EXISTS(json_input,'$.max_distancekm') + AND json_input->'max_distancekm' IS NOT NULL + AND json_input->>'max_distancekm' != '' + THEN + num_max_distancekm := cipsrv_engine.json2numeric(json_input->'max_distancekm'); + + END IF; + + IF JSONB_PATH_EXISTS(json_input,'$.max_flowtimeday') + AND json_input->'max_flowtimeday' IS NOT NULL + AND json_input->>'max_flowtimeday' != '' + THEN + num_max_flowtimeday := cipsrv_engine.json2numeric(json_input->'max_flowtimeday'); + + END IF; + + IF JSONB_PATH_EXISTS(json_input,'$.return_flowline_details') + AND json_input->'return_flowline_details' IS NOT NULL + AND json_input->>'return_flowline_details' != '' + THEN + boo_return_flowline_details := (json_input->'return_flowline_details')::BOOLEAN; + + END IF; + + IF JSONB_PATH_EXISTS(json_input,'$.return_flowline_geometry') + AND json_input->'return_flowline_geometry' IS NOT NULL + AND json_input->>'return_flowline_geometry' != '' + THEN + boo_return_flowline_geometry := (json_input->'return_flowline_geometry')::BOOLEAN; + + END IF; + + IF JSONB_PATH_EXISTS(json_input,'$.known_region') + AND json_input->>'known_region' IS NOT NULL + AND json_input->>'known_region' != '' + THEN + str_known_region := json_input->>'known_region'; + + END IF; + + ---------------------------------------------------------------------------- + -- Step 20 + -- Call the upstreamdownstream engine + ---------------------------------------------------------------------------- + rec := cipsrv_owld.upstreamdownstream( + p_nhdplus_version := str_nhdplus_version + ,p_search_type := str_search_type + + ,p_start_nhdplusid := int_start_nhdplusid + ,p_start_permanent_identifier := str_start_permanent_identifier + ,p_start_reachcode := str_start_reachcode + ,p_start_hydroseq := int_start_hydroseq + ,p_start_measure := num_start_measure + ,p_start_source_featureid := str_start_source_featureid + ,p_start_source_featureid2 := str_start_source_featureid2 + ,p_start_source_originator := str_start_source_originator + ,p_start_source_series := str_start_source_series + ,p_start_start_date := dat_start_start_date + ,p_start_end_date := dat_start_end_date + ,p_start_permid_joinkey := str_start_permid_joinkey + ,p_start_source_joinkey := str_start_source_joinkey + ,p_start_cat_joinkey := str_start_cat_joinkey + ,p_start_linked_data_program := str_start_linked_data_program + ,p_start_search_precision := str_start_search_precision + ,p_start_search_logic := str_start_search_logic + + ,p_stop_nhdplusid := int_stop_nhdplusid + ,p_stop_permanent_identifier := str_stop_permanent_identifier + ,p_stop_reachcode := str_stop_reachcode + ,p_stop_hydroseq := int_stop_hydroseq + ,p_stop_measure := num_stop_measure + ,p_stop_source_featureid := str_stop_source_featureid + ,p_stop_source_featureid2 := str_stop_source_featureid2 + ,p_stop_source_originator := str_stop_source_originator + ,p_stop_source_series := str_stop_source_series + ,p_stop_start_date := dat_stop_start_date + ,p_stop_end_date := dat_stop_end_date + ,p_stop_permid_joinkey := str_stop_permid_joinkey + ,p_stop_source_joinkey := str_stop_source_joinkey + ,p_stop_cat_joinkey := str_stop_cat_joinkey + ,p_stop_linked_data_program := str_stop_linked_data_program + ,p_stop_search_precision := str_stop_search_precision + ,p_stop_search_logic := str_stop_search_logic + + ,p_max_distancekm := num_max_distancekm + ,p_max_flowtimeday := num_max_flowtimeday + ,p_linked_data_search_list := ary_linked_data_search_list + + ,p_return_flowlines := boo_return_flowlines + ,p_return_flowline_details := boo_return_flowline_details + ,p_return_flowline_geometry := boo_return_flowline_geometry + ,p_return_catchments := boo_return_catchments + ,p_return_linked_data_cip := boo_return_linked_data_cip + ,p_return_linked_data_huc12 := boo_return_linked_data_huc12 + ,p_return_linked_data_source := boo_return_linked_data_source + ,p_return_linked_data_rad := boo_return_linked_data_rad + ,p_return_linked_data_attributes := boo_return_linked_data_attributes + ,p_remove_stop_start_sfids := boo_remove_stop_start_sfids + ,p_push_source_geometry_as_rad := boo_push_source_geometry_as_rad + + ,p_known_region := str_known_region + ); + int_start_nhdplusid := rec.out_start_nhdplusid; + str_start_permanent_identifier := rec.out_start_permanent_identifier; + num_start_measure := rec.out_start_measure; + int_grid_srid := rec.out_grid_srid; + int_stop_nhdplusid := rec.out_stop_nhdplusid; + num_stop_measure := rec.out_stop_measure; + int_flowline_count := rec.out_flowline_count; + int_return_code := rec.out_return_code; + str_status_message := rec.out_status_message; + + IF int_return_code != 0 + THEN + RETURN JSONB_BUILD_OBJECT( + 'flowlines' , NULL + ,'catchments' , NULL + ,'linked_data_sfid_found' , NULL + ,'linked_data_cip_found' , NULL + ,'linked_data_huc12_found' , NULL + ,'linked_data_source_points' , NULL + ,'linked_data_source_lines' , NULL + ,'linked_data_source_areas' , NULL + ,'linked_data_reached_points', NULL + ,'linked_data_reached_lines' , NULL + ,'linked_data_reached_areas' , NULL + ,'linked_data_attributes' , NULL + ,'result_link_path' , NULL + ,'return_code' , int_return_code + ,'status_message' , str_status_message + ); + + END IF; + + ---------------------------------------------------------------------------- + -- Step 40 + -- Build the flowlines featurecollection + ---------------------------------------------------------------------------- + IF boo_return_flowlines + THEN + json_flowlines := ( + SELECT + JSONB_AGG(j.my_json) AS my_feats + FROM ( + SELECT + JSONB_BUILD_OBJECT( + 'type', 'Feature' + ,'obj_type', 'navigated_flowline_properties' + ,'geometry', ST_AsGeoJSON(t.geom)::JSONB + ,'properties', TO_JSONB(t.*) - 'geom' + ) AS my_json + FROM ( + SELECT + a.nhdplusid + ,a.hydroseq + ,a.fmeasure + ,a.tmeasure + ,a.levelpathi + ,a.terminalpa + ,a.uphydroseq + ,a.dnhydroseq + ,TRUNC(a.lengthkm,8) AS lengthkm + ,TRUNC(a.flowtimeday,8) AS flowtimeday + /* +++++++++ */ + ,TRUNC(a.network_distancekm,8) AS network_distancekm + ,TRUNC(a.network_flowtimeday,8) AS network_flowtimeday + /* +++++++++ */ + ,a.permanent_identifier + ,a.reachcode + ,a.fcode + ,a.gnis_id + ,a.gnis_name + ,a.wbarea_permanent_identifier + /* +++++++++ */ + ,a.navtermination_flag + ,a.nav_order + ,CASE WHEN boo_return_flowline_geometry THEN ST_Transform(a.shape,4326) ELSE NULL::GEOMETRY END AS geom + FROM + tmp_navigation_results a + ORDER BY + a.nav_order + ,a.network_distancekm + ) t + ) j + ); + + IF json_flowlines IS NULL + OR JSONB_ARRAY_LENGTH(json_flowlines) = 0 + THEN + json_flowlines := NULL; + + ELSE + json_flowlines := JSON_BUILD_OBJECT( + 'type' , 'FeatureCollection' + ,'features', json_flowlines + ); + + END IF; + + ELSE + json_flowlines := NULL; + + END IF; + + ---------------------------------------------------------------------------- + -- Step 50 + -- Return what we got + ---------------------------------------------------------------------------- + RETURN JSONB_BUILD_OBJECT( + 'flowlines' , json_flowlines + ,'catchments' , NULL + ,'linked_data_sfid_found' , NULL + ,'linked_data_cip_found' , NULL + ,'linked_data_huc12_found' , NULL + ,'linked_data_source_points' , NULL + ,'linked_data_source_lines' , NULL + ,'linked_data_source_areas' , NULL + ,'linked_data_reached_points', NULL + ,'linked_data_reached_lines' , NULL + ,'linked_data_reached_areas' , NULL + ,'linked_data_attributes' , NULL + ,'result_link_path' , NULL + ,'return_code' , int_return_code + ,'status_message' , str_status_message + ); + +END; +$BODY$ +LANGUAGE plpgsql; + +ALTER FUNCTION cipsrv_pgrest.upstreamdownstream( + JSONB +) OWNER TO cipsrv_pgrest; + +GRANT EXECUTE ON FUNCTION cipsrv_pgrest.upstreamdownstream( + JSONB +) TO PUBLIC; + --******************************-- ----- functions/randomcatchment.sql diff --git a/src/database/cipsrv_pgrest/functions/upstreamdownstream.sql b/src/database/cipsrv_pgrest/functions/upstreamdownstream.sql new file mode 100644 index 0000000..d015077 --- /dev/null +++ b/src/database/cipsrv_pgrest/functions/upstreamdownstream.sql @@ -0,0 +1,445 @@ +DO $$DECLARE + a VARCHAR;b VARCHAR; +BEGIN + SELECT p.oid::regproc,pg_get_function_identity_arguments(p.oid) + INTO a,b FROM pg_catalog.pg_proc p LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace + WHERE p.oid::regproc::text = 'cipsrv_pgrest.upstreamdownstream'; + IF b IS NOT NULL THEN + EXECUTE FORMAT('DROP FUNCTION IF EXISTS %s(%s)',a,b);ELSE + IF a IS NOT NULL THEN EXECUTE FORMAT('DROP FUNCTION IF EXISTS %s',a);END IF;END IF; +END$$; + +CREATE OR REPLACE FUNCTION cipsrv_pgrest.upstreamdownstream( + JSONB +) RETURNS JSONB +VOLATILE +AS +$BODY$ +DECLARE + rec RECORD; + json_input JSONB := $1; + str_search_type VARCHAR(5); + str_nhdplus_version VARCHAR(50); + + int_start_nhdplusid BIGINT; + str_start_permanent_identifier VARCHAR(40); + str_start_reachcode VARCHAR(14); + int_start_hydroseq BIGINT; + num_start_measure NUMERIC; + str_start_source_featureid VARCHAR; + str_start_source_featureid2 VARCHAR; + str_start_source_originator VARCHAR; + str_start_source_series VARCHAR; + dat_start_start_date DATE; + dat_start_end_date DATE; + str_start_permid_joinkey VARCHAR; + str_start_source_joinkey VARCHAR; + str_start_cat_joinkey VARCHAR; + str_start_linked_data_program VARCHAR; + str_start_search_precision VARCHAR; + str_start_search_logic VARCHAR; + + int_stop_nhdplusid BIGINT; + str_stop_permanent_identifier VARCHAR(40); + str_stop_reachcode VARCHAR(14); + int_stop_hydroseq BIGINT; + num_stop_measure NUMERIC; + str_stop_source_featureid VARCHAR; + str_stop_source_featureid2 VARCHAR; + str_stop_source_originator VARCHAR; + str_stop_source_series VARCHAR; + dat_stop_start_date DATE; + dat_stop_end_date DATE; + str_stop_permid_joinkey VARCHAR; + str_stop_source_joinkey VARCHAR; + str_stop_cat_joinkey VARCHAR; + str_stop_linked_data_program VARCHAR; + str_stop_search_precision VARCHAR; + str_stop_search_logic VARCHAR; + + num_max_distancekm NUMERIC; + num_max_flowtimeday NUMERIC; + ary_linked_data_search_list VARCHAR[]; + + boo_return_flowlines BOOLEAN; + boo_return_flowline_details BOOLEAN; + boo_return_flowline_geometry BOOLEAN; + boo_return_catchments BOOLEAN; + boo_return_linked_data_cip BOOLEAN; + boo_return_linked_data_huc12 BOOLEAN; + boo_return_linked_data_source BOOLEAN; + boo_return_linked_data_rad BOOLEAN; + boo_return_linked_data_attributes BOOLEAN; + boo_remove_stop_start_sfids BOOLEAN; + boo_push_source_geometry_as_rad BOOLEAN; + + int_grid_srid INTEGER; + int_flowline_count INTEGER; + int_return_code INTEGER; + str_status_message VARCHAR; + + json_flowlines JSONB; + str_known_region VARCHAR; + +BEGIN + + int_return_code := 0; + + ---------------------------------------------------------------------------- + -- Step 10 + -- Check over incoming parameters + ---------------------------------------------------------------------------- + IF JSONB_PATH_EXISTS(json_input,'$.nhdplus_version') + AND json_input->>'nhdplus_version' IS NOT NULL + AND json_input->>'nhdplus_version' != '' + THEN + str_nhdplus_version := json_input->>'nhdplus_version'; + + ELSE + RETURN JSONB_BUILD_OBJECT( + 'flowlines' , NULL + ,'catchments' , NULL + ,'linked_data_sfid_found' , NULL + ,'linked_data_cip_found' , NULL + ,'linked_data_huc12_found' , NULL + ,'linked_data_source_points' , NULL + ,'linked_data_source_lines' , NULL + ,'linked_data_source_areas' , NULL + ,'linked_data_reached_points', NULL + ,'linked_data_reached_lines' , NULL + ,'linked_data_reached_areas' , NULL + ,'linked_data_attributes' , NULL + ,'result_link_path' , NULL + ,'return_code' , -100 + ,'status_message' , 'nhdplus version parameter is required' + ); + + END IF; + + IF JSONB_PATH_EXISTS(json_input,'$.search_type') + AND json_input->>'search_type' IS NOT NULL + AND json_input->>'search_type' != '' + THEN + + str_search_type := json_input->>'search_type'; + + END IF; + + IF JSONB_PATH_EXISTS(json_input,'$.start_nhdplusid') + AND json_input->'start_nhdplusid' IS NOT NULL + AND json_input->>'start_nhdplusid' != '' + THEN + int_start_nhdplusid := cipsrv_engine.json2bigint(json_input->'start_nhdplusid'); + + END IF; + + IF JSONB_PATH_EXISTS(json_input,'$.start_permanent_identifier') + AND json_input->>'start_permanent_identifier' IS NOT NULL + AND json_input->>'start_permanent_identifier' != '' + THEN + str_start_permanent_identifier := json_input->>'start_permanent_identifier'; + + END IF; + + IF JSONB_PATH_EXISTS(json_input,'$.start_reachcode') + AND json_input->>'start_reachcode' IS NOT NULL + AND json_input->>'start_reachcode' != '' + THEN + str_start_reachcode := json_input->>'start_reachcode'; + + END IF; + + IF JSONB_PATH_EXISTS(json_input,'$.start_hydroseq') + AND json_input->'start_hydroseq' IS NOT NULL + AND json_input->>'start_hydroseq' != '' + THEN + int_start_hydroseq := cipsrv_engine.json2numeric(json_input->'start_hydroseq'); + + END IF; + + IF JSONB_PATH_EXISTS(json_input,'$.start_measure') + AND json_input->'start_measure' IS NOT NULL + AND json_input->>'start_measure' != '' + THEN + num_start_measure := cipsrv_engine.json2numeric(json_input->'start_measure'); + + END IF; + + IF JSONB_PATH_EXISTS(json_input,'$.stop_nhdplusid') + AND json_input->'stop_nhdplusid' IS NOT NULL + AND json_input->>'stop_nhdplusid' != '' + THEN + int_stop_nhdplusid := cipsrv_engine.json2bigint(json_input->'stop_nhdplusid'); + + END IF; + + IF JSONB_PATH_EXISTS(json_input,'$.stop_permanent_identifier') + AND json_input->>'stop_permanent_identifier' IS NOT NULL + AND json_input->>'stop_permanent_identifier' != '' + THEN + str_stop_permanent_identifier := json_input->>'stop_permanent_identifier'; + + END IF; + + IF JSONB_PATH_EXISTS(json_input,'$.stop_reachcode') + AND json_input->>'stop_reachcode' IS NOT NULL + AND json_input->>'stop_reachcode' != '' + THEN + str_stop_reachcode := json_input->>'stop_reachcode'; + + END IF; + + IF JSONB_PATH_EXISTS(json_input,'$.stop_hydroseq') + AND json_input->'stop_hydroseq' IS NOT NULL + AND json_input->>'stop_hydroseq' != '' + THEN + int_stop_hydroseq := cipsrv_engine.json2bigint(json_input->'stop_hydroseq'); + + END IF; + + IF JSONB_PATH_EXISTS(json_input,'$.stop_measure') + AND json_input->'stop_measure' IS NOT NULL + AND json_input->>'stop_measure' != '' + THEN + num_stop_measure := cipsrv_engine.json2numeric(json_input->'stop_measure'); + + END IF; + + IF JSONB_PATH_EXISTS(json_input,'$.max_distancekm') + AND json_input->'max_distancekm' IS NOT NULL + AND json_input->>'max_distancekm' != '' + THEN + num_max_distancekm := cipsrv_engine.json2numeric(json_input->'max_distancekm'); + + END IF; + + IF JSONB_PATH_EXISTS(json_input,'$.max_flowtimeday') + AND json_input->'max_flowtimeday' IS NOT NULL + AND json_input->>'max_flowtimeday' != '' + THEN + num_max_flowtimeday := cipsrv_engine.json2numeric(json_input->'max_flowtimeday'); + + END IF; + + IF JSONB_PATH_EXISTS(json_input,'$.return_flowline_details') + AND json_input->'return_flowline_details' IS NOT NULL + AND json_input->>'return_flowline_details' != '' + THEN + boo_return_flowline_details := (json_input->'return_flowline_details')::BOOLEAN; + + END IF; + + IF JSONB_PATH_EXISTS(json_input,'$.return_flowline_geometry') + AND json_input->'return_flowline_geometry' IS NOT NULL + AND json_input->>'return_flowline_geometry' != '' + THEN + boo_return_flowline_geometry := (json_input->'return_flowline_geometry')::BOOLEAN; + + END IF; + + IF JSONB_PATH_EXISTS(json_input,'$.known_region') + AND json_input->>'known_region' IS NOT NULL + AND json_input->>'known_region' != '' + THEN + str_known_region := json_input->>'known_region'; + + END IF; + + ---------------------------------------------------------------------------- + -- Step 20 + -- Call the upstreamdownstream engine + ---------------------------------------------------------------------------- + rec := cipsrv_owld.upstreamdownstream( + p_nhdplus_version := str_nhdplus_version + ,p_search_type := str_search_type + + ,p_start_nhdplusid := int_start_nhdplusid + ,p_start_permanent_identifier := str_start_permanent_identifier + ,p_start_reachcode := str_start_reachcode + ,p_start_hydroseq := int_start_hydroseq + ,p_start_measure := num_start_measure + ,p_start_source_featureid := str_start_source_featureid + ,p_start_source_featureid2 := str_start_source_featureid2 + ,p_start_source_originator := str_start_source_originator + ,p_start_source_series := str_start_source_series + ,p_start_start_date := dat_start_start_date + ,p_start_end_date := dat_start_end_date + ,p_start_permid_joinkey := str_start_permid_joinkey + ,p_start_source_joinkey := str_start_source_joinkey + ,p_start_cat_joinkey := str_start_cat_joinkey + ,p_start_linked_data_program := str_start_linked_data_program + ,p_start_search_precision := str_start_search_precision + ,p_start_search_logic := str_start_search_logic + + ,p_stop_nhdplusid := int_stop_nhdplusid + ,p_stop_permanent_identifier := str_stop_permanent_identifier + ,p_stop_reachcode := str_stop_reachcode + ,p_stop_hydroseq := int_stop_hydroseq + ,p_stop_measure := num_stop_measure + ,p_stop_source_featureid := str_stop_source_featureid + ,p_stop_source_featureid2 := str_stop_source_featureid2 + ,p_stop_source_originator := str_stop_source_originator + ,p_stop_source_series := str_stop_source_series + ,p_stop_start_date := dat_stop_start_date + ,p_stop_end_date := dat_stop_end_date + ,p_stop_permid_joinkey := str_stop_permid_joinkey + ,p_stop_source_joinkey := str_stop_source_joinkey + ,p_stop_cat_joinkey := str_stop_cat_joinkey + ,p_stop_linked_data_program := str_stop_linked_data_program + ,p_stop_search_precision := str_stop_search_precision + ,p_stop_search_logic := str_stop_search_logic + + ,p_max_distancekm := num_max_distancekm + ,p_max_flowtimeday := num_max_flowtimeday + ,p_linked_data_search_list := ary_linked_data_search_list + + ,p_return_flowlines := boo_return_flowlines + ,p_return_flowline_details := boo_return_flowline_details + ,p_return_flowline_geometry := boo_return_flowline_geometry + ,p_return_catchments := boo_return_catchments + ,p_return_linked_data_cip := boo_return_linked_data_cip + ,p_return_linked_data_huc12 := boo_return_linked_data_huc12 + ,p_return_linked_data_source := boo_return_linked_data_source + ,p_return_linked_data_rad := boo_return_linked_data_rad + ,p_return_linked_data_attributes := boo_return_linked_data_attributes + ,p_remove_stop_start_sfids := boo_remove_stop_start_sfids + ,p_push_source_geometry_as_rad := boo_push_source_geometry_as_rad + + ,p_known_region := str_known_region + ); + int_start_nhdplusid := rec.out_start_nhdplusid; + str_start_permanent_identifier := rec.out_start_permanent_identifier; + num_start_measure := rec.out_start_measure; + int_grid_srid := rec.out_grid_srid; + int_stop_nhdplusid := rec.out_stop_nhdplusid; + num_stop_measure := rec.out_stop_measure; + int_flowline_count := rec.out_flowline_count; + int_return_code := rec.out_return_code; + str_status_message := rec.out_status_message; + + IF int_return_code != 0 + THEN + RETURN JSONB_BUILD_OBJECT( + 'flowlines' , NULL + ,'catchments' , NULL + ,'linked_data_sfid_found' , NULL + ,'linked_data_cip_found' , NULL + ,'linked_data_huc12_found' , NULL + ,'linked_data_source_points' , NULL + ,'linked_data_source_lines' , NULL + ,'linked_data_source_areas' , NULL + ,'linked_data_reached_points', NULL + ,'linked_data_reached_lines' , NULL + ,'linked_data_reached_areas' , NULL + ,'linked_data_attributes' , NULL + ,'result_link_path' , NULL + ,'return_code' , int_return_code + ,'status_message' , str_status_message + ); + + END IF; + + ---------------------------------------------------------------------------- + -- Step 40 + -- Build the flowlines featurecollection + ---------------------------------------------------------------------------- + IF boo_return_flowlines + THEN + json_flowlines := ( + SELECT + JSONB_AGG(j.my_json) AS my_feats + FROM ( + SELECT + JSONB_BUILD_OBJECT( + 'type', 'Feature' + ,'obj_type', 'navigated_flowline_properties' + ,'geometry', ST_AsGeoJSON(t.geom)::JSONB + ,'properties', TO_JSONB(t.*) - 'geom' + ) AS my_json + FROM ( + SELECT + a.nhdplusid + ,a.hydroseq + ,a.fmeasure + ,a.tmeasure + ,a.levelpathi + ,a.terminalpa + ,a.uphydroseq + ,a.dnhydroseq + ,TRUNC(a.lengthkm,8) AS lengthkm + ,TRUNC(a.flowtimeday,8) AS flowtimeday + /* +++++++++ */ + ,TRUNC(a.network_distancekm,8) AS network_distancekm + ,TRUNC(a.network_flowtimeday,8) AS network_flowtimeday + /* +++++++++ */ + ,a.permanent_identifier + ,a.reachcode + ,a.fcode + ,a.gnis_id + ,a.gnis_name + ,a.wbarea_permanent_identifier + /* +++++++++ */ + ,a.navtermination_flag + ,a.nav_order + ,CASE WHEN boo_return_flowline_geometry THEN ST_Transform(a.shape,4326) ELSE NULL::GEOMETRY END AS geom + FROM + tmp_navigation_results a + ORDER BY + a.nav_order + ,a.network_distancekm + ) t + ) j + ); + + IF json_flowlines IS NULL + OR JSONB_ARRAY_LENGTH(json_flowlines) = 0 + THEN + json_flowlines := NULL; + + ELSE + json_flowlines := JSON_BUILD_OBJECT( + 'type' , 'FeatureCollection' + ,'features', json_flowlines + ); + + END IF; + + ELSE + json_flowlines := NULL; + + END IF; + + ---------------------------------------------------------------------------- + -- Step 50 + -- Return what we got + ---------------------------------------------------------------------------- + RETURN JSONB_BUILD_OBJECT( + 'flowlines' , json_flowlines + ,'catchments' , NULL + ,'linked_data_sfid_found' , NULL + ,'linked_data_cip_found' , NULL + ,'linked_data_huc12_found' , NULL + ,'linked_data_source_points' , NULL + ,'linked_data_source_lines' , NULL + ,'linked_data_source_areas' , NULL + ,'linked_data_reached_points', NULL + ,'linked_data_reached_lines' , NULL + ,'linked_data_reached_areas' , NULL + ,'linked_data_attributes' , NULL + ,'result_link_path' , NULL + ,'return_code' , int_return_code + ,'status_message' , str_status_message + ); + +END; +$BODY$ +LANGUAGE plpgsql; + +ALTER FUNCTION cipsrv_pgrest.upstreamdownstream( + JSONB +) OWNER TO cipsrv_pgrest; + +GRANT EXECUTE ON FUNCTION cipsrv_pgrest.upstreamdownstream( + JSONB +) TO PUBLIC; + diff --git a/src/database/cipsrv_pgrest/manifest.json b/src/database/cipsrv_pgrest/manifest.json index dc9f3eb..de76b82 100644 --- a/src/database/cipsrv_pgrest/manifest.json +++ b/src/database/cipsrv_pgrest/manifest.json @@ -28,6 +28,7 @@ ,"functions/healthcheck.sql" ,"functions/navigate.sql" ,"functions/pointindexing.sql" + ,"functions/upstreamdownstream.sql" ,"functions/randomcatchment.sql" ,"functions/randomhuc12.sql" ,"functions/randomnav.sql"