From 51cb2d2e0ca5e1eac92fabf08d3f578bd4767d68 Mon Sep 17 00:00:00 2001 From: Jared Erickson Date: Thu, 4 Jun 2020 17:39:42 -0700 Subject: [PATCH] Add flatgeobuf workspace --- doc/api/workspace/flatgeobuf.rst | 10 ++++++++++ doc/api/workspace/geobuf.rst | 10 ++++++++++ geoscript/workspace/__init__.py | 2 +- geoscript/workspace/flatgeobuf.py | 24 ++++++++++++++++++++++++ pom.xml | 5 +++++ tests/workspace/test_flatgeobuf.py | 13 +++++++++++++ 6 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 doc/api/workspace/flatgeobuf.rst create mode 100644 doc/api/workspace/geobuf.rst create mode 100644 geoscript/workspace/flatgeobuf.py create mode 100644 tests/workspace/test_flatgeobuf.py diff --git a/doc/api/workspace/flatgeobuf.rst b/doc/api/workspace/flatgeobuf.rst new file mode 100644 index 0000000..2911876 --- /dev/null +++ b/doc/api/workspace/flatgeobuf.rst @@ -0,0 +1,10 @@ +.. module:: workspace.flatgeobuf + :synopsis: Flatgeobuf workspace implementation. + +Geobuf +====== + + .. automodule:: geoscript.workspace.flatgeobuf + :members: Flatgeobuf + + diff --git a/doc/api/workspace/geobuf.rst b/doc/api/workspace/geobuf.rst new file mode 100644 index 0000000..8706a8e --- /dev/null +++ b/doc/api/workspace/geobuf.rst @@ -0,0 +1,10 @@ +.. module:: workspace.geobuf + :synopsis: Geobuf workspace implementation. + +Geobuf +====== + + .. automodule:: geoscript.workspace.geobuf + :members: Geobuf + + diff --git a/geoscript/workspace/__init__.py b/geoscript/workspace/__init__.py index e212c1b..178ea7f 100644 --- a/geoscript/workspace/__init__.py +++ b/geoscript/workspace/__init__.py @@ -18,4 +18,4 @@ def _import(mod, clas): Oracle = _import('oracle', 'Oracle') GeoPackage = _import('geopackage', 'GeoPackage') Geobuf = _import('geobuf', 'Geobuf') - +FlatGeobuf = _import('flatgeobuf', 'FlatGeobuf') diff --git a/geoscript/workspace/flatgeobuf.py b/geoscript/workspace/flatgeobuf.py new file mode 100644 index 0000000..1bc114d --- /dev/null +++ b/geoscript/workspace/flatgeobuf.py @@ -0,0 +1,24 @@ +""" +the :mod:`workspace.property` module provides a workspace implemntation based on a directory of java style property files. +""" + +import os +from java import io, net +from geoscript import util +from geoscript.workspace import Workspace +from org.geotools.data.flatgeobuf import FlatgeobufDataStoreFactory + +class FlatGeobuf(Workspace): + """ + A subclass of :class:`Workspace ` that provides layers that correspond to flatgeobuf files in a directory. + + *dir* is the optional path as a ``str`` to a directory. If not specified it defaults to ``os.getcwd()``. + """ + + def __init__(self, dir=None): + dir = dir or os.getcwd() + params = {'flatgeobuf-file': util.toFile(dir)} + Workspace.__init__(self, FlatgeobufDataStoreFactory(), params) + + def __repr__(self): + return 'FlatGeobuf[%s]' % str(self._store.info.source.path) diff --git a/pom.xml b/pom.xml index ff1a5ad..855299f 100644 --- a/pom.xml +++ b/pom.xml @@ -155,6 +155,11 @@ gt-imageio-ext-gdal ${gt.version} + + org.geotools + gt-flatgeobuf + ${gt.version} + org.geotools gt-geopkg diff --git a/tests/workspace/test_flatgeobuf.py b/tests/workspace/test_flatgeobuf.py new file mode 100644 index 0000000..bdb8756 --- /dev/null +++ b/tests/workspace/test_flatgeobuf.py @@ -0,0 +1,13 @@ +import os +import shutil +from tests.workspace.workspacetest import WorkspaceTest +from geoscript.workspace import FlatGeobuf + +class FlatGeobufWorkspace_Test(WorkspaceTest): + + def setUp(self): + self.path = 'work/flatgeobufs' + if os.path.isdir(self.path): + shutil.rmtree(self.path) + os.mkdir(self.path) + self.ws = FlatGeobuf(self.path)