Merge pull request #5859 from tchak/fix-champ-carto

Stop crashing if a selection utilisateur contains no geometry
This commit is contained in:
Paul Chavard 2021-01-27 17:33:42 +01:00 committed by GitHub
commit 6a5722a5e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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