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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 70efb98c76757b8d4b76558606db71124568bf1d
4
- data.tar.gz: cab7e5b2fae977d869bf2294eb5c6e2967bd808f
3
+ metadata.gz: 8779fb51c195879850b9e6ee92ed8035ebedf10f
4
+ data.tar.gz: 2e22c99ec989b7a4a8991359ab496f7974809706
5
5
  SHA512:
6
- metadata.gz: 08e1a4b69a8cc91a96863e6e3e7bbc4732885b774b65e8eefd3ddfc02056765f819ac3bc952b67f9e9340cf544fbca796a592687214a3f63329ad82e0916ffb5
7
- data.tar.gz: e176254a3cf5d3956f0cd37a2783e137b5dc6f672c8eb420b6e9b69405d3e0a11c7b037b474e61768f96f4b906f4a27ce18c09d511144c21c1b1270429a2b3ee
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
- submitJobUrl = 'https://logistics.arcgis.com/arcgis/rest/services/World/VehicleRoutingProblem/GPServer/SolveVehicleRoutingProblem/submitJob'
53
-
54
- params = {
55
- orders: ordersObj.to_json,
56
- depots: depotsObj.to_json,
57
- routes: routesObj.to_json,
58
- default_date: (Time.now.to_f * 1000).to_i,
59
- # default_date: 1441933200000,
60
- token: @token,
61
- f: 'json',
62
- time_units: 'Seconds',
63
- distance_units: 'Meters'
64
- }
65
-
66
- res = Net::HTTP.post_form(URI(submitJobUrl), params)
67
-
68
- @jobId = JSON.parse(res.body)["jobId"]
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
- urlWithJobId = 'https://logistics.arcgis.com/arcgis/rest/services/World/VehicleRoutingProblem/GPServer/SolveVehicleRoutingProblem/jobs/'+@jobId
132
- res = Net::HTTP.post_form URI(urlWithJobId),
133
- token: @token,
134
- returnMessages: true,
135
- f: 'json'
136
-
137
- status = JSON.parse(res.body)["jobStatus"]
138
- # puts res.body
139
- # puts
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
- urlWithJobId = 'https://logistics.arcgis.com/arcgis/rest/services/World/VehicleRoutingProblem/GPServer/SolveVehicleRoutingProblem/jobs/'+@jobId+'/results/out_routes'
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
- res = Net::HTTP.post_form URI(urlWithJobId),
158
- token: @token,
159
- f: 'json'
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
- urlWithJobId = 'https://logistics.arcgis.com/arcgis/rest/services/World/VehicleRoutingProblem/GPServer/SolveVehicleRoutingProblem/jobs/'+@jobId+'/results/out_stops'
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
- res = Net::HTTP.post_form URI(urlWithJobId),
181
- token: @token,
182
- f: 'json'
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)
@@ -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 = {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arcgis_vrps
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3.2
4
+ version: 0.0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kiong