Merge pull request #9171 from tchak/fix-geo-json-with-z
fix(carto): no crash on points with elevation
This commit is contained in:
commit
8152382e58
3 changed files with 24 additions and 1 deletions
|
@ -110,7 +110,7 @@ class GeoArea < ApplicationRecord
|
||||||
|
|
||||||
def location
|
def location
|
||||||
if point?
|
if point?
|
||||||
Geo::Coord.new(*geometry['coordinates'].reverse).to_s
|
Geo::Coord.new(*geometry['coordinates'][0..1].reverse).to_s
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -116,6 +116,15 @@ FactoryBot.define do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
trait :point_with_z do
|
||||||
|
geometry do
|
||||||
|
{
|
||||||
|
"type": "Point",
|
||||||
|
"coordinates": [2.428439855575562, 46.538476837725796, 42]
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
trait :invalid_point do
|
trait :invalid_point do
|
||||||
geometry do
|
geometry do
|
||||||
{
|
{
|
||||||
|
|
|
@ -122,6 +122,20 @@ RSpec.describe GeoArea, type: :model do
|
||||||
end
|
end
|
||||||
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
|
context "when geo is a cadastre parcelle" do
|
||||||
let(:geo_area) { build(:geo_area, :selection_utilisateur, :cadastre, champ: nil) }
|
let(:geo_area) { build(:geo_area, :selection_utilisateur, :cadastre, champ: nil) }
|
||||||
it "should return the label" do
|
it "should return the label" do
|
||||||
|
|
Loading…
Reference in a new issue