From 68fcc412e64690f3490b9f8036bb2111399616e5 Mon Sep 17 00:00:00 2001 From: Christian Lautier <15379878+maatinito@users.noreply.github.com> Date: Tue, 26 Mar 2024 12:27:17 -1000 Subject: [PATCH] te_fenua_champ: added export --- app/models/champs/te_fenua_champ.rb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/models/champs/te_fenua_champ.rb b/app/models/champs/te_fenua_champ.rb index ac1d3164093..4c326da8104 100644 --- a/app/models/champs/te_fenua_champ.rb +++ b/app/models/champs/te_fenua_champ.rb @@ -104,6 +104,19 @@ def for_api end def for_export - nil + geo_json_from_value&.map do |k, v| + case k + when :parcelles + for_each_feature(v) { |_f, p| "Parcelle n°#{p[:sec_parcelle]} - #{p[:surface_adop]} m2 - #{p[:terre]} à #{p[:commune]} (#{p[:ile]})" } + when :zones_manuelles + for_each_feature(v) { |f, p| "#{f[:id]} à #{p[:commune]} (#{p[:ile]})" } + end + end&.join("\r\n") + end + + def for_each_feature(value) + value[:features].map do |f| + yield f, f[:properties] + end.join("\r\n") end end