defra_ruby_area 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +8 -0
- data/README.md +150 -0
- data/Rakefile +33 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/defra_ruby.rb +7 -0
- data/lib/defra_ruby/area.rb +13 -0
- data/lib/defra_ruby/area/no_match_error.rb +11 -0
- data/lib/defra_ruby/area/response.rb +33 -0
- data/lib/defra_ruby/area/services/base_area_service.rb +58 -0
- data/lib/defra_ruby/area/services/public_face_area_service.rb +25 -0
- data/lib/defra_ruby/area/services/water_management_area_service.rb +25 -0
- data/lib/defra_ruby/area/version.rb +7 -0
- data/spec/cassettes/public_face_area_invalid_blank.yml +157 -0
- data/spec/cassettes/public_face_area_invalid_coords.yml +47 -0
- data/spec/cassettes/public_face_area_valid.yml +165 -0
- data/spec/cassettes/water_management_area_invalid_blank.yml +49 -0
- data/spec/cassettes/water_management_area_invalid_coords.yml +52 -0
- data/spec/cassettes/water_management_area_valid.yml +60 -0
- data/spec/defra_ruby/area/response_spec.rb +67 -0
- data/spec/defra_ruby/area/services/public_face_area_service_spec.rb +63 -0
- data/spec/defra_ruby/area/services/water_management_area_service_spec.rb +63 -0
- data/spec/defra_ruby/area_spec.rb +12 -0
- data/spec/examples.txt +15 -0
- data/spec/spec_helper.rb +83 -0
- data/spec/support/defra_ruby_area.rb +4 -0
- data/spec/support/dotenv.rb +4 -0
- data/spec/support/pry.rb +7 -0
- data/spec/support/simplecov.rb +17 -0
- data/spec/support/vcr.rb +17 -0
- metadata +261 -0
@@ -0,0 +1,47 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://environment.data.gov.uk/spatialdata/administrative-boundaries-environment-agency-and-natural-england-public-face-areas/wfs?Filter=(%3CFilter%3E%3CIntersects%3E%3CPropertyName%3ESHAPE%3C/PropertyName%3E%3Cgml:Point%3E%3Cgml:coordinates%3E301233.0,221592.0%3C/gml:coordinates%3E%3C/gml:Point%3E%3C/Intersects%3E%3C/Filter%3E)&REQUEST=GetFeature&SERVICE=WFS&SRSName=EPSG:27700&VERSION=2.0.0&propertyName=long_name,short_name&typeNames=ms:Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- "*/*"
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip, deflate
|
14
|
+
User-Agent:
|
15
|
+
- rest-client/2.0.2 (darwin18.2.0 x86_64) ruby/2.4.2p198
|
16
|
+
Host:
|
17
|
+
- environment.data.gov.uk
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Server:
|
24
|
+
- nginx
|
25
|
+
Date:
|
26
|
+
- Wed, 31 Jul 2019 19:06:40 GMT
|
27
|
+
Content-Type:
|
28
|
+
- application/xml
|
29
|
+
Content-Length:
|
30
|
+
- '1024'
|
31
|
+
Connection:
|
32
|
+
- keep-alive
|
33
|
+
Cache-Control:
|
34
|
+
- private
|
35
|
+
X-Aspnet-Version:
|
36
|
+
- 4.0.30319
|
37
|
+
X-Powered-By:
|
38
|
+
- ASP.NET
|
39
|
+
body:
|
40
|
+
encoding: UTF-8
|
41
|
+
string: |-
|
42
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
43
|
+
<wfs:FeatureCollection xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wfs="http://www.opengis.net/wfs/2.0" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:ms="https://environment.data.gov.uk/spatialdata/administrative-boundaries-environment-agency-and-natural-england-public-face-areas/wfs" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" timeStamp="2019-07-31T19:06:40Z" numberMatched="unknown" numberReturned="0" xsi:schemaLocation="http://www.opengis.net/wfs/2.0 http://schemas.opengis.net/wfs/2.0/wfs.xsd http://www.opengis.net/gml/3.2 http://schemas.opengis.net/gml/3.2.1/gml.xsd https://environment.data.gov.uk/spatialdata/administrative-boundaries-environment-agency-and-natural-england-public-face-areas/wfs https://environment.data.gov.uk/spatialdata/administrative-boundaries-environment-agency-and-natural-england-public-face-areas/wfs?service=wfs%26version=2.0.0%26request=DescribeFeatureType">
|
44
|
+
</wfs:FeatureCollection>
|
45
|
+
http_version:
|
46
|
+
recorded_at: Wed, 31 Jul 2019 19:06:40 GMT
|
47
|
+
recorded_with: VCR 4.0.0
|
@@ -0,0 +1,165 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://environment.data.gov.uk/spatialdata/administrative-boundaries-environment-agency-and-natural-england-public-face-areas/wfs?Filter=(%3CFilter%3E%3CIntersects%3E%3CPropertyName%3ESHAPE%3C/PropertyName%3E%3Cgml:Point%3E%3Cgml:coordinates%3E408602.61,257535.31%3C/gml:coordinates%3E%3C/gml:Point%3E%3C/Intersects%3E%3C/Filter%3E)&REQUEST=GetFeature&SERVICE=WFS&SRSName=EPSG:27700&VERSION=2.0.0&propertyName=long_name,short_name&typeNames=ms:Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- "*/*"
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip, deflate
|
14
|
+
User-Agent:
|
15
|
+
- rest-client/2.0.2 (darwin18.5.0 x86_64) ruby/2.4.2p198
|
16
|
+
Host:
|
17
|
+
- environment.data.gov.uk
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Server:
|
24
|
+
- nginx
|
25
|
+
Date:
|
26
|
+
- Tue, 09 Jul 2019 10:13:56 GMT
|
27
|
+
Content-Type:
|
28
|
+
- application/xml
|
29
|
+
Content-Length:
|
30
|
+
- '1607'
|
31
|
+
Connection:
|
32
|
+
- keep-alive
|
33
|
+
Cache-Control:
|
34
|
+
- private
|
35
|
+
X-Aspnet-Version:
|
36
|
+
- 4.0.30319
|
37
|
+
X-Powered-By:
|
38
|
+
- ASP.NET
|
39
|
+
body:
|
40
|
+
encoding: UTF-8
|
41
|
+
string: |-
|
42
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
43
|
+
<wfs:FeatureCollection xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wfs="http://www.opengis.net/wfs/2.0" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:ms="https://environment.data.gov.uk/spatialdata/administrative-boundaries-environment-agency-and-natural-england-public-face-areas/wfs" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" timeStamp="2019-07-09T10:13:56Z" numberMatched="unknown" numberReturned="1" xsi:schemaLocation="http://www.opengis.net/wfs/2.0 http://schemas.opengis.net/wfs/2.0/wfs.xsd http://www.opengis.net/gml/3.2 http://schemas.opengis.net/gml/3.2.1/gml.xsd https://environment.data.gov.uk/spatialdata/administrative-boundaries-environment-agency-and-natural-england-public-face-areas/wfs https://environment.data.gov.uk/spatialdata/administrative-boundaries-environment-agency-and-natural-england-public-face-areas/wfs?service=wfs%26version=2.0.0%26request=DescribeFeatureType">
|
44
|
+
<wfs:member>
|
45
|
+
<ms:Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas gml:id="Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas.23">
|
46
|
+
<ms:OBJECTID>23</ms:OBJECTID>
|
47
|
+
<ms:long_name>West Midlands</ms:long_name>
|
48
|
+
<ms:short_name>West Midlands</ms:short_name>
|
49
|
+
<ms:st_area_shape_>14543741870.84492</ms:st_area_shape_>
|
50
|
+
<ms:st_perimeter_shape_>1043376.795941756</ms:st_perimeter_shape_>
|
51
|
+
</ms:Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas>
|
52
|
+
</wfs:member>
|
53
|
+
</wfs:FeatureCollection>
|
54
|
+
http_version:
|
55
|
+
recorded_at: Tue, 09 Jul 2019 10:13:56 GMT
|
56
|
+
- request:
|
57
|
+
method: get
|
58
|
+
uri: https://environment.data.gov.uk/spatialdata/administrative-boundaries-environment-agency-and-natural-england-public-face-areas/wfs?Filter=(%3CFilter%3E%3CIntersects%3E%3CPropertyName%3ESHAPE%3C/PropertyName%3E%3Cgml:Point%3E%3Cgml:coordinates%3E408602.61,257535.31%3C/gml:coordinates%3E%3C/gml:Point%3E%3C/Intersects%3E%3C/Filter%3E)&REQUEST=GetFeature&SERVICE=WFS&SRSName=EPSG:27700&VERSION=2.0.0&propertyName=long_name&typeNames=ms:Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas
|
59
|
+
body:
|
60
|
+
encoding: US-ASCII
|
61
|
+
string: ''
|
62
|
+
headers:
|
63
|
+
Accept:
|
64
|
+
- "*/*"
|
65
|
+
Accept-Encoding:
|
66
|
+
- gzip, deflate
|
67
|
+
User-Agent:
|
68
|
+
- rest-client/2.0.2 (darwin18.5.0 x86_64) ruby/2.4.2p198
|
69
|
+
Host:
|
70
|
+
- environment.data.gov.uk
|
71
|
+
response:
|
72
|
+
status:
|
73
|
+
code: 200
|
74
|
+
message: OK
|
75
|
+
headers:
|
76
|
+
Server:
|
77
|
+
- nginx
|
78
|
+
Date:
|
79
|
+
- Thu, 01 Aug 2019 10:07:06 GMT
|
80
|
+
Content-Type:
|
81
|
+
- application/xml
|
82
|
+
Content-Length:
|
83
|
+
- '1556'
|
84
|
+
Connection:
|
85
|
+
- keep-alive
|
86
|
+
Cache-Control:
|
87
|
+
- private
|
88
|
+
X-Aspnet-Version:
|
89
|
+
- 4.0.30319
|
90
|
+
X-Powered-By:
|
91
|
+
- ASP.NET
|
92
|
+
body:
|
93
|
+
encoding: UTF-8
|
94
|
+
string: |-
|
95
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
96
|
+
<wfs:FeatureCollection xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wfs="http://www.opengis.net/wfs/2.0" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:ms="https://environment.data.gov.uk/spatialdata/administrative-boundaries-environment-agency-and-natural-england-public-face-areas/wfs" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" timeStamp="2019-08-01T10:07:06Z" numberMatched="unknown" numberReturned="1" xsi:schemaLocation="http://www.opengis.net/wfs/2.0 http://schemas.opengis.net/wfs/2.0/wfs.xsd http://www.opengis.net/gml/3.2 http://schemas.opengis.net/gml/3.2.1/gml.xsd https://environment.data.gov.uk/spatialdata/administrative-boundaries-environment-agency-and-natural-england-public-face-areas/wfs https://environment.data.gov.uk/spatialdata/administrative-boundaries-environment-agency-and-natural-england-public-face-areas/wfs?service=wfs%26version=2.0.0%26request=DescribeFeatureType">
|
97
|
+
<wfs:member>
|
98
|
+
<ms:Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas gml:id="Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas.23">
|
99
|
+
<ms:OBJECTID>23</ms:OBJECTID>
|
100
|
+
<ms:long_name>West Midlands</ms:long_name>
|
101
|
+
<ms:st_area_shape_>14543741870.84492</ms:st_area_shape_>
|
102
|
+
<ms:st_perimeter_shape_>1043376.795941756</ms:st_perimeter_shape_>
|
103
|
+
</ms:Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas>
|
104
|
+
</wfs:member>
|
105
|
+
</wfs:FeatureCollection>
|
106
|
+
http_version:
|
107
|
+
recorded_at: Thu, 01 Aug 2019 10:07:05 GMT
|
108
|
+
- request:
|
109
|
+
method: get
|
110
|
+
uri: https://environment.data.gov.uk/spatialdata/administrative-boundaries-environment-agency-and-natural-england-public-face-areas/wfs?Filter=(%3CFilter%3E%3CIntersects%3E%3CPropertyName%3ESHAPE%3C/PropertyName%3E%3Cgml:Point%3E%3Cgml:coordinates%3E408602.61,257535.31%3C/gml:coordinates%3E%3C/gml:Point%3E%3C/Intersects%3E%3C/Filter%3E)&REQUEST=GetFeature&SERVICE=WFS&SRSName=EPSG:27700&VERSION=1.0.0&propertyName=long_name&typeNames=ms:Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas
|
111
|
+
body:
|
112
|
+
encoding: US-ASCII
|
113
|
+
string: ''
|
114
|
+
headers:
|
115
|
+
Accept:
|
116
|
+
- "*/*"
|
117
|
+
Accept-Encoding:
|
118
|
+
- gzip, deflate
|
119
|
+
User-Agent:
|
120
|
+
- rest-client/2.0.2 (darwin18.5.0 x86_64) ruby/2.4.2p198
|
121
|
+
Host:
|
122
|
+
- environment.data.gov.uk
|
123
|
+
response:
|
124
|
+
status:
|
125
|
+
code: 200
|
126
|
+
message: OK
|
127
|
+
headers:
|
128
|
+
Server:
|
129
|
+
- nginx
|
130
|
+
Date:
|
131
|
+
- Sat, 03 Aug 2019 10:48:43 GMT
|
132
|
+
Content-Type:
|
133
|
+
- application/xml
|
134
|
+
Content-Length:
|
135
|
+
- '1613'
|
136
|
+
Connection:
|
137
|
+
- keep-alive
|
138
|
+
Cache-Control:
|
139
|
+
- private
|
140
|
+
X-Aspnet-Version:
|
141
|
+
- 4.0.30319
|
142
|
+
X-Powered-By:
|
143
|
+
- ASP.NET
|
144
|
+
body:
|
145
|
+
encoding: UTF-8
|
146
|
+
string: |-
|
147
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
148
|
+
<wfs:FeatureCollection xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wfs="http://www.opengis.net/wfs" xmlns:gml="http://www.opengis.net/gml" xmlns:ms="https://environment.data.gov.uk/spatialdata/administrative-boundaries-environment-agency-and-natural-england-public-face-areas/wfs" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd http://www.opengis.net/gml http://schemas.opengis.net/gml/2.1.2/feature.xsd https://environment.data.gov.uk/spatialdata/administrative-boundaries-environment-agency-and-natural-england-public-face-areas/wfs https://environment.data.gov.uk/spatialdata/administrative-boundaries-environment-agency-and-natural-england-public-face-areas/wfs?service=wfs%26version=1.0.0%26request=DescribeFeatureType">
|
149
|
+
<gml:boundedBy>
|
150
|
+
<gml:Box srsName="EPSG:27700">
|
151
|
+
<gml:coordinates>0,0,0,0</gml:coordinates>
|
152
|
+
</gml:Box>
|
153
|
+
</gml:boundedBy>
|
154
|
+
<gml:featureMember>
|
155
|
+
<ms:Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas fid="Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas.23">
|
156
|
+
<ms:OBJECTID>23</ms:OBJECTID>
|
157
|
+
<ms:long_name>West Midlands</ms:long_name>
|
158
|
+
<ms:st_area_shape_>14543741870.84492</ms:st_area_shape_>
|
159
|
+
<ms:st_perimeter_shape_>1043376.795941756</ms:st_perimeter_shape_>
|
160
|
+
</ms:Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas>
|
161
|
+
</gml:featureMember>
|
162
|
+
</wfs:FeatureCollection>
|
163
|
+
http_version:
|
164
|
+
recorded_at: Sat, 03 Aug 2019 10:48:44 GMT
|
165
|
+
recorded_with: VCR 4.0.0
|
@@ -0,0 +1,49 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://environment.data.gov.uk/spatialdata/administrative-boundaries-water-management-areas/wfs?Filter=(%3CFilter%3E%3CIntersects%3E%3CPropertyName%3ESHAPE%3C/PropertyName%3E%3Cgml:Point%3E%3Cgml:coordinates%3E,%3C/gml:coordinates%3E%3C/gml:Point%3E%3C/Intersects%3E%3C/Filter%3E)&REQUEST=GetFeature&SERVICE=WFS&SRSName=EPSG:27700&VERSION=1.0.0&propertyName=long_name&typeNames=ms:Administrative_Boundaries_Water_Management_Areas
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- "*/*"
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip, deflate
|
14
|
+
User-Agent:
|
15
|
+
- rest-client/2.0.2 (darwin18.5.0 x86_64) ruby/2.4.2p198
|
16
|
+
Host:
|
17
|
+
- environment.data.gov.uk
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Server:
|
24
|
+
- nginx
|
25
|
+
Date:
|
26
|
+
- Thu, 01 Aug 2019 08:44:09 GMT
|
27
|
+
Content-Type:
|
28
|
+
- application/xml
|
29
|
+
Content-Length:
|
30
|
+
- '349'
|
31
|
+
Connection:
|
32
|
+
- keep-alive
|
33
|
+
Cache-Control:
|
34
|
+
- private
|
35
|
+
X-Aspnet-Version:
|
36
|
+
- 4.0.30319
|
37
|
+
X-Powered-By:
|
38
|
+
- ASP.NET
|
39
|
+
body:
|
40
|
+
encoding: UTF-8
|
41
|
+
string: |
|
42
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
43
|
+
<ogc:ServiceExceptionReport xmlns:ogc="http://www.opengis.net/ogc" version="1.2.0">
|
44
|
+
<ogc:ServiceException><![CDATA[The geometry was not recognized.]]></ogc:ServiceException>
|
45
|
+
<ogc:ServiceException><![CDATA[Operator 'Intersects' can't parse geometry.]]></ogc:ServiceException>
|
46
|
+
</ogc:ServiceExceptionReport>
|
47
|
+
http_version:
|
48
|
+
recorded_at: Thu, 01 Aug 2019 08:44:09 GMT
|
49
|
+
recorded_with: VCR 4.0.0
|
@@ -0,0 +1,52 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://environment.data.gov.uk/spatialdata/administrative-boundaries-water-management-areas/wfs?Filter=(%3CFilter%3E%3CIntersects%3E%3CPropertyName%3ESHAPE%3C/PropertyName%3E%3Cgml:Point%3E%3Cgml:coordinates%3E301233.0,221592.0%3C/gml:coordinates%3E%3C/gml:Point%3E%3C/Intersects%3E%3C/Filter%3E)&REQUEST=GetFeature&SERVICE=WFS&SRSName=EPSG:27700&VERSION=1.0.0&propertyName=long_name&typeNames=ms:Administrative_Boundaries_Water_Management_Areas
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- "*/*"
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip, deflate
|
14
|
+
User-Agent:
|
15
|
+
- rest-client/2.0.2 (darwin18.5.0 x86_64) ruby/2.4.2p198
|
16
|
+
Host:
|
17
|
+
- environment.data.gov.uk
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Server:
|
24
|
+
- nginx
|
25
|
+
Date:
|
26
|
+
- Thu, 01 Aug 2019 08:44:09 GMT
|
27
|
+
Content-Type:
|
28
|
+
- application/xml
|
29
|
+
Content-Length:
|
30
|
+
- '968'
|
31
|
+
Connection:
|
32
|
+
- keep-alive
|
33
|
+
Cache-Control:
|
34
|
+
- private
|
35
|
+
X-Aspnet-Version:
|
36
|
+
- 4.0.30319
|
37
|
+
X-Powered-By:
|
38
|
+
- ASP.NET
|
39
|
+
body:
|
40
|
+
encoding: UTF-8
|
41
|
+
string: |-
|
42
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
43
|
+
<wfs:FeatureCollection xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wfs="http://www.opengis.net/wfs" xmlns:gml="http://www.opengis.net/gml" xmlns:ms="https://environment.data.gov.uk/spatialdata/administrative-boundaries-water-management-areas/wfs" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd http://www.opengis.net/gml http://schemas.opengis.net/gml/2.1.2/feature.xsd https://environment.data.gov.uk/spatialdata/administrative-boundaries-water-management-areas/wfs https://environment.data.gov.uk/spatialdata/administrative-boundaries-water-management-areas/wfs?service=wfs%26version=1.0.0%26request=DescribeFeatureType">
|
44
|
+
<gml:boundedBy>
|
45
|
+
<gml:Box srsName="EPSG:27700">
|
46
|
+
<gml:coordinates>0,0,0,0</gml:coordinates>
|
47
|
+
</gml:Box>
|
48
|
+
</gml:boundedBy>
|
49
|
+
</wfs:FeatureCollection>
|
50
|
+
http_version:
|
51
|
+
recorded_at: Thu, 01 Aug 2019 08:44:09 GMT
|
52
|
+
recorded_with: VCR 4.0.0
|
@@ -0,0 +1,60 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://environment.data.gov.uk/spatialdata/administrative-boundaries-water-management-areas/wfs?Filter=(%3CFilter%3E%3CIntersects%3E%3CPropertyName%3ESHAPE%3C/PropertyName%3E%3Cgml:Point%3E%3Cgml:coordinates%3E408602.61,257535.31%3C/gml:coordinates%3E%3C/gml:Point%3E%3C/Intersects%3E%3C/Filter%3E)&REQUEST=GetFeature&SERVICE=WFS&SRSName=EPSG:27700&VERSION=1.0.0&propertyName=long_name&typeNames=ms:Administrative_Boundaries_Water_Management_Areas
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- "*/*"
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip, deflate
|
14
|
+
User-Agent:
|
15
|
+
- rest-client/2.0.2 (darwin18.5.0 x86_64) ruby/2.4.2p198
|
16
|
+
Host:
|
17
|
+
- environment.data.gov.uk
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Server:
|
24
|
+
- nginx
|
25
|
+
Date:
|
26
|
+
- Thu, 01 Aug 2019 08:44:09 GMT
|
27
|
+
Content-Type:
|
28
|
+
- application/xml
|
29
|
+
Content-Length:
|
30
|
+
- '1434'
|
31
|
+
Connection:
|
32
|
+
- keep-alive
|
33
|
+
Cache-Control:
|
34
|
+
- private
|
35
|
+
X-Aspnet-Version:
|
36
|
+
- 4.0.30319
|
37
|
+
X-Powered-By:
|
38
|
+
- ASP.NET
|
39
|
+
body:
|
40
|
+
encoding: UTF-8
|
41
|
+
string: |-
|
42
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
43
|
+
<wfs:FeatureCollection xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wfs="http://www.opengis.net/wfs" xmlns:gml="http://www.opengis.net/gml" xmlns:ms="https://environment.data.gov.uk/spatialdata/administrative-boundaries-water-management-areas/wfs" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd http://www.opengis.net/gml http://schemas.opengis.net/gml/2.1.2/feature.xsd https://environment.data.gov.uk/spatialdata/administrative-boundaries-water-management-areas/wfs https://environment.data.gov.uk/spatialdata/administrative-boundaries-water-management-areas/wfs?service=wfs%26version=1.0.0%26request=DescribeFeatureType">
|
44
|
+
<gml:boundedBy>
|
45
|
+
<gml:Box srsName="EPSG:27700">
|
46
|
+
<gml:coordinates>0,0,0,0</gml:coordinates>
|
47
|
+
</gml:Box>
|
48
|
+
</gml:boundedBy>
|
49
|
+
<gml:featureMember>
|
50
|
+
<ms:Administrative_Boundaries_Water_Management_Areas fid="Administrative_Boundaries_Water_Management_Areas.15">
|
51
|
+
<ms:OBJECTID>15</ms:OBJECTID>
|
52
|
+
<ms:long_name>Staffordshire Warwickshire and West Midlands</ms:long_name>
|
53
|
+
<ms:st_area_shape_>6460280400.1</ms:st_area_shape_>
|
54
|
+
<ms:st_perimeter_shape_>759189.708848595</ms:st_perimeter_shape_>
|
55
|
+
</ms:Administrative_Boundaries_Water_Management_Areas>
|
56
|
+
</gml:featureMember>
|
57
|
+
</wfs:FeatureCollection>
|
58
|
+
http_version:
|
59
|
+
recorded_at: Thu, 01 Aug 2019 08:44:08 GMT
|
60
|
+
recorded_with: VCR 4.0.0
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
module DefraRuby
|
6
|
+
module Area
|
7
|
+
RSpec.describe Response do
|
8
|
+
subject(:response) { described_class.new(response_exe) }
|
9
|
+
let(:successful) { -> { { area: "Gallifrey" } } }
|
10
|
+
let(:errored) { -> { raise "Boom!" } }
|
11
|
+
|
12
|
+
describe "#successful?" do
|
13
|
+
context "when the response throws an error" do
|
14
|
+
let(:response_exe) { errored }
|
15
|
+
|
16
|
+
it "returns false" do
|
17
|
+
expect(response).to_not be_successful
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "when the response don't throw an error" do
|
22
|
+
let(:response_exe) { successful }
|
23
|
+
|
24
|
+
it "returns true" do
|
25
|
+
expect(response).to be_successful
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "#area" do
|
31
|
+
context "when the response throws an error" do
|
32
|
+
let(:response_exe) { errored }
|
33
|
+
|
34
|
+
it "returns nothing" do
|
35
|
+
expect(response.area).to be_nil
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context "when the response does not throw an error" do
|
40
|
+
let(:response_exe) { successful }
|
41
|
+
|
42
|
+
it "returns an area" do
|
43
|
+
expect(response.area).to eq("Gallifrey")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "#error" do
|
49
|
+
context "when the response throws an error" do
|
50
|
+
let(:response_exe) { errored }
|
51
|
+
|
52
|
+
it "returns the error" do
|
53
|
+
expect(response.error).to be_a(StandardError)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context "when the response don't throw an error" do
|
58
|
+
let(:response_exe) { successful }
|
59
|
+
|
60
|
+
it "returns a nil object" do
|
61
|
+
expect(response.error).to be_nil
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
module DefraRuby
|
6
|
+
module Area
|
7
|
+
RSpec.describe PublicFaceAreaService do
|
8
|
+
describe "#run" do
|
9
|
+
|
10
|
+
context "when the coordinates are valid and in England" do
|
11
|
+
before(:each) { VCR.insert_cassette("public_face_area_valid") }
|
12
|
+
after(:each) { VCR.eject_cassette }
|
13
|
+
|
14
|
+
let(:easting) { 408_602.61 }
|
15
|
+
let(:northing) { 257_535.31 }
|
16
|
+
|
17
|
+
it "returns a successful response" do
|
18
|
+
response = described_class.run(easting, northing)
|
19
|
+
expect(response).to be_a(Response)
|
20
|
+
expect(response.successful?).to eq(true)
|
21
|
+
expect(response.area).to eq("West Midlands")
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
context "when the coordinates are invalid" do
|
27
|
+
context "because they are blank" do
|
28
|
+
before(:each) { VCR.insert_cassette("public_face_area_invalid_blank") }
|
29
|
+
after(:each) { VCR.eject_cassette }
|
30
|
+
|
31
|
+
let(:easting) { nil }
|
32
|
+
let(:northing) { nil }
|
33
|
+
|
34
|
+
it "returns a failed response" do
|
35
|
+
response = described_class.run(easting, northing)
|
36
|
+
expect(response).to be_a(Response)
|
37
|
+
expect(response).to_not be_successful
|
38
|
+
expect(response.area).to be_nil
|
39
|
+
expect(response.error).to_not be_nil
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context "because they are not in an area" do
|
44
|
+
before(:each) { VCR.insert_cassette("public_face_area_invalid_coords") }
|
45
|
+
after(:each) { VCR.eject_cassette }
|
46
|
+
|
47
|
+
let(:easting) { 301_233.0 }
|
48
|
+
let(:northing) { 221_592.0 }
|
49
|
+
|
50
|
+
it "returns a failed response" do
|
51
|
+
response = described_class.run(easting, northing)
|
52
|
+
expect(response).to be_a(Response)
|
53
|
+
expect(response).to_not be_successful
|
54
|
+
expect(response.area).to be_nil
|
55
|
+
expect(response.error).to_not be_nil
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|