Class: Geoserver::Publish::FeatureType

Inherits:
Object
  • Object
show all
Defined in:
lib/geoserver/publish/feature_type.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(conn = nil) ⇒ FeatureType

Returns a new instance of FeatureType.



7
8
9
# File 'lib/geoserver/publish/feature_type.rb', line 7

def initialize(conn = nil)
  @connection = conn || Geoserver::Publish::Connection.new
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



5
6
7
# File 'lib/geoserver/publish/feature_type.rb', line 5

def connection
  @connection
end

Instance Method Details

#create(workspace_name:, data_store_name:, feature_type_name:, title:, additional_payload: nil) ⇒ Object

Feature type name must be the same name as the shapefile without the extenstion. E.g. If the file is ‘12345.shp`, then feature_type_name = “12345”.



24
25
26
27
28
# File 'lib/geoserver/publish/feature_type.rb', line 24

def create(workspace_name:, data_store_name:, feature_type_name:, title:, additional_payload: nil)
  path = feature_type_url(workspace_name: workspace_name, data_store_name: data_store_name, feature_type_name: nil)
  payload = payload_new(feature_type_name: feature_type_name, title: title, payload: additional_payload)
  connection.post(path: path, payload: payload)
end

#delete(workspace_name:, data_store_name:, feature_type_name:) ⇒ Object



11
12
13
14
# File 'lib/geoserver/publish/feature_type.rb', line 11

def delete(workspace_name:, data_store_name:, feature_type_name:)
  path = feature_type_url(workspace_name: workspace_name, data_store_name: data_store_name, feature_type_name: feature_type_name)
  connection.delete(path: path)
end

#find(workspace_name:, data_store_name:, feature_type_name:) ⇒ Object



16
17
18
19
20
# File 'lib/geoserver/publish/feature_type.rb', line 16

def find(workspace_name:, data_store_name:, feature_type_name:)
  path = feature_type_url(workspace_name: workspace_name, data_store_name: data_store_name, feature_type_name: feature_type_name)
  out = connection.get(path: path)
  JSON.parse(out) if out
end

#update(workspace_name:, data_store_name:, feature_type_name:, title:, additional_payload: nil) ⇒ Object



30
31
32
33
34
# File 'lib/geoserver/publish/feature_type.rb', line 30

def update(workspace_name:, data_store_name:, feature_type_name:, title:, additional_payload: nil)
  path = feature_type_url(workspace_name: workspace_name, data_store_name: data_store_name, feature_type_name: feature_type_name)
  payload = payload_new(feature_type_name: feature_type_name, title: title, payload: additional_payload)
  connection.put(path: path, payload: payload, content_type: "application/json")
end