Add get_cadastre on TPS carte page and display on leaflet map
This commit is contained in:
parent
6d4b29cf36
commit
2ce8e4734b
14 changed files with 283 additions and 91 deletions
|
@ -10,4 +10,44 @@ describe ModuleAPICarto do
|
|||
it { is_expected.to have_db_column(:quartiers_prioritaires) }
|
||||
it { is_expected.to have_db_column(:cadastre) }
|
||||
end
|
||||
|
||||
describe '#classes' do
|
||||
let(:module_api_carto) { create(:module_api_carto, quartiers_prioritaires: qp, cadastre: cadastre) }
|
||||
|
||||
context 'when module api carto qp is true' do
|
||||
let(:qp) { true }
|
||||
let(:cadastre) { false }
|
||||
|
||||
subject { module_api_carto.classes }
|
||||
|
||||
it { is_expected.to eq 'qp ' }
|
||||
end
|
||||
|
||||
context 'when module api carto cadastre is true' do
|
||||
let(:qp) { false }
|
||||
let(:cadastre) { true }
|
||||
|
||||
subject { module_api_carto.classes }
|
||||
|
||||
it { is_expected.to eq 'cadastre ' }
|
||||
end
|
||||
|
||||
context 'when module api carto qp is true and cadastre is true' do
|
||||
let(:qp) { true }
|
||||
let(:cadastre) { true }
|
||||
|
||||
subject { module_api_carto.classes }
|
||||
|
||||
it { is_expected.to eq 'qp cadastre ' }
|
||||
end
|
||||
|
||||
context 'when module api carto qp is false and cadastre is false' do
|
||||
let(:qp) { false }
|
||||
let(:cadastre) { false }
|
||||
|
||||
subject { module_api_carto.classes }
|
||||
|
||||
it { is_expected.to eq '' }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,8 +1,23 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe GeojsonService do
|
||||
describe '.toGeoJsonPolygon' do
|
||||
subject { JSON.parse(described_class.to_json_polygon coordinates) }
|
||||
let(:good_coordinates) {
|
||||
[
|
||||
[5.93536376953125,
|
||||
48.91888968903368],
|
||||
[5.93536376953125,
|
||||
49.26780455063753],
|
||||
[7.094421386718749,
|
||||
49.26780455063753],
|
||||
[7.094421386718749,
|
||||
48.91888968903368],
|
||||
[5.93536376953125,
|
||||
48.91888968903368]
|
||||
]
|
||||
}
|
||||
|
||||
describe '.toGeoJsonPolygonForQp' do
|
||||
subject { JSON.parse(described_class.to_json_polygon_for_qp coordinates) }
|
||||
|
||||
describe 'coordinates are empty' do
|
||||
let(:coordinates) { '' }
|
||||
|
@ -12,23 +27,30 @@ describe GeojsonService do
|
|||
end
|
||||
|
||||
describe 'coordinates are informed' do
|
||||
let(:coordinates) {
|
||||
[
|
||||
[5.93536376953125,
|
||||
48.91888968903368],
|
||||
[5.93536376953125,
|
||||
49.26780455063753],
|
||||
[7.094421386718749,
|
||||
49.26780455063753],
|
||||
[7.094421386718749,
|
||||
48.91888968903368],
|
||||
[5.93536376953125,
|
||||
48.91888968903368]
|
||||
]
|
||||
}
|
||||
let(:coordinates) { good_coordinates }
|
||||
|
||||
it { expect(subject['geo']['type']).to eq('Polygon') }
|
||||
it { expect(subject['geo']['coordinates']).to eq([coordinates]) }
|
||||
end
|
||||
end
|
||||
|
||||
describe '.toGeoJsonPolygonForCadastre' do
|
||||
subject { JSON.parse(described_class.to_json_polygon_for_cadastre coordinates) }
|
||||
|
||||
describe 'coordinates are empty' do
|
||||
let(:coordinates) { '' }
|
||||
|
||||
it { expect(subject['geom']['type']).to eq('Feature') }
|
||||
it { expect(subject['geom']['geometry']['type']).to eq('Polygon') }
|
||||
it { expect(subject['geom']['geometry']['coordinates']).to eq([[coordinates]]) }
|
||||
end
|
||||
|
||||
describe 'coordinates are informed' do
|
||||
let(:coordinates) { good_coordinates }
|
||||
|
||||
it { expect(subject['geom']['type']).to eq('Feature') }
|
||||
it { expect(subject['geom']['geometry']['type']).to eq('Polygon') }
|
||||
it { expect(subject['geom']['geometry']['coordinates']).to eq([[coordinates]]) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue