fix(carto): no crash on points with elevation
This commit is contained in:
parent
9d8ad9b3d8
commit
6723bdcd9d
3 changed files with 24 additions and 1 deletions
|
@ -110,7 +110,7 @@ class GeoArea < ApplicationRecord
|
|||
|
||||
def location
|
||||
if point?
|
||||
Geo::Coord.new(*geometry['coordinates'].reverse).to_s
|
||||
Geo::Coord.new(*geometry['coordinates'][0..1].reverse).to_s
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -116,6 +116,15 @@ FactoryBot.define do
|
|||
end
|
||||
end
|
||||
|
||||
trait :point_with_z do
|
||||
geometry do
|
||||
{
|
||||
"type": "Point",
|
||||
"coordinates": [2.428439855575562, 46.538476837725796, 42]
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
trait :invalid_point do
|
||||
geometry do
|
||||
{
|
||||
|
|
|
@ -122,6 +122,20 @@ RSpec.describe GeoArea, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context "when geo is a point" do
|
||||
let(:geo_area) { build(:geo_area, :selection_utilisateur, :point, champ: nil) }
|
||||
it "should return the label" do
|
||||
expect(geo_area.label).to eq("Un point situé à 46°32'19\"N 2°25'42\"E")
|
||||
end
|
||||
end
|
||||
|
||||
context "when geo is a point with elevation" do
|
||||
let(:geo_area) { build(:geo_area, :selection_utilisateur, :point_with_z, champ: nil) }
|
||||
it "should return the label" do
|
||||
expect(geo_area.label).to eq("Un point situé à 46°32'19\"N 2°25'42\"E")
|
||||
end
|
||||
end
|
||||
|
||||
context "when geo is a cadastre parcelle" do
|
||||
let(:geo_area) { build(:geo_area, :selection_utilisateur, :cadastre, champ: nil) }
|
||||
it "should return the label" do
|
||||
|
|
Loading…
Reference in a new issue