ruby_ptv_api 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
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
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4527df64f46e3339016be3ad00bde23f29f3f145
4
+ data.tar.gz: 495bfd93b229601574aebaa2572c00fbab6b13e2
5
+ SHA512:
6
+ metadata.gz: bcbfda7701b2a736e1eecc17571cc0cd3f3fdd7d842c13be3eae5a0ec42d476ee4dc68b7b8d2a86c50417619cb90b8ad4f0c39395b7846002e55812b2915bc76
7
+ data.tar.gz: b4fff08081ecdc68296335f805722f5334557974aebf4fe5b8cb542bcead247bf7eb3e0b4e413a9929c0029de10b70534b4aa1788407a7a3e6e7f8f6a776eb47
data/.directory ADDED
@@ -0,0 +1,11 @@
1
+ [Dolphin]
2
+ GroupedSorting=true
3
+ PreviewsShown=true
4
+ SortRole=type
5
+ Timestamp=2016,6,21,12,21,25
6
+ Version=3
7
+ ViewMode=2
8
+ VisibleRoles=Compact_text,Compact_size,Compact_date
9
+
10
+ [Settings]
11
+ HiddenFilesShown=true
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /.idea/
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+
12
+ .ruby-version
13
+ .ruby-gemset
14
+ ruby_ptv_api-*.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ before_install: gem install bundler -v 1.11.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ruby_ptv_api.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,36 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features) \
6
+ # .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
+
8
+ #directories %w(lib spec)
9
+
10
+ ## Note: if you are using the `directories` clause above and you are not
11
+ ## watching the project directory ('.'), then you will want to move
12
+ ## the Guardfile to a watched dir and symlink it back, e.g.
13
+ #
14
+ # $ mkdir config
15
+ # $ mv Guardfile config/
16
+ # $ ln -s config/Guardfile .
17
+ #
18
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
19
+
20
+ guard :rspec, cmd: "bundle exec rspec" do
21
+ require "guard/rspec/dsl"
22
+ dsl = Guard::RSpec::Dsl.new(self)
23
+
24
+ # Feel free to open issues for suggestions and improvements
25
+
26
+ # RSpec files
27
+ rspec = dsl.rspec
28
+ watch(rspec.spec_helper) { rspec.spec_dir }
29
+ watch(rspec.spec_support) { rspec.spec_dir }
30
+ watch(rspec.spec_files)
31
+
32
+ # Ruby files
33
+ ruby = dsl.ruby
34
+ dsl.watch_spec_files_for(ruby.lib_files)
35
+
36
+ end
data/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # RubyPtvApi
2
+
3
+ Unofficial PTV API client
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'ruby_ptv_api'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install ruby_ptv_api
20
+
21
+ ## Setup
22
+
23
+ Setup configuration parameters
24
+
25
+ ```ruby
26
+ RubyPtvApi.configure do |c|
27
+ c.x_locate_endpoint = "http://<your PTV server>"
28
+ c.x_route_endpoint = "http://<your PTV server>"
29
+ c.x_tour_endpoint = "http://<your PTV server>"
30
+ end
31
+ ```
32
+
33
+ ## Usage
34
+
35
+ TODO: Write usage instructions here
36
+
37
+ ## Development
38
+
39
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
40
+
41
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
42
+
43
+ ## Contributing
44
+
45
+ Bug reports and pull requests are welcome on GitHub at https://github.com/satelicom/ruby-ptv-api/.
46
+
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
8
+ desc "Open an irb session preloaded with this library"
9
+ task :console do
10
+ sh "irb -rubygems -I lib -r ruby_ptv_api.rb -r ./console_initializer.rb "
11
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ruby_ptv_api"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,5 @@
1
+ RubyPtvApi.configure do |c|
2
+ c.x_locate_endpoint = "http://ptv.dev.satelicom.com:50020"
3
+ c.x_route_endpoint = "http://ptv.dev.satelicom.com:50030"
4
+ c.x_tour_endpoint = "http://ptv.dev.satelicom.com:50090"
5
+ end
@@ -0,0 +1,105 @@
1
+ module RubyPtvApi
2
+ class Base
3
+ attr_accessor :profile, :coord_format
4
+
5
+ def endpoint
6
+ RubyPtvApi.config.send("#{parent_module_name.downcase}_endpoint")
7
+ end
8
+
9
+ def uri
10
+ "#{endpoint}/#{ptv_path}/#{ptv_function}"
11
+ end
12
+
13
+ def ptv_path
14
+ raise "Not implemented PTV path in #{demodulized_name}"
15
+ end
16
+
17
+ def ptv_function
18
+ raise "Not implemented PTV function in #{demodulized_name}"
19
+ end
20
+
21
+ def parent_module_name
22
+ name = self.class.name.split('::')[-2]
23
+ return nil unless name
24
+ underscore(name)
25
+ end
26
+
27
+ def demodulized_name
28
+ demodulize(self.class.name)
29
+ end
30
+
31
+ # Avoid active support import
32
+ def demodulize(path)
33
+ path = path.to_s
34
+ if i = path.rindex('::')
35
+ path[(i+2)..-1]
36
+ else
37
+ path
38
+ end
39
+ end
40
+
41
+ def underscore(path)
42
+ path.gsub!(/([A-Z\d]+)([A-Z][a-z])/,'\1_\2').downcase
43
+ end
44
+
45
+ def post(params)
46
+ params.merge!(default_params)
47
+ #p params.to_json
48
+ response = connection.post do |req|
49
+ req.url "#{ptv_path}/#{ptv_function}"
50
+ req.headers['Content-Type'] = 'application/json; charset=utf-8'
51
+ req.body = Oj.dump(params)
52
+ end
53
+ body = Oj.load(response.body)
54
+ #p body
55
+ (200..300).include?(response.status) ? body : raise(BadResponse.new(response.body))
56
+ end
57
+
58
+ def connection
59
+ Faraday.new(url: endpoint) do |faraday|
60
+ faraday.request :url_encoded # form-encode POST params
61
+ #faraday.response :logger # log requests to STDOUT
62
+ faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
63
+ end
64
+ end
65
+
66
+ def default_params
67
+ {
68
+ callerContext: {
69
+ properties: [
70
+ {
71
+ key: 'Profile',
72
+ value: 'car'
73
+ },
74
+ {
75
+ key: 'CoordFormat',
76
+ value: coord_format || :PTV_GEODECIMAL
77
+ }
78
+ ]
79
+ }
80
+ }
81
+ end
82
+
83
+ protected
84
+
85
+ def parse_response(response)
86
+ if response.is_a? Array
87
+ multiple_response(response)
88
+ else
89
+ single_response(response)
90
+ end
91
+ end
92
+
93
+ def single_response(response)
94
+ response_class.new(response)
95
+ end
96
+
97
+ def multiple_response(responses)
98
+ lists = []
99
+ responses.each do |response|
100
+ lists << response_class.new(response)
101
+ end
102
+ lists
103
+ end
104
+ end
105
+ end
@@ -0,0 +1,107 @@
1
+ module RubyPtvApi
2
+ module Constant
3
+ RESULT_FIELD = [
4
+ :COUNTRY, :STATE, :ADMINREGION, :CITY, :CITY2, :POSTCODE, :STREET, :HOUSENR,
5
+ :COORDX, :COORDY, :DETAILLEVEL, :DETAILLEVEL_DESCRIPTION, :POPULATION, :EXTENSIONCLASS,
6
+ :LEVEL, :ISCITYDISTRICT, :COUNTRY_ISO2, :COUNTRY_ISO3, :COUNTRY_COUNTRYCODEPLATE,
7
+ :COUNTRY_DIALINGCODE, :COUNTRY_CAPITAL, :COUNTRY_NAME, :HOUSENR_SIDE, :HOUSENR_STRUCTURE,
8
+ :HOUSENR_STARTFORMAT, :HOUSENR_ENDFORMAT, :APPENDIX, :SCORE_TOTALSCORE, :SCORE_FINALPENALTY,
9
+ :FOUNDBY_CITY, :FOUNDBY_CITY2, :FOUNDBY_POSTCODE, :FOUNDBY_STREET, :CLASSIFICATION,
10
+ :CLASSIFICATION_DESCRIPTION, :SWAPANDSPLITMODE, :POPUPINFO, :PHONENUMBER, :SEGMENT_ID,
11
+ :SEGMENT_COUNTRY, :SEGMENT_DIRECTION, :XYN, :POINAME, :POITYPE, :ADDRESS_CLASSIFICATION,
12
+ :ADDRESS_CLASSIFICATION_DESCRIPTION, :POSTCODE_CLASSIFICATION, :TOWN_CLASSIFICATION,
13
+ :STREET_CLASSIFICATION, :HOUSENR_CLASSIFICATION, :POSTCODE_CHARACTERISTICS, :TOWN_CHARACTERISTICS,
14
+ :STREET_CHARACTERISTICS, :HOUSENR_CHARACTERISTICS, :UNMATCHED_WORDS, :UNMATCHED_WORDS_COUNT,
15
+ :STREETX, :STREETY, :ADMINX, :ADMINY, :DESTINATION_LOCATION_NODE_N, :DESTINATION_LOCATION_NODE_Y,
16
+ :DESTINATION_LOCATION_NODE_X, :DESTINATION_LOCATION_TILE_Y, :DESTINATION_LOCATION_TILE_X,
17
+ :DESTINATION_LOCATION_COUNTRYCODE, :START_LOCATION_NODE_N, :START_LOCATION_NODE_Y,
18
+ :START_LOCATION_NODE_X, :START_LOCATION_TILE_Y, :START_LOCATION_TILE_X, :START_LOCATION_COUNTRYCODE,
19
+ :ISBLOCKEDFORPEDESTRIANS, :ISBLOCKEDFORBICYCLES, :ISBLOCKEDFORMOTORCYCLES, :ISBLOCKEDFORCARS,
20
+ :ISBLOCKEDFORVANS, :ISBLOCKEDFORCAMPERS, :ISBLOCKEDFORBUSES, :ISBLOCKEDFORHAZARDOUSGOODS,
21
+ :ISBLOCKEDFORCOMBUSTIBLEGOODS, :ISBLOCKEDFORTRUCKS, :ARTIFICIALTOWNCHARACTERIZATION,
22
+ :CITY_LEVEL, :STREETNUMBER, :HOUSENR_ATINPUTCOORDINATESIDE, :PROVINCE
23
+ ]
24
+
25
+ SORT_ORDER = [:ASCENDING, :DESCENDING]
26
+
27
+ CO_DRIVER_STATUS = [:NEVER, :ALWAYS, :IF_REQUIRED]
28
+
29
+ UNSCHEDULED_STOP_STATUS = [:FEASIBLE, :UNSCHEDULED_DUE_TO_PLAN, :UNSCHEDULED_DUE_TO_VEHICLES]
30
+
31
+ COORD_FORMAT = [:OG_GEODECIMAL, :PTV_MERCATOR, :PTV_GEOMINSEC, :PTV_GEODECIMAL, :PTV_CONFORM, :PTV_SUPERCONFORM, :PTV_SMARTUNITS, :OG_SRID]
32
+
33
+ OPENING_INTERVAL_CONTRAINT = [:START_OF_SERVICE, :COMPLETE_SERVICE]
34
+
35
+ PRODUCT_INCOMPATIBILITY_TYPE = [:NOT_ON_SAME_TOUR, :NOT_AT_SAME_TIME]
36
+
37
+ TOUR_POINT_FIXATION = [:NONE, :NO_TOUR_POINT_OUT, :NO_TOUR_POINT_IN_AND_OUT, :COMPLETELY_FIXED]
38
+
39
+ TOUR_POINT_TYPE = [:TRANSPORT_POINT, :DEPOT]
40
+
41
+ LINK_TYPE = [:NEXT_NODE, :NEXT_SEGMENT, :NEXT_MAIN_NODE, :FUZZY_LINKING, :AUTO_LINKING, :NEXT_MAIN_TOLL_NODE, :TOLL_STATION, :TI_LINKING]
42
+
43
+ ROUTING_PARAMETER = [
44
+ :OPTIMIZATION, :SPEED_PROFILE, :AVOID_NATIONALNAMEDTOLL_ROADS, :AVOID_TOLLROADS, :AVOID_VIGNETTEROADS,
45
+ :AVOID_HIGHWAYS, :AVOID_FERRIES, :AVOID_RESIDENTS_ONLY, :AVOID_URBAN_AREAS, :AVOID_RAMPS, :AVOID_LOW_EMISSION_ZONES,
46
+ :ALLOW_SEGMENT_VIOLATIONS, :COST_OF_SEGMENT_VIOLATIONS, :EXCLUDE_COUNTRIES , :ROUTING_COUNTRIES,
47
+ :ROUTING_RECTANGLE, :AUTO, :ROUTE_LANGUAGE, :START_TIME, :IS_DESTTIME, :DYNAMIC_PROFILE, :ENABLE_DYNAMIC,
48
+ :DYNAMIC_PROFILE, :ENABLE_ROADEDITOR, :ROADEDITOR_LAYERNAME, :START_TIME_ROADEDITOR, :ROADEDITOR_LAYERNAME,
49
+ :ROADEDITOR_ATTRIBUTESET, :ROADEDITOR_ADDITIONAL_OPTIONS, :DISTANCE_MEASURE, :COUNTRY_ENCODING,
50
+ :GENERATE_EXTWAYPOINTS, :EXPERT_OPTIONS, :ALT, :REQUEST_VERSION, :LOW_EMISSION_ZONE_TYPE,
51
+ :DYNAMIC_TIME_ON_STATICROUTE, :DYNAMIC_TRAVEL_TIME_STEP_SIZE, :DYNAMIC_TRAVEL_TIME_STEP_COUNT,
52
+ :SPEED_INFOS, :ENABLE_DYNAMIC_WITH_FREE_FLOW_SPEED, :GEODATASOURCE_LAYER, :REMAINING_DRIVING_TIMES
53
+ ]
54
+
55
+ VIA_TYPE_ENUM = [:VIA, :VIA_STOP, :FUZZY, :COMBINED_TRANSPORT]
56
+
57
+ DETAIL_LEVEL = [:BORDERS, :VERY_IMPORTANT, :STANDARD, :LESS_IMPORTANT, :OTHER_OPPORTUNITIES, :ORTHOGONAL , :ALL]
58
+
59
+ EMISSION_LEVEL = [:NONE, :BASIC, :SEGMENTS, :STATIONS, :ALL]
60
+
61
+ HBEFA_VERSION = [:HBEFA_2_1, :HBEFA_3_1, :NO_HBEFA, :HBEFA_3_2, :COPERT_AUS_1_2]
62
+
63
+ CEN_VERSION = [:CEN_2011, :CEN_2012, :CO2_DECREE_FRANCE_2011, :AUSTRALIA_NGA_2011, :UK_DEFRA_2014]
64
+
65
+ WAY_POINT_TYPE = [:START, :VIA, :DEST]
66
+
67
+ TURN_WEIGHT = [:NORMAL, :HALF, :STRONG]
68
+
69
+ TURN_ORIENT = [:STRAIGHT, :LEFT, :RIGHT]
70
+
71
+ MANOEUVRE_TYPE = [
72
+ :FURTHER, :KEEP , :TURN , :UTURN, :ENTER, :EXIT , :ENTER_RA , :STAY_RA, :EXIT_RA,
73
+ :CHANGE , :ENTER_FERRY , :EXIT_FERRY , :EXIT_RA_ENTER , :EXIT_RA_ENTER_FERRY
74
+ ]
75
+
76
+ INFO_NODE_TYPE = [:NORMAL , :AE , :AS , :AD , :AK , :BORDER , :BUILT_UP , :FERRY, :TOLL_ROAD, :SIGN]
77
+
78
+ NETWORK_CLASS = [
79
+ :MOTORWAY, :HIGHWAY, :TRUNK_ROAD, :COUNTRY_ROAD, :CITY_ROAD, :RESIDENTIAL_ROAD,
80
+ :SPECIAL_ROAD, :CYCLE_AND_WALKWAY
81
+ ]
82
+
83
+ NORM_SPEED_TYPE = [:FREE_FLOW, :MAX_DYNAMIC, :STATIC]
84
+
85
+ BRUNNEL_CODE = [
86
+ :NOTHING, :OVER_WATER , :UNDER_WATER, :OVER_TRAIN , :UNDER_TRAIN, :OVER_STREET,
87
+ :UNDER_STREET , :BRIDGE , :TUNNEL
88
+ ]
89
+
90
+ MANOEUVRE_GROUP_TYPE = [:MG_TYPE1, :MG_TYPE2]
91
+
92
+ EXPANSION_TYPE = [:EXP_TIME, :EXP_DIST]
93
+
94
+ def self.constant_by_value( val )
95
+ constants.find{ |name| const_get(name)==val }
96
+ end
97
+
98
+ def self.validate(constant, value)
99
+ value = value.to_sym
100
+ if constant.include?(value)
101
+ value
102
+ else
103
+ raise WrongParameterFormat.new("#{value} is not a valid #{constant_by_value(constant)}")
104
+ end
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,17 @@
1
+ module RubyPtvApi
2
+ class IdManager
3
+ def initialize
4
+ @uuid_list = []
5
+ end
6
+
7
+ def add(uuid)
8
+ @uuid_list << uuid
9
+ @uuid_list.size
10
+ end
11
+
12
+ def uuid(id)
13
+ @uuid_list[id - 1]
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,12 @@
1
+ module RubyPtvApi
2
+ module Model
3
+ class Base < Hashie::Dash
4
+ # Do not change include order
5
+ include Hashie::Extensions::Dash::PropertyTranslation
6
+ include Hashie::Extensions::MethodAccess
7
+ include Hashie::Extensions::Coercion
8
+
9
+ property '$type', default: ->(obj) { obj.class.name.split(':').last }
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,21 @@
1
+ module RubyPtvApi
2
+ module Model
3
+ class PlainPoint < Base
4
+ # longitude
5
+ property 'x', transform_with: ->(value) do
6
+ if value.to_i.to_s.size != 7
7
+ raise WrongParameterFormat.new("longitude must be a integer and have size 7 but #{value}")
8
+ end
9
+ value
10
+ end
11
+ # latitude
12
+ property 'y', transform_with: ->(value) do
13
+ if value.to_i.to_s.size != 7
14
+ raise WrongParameterFormat.new("latitude must be a integer and have size 7 but #{value}")
15
+ end
16
+ value
17
+ end
18
+ property 'z'
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,9 @@
1
+ module RubyPtvApi
2
+ module Model
3
+ class Point < Base
4
+ property 'point'
5
+
6
+ coerce_key :point, PlainPoint
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,14 @@
1
+ module RubyPtvApi
2
+ module Model
3
+ module XLocate
4
+ class AdditionalField < RubyPtvApi::Model::Base
5
+
6
+ property 'field', transform_with: ->(value) do
7
+ RubyPtvApi::Constant.validate(RubyPtvApi::Constant::RESULT_FIELD, value)
8
+ end
9
+
10
+ property 'value'
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,24 @@
1
+ module RubyPtvApi
2
+ module Model
3
+ module XLocate
4
+ # Attribute Name | Type | Description
5
+ # country String The country code of this address. Depends on the COUNTRY_CODETYPE settings.
6
+ # state String The state code of this address.
7
+ # postCode String The postcode of this address.
8
+ # city String The city name of this address.
9
+ # city2 String The city district of this address.
10
+ # street String The street name of this address.
11
+ # houseNumber String The house number of this address.
12
+
13
+ class Address < RubyPtvApi::Model::Base
14
+ property 'country'
15
+ property 'state'
16
+ property 'postCode'
17
+ property 'city'
18
+ property 'city2'
19
+ property 'street'
20
+ property 'houseNumber'
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,13 @@
1
+ module RubyPtvApi
2
+ module Model
3
+ module XLocate
4
+ class AddressResponse < RubyPtvApi::Model::Base
5
+ property 'errorCode'
6
+ property 'errorDescription'
7
+ property 'resultList'
8
+
9
+ coerce_key :resultList, Array[ResultAddress] # Do not work if String 'resultList'
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module RubyPtvApi
2
+ module Model
3
+ module XLocate
4
+ class CombinedTransportLocation < RubyPtvApi::Model::Base
5
+ property 'coordinate'
6
+ property 'country'
7
+ property 'name'
8
+
9
+ coerce_key :coordinate, Point
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module RubyPtvApi
2
+ module Model
3
+ module XLocate
4
+ class CombinedTransportResponse < RubyPtvApi::Model::Base
5
+ property 'errorCode'
6
+ property 'errorDescription'
7
+ property 'resultList'
8
+
9
+ coerce_key :resultList, Array[RubyPtvApi::Model::XLocate::ResultCombinedTransport] # Do not work if String 'resultList'
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ module RubyPtvApi
2
+ module Model
3
+ module XLocate
4
+ class Location < RubyPtvApi::Model::Base
5
+ property 'coordinate'
6
+
7
+ coerce_key :coordinate, RubyPtvApi::Model::Point
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,27 @@
1
+ module RubyPtvApi
2
+ module Model
3
+ module XLocate
4
+ # adminRegion String The administrative address supplement of the address.
5
+ # appendix String The appendix of the address.
6
+ # countryCapital String The capital of the country.
7
+ # totalScore int The quality score of the address candidate. Indicates the overall quality of the resultlist candidate. Does not indicate the match quality of the input address to the result (for this szenario use the classification). In location based search modes, this value is the distance in meter.
8
+ # detailLevelDescription DetailLevelDescription The detail level of the candidate. See DetailLevelDescription for possible values.
9
+ # classificationDescription ClassificationDescription The classification of the address candidate based on the quality of the match. See ClassificationDescription for possible values.
10
+ # coordinates Point The coordinates of the address candidate.
11
+ # additionalFields AdditionalField[] Additional result fields. The fields are returned in the same order as they have been requested.
12
+
13
+ class ResultAddress < Address
14
+ property 'adminRegion'
15
+ property 'appendix'
16
+ property 'countryCapital'
17
+ property 'totalScore'
18
+ property 'detailLevelDescription'
19
+ property 'classificationDescription'
20
+ property 'coordinates'
21
+ property 'additionalFields'
22
+
23
+ coerce_key :coordinates, Point
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,30 @@
1
+ module RubyPtvApi
2
+ module Model
3
+ module XLocate
4
+ # id String The unique key to identify the combined transport.
5
+ # name String The name of the combined transport.
6
+ # duration int The duration in seconds of the combined transport.
7
+ # distance double The distance to the input location in meters.
8
+ # type int The type of the combined transport. Legal values are:
9
+ # 1 - ferry: The combined transport is a ferry boat connection.
10
+ # 2 - piggyback: The combined transport is a piggyback train connection.
11
+ # start CombinedTransportLocation The start of the combined transport.
12
+ # destination CombinedTransportLocation The destination of the combined transport.
13
+ # combinedTransportFields AdditionalField[] Additional combined transport result fields. The fields are returned in the same order as they have been requested.
14
+ class ResultCombinedTransport < RubyPtvApi::Model::Base
15
+ property 'id'
16
+ property 'name'
17
+ property 'duration'
18
+ property 'distance'
19
+ property 'type'
20
+ property 'start'
21
+ property 'destination'
22
+ property 'combinedTransportFields'
23
+
24
+ coerce_key :start, CombinedTransportLocation
25
+ coerce_key :destination, CombinedTransportLocation
26
+ coerce_key :combinedTransportFields, Array[AdditionalField]
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,14 @@
1
+ module RubyPtvApi
2
+ module Model
3
+ module XLocate
4
+ class SortOption < RubyPtvApi::Model::Base
5
+ property 'field', transform_with: ->(value) do
6
+ RubyPtvApi::Constant.validate(RubyPtvApi::Constant::RESULT_FIELD, value)
7
+ end
8
+ property 'order', transform_with: ->(value) do
9
+ RubyPtvApi::Constant.validate(RubyPtvApi::Constant::SORT_ORDER, value)
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,12 @@
1
+ module RubyPtvApi
2
+ module Model
3
+ module XLocate
4
+ class Suggestion < RubyPtvApi::Model::Base
5
+ property 'text'
6
+ property 'additionalFields'
7
+
8
+ coerce_key :suggestionList, Array[AdditionalField]
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ module RubyPtvApi
2
+ module Model
3
+ module XLocate
4
+ class SuggestionResponse < RubyPtvApi::Model::Base
5
+ property 'suggestionList'
6
+ property 'errorcode'
7
+ property 'errorDescription'
8
+
9
+ coerce_key :suggestionList, Array[Suggestion]
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module RubyPtvApi
2
+ module Model
3
+ module XRoute
4
+ class BoundingRectangle < RubyPtvApi::Model::Base
5
+ property 'leftBottom'
6
+ property 'rightTop'
7
+
8
+ coerce_key :leftBottom, Point
9
+ coerce_key :rightTop , Point
10
+ end
11
+ end
12
+ end
13
+ end