2015-11-23 18:41:48 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe GeojsonService do
|
2016-01-15 11:53:00 +01:00
|
|
|
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) }
|
2015-11-23 18:41:48 +01:00
|
|
|
|
|
|
|
describe 'coordinates are empty' do
|
|
|
|
let(:coordinates) { '' }
|
|
|
|
|
2015-11-30 17:12:32 +01:00
|
|
|
it { expect(subject['geo']['type']).to eq('Polygon') }
|
|
|
|
it { expect(subject['geo']['coordinates']).to eq([coordinates]) }
|
2015-11-23 18:41:48 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'coordinates are informed' do
|
2016-01-15 11:53:00 +01:00
|
|
|
let(:coordinates) { good_coordinates }
|
2015-11-23 18:41:48 +01:00
|
|
|
|
2015-11-30 17:12:32 +01:00
|
|
|
it { expect(subject['geo']['type']).to eq('Polygon') }
|
|
|
|
it { expect(subject['geo']['coordinates']).to eq([coordinates]) }
|
2015-11-23 18:41:48 +01:00
|
|
|
end
|
|
|
|
end
|
2016-01-15 11:53:00 +01:00
|
|
|
|
|
|
|
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') }
|
2016-01-15 13:15:50 +01:00
|
|
|
it { expect(subject['geom']['geometry']['coordinates']).to eq([coordinates]) }
|
2016-01-15 11:53:00 +01:00
|
|
|
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') }
|
2016-01-15 13:15:50 +01:00
|
|
|
it { expect(subject['geom']['geometry']['coordinates']).to eq([coordinates]) }
|
2016-01-15 11:53:00 +01:00
|
|
|
end
|
|
|
|
end
|
2015-11-23 18:41:48 +01:00
|
|
|
end
|