diff --git a/app/models/geozone.rb b/app/models/geozone.rb index be2930ca8..eddf5a13f 100644 --- a/app/models/geozone.rb +++ b/app/models/geozone.rb @@ -28,9 +28,10 @@ class Geozone < ApplicationRecord def normalized_coordinates if geojson.present? - if geojson.match(/"coordinates"\s*:\s*\[{4}/) + if geojson.match(/"coordinates"\s*:\s*\[\s*\[\s*\[\s*\[/) coordinates.reduce([], :concat).reduce([], :concat) - elsif geojson.match(/"coordinates"\s*:\s*\[{3}/) + elsif geojson.match(/"coordinates"\s*:\s*\[\s*\[\s*\[/) + coordinates.reduce([], :concat) else coordinates @@ -39,7 +40,7 @@ class Geozone < ApplicationRecord [] end end - + def coordinates JSON.parse(geojson)["geometry"]["coordinates"] end