ruby_ptv_api 0.1.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.
Files changed (149) hide show
  1. checksums.yaml +7 -0
  2. data/.directory +11 -0
  3. data/.gitignore +14 -0
  4. data/.rspec +2 -0
  5. data/.travis.yml +4 -0
  6. data/Gemfile +4 -0
  7. data/Guardfile +36 -0
  8. data/README.md +46 -0
  9. data/Rakefile +11 -0
  10. data/bin/console +14 -0
  11. data/bin/setup +8 -0
  12. data/console_initializer.rb +5 -0
  13. data/lib/ruby_ptv_api/base.rb +105 -0
  14. data/lib/ruby_ptv_api/constant.rb +107 -0
  15. data/lib/ruby_ptv_api/id_manager.rb +17 -0
  16. data/lib/ruby_ptv_api/model/base.rb +12 -0
  17. data/lib/ruby_ptv_api/model/plain_point.rb +21 -0
  18. data/lib/ruby_ptv_api/model/point.rb +9 -0
  19. data/lib/ruby_ptv_api/model/x_locate/additional_field.rb +14 -0
  20. data/lib/ruby_ptv_api/model/x_locate/address.rb +24 -0
  21. data/lib/ruby_ptv_api/model/x_locate/address_response.rb +13 -0
  22. data/lib/ruby_ptv_api/model/x_locate/combined_transport_location.rb +13 -0
  23. data/lib/ruby_ptv_api/model/x_locate/combined_transport_response.rb +13 -0
  24. data/lib/ruby_ptv_api/model/x_locate/location.rb +11 -0
  25. data/lib/ruby_ptv_api/model/x_locate/result_address.rb +27 -0
  26. data/lib/ruby_ptv_api/model/x_locate/result_combined_transport.rb +30 -0
  27. data/lib/ruby_ptv_api/model/x_locate/sort_option.rb +14 -0
  28. data/lib/ruby_ptv_api/model/x_locate/suggestion.rb +12 -0
  29. data/lib/ruby_ptv_api/model/x_locate/suggestion_response.rb +13 -0
  30. data/lib/ruby_ptv_api/model/x_route/bounding_rectangle.rb +13 -0
  31. data/lib/ruby_ptv_api/model/x_route/brunnel_manoeuvre.rb +11 -0
  32. data/lib/ruby_ptv_api/model/x_route/cen_emission_configuration.rb +14 -0
  33. data/lib/ruby_ptv_api/model/x_route/cen_emission_conversion_factors.rb +11 -0
  34. data/lib/ruby_ptv_api/model/x_route/cen_emission_scenarios.rb +21 -0
  35. data/lib/ruby_ptv_api/model/x_route/cen_emissions.rb +8 -0
  36. data/lib/ruby_ptv_api/model/x_route/commuter_travel_trend.rb +10 -0
  37. data/lib/ruby_ptv_api/model/x_route/detail_description_option.rb +12 -0
  38. data/lib/ruby_ptv_api/model/x_route/dynamic_info.rb +12 -0
  39. data/lib/ruby_ptv_api/model/x_route/emission_type.rb +11 -0
  40. data/lib/ruby_ptv_api/model/x_route/emissions.rb +23 -0
  41. data/lib/ruby_ptv_api/model/x_route/encoded_geometry.rb +13 -0
  42. data/lib/ruby_ptv_api/model/x_route/exception_path.rb +17 -0
  43. data/lib/ruby_ptv_api/model/x_route/expansion_description.rb +12 -0
  44. data/lib/ruby_ptv_api/model/x_route/feauture_description.rb +11 -0
  45. data/lib/ruby_ptv_api/model/x_route/hbefa_type.rb +11 -0
  46. data/lib/ruby_ptv_api/model/x_route/klm.rb +10 -0
  47. data/lib/ruby_ptv_api/model/x_route/line_string.rb +11 -0
  48. data/lib/ruby_ptv_api/model/x_route/manoeuvre_attr.rb +17 -0
  49. data/lib/ruby_ptv_api/model/x_route/manoeuvre_group.rb +16 -0
  50. data/lib/ruby_ptv_api/model/x_route/norm_speed.rb +12 -0
  51. data/lib/ruby_ptv_api/model/x_route/plain_geometry_base.rb +8 -0
  52. data/lib/ruby_ptv_api/model/x_route/plain_line_string.rb +11 -0
  53. data/lib/ruby_ptv_api/model/x_route/reach.rb +12 -0
  54. data/lib/ruby_ptv_api/model/x_route/reach_info.rb +14 -0
  55. data/lib/ruby_ptv_api/model/x_route/result_list_options.rb +46 -0
  56. data/lib/ruby_ptv_api/model/x_route/route.rb +38 -0
  57. data/lib/ruby_ptv_api/model/x_route/route_info.rb +15 -0
  58. data/lib/ruby_ptv_api/model/x_route/route_list_segment.rb +39 -0
  59. data/lib/ruby_ptv_api/model/x_route/route_manoeuvre.rb +44 -0
  60. data/lib/ruby_ptv_api/model/x_route/routing_option.rb +12 -0
  61. data/lib/ruby_ptv_api/model/x_route/segment_attributes.rb +27 -0
  62. data/lib/ruby_ptv_api/model/x_route/speed_limit.rb +10 -0
  63. data/lib/ruby_ptv_api/model/x_route/speed_limits.rb +10 -0
  64. data/lib/ruby_ptv_api/model/x_route/template +16 -0
  65. data/lib/ruby_ptv_api/model/x_route/unique_geo_id.rb +13 -0
  66. data/lib/ruby_ptv_api/model/x_route/urban_manoeuvre.rb +10 -0
  67. data/lib/ruby_ptv_api/model/x_route/vehicle_option.rb +11 -0
  68. data/lib/ruby_ptv_api/model/x_route/via_type.rb +11 -0
  69. data/lib/ruby_ptv_api/model/x_route/way_point.rb +30 -0
  70. data/lib/ruby_ptv_api/model/x_route/waypoint_desc.rb +28 -0
  71. data/lib/ruby_ptv_api/model/x_tour/abstract_costs.rb +10 -0
  72. data/lib/ruby_ptv_api/model/x_tour/abstract_tour.rb +10 -0
  73. data/lib/ruby_ptv_api/model/x_tour/abstract_tour_point.rb +16 -0
  74. data/lib/ruby_ptv_api/model/x_tour/abstract_tour_result.rb +38 -0
  75. data/lib/ruby_ptv_api/model/x_tour/abstract_transport_order.rb +11 -0
  76. data/lib/ruby_ptv_api/model/x_tour/abstract_vehicle.rb +14 -0
  77. data/lib/ruby_ptv_api/model/x_tour/base_vehicle.rb +30 -0
  78. data/lib/ruby_ptv_api/model/x_tour/capacities.rb +11 -0
  79. data/lib/ruby_ptv_api/model/x_tour/chain.rb +14 -0
  80. data/lib/ruby_ptv_api/model/x_tour/chain_result.rb +20 -0
  81. data/lib/ruby_ptv_api/model/x_tour/costs.rb +10 -0
  82. data/lib/ruby_ptv_api/model/x_tour/depot.rb +8 -0
  83. data/lib/ruby_ptv_api/model/x_tour/distance_matrix_by_road.rb +12 -0
  84. data/lib/ruby_ptv_api/model/x_tour/distance_matrix_calculation.rb +9 -0
  85. data/lib/ruby_ptv_api/model/x_tour/driver_settings.rb +17 -0
  86. data/lib/ruby_ptv_api/model/x_tour/fleet.rb +15 -0
  87. data/lib/ruby_ptv_api/model/x_tour/goal_importance.rb +44 -0
  88. data/lib/ruby_ptv_api/model/x_tour/interval.rb +15 -0
  89. data/lib/ruby_ptv_api/model/x_tour/loading_area.rb +13 -0
  90. data/lib/ruby_ptv_api/model/x_tour/loading_function.rb +16 -0
  91. data/lib/ruby_ptv_api/model/x_tour/logistic_point.rb +19 -0
  92. data/lib/ruby_ptv_api/model/x_tour/maximum_tour_period_restriction.rb +10 -0
  93. data/lib/ruby_ptv_api/model/x_tour/plan.rb +13 -0
  94. data/lib/ruby_ptv_api/model/x_tour/plan_result.rb +21 -0
  95. data/lib/ruby_ptv_api/model/x_tour/planning_params.rb +23 -0
  96. data/lib/ruby_ptv_api/model/x_tour/product_incompatibility.rb +11 -0
  97. data/lib/ruby_ptv_api/model/x_tour/quantities.rb +9 -0
  98. data/lib/ruby_ptv_api/model/x_tour/quantity_dependent_periods.rb +9 -0
  99. data/lib/ruby_ptv_api/model/x_tour/regulations_base.rb +9 -0
  100. data/lib/ruby_ptv_api/model/x_tour/restrictions.rb +13 -0
  101. data/lib/ruby_ptv_api/model/x_tour/seconds_per_quantity_unit.rb +9 -0
  102. data/lib/ruby_ptv_api/model/x_tour/sequencing_params.rb +12 -0
  103. data/lib/ruby_ptv_api/model/x_tour/sequencing_plan.rb +13 -0
  104. data/lib/ruby_ptv_api/model/x_tour/sequencing_plan_result.rb +16 -0
  105. data/lib/ruby_ptv_api/model/x_tour/sequencing_tour.rb +13 -0
  106. data/lib/ruby_ptv_api/model/x_tour/sequencing_tour_point.rb +16 -0
  107. data/lib/ruby_ptv_api/model/x_tour/sequencing_tour_result.rb +38 -0
  108. data/lib/ruby_ptv_api/model/x_tour/sequencing_transport_depot.rb +19 -0
  109. data/lib/ruby_ptv_api/model/x_tour/sequencing_transport_order.rb +9 -0
  110. data/lib/ruby_ptv_api/model/x_tour/sequencing_vehicle.rb +8 -0
  111. data/lib/ruby_ptv_api/model/x_tour/standard_params.rb +22 -0
  112. data/lib/ruby_ptv_api/model/x_tour/total_costs.rb +10 -0
  113. data/lib/ruby_ptv_api/model/x_tour/tour.rb +26 -0
  114. data/lib/ruby_ptv_api/model/x_tour/tour_event.rb +14 -0
  115. data/lib/ruby_ptv_api/model/x_tour/tour_point.rb +10 -0
  116. data/lib/ruby_ptv_api/model/x_tour/tour_point_result.rb +28 -0
  117. data/lib/ruby_ptv_api/model/x_tour/tour_restrictions.rb +13 -0
  118. data/lib/ruby_ptv_api/model/x_tour/tour_result.rb +17 -0
  119. data/lib/ruby_ptv_api/model/x_tour/tour_violations.rb +10 -0
  120. data/lib/ruby_ptv_api/model/x_tour/trailer.rb +10 -0
  121. data/lib/ruby_ptv_api/model/x_tour/train.rb +26 -0
  122. data/lib/ruby_ptv_api/model/x_tour/transport_depot.rb +20 -0
  123. data/lib/ruby_ptv_api/model/x_tour/transport_order.rb +19 -0
  124. data/lib/ruby_ptv_api/model/x_tour/transport_point.rb +17 -0
  125. data/lib/ruby_ptv_api/model/x_tour/unscheduled_order_analysis_result.rb +15 -0
  126. data/lib/ruby_ptv_api/model/x_tour/vehicle.rb +27 -0
  127. data/lib/ruby_ptv_api/model/x_tour/vehicle_costs.rb +9 -0
  128. data/lib/ruby_ptv_api/model/x_tour/vehicle_restrictions.rb +11 -0
  129. data/lib/ruby_ptv_api/model/x_tour/vehicle_violations.rb +12 -0
  130. data/lib/ruby_ptv_api/operation/x_locate/base.rb +68 -0
  131. data/lib/ruby_ptv_api/operation/x_locate/find_address.rb +26 -0
  132. data/lib/ruby_ptv_api/operation/x_locate/find_address_by_text.rb +28 -0
  133. data/lib/ruby_ptv_api/operation/x_locate/find_addresses.rb +27 -0
  134. data/lib/ruby_ptv_api/operation/x_locate/find_combined_transport_by_location.rb +31 -0
  135. data/lib/ruby_ptv_api/operation/x_locate/find_location.rb +26 -0
  136. data/lib/ruby_ptv_api/operation/x_locate/find_locations.rb +27 -0
  137. data/lib/ruby_ptv_api/operation/x_locate/find_suggestion.rb +36 -0
  138. data/lib/ruby_ptv_api/operation/x_route/base.rb +25 -0
  139. data/lib/ruby_ptv_api/operation/x_route/calculate_reachable_objects.rb +38 -0
  140. data/lib/ruby_ptv_api/operation/x_route/calculate_route.rb +35 -0
  141. data/lib/ruby_ptv_api/operation/x_route/calculate_route_info.rb +33 -0
  142. data/lib/ruby_ptv_api/operation/x_tour/base.rb +24 -0
  143. data/lib/ruby_ptv_api/operation/x_tour/plan_basic_tours.rb +48 -0
  144. data/lib/ruby_ptv_api/operation/x_tour/plan_sequence.rb +52 -0
  145. data/lib/ruby_ptv_api/version.rb +3 -0
  146. data/lib/ruby_ptv_api/x_tour.rb +94 -0
  147. data/lib/ruby_ptv_api.rb +202 -0
  148. data/ruby_ptv_api.gemspec +32 -0
  149. metadata +331 -0
