arcgis_vrps 0.0.3.2 → 0.0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/arcgis_vrps.rb +67 -34
- data/lib/arcgis_vrps/orders.rb +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8779fb51c195879850b9e6ee92ed8035ebedf10f
|
4
|
+
data.tar.gz: 2e22c99ec989b7a4a8991359ab496f7974809706
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7e6d604d849b0b4db04a0e9a8bda53088cd369518593cce74c97edd89f532669ed68adf507f9171c27350377676c10f35ed0c6a8b9a9f595d7a9639688a364f
|
7
|
+
data.tar.gz: f62618e0a569635b777909c9822125888f438f088c7724b315d18211ff833e58c361facad2b143d0784a87c66b16dbaede7a3352e1baee2527e9e28702a094f2
|
data/lib/arcgis_vrps.rb
CHANGED
@@ -49,24 +49,30 @@ class Arcgis_Vrps
|
|
49
49
|
|
50
50
|
t1 = Time.now
|
51
51
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
52
|
+
url = "https://logistics.arcgis.com/arcgis/rest/services/World/VehicleRoutingProblem/GPServer/SolveVehicleRoutingProblem/submitJob"
|
53
|
+
escaped_url = URI.encode(url)
|
54
|
+
uri = URI.parse(escaped_url)
|
55
|
+
req = Net::HTTP::Post.new(uri.to_s)
|
56
|
+
|
57
|
+
# Expiration is set to 20160 minutes = 2 weeks
|
58
|
+
req.set_form_data(
|
59
|
+
orders: ordersObj.to_json,
|
60
|
+
depots: depotsObj.to_json,
|
61
|
+
routes: routesObj.to_json,
|
62
|
+
default_date: (Time.now.to_f * 1000).to_i,
|
63
|
+
# default_date: 1441933200000,
|
64
|
+
token: @token,
|
65
|
+
f: 'json',
|
66
|
+
time_units: 'Seconds',
|
67
|
+
distance_units: 'Meters'
|
68
|
+
)
|
69
69
|
|
70
|
+
http = Net::HTTP.new(uri.hostname, uri.port)
|
71
|
+
http.use_ssl = true
|
72
|
+
|
73
|
+
res = http.request(req)
|
74
|
+
|
75
|
+
@jobId = JSON.parse(res.body)['jobId']
|
70
76
|
|
71
77
|
if @jobId.nil?
|
72
78
|
raise "Error! #{res.body}"
|
@@ -128,15 +134,24 @@ class Arcgis_Vrps
|
|
128
134
|
end
|
129
135
|
|
130
136
|
def getJobStatus
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
137
|
+
url = "https://logistics.arcgis.com/arcgis/rest/services/World/VehicleRoutingProblem/GPServer/SolveVehicleRoutingProblem/jobs/"+@jobId
|
138
|
+
escaped_url = URI.encode(url)
|
139
|
+
uri = URI.parse(escaped_url)
|
140
|
+
req = Net::HTTP::Post.new(uri.to_s)
|
141
|
+
|
142
|
+
req.set_form_data(
|
143
|
+
token: @token,
|
144
|
+
returnMessages: true,
|
145
|
+
f: 'json'
|
146
|
+
)
|
147
|
+
|
148
|
+
http = Net::HTTP.new(uri.hostname, uri.port)
|
149
|
+
http.use_ssl = true
|
150
|
+
|
151
|
+
res = http.request(req)
|
152
|
+
|
153
|
+
status = JSON.parse(res.body)['jobStatus']
|
154
|
+
|
140
155
|
|
141
156
|
if status == "esriJobSucceeded"
|
142
157
|
return res.body
|
@@ -152,11 +167,20 @@ class Arcgis_Vrps
|
|
152
167
|
@jobId = jobId
|
153
168
|
end
|
154
169
|
|
155
|
-
|
170
|
+
url = 'https://logistics.arcgis.com/arcgis/rest/services/World/VehicleRoutingProblem/GPServer/SolveVehicleRoutingProblem/jobs/'+@jobId+'/results/out_routes'
|
171
|
+
escaped_url = URI.encode(url)
|
172
|
+
uri = URI.parse(escaped_url)
|
173
|
+
req = Net::HTTP::Post.new(uri.to_s)
|
174
|
+
|
175
|
+
req.set_form_data(
|
176
|
+
token: @token,
|
177
|
+
f: 'json'
|
178
|
+
)
|
156
179
|
|
157
|
-
|
158
|
-
|
159
|
-
|
180
|
+
http = Net::HTTP.new(uri.hostname, uri.port)
|
181
|
+
http.use_ssl = true
|
182
|
+
|
183
|
+
res = http.request(req)
|
160
184
|
|
161
185
|
# We return the entire string is because it have meta data about the geometry type, spatial reference, etc
|
162
186
|
routesFeatures = JSON.parse(res.body)
|
@@ -175,11 +199,20 @@ class Arcgis_Vrps
|
|
175
199
|
@jobId = jobId
|
176
200
|
end
|
177
201
|
|
178
|
-
|
202
|
+
url = 'https://logistics.arcgis.com/arcgis/rest/services/World/VehicleRoutingProblem/GPServer/SolveVehicleRoutingProblem/jobs/'+@jobId+'/results/out_stops'
|
203
|
+
escaped_url = URI.encode(url)
|
204
|
+
uri = URI.parse(escaped_url)
|
205
|
+
req = Net::HTTP::Post.new(uri.to_s)
|
206
|
+
|
207
|
+
req.set_form_data(
|
208
|
+
token: @token,
|
209
|
+
f: 'json'
|
210
|
+
)
|
179
211
|
|
180
|
-
|
181
|
-
|
182
|
-
|
212
|
+
http = Net::HTTP.new(uri.hostname, uri.port)
|
213
|
+
http.use_ssl = true
|
214
|
+
|
215
|
+
res = http.request(req)
|
183
216
|
|
184
217
|
# We return the entire string is because it have meta data about the geometry type, spatial reference, etc
|
185
218
|
ordersFeatures = JSON.parse(res.body)
|
data/lib/arcgis_vrps/orders.rb
CHANGED
@@ -30,6 +30,7 @@ class Orders
|
|
30
30
|
|
31
31
|
# Get orders attribute object from the param passed in
|
32
32
|
# timeWindow* refers to the time that the service
|
33
|
+
# serviceTime specify how much time can be spent there
|
33
34
|
def getOrderAttributeObj (orderName, serviceTime, timeWindowStart1, timeWindowEnd1, maxViolationTime1)
|
34
35
|
if maxViolationTime1.nil?
|
35
36
|
orderAttributeObj = {
|