stac 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/CHANGELOG.md +10 -0
- data/GETTING_STARTED.md +384 -0
- data/Gemfile.lock +48 -37
- data/README.md +12 -59
- data/Rakefile +62 -4
- data/Steepfile +2 -0
- data/lib/stac/asset.rb +3 -1
- data/lib/stac/catalog.rb +78 -8
- data/lib/stac/collection.rb +43 -9
- data/lib/stac/common_metadata.rb +1 -1
- data/lib/stac/errors.rb +2 -5
- data/lib/stac/extension.rb +34 -0
- data/lib/stac/extensions/electro_optical.rb +67 -0
- data/lib/stac/extensions/projection.rb +42 -0
- data/lib/stac/extensions/scientific_citation.rb +84 -0
- data/lib/stac/extensions/view_geometry.rb +38 -0
- data/lib/stac/extent.rb +39 -31
- data/lib/stac/file_writer.rb +31 -0
- data/lib/stac/hash_like.rb +74 -0
- data/lib/stac/item.rb +56 -22
- data/lib/stac/link.rb +51 -9
- data/lib/stac/object_resolver.rb +4 -4
- data/lib/stac/properties.rb +3 -1
- data/lib/stac/provider.rb +5 -1
- data/lib/stac/simple_http_client.rb +3 -0
- data/lib/stac/stac_object.rb +138 -36
- data/lib/stac/version.rb +1 -1
- data/lib/stac.rb +12 -1
- data/sig/stac/asset.rbs +1 -3
- data/sig/stac/catalog.rbs +28 -5
- data/sig/stac/collection.rbs +13 -5
- data/sig/stac/common_metadata.rbs +2 -2
- data/sig/stac/errors.rbs +1 -4
- data/sig/stac/extension.rbs +12 -0
- data/sig/stac/extensions/electro_optical.rbs +40 -0
- data/sig/stac/extensions/projection.rbs +32 -0
- data/sig/stac/extensions/scientific_citation.rbs +38 -0
- data/sig/stac/extensions/view_geometry.rbs +22 -0
- data/sig/stac/extent.rbs +13 -16
- data/sig/stac/file_writer.rbs +13 -0
- data/sig/stac/hash_like.rbs +13 -0
- data/sig/stac/item.rbs +16 -7
- data/sig/stac/link.rbs +20 -12
- data/sig/stac/object_resolver.rbs +2 -2
- data/sig/stac/properties.rbs +1 -3
- data/sig/stac/provider.rbs +2 -3
- data/sig/stac/simple_http_client.rbs +3 -0
- data/sig/stac/stac_object.rbs +33 -10
- data/stac.gemspec +1 -1
- metadata +18 -3
data/lib/stac/stac_object.rb
CHANGED
@@ -1,49 +1,67 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'json'
|
4
3
|
require_relative 'errors'
|
4
|
+
require_relative 'file_writer'
|
5
|
+
require_relative 'hash_like'
|
5
6
|
require_relative 'link'
|
6
7
|
require_relative 'spec_version'
|
7
8
|
|
8
9
|
module STAC
|
9
|
-
#
|
10
|
+
# Raised when a STAC object does not have rel="self" link HREF.
|
11
|
+
class NoSelfHrefError < Error
|
12
|
+
attr_reader :stac_object
|
13
|
+
|
14
|
+
def initialize(msg = nil, stac_object:)
|
15
|
+
super(msg)
|
16
|
+
@stac_object = stac_object
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# Base class for \STAC objects (i.e. Catalog, Collection, and Item).
|
10
21
|
class STACObject
|
22
|
+
include HashLike
|
23
|
+
|
24
|
+
@@extendables = {} # rubocop:disable Style/ClassVars
|
25
|
+
|
26
|
+
# Returns available extension modules.
|
27
|
+
def self.extendables
|
28
|
+
@@extendables.values.uniq
|
29
|
+
end
|
30
|
+
|
31
|
+
# Adds the given extension module to .extendables.
|
32
|
+
def self.add_extendable(extendable)
|
33
|
+
@@extendables[extendable.identifier] = extendable
|
34
|
+
self
|
35
|
+
end
|
36
|
+
|
11
37
|
class << self
|
12
|
-
|
38
|
+
attr_reader :type # :nodoc:
|
13
39
|
|
14
40
|
# Base method to deserialize shared fields from a Hash.
|
15
41
|
#
|
16
42
|
# Raises ArgumentError when any required fields are missing.
|
17
43
|
def from_hash(hash)
|
18
|
-
|
44
|
+
h = hash.transform_keys(&:to_sym)
|
45
|
+
raise TypeError, "type field is not '#{type}': #{h[:type]}" if h.fetch(:type) != type
|
19
46
|
|
20
|
-
|
21
|
-
transformed[:links] = transformed.fetch(:links).map { |link| Link.from_hash(link) }
|
22
|
-
new(**transformed)
|
23
|
-
rescue KeyError => e
|
24
|
-
raise ArgumentError, "required field not found: #{e.key}"
|
47
|
+
new(**h.except(:type, :stac_version))
|
25
48
|
end
|
26
49
|
end
|
27
50
|
|
28
|
-
attr_accessor :stac_extensions, :extra
|
29
|
-
|
30
51
|
# HTTP Client to fetch objects from HTTP HREF links.
|
31
52
|
attr_accessor :http_client
|
32
53
|
|
33
|
-
attr_reader :links
|
54
|
+
attr_reader :stac_extensions, :links
|
34
55
|
|
35
|
-
def initialize(links
|
56
|
+
def initialize(links: [], stac_extensions: [], **extra)
|
36
57
|
@links = []
|
37
58
|
links.each do |link|
|
38
|
-
add_link(link) # to set `owner`
|
59
|
+
add_link(**link.transform_keys(&:to_sym)) # to set `owner`
|
39
60
|
end
|
40
61
|
@stac_extensions = stac_extensions
|
41
62
|
@extra = extra.transform_keys(&:to_s)
|
42
63
|
@http_client = STAC.default_http_client
|
43
|
-
|
44
|
-
|
45
|
-
def type
|
46
|
-
self.class.type
|
64
|
+
apply_extensions!
|
47
65
|
end
|
48
66
|
|
49
67
|
# Serializes self to a Hash.
|
@@ -51,34 +69,41 @@ module STAC
|
|
51
69
|
{
|
52
70
|
'type' => type,
|
53
71
|
'stac_version' => SPEC_VERSION,
|
54
|
-
'stac_extensions' => stac_extensions,
|
72
|
+
'stac_extensions' => stac_extensions.empty? ? nil : stac_extensions,
|
55
73
|
'links' => links.map(&:to_h),
|
56
74
|
}.merge(extra).compact
|
57
75
|
end
|
58
76
|
|
59
|
-
|
60
|
-
|
61
|
-
|
77
|
+
def deep_dup
|
78
|
+
super.tap do |obj|
|
79
|
+
obj.http_client = http_client.dup
|
80
|
+
end
|
62
81
|
end
|
63
82
|
|
64
|
-
|
65
|
-
|
66
|
-
link.owner = self
|
67
|
-
links << link
|
83
|
+
def type
|
84
|
+
self.class.type.to_s
|
68
85
|
end
|
69
86
|
|
70
|
-
#
|
71
|
-
def
|
72
|
-
|
87
|
+
# Returns extended extension modules.
|
88
|
+
def extended
|
89
|
+
@extended ||= []
|
73
90
|
end
|
74
91
|
|
75
|
-
# Adds
|
92
|
+
# Adds the given extension identifier to #stac_extensions.
|
76
93
|
#
|
77
|
-
# When
|
78
|
-
def
|
79
|
-
|
80
|
-
|
81
|
-
|
94
|
+
# When the given argument is extendable, the item extends the module.
|
95
|
+
def add_extension(extension)
|
96
|
+
case extension
|
97
|
+
when Extension
|
98
|
+
stac_extensions << extension.identifier
|
99
|
+
apply_extension!(extension)
|
100
|
+
else
|
101
|
+
stac_extensions << extension
|
102
|
+
if (extension = @@extendables[extension]) && extension.scope.include?(self.class)
|
103
|
+
apply_extension!(extension)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
self
|
82
107
|
end
|
83
108
|
|
84
109
|
# Returns a link matching the arguments.
|
@@ -92,9 +117,86 @@ module STAC
|
|
92
117
|
end
|
93
118
|
end
|
94
119
|
|
120
|
+
# Adds a link with setting Link#owner as self.
|
121
|
+
#
|
122
|
+
# Raises ArgumentError when both target and href are not given.
|
123
|
+
def add_link(target = nil, rel:, href: nil, type: nil, title: nil, **extra)
|
124
|
+
raise ArgumentError, 'target or href must be given' if target.nil? && href.nil?
|
125
|
+
|
126
|
+
link = Link.new(target, rel: rel, href: href, type: type, title: title, **extra)
|
127
|
+
link.owner = self
|
128
|
+
links << link
|
129
|
+
self
|
130
|
+
end
|
131
|
+
|
132
|
+
# Reterns HREF of the rel="self" link.
|
133
|
+
def self_href
|
134
|
+
find_link(rel: 'self')&.href
|
135
|
+
end
|
136
|
+
|
137
|
+
# Overwrites rel="self" link with the given HREF.
|
138
|
+
#
|
139
|
+
# When any ref="self" links already exist, removes them.
|
140
|
+
def self_href=(absolute_href)
|
141
|
+
remove_links(rel: 'self')
|
142
|
+
add_link(rel: 'self', href: absolute_href, type: 'application/json')
|
143
|
+
end
|
144
|
+
|
145
|
+
# Returns a rel="root" link as a catalog/collection object if it exists.
|
146
|
+
def root
|
147
|
+
find_link(rel: 'root')&.target
|
148
|
+
end
|
149
|
+
|
150
|
+
# Overwrites rel="root" link.
|
151
|
+
def root=(catalog)
|
152
|
+
remove_links(rel: 'root')
|
153
|
+
add_link(catalog, rel: 'root', type: 'application/json', title: catalog.title) if catalog
|
154
|
+
end
|
155
|
+
|
156
|
+
# Returns a rel="parent" link as a catalog/collection object if it exists.
|
157
|
+
def parent
|
158
|
+
find_link(rel: 'parent')&.target
|
159
|
+
end
|
160
|
+
|
161
|
+
# Overwrites rel="parent" link.
|
162
|
+
def parent=(catalog)
|
163
|
+
remove_links(rel: 'parent')
|
164
|
+
add_link(catalog, rel: 'parent', type: 'application/json', title: catalog.title) if catalog
|
165
|
+
end
|
166
|
+
|
167
|
+
# Writes self on `dest` with the given writer.
|
168
|
+
#
|
169
|
+
# The default writer is a FileWriter.
|
170
|
+
def save(dest = nil, writer: FileWriter.new)
|
171
|
+
writer.write(to_h, dest: dest || self_href!)
|
172
|
+
end
|
173
|
+
|
174
|
+
protected
|
175
|
+
|
176
|
+
def self_href!
|
177
|
+
self_href or raise NoSelfHrefError.new('no rel="self" link href', stac_object: self)
|
178
|
+
end
|
179
|
+
|
95
180
|
private
|
96
181
|
|
97
|
-
def
|
182
|
+
def extensions
|
183
|
+
stac_extensions
|
184
|
+
.map { |extension_id| @@extendables[extension_id] }
|
185
|
+
.compact
|
186
|
+
.select { |extension| extension.scope.include?(self.class) }
|
187
|
+
end
|
188
|
+
|
189
|
+
def apply_extensions!
|
190
|
+
extensions.each do |extension|
|
191
|
+
apply_extension!(extension)
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
def apply_extension!(extension)
|
196
|
+
extended << extension
|
197
|
+
end
|
198
|
+
|
199
|
+
def remove_links(rel:)
|
98
200
|
links.reject! { |link| link.rel == rel }
|
99
201
|
end
|
100
202
|
end
|
data/lib/stac/version.rb
CHANGED
data/lib/stac.rb
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative 'stac/simple_http_client'
|
4
3
|
require_relative 'stac/object_resolver'
|
4
|
+
require_relative 'stac/simple_http_client'
|
5
|
+
require_relative 'stac/stac_object'
|
6
|
+
require_relative 'stac/extensions/electro_optical'
|
7
|
+
require_relative 'stac/extensions/projection'
|
8
|
+
require_relative 'stac/extensions/scientific_citation'
|
9
|
+
require_relative 'stac/extensions/view_geometry'
|
5
10
|
require_relative 'stac/version'
|
6
11
|
|
7
12
|
# Gem namespace.
|
@@ -27,4 +32,10 @@ module STAC
|
|
27
32
|
end
|
28
33
|
|
29
34
|
self.default_http_client = SimpleHTTPClient.new
|
35
|
+
|
36
|
+
STACObject
|
37
|
+
.add_extendable(Extensions::ElectroOptical)
|
38
|
+
.add_extendable(Extensions::Projection)
|
39
|
+
.add_extendable(Extensions::ScientificCitation)
|
40
|
+
.add_extendable(Extensions::ViewGeometry)
|
30
41
|
end
|
data/sig/stac/asset.rbs
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
module STAC
|
2
2
|
class Asset
|
3
|
+
include HashLike
|
3
4
|
include CommonMetadata
|
4
5
|
|
5
6
|
def self.from_hash: (Hash[String, untyped] hash) -> Asset
|
@@ -9,12 +10,9 @@ module STAC
|
|
9
10
|
attr_accessor description: String?
|
10
11
|
attr_accessor type: String?
|
11
12
|
attr_accessor roles: Array[String]?
|
12
|
-
attr_accessor extra: Hash[String, untyped]
|
13
13
|
|
14
14
|
def initialize: (
|
15
15
|
href: String, ?title: String?, ?description: String?, ?type: String?, ?roles: Array[String]?, **untyped
|
16
16
|
) -> void
|
17
|
-
|
18
|
-
def to_h: -> Hash[String, untyped]
|
19
17
|
end
|
20
18
|
end
|
data/sig/stac/catalog.rbs
CHANGED
@@ -1,21 +1,44 @@
|
|
1
1
|
module STAC
|
2
2
|
class Catalog < STACObject
|
3
|
-
def self.from_hash: (Hash[String, untyped] hash) -> Catalog
|
3
|
+
def self.from_hash: (Hash[String | Symbol, untyped] hash) -> Catalog
|
4
|
+
def self.root: (
|
5
|
+
id: String,
|
6
|
+
description: String,
|
7
|
+
href: String,
|
8
|
+
?links: Array[Hash[String, String]],
|
9
|
+
?title: String?,
|
10
|
+
?stac_extensions: Array[String],
|
11
|
+
**untyped
|
12
|
+
) -> Catalog
|
4
13
|
|
5
14
|
attr_accessor id: String
|
6
15
|
attr_accessor description: String
|
7
16
|
attr_accessor title: String?
|
8
17
|
|
9
18
|
def initialize: (
|
10
|
-
id: String,
|
19
|
+
id: String,
|
20
|
+
description: String,
|
21
|
+
?links: Array[Hash[String, String]],
|
22
|
+
?title: String?,
|
23
|
+
?stac_extensions: Array[String],
|
24
|
+
**untyped
|
11
25
|
) -> void
|
12
26
|
|
13
|
-
def
|
14
|
-
def
|
27
|
+
def children: -> Enumerator::Lazy[Catalog, void]
|
28
|
+
def all_children: -> Enumerator::Lazy[Catalog, void]
|
15
29
|
def collections: -> Enumerator::Lazy[Collection, void]
|
16
|
-
def
|
30
|
+
def all_collections: -> Enumerator::Lazy[Collection, void]
|
31
|
+
def find_child: (String id, ?recursive: bool) -> Catalog?
|
17
32
|
def items: -> Enumerator::Lazy[Item, void]
|
18
33
|
def all_items: -> Enumerator::Lazy[Item, void]
|
19
34
|
def find_item: (String id, ?recursive: bool) -> Item?
|
35
|
+
def add_child: (Catalog catalog, ?href: String, ?title: String?) -> self
|
36
|
+
def add_item: (Item item, ?href: String, ?title: String?) -> self
|
37
|
+
def export: (?String? dest_dir, ?writer: _Writer) -> void
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def child_links: -> Array[Link]
|
42
|
+
def item_links: -> Array[Link]
|
20
43
|
end
|
21
44
|
end
|
data/sig/stac/collection.rbs
CHANGED
@@ -1,29 +1,37 @@
|
|
1
1
|
module STAC
|
2
2
|
class Collection < Catalog
|
3
|
-
def self.from_hash: (Hash[String, untyped] hash) -> Collection
|
3
|
+
def self.from_hash: (Hash[String | Symbol, untyped] hash) -> Collection
|
4
4
|
|
5
5
|
attr_accessor license: String
|
6
6
|
attr_accessor extent: Extent
|
7
7
|
attr_accessor keywords: Array[String]?
|
8
8
|
attr_accessor providers: Array[Provider]?
|
9
9
|
attr_accessor summaries: Hash[String, untyped]?
|
10
|
-
|
10
|
+
attr_reader assets: Hash[String, Asset]?
|
11
11
|
|
12
12
|
def initialize: (
|
13
13
|
id: String,
|
14
14
|
description: String,
|
15
|
-
links: Array[Link],
|
16
15
|
license: String,
|
17
16
|
extent: Extent,
|
17
|
+
?links: Array[Hash[String, String]],
|
18
18
|
?title: String?,
|
19
19
|
?keywords: Array[String]?,
|
20
20
|
?providers: Array[Provider]?,
|
21
21
|
?summaries: Hash[String, untyped]?,
|
22
22
|
?assets: Hash[String, Asset]?,
|
23
|
-
?stac_extensions: Array[String]
|
23
|
+
?stac_extensions: Array[String],
|
24
24
|
**untyped
|
25
25
|
) -> void
|
26
26
|
|
27
|
-
def
|
27
|
+
def add_asset: (
|
28
|
+
key: String,
|
29
|
+
href: String,
|
30
|
+
?title: String?,
|
31
|
+
?description: String?,
|
32
|
+
?type: String?,
|
33
|
+
?roles: Array[String]?,
|
34
|
+
**untyped
|
35
|
+
) -> self
|
28
36
|
end
|
29
37
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module STAC
|
2
2
|
module CommonMetadata
|
3
|
-
|
3
|
+
attr_reader extra: Hash[String, untyped]
|
4
4
|
|
5
5
|
def title: -> String?
|
6
6
|
def title=: (String) -> void
|
@@ -19,7 +19,7 @@ module STAC
|
|
19
19
|
def license: -> String?
|
20
20
|
def license=: (String) -> void
|
21
21
|
def providers: -> Array[Provider]
|
22
|
-
def providers=: (Array[Provider]) -> void
|
22
|
+
def providers=: (Array[Provider | Hash[String, untyped]]) -> void
|
23
23
|
def platform: -> String?
|
24
24
|
def platform=: (String) -> void
|
25
25
|
def instruments: -> Array[String]?
|
data/sig/stac/errors.rbs
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
module STAC
|
2
|
+
module Extensions
|
3
|
+
module ElectroOptical
|
4
|
+
extend Extension
|
5
|
+
|
6
|
+
module Properties
|
7
|
+
attr_reader extra: Hash[String, untyped]
|
8
|
+
|
9
|
+
def eo_bands: -> Array[Band]
|
10
|
+
def eo_bands=: (Array[Hash[String, untyped] | Band]) -> void
|
11
|
+
def eo_cloud_cover: -> Numeric?
|
12
|
+
def eo_cloud_cover=: (Numeric) -> void
|
13
|
+
end
|
14
|
+
|
15
|
+
module Asset
|
16
|
+
include Properties
|
17
|
+
end
|
18
|
+
|
19
|
+
class Band
|
20
|
+
attr_reader raw_hash: Hash[String, untyped]
|
21
|
+
|
22
|
+
def initialize: (Hash[String, untyped] raw_hash) -> void
|
23
|
+
|
24
|
+
def to_h: -> Hash[String, untyped]
|
25
|
+
def name: -> String?
|
26
|
+
def name=: (String) -> void
|
27
|
+
def common_name: -> String?
|
28
|
+
def common_name=: (String) -> void
|
29
|
+
def description: -> String?
|
30
|
+
def description=: (String) -> void
|
31
|
+
def center_wavelength: -> Numeric?
|
32
|
+
def center_wavelength=: (Numeric) -> void
|
33
|
+
def full_width_half_max: -> Numeric?
|
34
|
+
def full_width_half_max=: (Numeric) -> void
|
35
|
+
def solar_illumination: -> Numeric?
|
36
|
+
def solar_illumination=: (Numeric) -> void
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module STAC
|
2
|
+
module Extensions
|
3
|
+
module Projection
|
4
|
+
extend Extension
|
5
|
+
|
6
|
+
module Properties
|
7
|
+
attr_reader extra: Hash[String, untyped]
|
8
|
+
|
9
|
+
def proj_epsg: -> Numeric?
|
10
|
+
def proj_epsg=: (Numeric) -> void
|
11
|
+
def proj_wkt2: -> String?
|
12
|
+
def proj_wkt2=: (String) -> void
|
13
|
+
def proj_projjson: -> Hash[String, untyped]?
|
14
|
+
def proj_projjson=: (Hash[String, untyped]) -> void
|
15
|
+
def proj_geometry: -> Hash[String, untyped]?
|
16
|
+
def proj_geometry=: (Hash[String, untyped]) -> void
|
17
|
+
def proj_bbox: -> Array[Numeric]?
|
18
|
+
def proj_bbox=: (Array[Numeric]) -> void
|
19
|
+
def proj_centroid: -> {'lat' => Numeric, 'lon' => Numeric}?
|
20
|
+
def proj_centroid=: ({'lat' => Numeric, 'lon' => Numeric}) -> void
|
21
|
+
def proj_shape: -> Array[Integer]?
|
22
|
+
def proj_shape=: (Array[Integer]) -> void
|
23
|
+
def proj_transform: -> Array[Numeric]?
|
24
|
+
def proj_transform=: (Array[Numeric]) -> void
|
25
|
+
end
|
26
|
+
|
27
|
+
module Asset
|
28
|
+
include Properties
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module STAC
|
2
|
+
module Extensions
|
3
|
+
module ScientificCitation
|
4
|
+
extend Extension
|
5
|
+
|
6
|
+
module Properties
|
7
|
+
attr_reader extra: Hash[String, untyped]
|
8
|
+
|
9
|
+
def sci_doi: -> String?
|
10
|
+
def sci_doi=: (String) -> void
|
11
|
+
def sci_citation: -> String?
|
12
|
+
def sci_citation=: (String) -> void
|
13
|
+
def sci_publications: -> Array[Publication]
|
14
|
+
def sci_publications=: (Array[Hash[String, String] | Publication]) -> void
|
15
|
+
end
|
16
|
+
|
17
|
+
module Asset
|
18
|
+
include Properties
|
19
|
+
end
|
20
|
+
|
21
|
+
module Collection
|
22
|
+
include Properties
|
23
|
+
end
|
24
|
+
|
25
|
+
class Publication
|
26
|
+
attr_reader raw_hash: Hash[String, String]
|
27
|
+
|
28
|
+
def initialize: (Hash[String, String] raw_hash) -> void
|
29
|
+
|
30
|
+
def to_h: -> Hash[String, String]
|
31
|
+
def doi: -> String?
|
32
|
+
def doi=: (String) -> void
|
33
|
+
def citation: -> String?
|
34
|
+
def citation=: (String) -> void
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module STAC
|
2
|
+
module Extensions
|
3
|
+
module ViewGeometry
|
4
|
+
extend Extension
|
5
|
+
|
6
|
+
module Properties
|
7
|
+
attr_reader extra: Hash[String, untyped]
|
8
|
+
|
9
|
+
def view_off_nadir: -> Numeric?
|
10
|
+
def view_off_nadir=: (Numeric) -> void
|
11
|
+
def view_incidence_angle: -> Numeric?
|
12
|
+
def view_incidence_angle=: (Numeric) -> void
|
13
|
+
def view_azimuth: -> Numeric?
|
14
|
+
def view_azimuth=: (Numeric) -> void
|
15
|
+
def view_sun_azimuth: -> Numeric?
|
16
|
+
def view_sun_azimuth=: (Numeric) -> void
|
17
|
+
def view_sun_elevation: -> Numeric?
|
18
|
+
def view_sun_elevation=: (Numeric) -> void
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/sig/stac/extent.rbs
CHANGED
@@ -1,35 +1,32 @@
|
|
1
1
|
module STAC
|
2
2
|
class Extent
|
3
|
+
include HashLike
|
4
|
+
|
5
|
+
def self.from_hash: (Hash[String, untyped] hash) -> Extent
|
6
|
+
|
7
|
+
attr_accessor spatial: Spatial
|
8
|
+
attr_accessor temporal: Temporal
|
9
|
+
|
10
|
+
def initialize: (spatial: Spatial, temporal: Temporal, **untyped) -> void
|
11
|
+
|
3
12
|
class Spatial
|
13
|
+
include HashLike
|
14
|
+
|
4
15
|
def self.from_hash: (Hash[String, untyped] hash) -> Spatial
|
5
16
|
|
6
17
|
attr_accessor bbox: Array[Array[Numeric]]
|
7
|
-
attr_accessor extra: Hash[String, untyped]
|
8
18
|
|
9
19
|
def initialize: (bbox: Array[Array[Numeric]], **untyped) -> void
|
10
|
-
|
11
|
-
def to_h: -> Hash[String, untyped]
|
12
20
|
end
|
13
21
|
|
14
22
|
class Temporal
|
23
|
+
include HashLike
|
24
|
+
|
15
25
|
def self.from_hash: (Hash[String, untyped] hash) -> Temporal
|
16
26
|
|
17
27
|
attr_accessor interval: Array[Array[String?]]
|
18
|
-
attr_accessor extra: Hash[String, untyped]
|
19
28
|
|
20
29
|
def initialize: (interval: Array[Array[String?]], **untyped) -> void
|
21
|
-
|
22
|
-
def to_h: -> Hash[String, untyped]
|
23
30
|
end
|
24
|
-
|
25
|
-
def self.from_hash: (Hash[String, untyped] hash) -> Extent
|
26
|
-
|
27
|
-
attr_accessor spatial: Spatial
|
28
|
-
attr_accessor temporal: Temporal
|
29
|
-
attr_accessor extra: Hash[String, untyped]
|
30
|
-
|
31
|
-
def initialize: (spatial: Spatial, temporal: Temporal, **untyped) -> void
|
32
|
-
|
33
|
-
def to_h: -> Hash[String, untyped]
|
34
31
|
end
|
35
32
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module STAC
|
2
|
+
class FileWriter
|
3
|
+
@hash_to_json: ^(Hash[String, untyped]) -> String
|
4
|
+
|
5
|
+
def initialize: (?hash_to_json: ^(Hash[String, untyped]) -> String) -> void
|
6
|
+
|
7
|
+
def write: (Hash[String, untyped], dest: String) -> void
|
8
|
+
end
|
9
|
+
|
10
|
+
interface _Writer
|
11
|
+
def write: (Hash[String, untyped], dest: String) -> void
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module STAC
|
2
|
+
module HashLike
|
3
|
+
attr_reader extra: Hash[String, untyped]
|
4
|
+
|
5
|
+
def []: (String | Symbol key) -> untyped
|
6
|
+
def []=: (String | Symbol key, untyped value) -> untyped
|
7
|
+
def update: (**untyped) -> self
|
8
|
+
def to_hash: -> Hash[String, untyped]
|
9
|
+
def to_h: -> Hash[String, untyped]
|
10
|
+
def to_json: -> String
|
11
|
+
def deep_dup: -> self
|
12
|
+
end
|
13
|
+
end
|
data/sig/stac/item.rbs
CHANGED
@@ -1,28 +1,37 @@
|
|
1
1
|
module STAC
|
2
2
|
class Item < STACObject
|
3
|
-
def self.from_hash: (Hash[String, untyped] hash) -> Item
|
3
|
+
def self.from_hash: (Hash[String | Symbol, untyped] hash) -> Item
|
4
4
|
|
5
5
|
attr_accessor id: String
|
6
6
|
attr_accessor geometry: Hash[String, untyped]?
|
7
|
-
attr_accessor properties: Properties
|
8
|
-
attr_accessor assets: Hash[String, Asset]
|
9
7
|
attr_accessor bbox: Array[Numeric]?
|
10
8
|
attr_accessor collection_id: String?
|
11
9
|
|
10
|
+
attr_reader properties: Properties
|
11
|
+
attr_reader assets: Hash[String, Asset]
|
12
|
+
|
12
13
|
def initialize: (
|
13
14
|
id: String,
|
14
15
|
geometry: Hash[String, untyped]?,
|
15
16
|
properties: Properties,
|
16
|
-
links: Array[
|
17
|
-
assets: Hash[String, Asset],
|
17
|
+
?links: Array[Hash[String, String]],
|
18
|
+
?assets: Hash[String, Asset],
|
18
19
|
?bbox: Array[Numeric]?,
|
19
20
|
?collection: String | Collection | nil,
|
20
|
-
?stac_extensions: Array[String]
|
21
|
+
?stac_extensions: Array[String],
|
21
22
|
**untyped
|
22
23
|
) -> void
|
23
24
|
|
24
|
-
def datetime: -> Time?
|
25
25
|
def collection: -> Collection?
|
26
26
|
def collection=: (Collection collection) -> void
|
27
|
+
def add_asset: (
|
28
|
+
key: String,
|
29
|
+
href: String,
|
30
|
+
?title: String?,
|
31
|
+
?description: String?,
|
32
|
+
?type: String?,
|
33
|
+
?roles: Array[String]?,
|
34
|
+
**untyped
|
35
|
+
) -> self
|
27
36
|
end
|
28
37
|
end
|