@@ -0,0 +1,36 @@
1
+ module RubyPtvApi
2
+ module Operation
3
+ module XLocate
4
+ class FindSuggestion < RubyPtvApi::Operation::XLocate::Base
5
+ attr_reader :text, :country, :state
6
+
7
+ def initialize(text:, country: "", state: "")
8
+ @text = text
9
+ @country = country
10
+ @state = state
11
+ end
12
+
13
+ def ptv_function
14
+ 'findSuggestion'
15
+ end
16
+
17
+ def params
18
+ {
19
+ text: text,
20
+ country: country,
21
+ state: state,
22
+ options: options,
23
+ sorting: sorting,
24
+ additionalFields: additional_fields
25
+ }
26
+ end
27
+
28
+ protected
29
+
30
+ def response_class
31
+ RubyPtvApi::Model::XLocate::SuggestionResponse
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,25 @@
1
+ module RubyPtvApi
2
+ module Operation
3
+ module XRoute
4
+ class Base < RubyPtvApi::Base
5
+ attr_reader :search_option_base_array, :sort_option_array, :result_field_array
6
+
7
+ def ptv_path
8
+ 'xroute/rs/XRoute'
9
+ end
10
+
11
+ def call #(options: nil, sorting: nil, additional_fields: nil)
12
+ response = post(params)
13
+ parse_response(response)
14
+ end
15
+
16
+ protected
17
+
18
+ def response_class
19
+ raise 'not implemented'
20
+ end
21
+
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,38 @@
1
+ module RubyPtvApi
2
+ module Operation
3
+ module XRoute
4
+ class CalcutateReachableObjects < Base
5
+ attr_reader :sink, :binaryPathDesc, :locations, :options, :expansionDesc
6
+
7
+ def initialize(binaryPathDesc:, locations:, expansionDesc:, sink: nil, options: [])
8
+ @sink = sink
9
+ @binaryPathDesc = binaryPathDesc
10
+ @locations = locations
11
+ @options = options
12
+ @expansionDesc = expansionDesc
13
+ end
14
+
15
+ def ptv_function
16
+ 'calculateReachableObjects'
17
+ end
18
+
19
+ def params
20
+ prms = {
21
+ binaryPathDesc: binaryPathDesc,
22
+ locations: locations,
23
+ options: options,
24
+ expansionDesc: expansionDesc,
25
+ }
26
+ prms.merge!({ sink: sink }) if sink
27
+ prms
28
+ end
29
+
30
+ protected
31
+
32
+ def response_class
33
+ RubyPtvApi::Model::XRoute::Reach
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,35 @@
1
+ module RubyPtvApi
2
+ module Operation
3
+ module XRoute
4
+ class CalcutateRoute < Base
5
+ attr_reader :waypoints, :options, :exceptionPaths, :details
6
+
7
+ def initialize(waypoints:, options:, exceptionPaths: , details:)
8
+ @waypoints = waypoints
9
+ @options = options
10
+ @exceptionPaths = exceptionPaths
11
+ @details = details
12
+ end
13
+
14
+ def ptv_function
15
+ 'calculateRoute'
16
+ end
17
+
18
+ def params
19
+ {
20
+ waypoints: waypoints,
21
+ options: options,
22
+ exceptionPaths: exceptionPaths,
23
+ details: details
24
+ }
25
+ end
26
+
27
+ protected
28
+
29
+ def response_class
30
+ RubyPtvApi::Model::XRoute::Route
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,33 @@
1
+ module RubyPtvApi
2
+ module Operation
3
+ module XRoute
4
+ class CalcutateRouteInfo < Base
5
+ attr_reader :waypoints, :options, :exceptionPaths
6
+
7
+ def initialize(waypoints:, options: [], exceptionPaths: [])
8
+ @waypoints = waypoints
9
+ @options = options
10
+ @exceptionPaths = exceptionPaths
11
+ end
12
+
13
+ def ptv_function
14
+ 'calculateRouteInfo'
15
+ end
16
+
17
+ def params
18
+ {
19
+ waypoints: waypoints,
20
+ options: options,
21
+ exceptionPaths: exceptionPaths
22
+ }
23
+ end
24
+
25
+ protected
26
+
27
+ def response_class
28
+ RubyPtvApi::Model::XRoute::RouteInfo
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,24 @@
1
+ module RubyPtvApi
2
+ module Operation
3
+ module XTour
4
+ class Base < RubyPtvApi::Base
5
+ attr_reader :search_option_base_array, :sort_option_array, :result_field_array
6
+
7
+ def ptv_path
8
+ 'xtour/rs/XTour'
9
+ end
10
+
11
+ def call
12
+ response = post(params)
13
+ parse_response(response)
14
+ end
15
+
16
+ protected
17
+
18
+ def response_class
19
+ raise 'not implemented'
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,48 @@
1
+ module RubyPtvApi
2
+ module Operation
3
+ module XTour
4
+ class PlanBasicTours < Base
5
+ attr_reader :transport_orders, :depots, :fleet
6
+
7
+ def initialize(transport_orders:, depots:, fleet:)
8
+ @transport_orders = transport_orders
9
+ @depots = depots
10
+ @fleet = fleet
11
+ end
12
+
13
+ def ptv_function
14
+ 'planBasicTours'
15
+ end
16
+
17
+ def planning_params
18
+ RubyPtvApi::Model::XTour::StandardParams.new({
19
+ "coDriverTransportPointsInSeparateTours" => false,
20
+ 'distanceMatrixCalculation' => [
21
+ RubyPtvApi::Model::XTour::DistanceMatrixByRoad.new({
22
+ 'dimaId' => 1,
23
+ 'deleteBeforeUsage' => true,
24
+ 'deleteAfterUsage' => true
25
+ })
26
+ ]
27
+ })
28
+ end
29
+
30
+ def params
31
+ {
32
+ transportOrders: transport_orders,
33
+ depots: depots,
34
+ fleet: fleet,
35
+ planningParams: planning_params,
36
+ inputPlan: nil
37
+ }
38
+ end
39
+
40
+ protected
41
+
42
+ def response_class
43
+ RubyPtvApi::Model::XTour::Plan
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,52 @@
1
+ module RubyPtvApi
2
+ module Operation
3
+ module XTour
4
+ class PlanSequence < Base
5
+ attr_reader :transport_orders, :depots, :vehicle
6
+
7
+ def initialize(transport_orders:, depots:, vehicle:)
8
+ @transport_orders = transport_orders
9
+ @depots = depots
10
+ @vehicle = vehicle
11
+ @dimaId = 1
12
+ end
13
+
14
+ def ptv_function
15
+ 'planSequence'
16
+ end
17
+
18
+ def sequencing_params
19
+ RubyPtvApi::Model::XTour::SequencingParams.new({
20
+ 'coDriverTransportPointsInSeparateTours' => false,
21
+ 'distanceMatrixCalculation' =>
22
+ [
23
+ RubyPtvApi::Model::XTour::DistanceMatrixByRoad.new({
24
+ 'dimaId' => 1,
25
+ 'deleteBeforeUsage' => true,
26
+ 'deleteAfterUsage' => true
27
+ })
28
+ ]
29
+ })
30
+ end
31
+
32
+ def params
33
+ {
34
+ transportOrders: transport_orders,
35
+ depots: depots,
36
+ vehicle: vehicle,
37
+ sequencingParams: sequencing_params,
38
+ inputPlan: nil
39
+ }
40
+ end
41
+
42
+ protected
43
+
44
+ def response_class
45
+ RubyPtvApi::Model::XTour::SequencingPlan
46
+ end
47
+
48
+
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,3 @@
1
+ module RubyPtvApi
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,94 @@
1
+ module RubyPtvApi
2
+ module XTour
3
+ class << self
4
+ def plan_sequence(points, garage)
5
+ required_keys = [:uuid, :latitude, :longitude]
6
+ raise "garage has to include the keys #{required_keys}" unless (required_keys - garage.methods).empty?
7
+
8
+ dimaId = 1
9
+ id_manager = RubyPtvApi::IdManager.new
10
+ depot = RubyPtvApi::Model::XTour::Depot.new(
11
+ 'id' => id_manager.add(garage.uuid),
12
+ 'location' => RubyPtvApi::Model::Point.new(
13
+ 'point' => RubyPtvApi::Model::PlainPoint.new(
14
+ 'x' => RubyPtvApi.cast_coordinate(garage.longitude),
15
+ 'y' => RubyPtvApi.cast_coordinate(garage.latitude)
16
+ )
17
+ )
18
+ )
19
+ depot.openingIntervals = [
20
+ RubyPtvApi::Model::XTour::Interval.new(
21
+ 'from' => garage.interval.first.to_i,
22
+ 'till' => garage.interval.last.to_i
23
+ )
24
+ ] if garage.interval
25
+
26
+ sequencing_transport_depots = []
27
+ vehicle = RubyPtvApi::Model::XTour::SequencingVehicle.new(
28
+ 'dimaId' => dimaId,
29
+ 'depotIdStart' => depot.id,
30
+ 'depotIdEnd' => depot.id,
31
+ 'isPreloaded' => true,
32
+ 'ignoreTransportPointServicePeriod' => false,
33
+ 'coDriverStatus' => :NEVER,
34
+ 'toursMustFitIntoSingleOperatingInterval' => true
35
+ )
36
+ vehicle.operatingIntervals = [
37
+ RubyPtvApi::Model::XTour::Interval.new(
38
+ 'from' => garage.interval.first.to_i,
39
+ 'till' => garage.interval.last.to_i
40
+ )
41
+ ] if garage.interval
42
+
43
+ points.each do |point|
44
+ raise "each point has to include the keys #{required_keys}" unless (required_keys - point.methods).empty?
45
+ sequencing_transport_depots << create_sequencing_transport_depot(
46
+ uuid: point.uuid,
47
+ latitude: RubyPtvApi.cast_coordinate(point.latitude),
48
+ longitude: RubyPtvApi.cast_coordinate(point.longitude),
49
+ interval: point.interval,
50
+ id_manager: id_manager
51
+ )
52
+ end
53
+ function = RubyPtvApi::Operation::XTour::PlanSequence.new(
54
+ transport_orders: sequencing_transport_depots,
55
+ depots: [depot],
56
+ vehicle: vehicle
57
+ )
58
+ response = function.call
59
+ sequence = response.tour.tourPoints ? response.tour.tourPoints.map{|tp| id_manager.uuid(tp.id.to_i)} : []
60
+ unmanaged_list = response.result.unscheduledOrderIds ? response.result.unscheduledOrderIds.map{|id| id_manager.uuid(id)} : []
61
+ hash = Hash[points.map{|e| [e.uuid, e]}]
62
+ {
63
+ sequence: sequence.map{|e| hash[e]}.compact,
64
+ unmanaged: unmanaged_list.map{|e| hash[e]},
65
+ raw_response: response
66
+ }
67
+ end
68
+
69
+ def create_sequencing_transport_depot(uuid:, id_manager:, latitude:, longitude:, interval:)
70
+ transport_point = RubyPtvApi::Model::XTour::TransportPoint.new(
71
+ 'id' => id_manager.add(uuid),
72
+ 'location' => RubyPtvApi::Model::Point.new(
73
+ 'point' => RubyPtvApi::Model::PlainPoint.new(
74
+ 'x' => longitude,
75
+ 'y' => latitude
76
+ )
77
+ )
78
+ )
79
+ transport_point.openingIntervals = [
80
+ RubyPtvApi::Model::XTour::Interval.new(
81
+ 'from' => interval.first.to_i,
82
+ 'till' => interval.last.to_i
83
+ )
84
+ ] if interval
85
+
86
+ std = RubyPtvApi::Model::XTour::SequencingTransportDepot.new(
87
+ 'id' => id_manager.add(uuid),
88
+ 'transportPoint' => transport_point
89
+ )
90
+ std
91
+ end
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,202 @@
1
+ require 'oj'
2
+ require 'hashie'
3
+ require 'faraday'
4
+
5
+ require "ruby_ptv_api/base"
6
+ require "ruby_ptv_api/constant"
7
+ require "ruby_ptv_api/version"
8
+
9
+ require "ruby_ptv_api/model/base"
10
+ require "ruby_ptv_api/model/plain_point"
11
+ require "ruby_ptv_api/model/point"
12
+
13
+ require "ruby_ptv_api/model/x_locate/address"
14
+ require "ruby_ptv_api/model/x_locate/result_address"
15
+ require "ruby_ptv_api/model/x_locate/address_response"
16
+ require "ruby_ptv_api/model/x_locate/location"
17
+ require "ruby_ptv_api/model/x_locate/sort_option"
18
+ require "ruby_ptv_api/model/x_locate/additional_field"
19
+ require "ruby_ptv_api/model/x_locate/combined_transport_location"
20
+ require "ruby_ptv_api/model/x_locate/result_combined_transport"
21
+ require "ruby_ptv_api/model/x_locate/combined_transport_response"
22
+ require "ruby_ptv_api/model/x_locate/suggestion"
23
+ require "ruby_ptv_api/model/x_locate/suggestion_response"
24
+
25
+ require "ruby_ptv_api/model/x_tour/abstract_transport_order.rb"
26
+ require "ruby_ptv_api/model/x_tour/quantities.rb"
27
+ require "ruby_ptv_api/model/x_tour/capacities.rb"
28
+ require "ruby_ptv_api/model/x_tour/interval.rb"
29
+ require "ruby_ptv_api/model/x_tour/maximum_tour_period_restriction.rb"
30
+ require "ruby_ptv_api/model/x_tour/driver_settings.rb"
31
+ require "ruby_ptv_api/model/x_tour/tour_restrictions.rb"
32
+ require "ruby_ptv_api/model/x_tour/restrictions.rb"
33
+ require "ruby_ptv_api/model/x_tour/quantity_dependent_periods.rb"
34
+ require "ruby_ptv_api/model/x_tour/loading_function.rb"
35
+ require "ruby_ptv_api/model/x_tour/distance_matrix_calculation.rb"
36
+ require "ruby_ptv_api/model/x_tour/distance_matrix_by_road.rb"
37
+ require "ruby_ptv_api/model/x_tour/product_incompatibility.rb"
38
+ require "ruby_ptv_api/model/x_tour/goal_importance.rb"
39
+ require "ruby_ptv_api/model/x_tour/planning_params.rb"
40
+ require "ruby_ptv_api/model/x_tour/standard_params.rb"
41
+ require "ruby_ptv_api/model/x_tour/sequencing_params.rb"
42
+ require "ruby_ptv_api/model/x_tour/abstract_costs.rb"
43
+ require "ruby_ptv_api/model/x_tour/total_costs.rb"
44
+ require "ruby_ptv_api/model/x_tour/abstract_tour.rb"
45
+ require "ruby_ptv_api/model/x_tour/sequencing_tour_result.rb"
46
+ require "ruby_ptv_api/model/x_tour/tour_point_result.rb"
47
+ require "ruby_ptv_api/model/x_tour/sequencing_tour_point.rb"
48
+ require "ruby_ptv_api/model/x_tour/sequencing_tour.rb"
49
+ require "ruby_ptv_api/model/x_tour/tour_event.rb"
50
+ require "ruby_ptv_api/model/x_tour/vehicle_violations.rb"
51
+ require "ruby_ptv_api/model/x_tour/tour_violations.rb"
52
+ require "ruby_ptv_api/model/x_tour/unscheduled_order_analysis_result.rb"
53
+ require "ruby_ptv_api/model/x_tour/sequencing_plan_result.rb"
54
+ require "ruby_ptv_api/model/x_tour/sequencing_plan.rb"
55
+ require "ruby_ptv_api/model/x_tour/vehicle_costs.rb"
56
+ require "ruby_ptv_api/model/x_tour/abstract_vehicle.rb"
57
+ require "ruby_ptv_api/model/x_tour/base_vehicle.rb"
58
+ require "ruby_ptv_api/model/x_tour/sequencing_vehicle.rb"
59
+ require "ruby_ptv_api/model/x_tour/logistic_point.rb"
60
+ require "ruby_ptv_api/model/x_tour/depot.rb"
61
+ require "ruby_ptv_api/model/x_tour/transport_point.rb"
62
+ require "ruby_ptv_api/model/x_tour/sequencing_transport_order.rb"
63
+ require "ruby_ptv_api/model/x_tour/sequencing_transport_depot.rb"
64
+ require "ruby_ptv_api/model/x_tour/loading_area.rb"
65
+ require "ruby_ptv_api/model/x_tour/transport_order.rb"
66
+ require "ruby_ptv_api/model/x_tour/transport_depot.rb"
67
+ require "ruby_ptv_api/model/x_tour/vehicle_restrictions.rb"
68
+ require "ruby_ptv_api/model/x_tour/vehicle.rb"
69
+ require "ruby_ptv_api/model/x_tour/abstract_tour_point.rb"
70
+ require "ruby_ptv_api/model/x_tour/chain_result.rb"
71
+ require "ruby_ptv_api/model/x_tour/tour_point.rb"
72
+ require "ruby_ptv_api/model/x_tour/abstract_tour_result.rb"
73
+ require "ruby_ptv_api/model/x_tour/tour_result.rb"
74
+ require "ruby_ptv_api/model/x_tour/tour.rb"
75
+ require "ruby_ptv_api/model/x_tour/chain.rb"
76
+ require "ruby_ptv_api/model/x_tour/plan_result.rb"
77
+ require "ruby_ptv_api/model/x_tour/plan.rb"
78
+ require "ruby_ptv_api/model/x_tour/trailer.rb"
79
+ require "ruby_ptv_api/model/x_tour/costs.rb"
80
+ require "ruby_ptv_api/model/x_tour/train.rb"
81
+ require "ruby_ptv_api/model/x_tour/fleet.rb"
82
+ require "ruby_ptv_api/model/x_tour/loading_area.rb"
83
+ require "ruby_ptv_api/model/x_tour/plan_result.rb"
84
+ require "ruby_ptv_api/model/x_tour/plan.rb"
85
+ require "ruby_ptv_api/model/x_tour/transport_order.rb"
86
+ require "ruby_ptv_api/model/x_tour/vehicle_restrictions.rb"
87
+ require "ruby_ptv_api/model/x_tour/vehicle.rb"
88
+
89
+ require "ruby_ptv_api/model/x_route/bounding_rectangle.rb"
90
+ require "ruby_ptv_api/model/x_route/brunnel_manoeuvre.rb"
91
+ require "ruby_ptv_api/model/x_route/cen_emissions.rb"
92
+ require "ruby_ptv_api/model/x_route/cen_emission_configuration.rb"
93
+ require "ruby_ptv_api/model/x_route/cen_emission_conversion_factors.rb"
94
+ require "ruby_ptv_api/model/x_route/cen_emission_scenarios.rb"
95
+ require "ruby_ptv_api/model/x_route/commuter_travel_trend.rb"
96
+ require "ruby_ptv_api/model/x_route/detail_description_option.rb"
97
+ require "ruby_ptv_api/model/x_route/dynamic_info.rb"
98
+ require "ruby_ptv_api/model/x_route/emission_type.rb"
99
+ require "ruby_ptv_api/model/x_route/emissions.rb"
100
+ require "ruby_ptv_api/model/x_route/unique_geo_id.rb"
101
+ require "ruby_ptv_api/model/x_route/plain_geometry_base.rb"
102
+ require "ruby_ptv_api/model/x_route/klm.rb"
103
+ require "ruby_ptv_api/model/x_route/encoded_geometry.rb"
104
+ require "ruby_ptv_api/model/x_route/plain_line_string.rb"
105
+ require "ruby_ptv_api/model/x_route/line_string.rb"
106
+ require "ruby_ptv_api/model/x_route/exception_path.rb"
107
+ require "ruby_ptv_api/model/x_route/feauture_description.rb"
108
+ require "ruby_ptv_api/model/x_route/hbefa_type.rb"
109
+ require "ruby_ptv_api/model/x_route/manoeuvre_attr.rb"
110
+ require "ruby_ptv_api/model/x_route/manoeuvre_group.rb"
111
+ require "ruby_ptv_api/model/x_route/norm_speed.rb"
112
+ require "ruby_ptv_api/model/x_route/result_list_options.rb"
113
+ require "ruby_ptv_api/model/x_route/segment_attributes.rb"
114
+ require "ruby_ptv_api/model/x_route/speed_limit.rb"
115
+ require "ruby_ptv_api/model/x_route/speed_limits.rb"
116
+ require "ruby_ptv_api/model/x_route/urban_manoeuvre.rb"
117
+ require "ruby_ptv_api/model/x_route/vehicle_option.rb"
118
+ require "ruby_ptv_api/model/x_route/via_type.rb"
119
+ require "ruby_ptv_api/model/x_route/way_point.rb"
120
+ require "ruby_ptv_api/model/x_route/routing_option.rb"
121
+ require "ruby_ptv_api/model/x_route/waypoint_desc.rb"
122
+ require "ruby_ptv_api/model/x_route/route_info.rb"
123
+ require "ruby_ptv_api/model/x_route/route_list_segment.rb"
124
+ require "ruby_ptv_api/model/x_route/route_manoeuvre.rb"
125
+ require "ruby_ptv_api/model/x_route/route.rb"
126
+ require "ruby_ptv_api/model/x_route/expansion_description.rb"
127
+ require "ruby_ptv_api/model/x_route/reach_info.rb"
128
+ require "ruby_ptv_api/model/x_route/reach.rb"
129
+
130
+ require "ruby_ptv_api/operation/x_locate/base"
131
+ require "ruby_ptv_api/operation/x_locate/find_address"
132
+ require "ruby_ptv_api/operation/x_locate/find_addresses"
133
+ require "ruby_ptv_api/operation/x_locate/find_location"
134
+ require "ruby_ptv_api/operation/x_locate/find_locations"
135
+ require "ruby_ptv_api/operation/x_locate/find_combined_transport_by_location"
136
+ require "ruby_ptv_api/operation/x_locate/find_address_by_text"
137
+ require "ruby_ptv_api/operation/x_locate/find_suggestion"
138
+
139
+ require "ruby_ptv_api/operation/x_tour/base"
140
+ require "ruby_ptv_api/operation/x_tour/plan_sequence"
141
+ require "ruby_ptv_api/operation/x_tour/plan_basic_tours"
142
+
143
+ require "ruby_ptv_api/operation/x_route/base"
144
+ require "ruby_ptv_api/operation/x_route/calculate_route"
145
+ require "ruby_ptv_api/operation/x_route/calculate_route_info"
146
+ require "ruby_ptv_api/operation/x_route/calculate_reachable_objects"
147
+
148
+ require "ruby_ptv_api/id_manager"
149
+ require "ruby_ptv_api/x_tour"
150
+
151
+ module RubyPtvApi
152
+
153
+ # Class method to set up configuration parameters
154
+ #
155
+ # @example
156
+ # RubyPtvApi.configure do |c|
157
+ # c.x_locate_endpoint = "http://..."
158
+ # end
159
+ #
160
+ def self.configure(&block)
161
+ Oj.default_options = { :mode => :compat }
162
+ yield @config ||= Configuration.new
163
+ end
164
+
165
+ # Return configuration parameters
166
+ #
167
+ # @example
168
+ # RubyPtvApi.config.x_locate_endpoint
169
+ #
170
+ def self.config
171
+ if @config.nil? or @config.instance_variables.count != 3
172
+ raise 'RubyPtvApi gem uncompleted config'
173
+ end
174
+ @config
175
+ end
176
+
177
+ # Container for configuration parameters
178
+ #
179
+ class Configuration
180
+ attr_accessor :x_locate_endpoint, :x_route_endpoint, :x_tour_endpoint
181
+ end
182
+
183
+ # Exception raised for connection error
184
+ #
185
+ class BadResponse < Exception; end
186
+
187
+ # Exception raised when a mandatory parameter is missing
188
+ #
189
+ class MissingParameter < Exception; end
190
+
191
+ # Exception raised when more than one require parameter is given
192
+ #
193
+ class TooManyParameters < Exception; end
194
+
195
+ # Exception raised when a parameter is in the wrong format
196
+ #
197
+ class WrongParameterFormat < Exception; end
198
+
199
+ def self.cast_coordinate(coord)
200
+ coord.to_i.to_s.size != 7 ? (coord * 100000).to_i : coord
201
+ end
202
+ end
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ruby_ptv_api/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ruby_ptv_api"
8
+ spec.version = RubyPtvApi::VERSION
9
+ spec.authors = ["Leanbit srl"]
10
+ spec.email = ["info@leanbit.it"]
11
+ spec.licenses = ['MIT']
12
+ spec.summary = "Unofficial PVT ruby client"
13
+ spec.description = "PTV client, incomplete implementation of x_route, x_locate, x_tour"
14
+ spec.homepage = "https://github.com/satelicom/ruby-ptv-api"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "faraday", '~> 0.9'
22
+ spec.add_dependency "oj", '~> 2.16'
23
+ spec.add_dependency "hashie", '~> 3.4'
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.11"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rspec", "~> 3.0"
28
+ spec.add_development_dependency "guard", "~> 2.13"
29
+ spec.add_development_dependency "guard-rspec", "~> 4.6"
30
+ spec.add_development_dependency "vcr", "~> 3.0"
31
+ spec.add_development_dependency "factory_girl", "~> 4.5"
32
+ end