Skip to content

Commit b61d211

Browse files
committed
add basic workspace functionality (memory only)
1 parent e6dc55e commit b61d211

File tree

6 files changed

+45
-8
lines changed

6 files changed

+45
-8
lines changed

lib/geoscript.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
require 'geoscript/projection'
1616
require 'geoscript/geom'
1717
require 'geoscript/feature'
18+
require 'geoscript/datastore'
19+
require 'geoscript/workspace'
1820
else
1921
warn "GeoScript requires JRuby (http://jruby.org)"
2022
end

lib/geoscript/datastore.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require 'datastore/memory'

lib/geoscript/datastore/memory.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
java_import org.geotools.data.memory.MemoryDataStore
2+
3+
module GeoScript
4+
module DataStore
5+
class Memory < MemoryDataStore
6+
def initialize(params)
7+
super()
8+
end
9+
end
10+
end
11+
end

lib/geoscript/geom.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
require 'geom/io/json'
2-
require 'geom/io/wkt'
3-
require 'geom/io/wkb'
41
require 'geom/geom'
52
require 'geom/bounds'
63
require 'geom/point'

lib/geoscript/workspace.rb

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,21 @@
1-
require 'workspace/memory'
1+
java_import org.geotools.data.DataStore
2+
3+
module GeoScript
4+
class Workspace
5+
DS_TYPES = {
6+
'memory' => GeoScript::DataStore::Memory
7+
}
8+
9+
attr_accessor :store
10+
11+
def initialize(store = nil, params = nil)
12+
unless store
13+
@store = GeoScript::DataStore::Memory.new(params)
14+
else
15+
if DS_TYPES[store]
16+
@store = DS_TYPES[store].new(params)
17+
end
18+
end
19+
end
20+
end
21+
end

lib/geoscript/workspace/workspace.rb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
java_import org.geotools.data.DataStore
22

33
module GeoScript
4-
module Workspace
5-
class Workspace < DataStore
6-
def initialize(store = nil, params = nil)
4+
class Workspace
5+
DS_TYPES = {
6+
'memory' => GeoScript::Workspace::Memory
7+
}
8+
9+
def initialize(store, params)
710
unless store
811
@store = GeoScript::Workspace::Memory.new
9-
elsif store.respond_to? :create
12+
elsif store.kind_of? DataStore
13+
@store = store
14+
elsif DS_TYPES[store]
15+
@store = DS_TYPES[store].new(params)
1016
end
1117
end
1218
end

0 commit comments

Comments
 (0)