Stop crashing if a selection utilisateur contains no geometry

This commit is contained in:
Paul Chavard 2021-01-27 14:15:58 +01:00
parent 749850da0a
commit 3d0c888058

View file

@ -71,7 +71,7 @@ class Champs::CarteController < ApplicationController
def cadastres_features_collection(feature_collection) def cadastres_features_collection(feature_collection)
coordinates = feature_collection[:features].filter do |feature| coordinates = feature_collection[:features].filter do |feature|
feature[:properties][:source] == GeoArea.sources.fetch(:selection_utilisateur) && feature[:geometry]['type'] == 'Polygon' feature[:properties][:source] == GeoArea.sources.fetch(:selection_utilisateur) && feature[:geometry] && feature[:geometry]['type'] == 'Polygon'
end.map do |feature| end.map do |feature|
feature[:geometry]['coordinates'][0].map { |(lng, lat)| { 'lng' => lng, 'lat' => lat } } feature[:geometry]['coordinates'][0].map { |(lng, lat)| { 'lng' => lng, 'lat' => lat } }
end end