Skip to content

Commit 51cb2d2

Browse files
committed
Add flatgeobuf workspace
1 parent 2c7dc38 commit 51cb2d2

File tree

6 files changed

+63
-1
lines changed

6 files changed

+63
-1
lines changed

doc/api/workspace/flatgeobuf.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.. module:: workspace.flatgeobuf
2+
:synopsis: Flatgeobuf workspace implementation.
3+
4+
Geobuf
5+
======
6+
7+
.. automodule:: geoscript.workspace.flatgeobuf
8+
:members: Flatgeobuf
9+
10+

doc/api/workspace/geobuf.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.. module:: workspace.geobuf
2+
:synopsis: Geobuf workspace implementation.
3+
4+
Geobuf
5+
======
6+
7+
.. automodule:: geoscript.workspace.geobuf
8+
:members: Geobuf
9+
10+

geoscript/workspace/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ def _import(mod, clas):
1818
Oracle = _import('oracle', 'Oracle')
1919
GeoPackage = _import('geopackage', 'GeoPackage')
2020
Geobuf = _import('geobuf', 'Geobuf')
21-
21+
FlatGeobuf = _import('flatgeobuf', 'FlatGeobuf')

geoscript/workspace/flatgeobuf.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""
2+
the :mod:`workspace.property` module provides a workspace implemntation based on a directory of java style property files.
3+
"""
4+
5+
import os
6+
from java import io, net
7+
from geoscript import util
8+
from geoscript.workspace import Workspace
9+
from org.geotools.data.flatgeobuf import FlatgeobufDataStoreFactory
10+
11+
class FlatGeobuf(Workspace):
12+
"""
13+
A subclass of :class:`Workspace <geoscript.workspace.workspace.Workspace>` that provides layers that correspond to flatgeobuf files in a directory.
14+
15+
*dir* is the optional path as a ``str`` to a directory. If not specified it defaults to ``os.getcwd()``.
16+
"""
17+
18+
def __init__(self, dir=None):
19+
dir = dir or os.getcwd()
20+
params = {'flatgeobuf-file': util.toFile(dir)}
21+
Workspace.__init__(self, FlatgeobufDataStoreFactory(), params)
22+
23+
def __repr__(self):
24+
return 'FlatGeobuf[%s]' % str(self._store.info.source.path)

pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,11 @@
155155
<artifactId>gt-imageio-ext-gdal</artifactId>
156156
<version>${gt.version}</version>
157157
</dependency>
158+
<dependency>
159+
<groupId>org.geotools</groupId>
160+
<artifactId>gt-flatgeobuf</artifactId>
161+
<version>${gt.version}</version>
162+
</dependency>
158163
<dependency>
159164
<groupId>org.geotools</groupId>
160165
<artifactId>gt-geopkg</artifactId>

tests/workspace/test_flatgeobuf.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import os
2+
import shutil
3+
from tests.workspace.workspacetest import WorkspaceTest
4+
from geoscript.workspace import FlatGeobuf
5+
6+
class FlatGeobufWorkspace_Test(WorkspaceTest):
7+
8+
def setUp(self):
9+
self.path = 'work/flatgeobufs'
10+
if os.path.isdir(self.path):
11+
shutil.rmtree(self.path)
12+
os.mkdir(self.path)
13+
self.ws = FlatGeobuf(self.path)

0 commit comments

Comments
 (0)