Skip to content

Commit 4877090

Browse files
committed
new constructor for AgroOptions
1 parent 8cade07 commit 4877090

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ using a set of simple asynchronous functions, for example:
5858
5959
func loadData() {
6060
let options = AgroOptions(polygon_id: "5f45273c734b52667be0bb1e",
61-
start: Date().addingTimeInterval(-60*60*24*20).utc,
62-
end: Date().utc)
61+
start: Date().addingTimeInterval(-60*60*24*20),
62+
end: Date())
6363

6464
agroProvider.getImagery(options: options) { imagery in
6565
if let sat = imagery?.first, let img = sat.image, let theUrl = img.ndvi {

Sources/AgroAPI/AgroProtocol.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,33 @@ public class AgroOptions {
133133
coverage_min: Double? = nil,
134134
clouds_max: Double? = nil,
135135
clouds_min: Double? = nil) {
136+
136137
self.polygon_id = polygon_id
137138
self.start = start
138139
self.end = end
140+
141+
self.resolution_min = resolution_min
142+
self.resolution_max = resolution_max
143+
self.type = type
144+
self.coverage_max = coverage_max
145+
self.coverage_min = coverage_min
146+
self.clouds_max = clouds_max
147+
self.clouds_min = clouds_min
148+
}
149+
150+
public init(polygon_id: String, start: Date, end: Date,
151+
resolution_min: Int? = nil,
152+
resolution_max: Int? = nil,
153+
type: String? = nil,
154+
coverage_max: Double? = nil,
155+
coverage_min: Double? = nil,
156+
clouds_max: Double? = nil,
157+
clouds_min: Double? = nil) {
158+
159+
self.polygon_id = polygon_id
160+
self.start = Int(start.timeIntervalSince1970)
161+
self.end = Int(end.timeIntervalSince1970)
162+
139163
self.resolution_min = resolution_min
140164
self.resolution_max = resolution_max
141165
self.type = type

0 commit comments

Comments
 (0)