diff --git a/api/v01/entities/vrp_input.rb b/api/v01/entities/vrp_input.rb index 8d7430d77..4ec6f2db5 100644 --- a/api/v01/entities/vrp_input.rb +++ b/api/v01/entities/vrp_input.rb @@ -192,11 +192,9 @@ module VrpConfiguration end params :vrp_request_restitution do - # TODO : when we find a good way to return polylines in geojson result, add authorized values here - # (we do not want users to send :polylines, :encoded_polylines for now) optional(:geometry, type: Array[Symbol], default: [], coerce_with: ->(value) { GeometryType.type_cast(value) }, - desc: 'Specifies the geometry structures to be returned. Can be a subset of `[partitions]` or a boolean value to output all or no geometry. Polylines and encoded_polylines are not compatible.') + desc: 'Specifies the geometry structures to be returned. Can be a subset of `[polylines encoded_polylines partitions]` or a boolean value to output all or no geometry. Polylines and encoded_polylines are not compatible together.') optional(:geometry_polyline, type: Boolean, documentation: { hidden: true }, desc: '[DEPRECATED] Use geometry instead, with :polylines or :encoded_polylines') optional(:intermediate_solutions, type: Boolean, desc: 'Return intermediate solutions if available') optional(:csv, type: Boolean, desc: 'The output is a CSV file if you do not specify api format') diff --git a/lib/output_helper.rb b/lib/output_helper.rb index 76a5c3cfc..85b7687ad 100644 --- a/lib/output_helper.rb +++ b/lib/output_helper.rb @@ -318,8 +318,7 @@ def self.generate_geometry(solution) geojson[:partitions] = generate_partitions_geometry(result) if expected_geometry.include?(:partitions) geojson[:points] = generate_points_geometry(result) - # TODO : re-activate this function call when we find a good way to return polylines in result - # geojson[:polylines] = generate_polylines_geometry(result) if expected_geometry.include?(:polylines) + geojson[:polylines] = generate_polylines_geometry(result) if expected_geometry.include?(:polylines) geojson } end diff --git a/models/types/geometry_type.rb b/models/types/geometry_type.rb index baaf52a5a..c9380ba04 100644 --- a/models/types/geometry_type.rb +++ b/models/types/geometry_type.rb @@ -25,8 +25,7 @@ def self.type_cast(value) if value.is_a?(FalseClass) [] elsif value.is_a?(TrueClass) - # ALL_TYPES - %i[polylines encoded_polylines] # ensures old behaviour is respected when geometry is true + ALL_TYPES elsif value.is_a?(Array) to_return = [] value.each{ |geometry_type| @@ -34,8 +33,7 @@ def self.type_cast(value) raise ArgumentError.new("Invalid geometry value: #{geometry_type}") end - # to_return << geometry_type.to_sym - to_return << geometry_type.to_sym unless %i[polylines encoded_polylines].include?(geometry_type.to_sym) + to_return << geometry_type.to_sym } if (to_return & [:polylines, :encoded_polylines]).size == 2 diff --git a/test/api/v01/output_test.rb b/test/api/v01/output_test.rb index 4a9c9d41a..a8613eb04 100644 --- a/test/api/v01/output_test.rb +++ b/test/api/v01/output_test.rb @@ -438,12 +438,6 @@ def test_geojsons_returned refute(result['geojsons'].first['partitions'].key?('work_day')) # points should always be returned refute_empty(result['geojsons'].first['points']) - - # TODO : remove when returning polylines is more performant and we allow this field in geometry : - vrp[:configuration][:restitution] = { geometry: [:partitions, :polylines] } - @job_id = submit_vrp api_key: 'ortools', vrp: vrp - result = wait_status @job_id, 'completed', api_key: 'ortools' - refute(result['geojsons'].first.key?('polylines')) end skip 'Remaining part of this test is skipped because at the moment POST does not return the same result as GET ' \