geo_combine 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,14 +1,14 @@
1
- <!--
1
+ <!--
2
2
  iso2geoBl.xsl - Transformation from ISO 19139 XML into GeoBlacklight solr json
3
-
3
+
4
4
  -->
5
- <xsl:stylesheet
6
- xmlns="http://www.loc.gov/mods/v3"
7
- xmlns:gco="http://www.isotc211.org/2005/gco"
8
- xmlns:gmi="http://www.isotc211.org/2005/gmi"
9
- xmlns:gmd="http://www.isotc211.org/2005/gmd"
5
+ <xsl:stylesheet
6
+ xmlns="http://www.loc.gov/mods/v3"
7
+ xmlns:gco="http://www.isotc211.org/2005/gco"
8
+ xmlns:gmi="http://www.isotc211.org/2005/gmi"
9
+ xmlns:gmd="http://www.isotc211.org/2005/gmd"
10
10
  xmlns:gml="http://www.opengis.net/gml"
11
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
11
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
12
12
  version="1.0" exclude-result-prefixes="gml gmd gco gmi xsl">
13
13
  <xsl:output method="text" version="1.0" omit-xml-declaration="yes" indent="no" media-type="application/json"/>
14
14
  <xsl:strip-space elements="*"/>
@@ -19,31 +19,31 @@
19
19
  <xsl:variable name="institution">
20
20
  <xsl:for-each select="gmd:MD_Metadata/gmd:contact/gmd:CI_ResponsibleParty">
21
21
  <xsl:choose>
22
-
23
- <!-- Stanford -->
22
+
23
+ <!-- Stanford -->
24
24
  <xsl:when test="contains(gmd:organisationName/gco:CharacterString, 'Stanford')">
25
25
  <xsl:text>Stanford</xsl:text>
26
26
  </xsl:when>
27
-
28
- <!-- UVa -->
27
+
28
+ <!-- UVa -->
29
29
  <xsl:when test="contains(gmd:organisationName/gco:CharacterString, 'Virginia')">
30
30
  <xsl:text>UVa</xsl:text>
31
31
  </xsl:when>
32
32
  <xsl:when test="contains(gmd:organisationName/gco:CharacterString, 'Scholars&apos;)">
33
33
  <xsl:text>UVa</xsl:text>
34
34
  </xsl:when>
35
-
35
+
36
36
  </xsl:choose>
37
37
  </xsl:for-each>
38
38
  </xsl:variable>
39
-
39
+
40
40
  <!-- bounding box -->
41
41
  <xsl:variable name="upperCorner">
42
42
  <xsl:value-of select="number(gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:geographicElement/gmd:EX_GeographicBoundingBox/gmd:eastBoundLongitude/gco:Decimal)"/>
43
43
  <xsl:text> </xsl:text>
44
44
  <xsl:value-of select="number(gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:geographicElement/gmd:EX_GeographicBoundingBox/gmd:northBoundLatitude/gco:Decimal)"/>
45
45
  </xsl:variable>
46
-
46
+
47
47
  <xsl:variable name="lowerCorner">
48
48
  <xsl:value-of select="number(gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:geographicElement/gmd:EX_GeographicBoundingBox/gmd:westBoundLongitude/gco:Decimal)"/>
49
49
  <xsl:text> </xsl:text>
@@ -96,7 +96,7 @@
96
96
  </xsl:choose>
97
97
  </xsl:variable>
98
98
  <xsl:text>{</xsl:text>
99
- <xsl:text>"uuid": "</xsl:text><xsl:value-of select="$uuid"/><xsl:text>",</xsl:text>
99
+ <xsl:text>"geoblacklight_version": "1.0",</xsl:text>
100
100
  <xsl:text>"dc_identifier_s": "</xsl:text><xsl:value-of select="$uuid"/><xsl:text>",</xsl:text>
101
101
  <xsl:text>"dc_title_s": "</xsl:text><xsl:value-of select="gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:title"/><xsl:text>",</xsl:text>
102
102
  <xsl:text>"dc_description_s": "</xsl:text><xsl:value-of select="gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:abstract"/><xsl:text>",</xsl:text>
@@ -132,7 +132,7 @@
132
132
  </xsl:otherwise>
133
133
  </xsl:choose><xsl:text>",</xsl:text>
134
134
  <xsl:text>"dct_provenance_s": "</xsl:text><xsl:value-of select="$institution"/>",
135
-
135
+
136
136
  <xsl:text>"layer_id_s": "</xsl:text>
137
137
  <xsl:choose>
138
138
  <xsl:when test="$institution = 'Stanford'">
@@ -144,6 +144,31 @@
144
144
  <xsl:value-of select="$identifier"/>
145
145
  </xsl:otherwise>
146
146
  </xsl:choose>
147
+ <xsl:text>",</xsl:text>
148
+ <xsl:text>"layer_geom_type_s": "</xsl:text>
149
+ <xsl:choose>
150
+ <xsl:when test="gmd:MD_Metadata/gmd:spatialRepresentationInfo/gmd:MD_VectorSpatialRepresentation/gmd:geometricObjects/gmd:MD_GeometricObjects/gmd:geometricObjectType/gmd:MD_GeometricObjectTypeCode[@codeListValue='surface']">
151
+ <xsl:text>Polygon</xsl:text>
152
+ </xsl:when>
153
+ <xsl:when test="contains(gmd:MD_Metadata/gmd:spatialRepresentationInfo/gmd:MD_VectorSpatialRepresentation/gmd:geometricObjects/gmd:MD_GeometricObjects/gmd:geometricObjectType/gmd:MD_GeometricObjectTypeCode, 'surface')">
154
+ <xsl:text>Polygon</xsl:text>
155
+ </xsl:when>
156
+ <xsl:when test="gmd:MD_Metadata/gmd:spatialRepresentationInfo/gmd:MD_VectorSpatialRepresentation/gmd:geometricObjects/gmd:MD_GeometricObjects/gmd:geometricObjectType/gmd:MD_GeometricObjectTypeCode[@codeListValue='curve']">
157
+ <xsl:text>Line</xsl:text>
158
+ </xsl:when>
159
+ <xsl:when test="contains(gmd:MD_Metadata/gmd:spatialRepresentationInfo/gmd:MD_VectorSpatialRepresentation/gmd:geometricObjects/gmd:MD_GeometricObjects/gmd:geometricObjectType/gmd:MD_GeometricObjectTypeCode, 'curve')">
160
+ <xsl:text>Line</xsl:text>
161
+ </xsl:when>
162
+ <xsl:when test="gmd:MD_Metadata/gmd:spatialRepresentationInfo/gmd:MD_VectorSpatialRepresentation/gmd:geometricObjects/gmd:MD_GeometricObjects/gmd:geometricObjectType/gmd:MD_GeometricObjectTypeCode[@codeListValue='point']">
163
+ <xsl:text>Point</xsl:text>
164
+ </xsl:when>
165
+ <xsl:when test="contains(gmd:MD_Metadata/gmd:spatialRepresentationInfo/gmd:MD_VectorSpatialRepresentation/gmd:geometricObjects/gmd:MD_GeometricObjects/gmd:geometricObjectType/gmd:MD_GeometricObjectTypeCode, 'point')">
166
+ <xsl:text>Point</xsl:text>
167
+ </xsl:when>
168
+ <xsl:when test="contains(gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:spatialRepresentationType/gmd:MD_SpatialRepresentationTypeCode, 'grid')">
169
+ <xsl:text>Raster</xsl:text>
170
+ </xsl:when>
171
+ </xsl:choose>
147
172
  <xsl:text>",</xsl:text>
148
173
  <xsl:text>"layer_slug_s": "</xsl:text>
149
174
  <xsl:value-of select="$institution"/>
@@ -163,10 +188,10 @@
163
188
  </xsl:when>
164
189
  </xsl:choose>
165
190
 
166
-
191
+
167
192
  <xsl:if test="gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:citedResponsibleParty/gmd:CI_ResponsibleParty/gmd:role/gmd:CI_RoleCode[@codeListValue='originator']">
168
193
  <xsl:text>"dc_creator_sm": [</xsl:text>
169
-
194
+
170
195
  <xsl:for-each select="gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:citedResponsibleParty/gmd:CI_ResponsibleParty/gmd:role/gmd:CI_RoleCode[@codeListValue='originator']">
171
196
  <xsl:if test="ancestor-or-self::*/gmd:organisationName">
172
197
  <xsl:text>"</xsl:text>
@@ -176,7 +201,7 @@
176
201
  <xsl:text>,</xsl:text>
177
202
  </xsl:if>
178
203
  </xsl:if>
179
-
204
+
180
205
  <xsl:if test="ancestor-or-self::*/gmd:individualName">
181
206
  <xsl:text>"</xsl:text>
182
207
  <xsl:value-of select="ancestor-or-self::*/gmd:individualName"/>
@@ -190,7 +215,7 @@
190
215
  </xsl:if>
191
216
  <xsl:if test="gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:citedResponsibleParty/gmd:CI_ResponsibleParty/gmd:role/gmd:CI_RoleCode[@codeListValue='publisher']">
192
217
  <xsl:text>"dc_publisher_sm": [</xsl:text>
193
-
218
+
194
219
  <xsl:for-each select="gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:citedResponsibleParty/gmd:CI_ResponsibleParty/gmd:role/gmd:CI_RoleCode[@codeListValue='publisher']">
195
220
  <xsl:if test="ancestor-or-self::*/gmd:organisationName">
196
221
  <xsl:text>"</xsl:text>
@@ -200,7 +225,7 @@
200
225
  <xsl:text>,</xsl:text>
201
226
  </xsl:if>
202
227
  </xsl:if>
203
-
228
+
204
229
  <xsl:if test="ancestor-or-self::*/gmd:individualName">
205
230
  <xsl:text>"</xsl:text>
206
231
  <xsl:value-of select="ancestor-or-self::*/gmd:individualName"/>
@@ -214,14 +239,14 @@
214
239
  </xsl:if>
215
240
 
216
241
  <xsl:text>"dc_format_s": "</xsl:text><xsl:value-of select="$format"/><xsl:text>",</xsl:text>
217
-
242
+
218
243
  <!-- TODO: add inputs for other languages -->
219
244
  <!-- <field name="dc_language_s">
220
245
  <xsl:if test="contains(gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:language | gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:language/gmd:LanguageCode, 'eng')">
221
246
  <xsl:text>English</xsl:text>
222
247
  </xsl:if>
223
248
  </field> -->
224
-
249
+
225
250
  <!-- from DCMI type vocabulary -->
226
251
  <xsl:choose>
227
252
  <xsl:when test="contains(gmd:MD_Metadata/gmd:hierarchyLevelName/gco:CharacterString, 'dataset')">
@@ -236,12 +261,12 @@
236
261
  <xsl:if test="gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:topicCategory/gmd:MD_TopicCategoryCode">
237
262
  <xsl:text>"dc_subject_sm": [</xsl:text>
238
263
  <xsl:for-each select="gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:topicCategory/gmd:MD_TopicCategoryCode">
239
- <xsl:text>"</xsl:text>
264
+ <xsl:text>"</xsl:text>
240
265
  <xsl:value-of select="."/>
241
266
  <xsl:text>"</xsl:text>
242
- <xsl:text>,</xsl:text>
267
+ <xsl:text>,</xsl:text>
243
268
  </xsl:for-each>
244
-
269
+
245
270
  <xsl:for-each select="gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:descriptiveKeywords/gmd:MD_Keywords">
246
271
  <xsl:if test="gmd:type/gmd:MD_KeywordTypeCode[@codeListValue='theme']">
247
272
  <xsl:for-each select="gmd:keyword">
@@ -256,7 +281,7 @@
256
281
  </xsl:for-each>
257
282
  <xsl:text>],</xsl:text>
258
283
  </xsl:if>
259
-
284
+
260
285
  <xsl:if test="gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:descriptiveKeywords/gmd:MD_Keywords/gmd:type/gmd:MD_KeywordTypeCode[@codeListValue='place']">
261
286
  <xsl:text>"dc_spatial_sm": [</xsl:text>
262
287
  <xsl:for-each select="gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:descriptiveKeywords/gmd:MD_Keywords/gmd:type/gmd:MD_KeywordTypeCode[@codeListValue='place']">
@@ -271,7 +296,7 @@
271
296
  </xsl:for-each>
272
297
  <xsl:text>],</xsl:text>
273
298
  </xsl:if>
274
-
299
+
275
300
  <xsl:choose>
276
301
  <xsl:when test="contains(gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:date/gmd:CI_Date/gmd:date/gco:DateTime, 'T')">
277
302
  <xsl:text>"dct_issued_s": "</xsl:text>
@@ -290,30 +315,30 @@
290
315
  <xsl:value-of select="gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:date/gmd:CI_Date/gmd:date/gco:Date"/>
291
316
  <xsl:text>",</xsl:text>
292
317
  </xsl:when>
293
-
318
+
294
319
  <!-- <xsl:otherwise>unknown</xsl:otherwise> -->
295
320
  </xsl:choose>
296
-
297
-
321
+
322
+
298
323
  <!-- content date: range YYYY-YYYY if dates differ -->
299
324
  <xsl:choose>
300
325
  <xsl:when test="gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:TimePeriod/gml:beginPosition/text() != ''">
301
326
  <xsl:text>"dct_temporal_sm": "</xsl:text>
302
327
  <xsl:value-of select="substring(gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:TimePeriod/gml:beginPosition, 1,4)"/>
303
- <xsl:if test="substring(gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:TimePeriod/gml:endPosition, 1,4) != substring(gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:TimePeriod/gml:beginPosition,1,4)">
328
+ <xsl:if test="substring(gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:TimePeriod/gml:endPosition, 1,4) != substring(gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:TimePeriod/gml:beginPosition,1,4)">
304
329
  <xsl:text>-</xsl:text>
305
330
  <xsl:value-of select="substring(gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:TimePeriod/gml:endPosition, 1,4)"/>
306
331
  </xsl:if>
307
332
  <xsl:text>",</xsl:text>
308
333
  </xsl:when>
309
-
334
+
310
335
  <xsl:when test="gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:TimeInstant">
311
336
  <xsl:text>"dct_temporal_sm": "</xsl:text>
312
337
  <xsl:value-of select="substring(gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:TimeInstant, 1,4)"/>
313
338
  <xsl:text>",</xsl:text>
314
339
  </xsl:when>
315
340
  </xsl:choose>
316
-
341
+
317
342
  <!-- collection -->
318
343
  <!-- <xsl:choose>
319
344
  <xsl:when test="gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:aggregationInfo/gmd:MD_AggregateInformation/gmd:associationType/gmd:DS_AssociationTypeCode[@codeListValue='largerWorkCitation']">
@@ -331,44 +356,7 @@
331
356
  </xsl:for-each>
332
357
  </xsl:when>
333
358
  </xsl:choose> -->
334
-
335
- <!-- cross-references -->
336
- <xsl:if test="gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:aggregationInfo/gmd:MD_AggregateInformation/gmd:associationType/gmd:DS_AssociationTypeCode[@codeListValue='crossReference']">
337
- <xsl:text>"dc_relation_sm": [</xsl:text>
338
- <xsl:for-each select="gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:aggregationInfo/gmd:MD_AggregateInformation/gmd:associationType/gmd:DS_AssociationTypeCode[@codeListValue='crossReference']">
339
- <xsl:text>"</xsl:text>
340
- <xsl:value-of select="ancestor-or-self::*/gmd:aggregateDataSetName/gmd:CI_Citation/gmd:title"/>
341
- <xsl:text>"</xsl:text>
342
- <xsl:if test="position() != last()">
343
- <xsl:text>,</xsl:text>
344
- </xsl:if>
345
- </xsl:for-each>
346
- </xsl:if>
347
-
348
- <!--<field name="georss_polygon_s">-->
349
- <xsl:text>"georss_polygon_s": "</xsl:text>
350
- <xsl:text></xsl:text>
351
- <xsl:value-of select="$y1"/>
352
- <xsl:text> </xsl:text>
353
- <xsl:value-of select="$x1"/>
354
- <xsl:text> </xsl:text>
355
- <xsl:value-of select="$y2"/>
356
- <xsl:text> </xsl:text>
357
- <xsl:value-of select="$x1"/>
358
- <xsl:text> </xsl:text>
359
- <xsl:value-of select="$y2"/>
360
- <xsl:text> </xsl:text>
361
- <xsl:value-of select="$x2"/>
362
- <xsl:text> </xsl:text>
363
- <xsl:value-of select="$y1"/>
364
- <xsl:text> </xsl:text>
365
- <xsl:value-of select="$x2"/>
366
- <xsl:text> </xsl:text>
367
- <xsl:value-of select="$y1"/>
368
- <xsl:text> </xsl:text>
369
- <xsl:value-of select="$x1"/>
370
- <xsl:text>",</xsl:text>
371
-
359
+
372
360
  <xsl:text>"solr_geom": "ENVELOPE(</xsl:text>
373
361
  <xsl:value-of select="$x1"/>
374
362
  <xsl:text>, </xsl:text>
@@ -378,17 +366,7 @@
378
366
  <xsl:text>, </xsl:text>
379
367
  <xsl:value-of select="$y1"/>
380
368
  <xsl:text>)",</xsl:text>
381
-
382
- <xsl:text>"georss_box_s": "</xsl:text>
383
- <xsl:value-of select="$y1"/>
384
- <xsl:text> </xsl:text>
385
- <xsl:value-of select="$x1"/>
386
- <xsl:text> </xsl:text>
387
- <xsl:value-of select="$y2"/>
388
- <xsl:text> </xsl:text>
389
- <xsl:value-of select="$x2"/>
390
- <xsl:text>",</xsl:text>
391
-
369
+
392
370
  <!-- content date: singular, or beginning date of range: YYYY -->
393
371
  <xsl:choose>
394
372
  <xsl:when test="gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:TimePeriod/gml:beginPosition/text() != ''">
@@ -1,5 +1,5 @@
1
- {
2
- "uuid":"http://purl.stanford.edu/bb338jh0716",
1
+ {
2
+ "geoblacklight_version":"1.0",
3
3
  "dc_identifier_s":"http://purl.stanford.edu/bb338jh0716",
4
4
  "dc_title_s":"Hydrologic Sub-Area Boundaries: Russian River Watershed, California, 1999",
5
5
  "dc_description_s":"This polygon dataset represents the Hydrologic Sub-Area boundaries for the Russian River basin, as defined by the Calwater 2.2a watershed boundaries. The original CALWATER22 layer (Calwater 2.2a watershed boundaries) was developed as a coverage named calw22a and is administered by the Interagency California Watershed Mapping Committee (ICWMC). ",
@@ -11,19 +11,17 @@
11
11
  "layer_modified_dt":"2014-10-08",
12
12
  "dc_format_s":"application/x-esri-shapefile",
13
13
  "dc_type_s":"Dataset",
14
- "dc_subject_sm":[
14
+ "dc_subject_sm":[
15
15
  "boundaries",
16
16
  "inlandWaters"
17
17
  ],
18
- "dc_spatial_sm":[
18
+ "dc_spatial_sm":[
19
19
  "Sonoma County (Calif.)",
20
20
  "Mendocino County (Calif.)",
21
21
  "Russian River Watershed (Calif.)"
22
22
  ],
23
23
  "dct_issued_s":"2002-09-01",
24
24
  "dct_temporal_sm":"1999",
25
- "georss_polygon_s":"38.298024 -123.387866 39.399217 -123.387866 39.399217 -122.522658 38.298024 -122.522658 38.298024 -123.387866",
26
25
  "solr_geom":"ENVELOPE(-123.387866 38.298024, -122.522658 38.298024, -122.522658 39.399217, -123.387866 39.399217, -123.387866 38.298024)",
27
- "georss_box_s":"38.298024 -123.387866 39.399217 -122.522658",
28
26
  "solr_year_i":1999
29
- }
27
+ }
@@ -1,5 +1,5 @@
1
1
  {
2
- "uuid":"http://purl.stanford.edu/cz128vq0535",
2
+ "geoblacklight_version":"1.0",
3
3
  "dc_identifier_s":"http://purl.stanford.edu/cz128vq0535",
4
4
  "dc_title_s":"2005 Rural Poverty GIS Database: Uganda",
5
5
  "dc_description_s":"This polygon shapefile contains 2005 poverty data for 855 rural subcounties in Uganda. These data are intended for researchers, students, policy makers and the general public for reference and mapping purposes, and may be used for basic applications such as viewing, querying, and map output production.",
@@ -28,12 +28,6 @@
28
28
  "dct_spatial_sm":[
29
29
  "Uganda"
30
30
  ],
31
- "dc_relation_sm":[
32
- "http://sws.geonames.org/226074/about.rdf"
33
- ],
34
- "georss_box_s":"-1.478794 29.572742 4.234077 35.000308",
35
- "georss_polygon_s":"-1.478794 29.572742 4.234077 29.572742 4.234077 35.000308 -1.478794 35.000308 -1.478794 29.572742",
36
31
  "solr_geom":"ENVELOPE(29.572742, 35.000308, 4.234077, -1.478794)",
37
- "solr_bbox":"29.572742 -1.478794 35.000308 4.234077",
38
32
  "solr_year_i":2005
39
- }
33
+ }
@@ -21,9 +21,6 @@ RSpec.describe GeoCombine::EsriOpenData do
21
21
  describe '#geoblacklight_terms' do
22
22
  describe 'builds a hash which maps metadata' do
23
23
  let(:metadata) { esri_sample.instance_variable_get(:@metadata) }
24
- it 'with uuid' do
25
- expect(esri_sample.geoblacklight_terms).to include(uuid: metadata['id'])
26
- end
27
24
  it 'with dc_identifier_s' do
28
25
  expect(esri_sample.geoblacklight_terms).to include(dc_identifier_s: metadata['id'])
29
26
  end
@@ -44,10 +41,6 @@ RSpec.describe GeoCombine::EsriOpenData do
44
41
  expect(esri_sample).to receive(:references).and_return ''
45
42
  expect(esri_sample.geoblacklight_terms).to include(:dct_references_s)
46
43
  end
47
- it 'with georss_box_s' do
48
- expect(esri_sample).to receive(:georss_box).and_return ''
49
- expect(esri_sample.geoblacklight_terms).to include(georss_box_s: '')
50
- end
51
44
  it 'with layer_id_s that is blank' do
52
45
  expect(esri_sample.geoblacklight_terms).to include(layer_id_s: '')
53
46
  end
@@ -81,16 +74,10 @@ RSpec.describe GeoCombine::EsriOpenData do
81
74
  expect(esri_sample.references_hash).to include('http://resources.arcgis.com/en/help/arcgis-rest-api' => metadata['url'])
82
75
  end
83
76
  end
84
- describe '#georss_box' do
85
- it 'creates a GeoRSS box' do
86
- expect(esri_sample.georss_box).to be_an String
87
- expect(esri_sample.georss_box.split(' ').count).to eq 4
88
- end
89
- end
90
77
  describe '#envelope' do
91
78
  it 'creates an envelope for use in Solr' do
92
79
  expect(esri_sample.envelope).to be_an String
93
- expect(esri_sample.envelope).to match /ENVELOPE\(/
80
+ expect(esri_sample.envelope).to match /ENVELOPE\(.+,.+,.+,.+\)/
94
81
  end
95
82
  end
96
83
  end
@@ -19,16 +19,18 @@ RSpec.describe GeoCombine::Fgdc do
19
19
  end
20
20
  end
21
21
  describe '#to_geoblacklight' do
22
- let(:fgdc_geobl) { fgdc_object.to_geoblacklight(dct_references_s: '', ) }
22
+ let(:fgdc_geobl) { fgdc_object.to_geoblacklight }
23
23
  it 'returns a GeoCombine::Geoblacklight object' do
24
24
  expect(fgdc_geobl).to be_an GeoCombine::Geoblacklight
25
25
  end
26
- it 'is not valid' do
27
- expect { fgdc_geobl.valid? }.to raise_error
26
+ it 'is not valid due to bad modification date but valid otherwise' do
27
+ expect { fgdc_geobl.valid? }.to raise_error(JSON::Schema::ValidationError, /layer_modified_dt/)
28
+ fgdc_geobl.metadata.delete 'layer_modified_dt'
29
+ expect(fgdc_geobl.valid?).to be_truthy
28
30
  end
29
31
  describe 'with GeoBlacklight-Schema fields' do
30
- it 'uuid' do
31
- expect(fgdc_geobl.metadata['uuid']).to eq 'Ecuador50KDrillingTower11'
32
+ it 'geoblacklight_version' do
33
+ expect(fgdc_geobl.metadata['geoblacklight_version']).to eq '1.0'
32
34
  end
33
35
  it 'dc_identifier_s' do
34
36
  expect(fgdc_geobl.metadata['dc_identifier_s']).to eq 'http://www.geoportaligm.gob.ec/portal/'
@@ -59,7 +61,7 @@ RSpec.describe GeoCombine::Fgdc do
59
61
  expect(fgdc_geobl.metadata['dc_creator_sm']).to include 'Instituto Geografico Militar (Ecuador)'
60
62
  end
61
63
  it 'dc_format_s' do
62
- expect(fgdc_geobl.metadata['dc_format_s']).to eq 'application/x-esri-shapefile'
64
+ expect(fgdc_geobl.metadata['dc_format_s']).to eq 'Shapefile'
63
65
  end
64
66
  it 'dc_language_s' do
65
67
  expect(fgdc_geobl.metadata['dc_language_s']).to eq 'English'
@@ -79,23 +81,18 @@ RSpec.describe GeoCombine::Fgdc do
79
81
  expect(fgdc_geobl.metadata['dct_issued_s']).to eq '2011'
80
82
  end
81
83
  it 'dct_temporal_sm' do
82
- expect(fgdc_geobl.metadata['dct_temporal_sm']).to eq '2011'
84
+ expect(fgdc_geobl.metadata['dct_temporal_sm']).to be_an Array
85
+ expect(fgdc_geobl.metadata['dct_temporal_sm']).to include '2011'
83
86
  end
84
87
  it 'dct_isPartOf_sm' do
85
88
  expect(fgdc_geobl.metadata['dct_isPartOf_sm']).to be_an Array
86
89
  expect(fgdc_geobl.metadata['dct_isPartOf_sm']).to include 'Ecuador', 'Instituto Geografico Militar Data'
87
90
  end
88
- it 'georss_polygon_s' do
89
- expect(fgdc_geobl.metadata['georss_polygon_s']).to eq '-1.377743 -79.904768 -1.377743 -79.904768 -1.377743 -79.904768 -1.377743 -79.904768 -1.377743 -79.904768'
90
- end
91
91
  it 'solr_geom' do
92
92
  expect(fgdc_geobl.metadata['solr_geom']).to eq 'ENVELOPE(-79.904768, -79.904768, -1.377743, -1.377743)'
93
93
  end
94
- it 'georss_box_s' do
95
- expect(fgdc_geobl.metadata['georss_box_s']).to eq '-1.377743 -79.904768 -1.377743 -79.904768'
96
- end
97
94
  it 'solr_year_i' do
98
- expect(fgdc_geobl.metadata['solr_year_i']).to eq '2011'
95
+ expect(fgdc_geobl.metadata['solr_year_i']).to eq 2011
99
96
  end
100
97
  end
101
98
  end
@@ -3,6 +3,7 @@ require 'spec_helper'
3
3
  RSpec.describe GeoCombine::Geoblacklight do
4
4
  include XmlDocs
5
5
  include JsonDocs
6
+ include GeoCombine::Exceptions
6
7
  let(:full_geobl) { GeoCombine::Geoblacklight.new(full_geoblacklight) }
7
8
  let(:basic_geobl) { GeoCombine::Geoblacklight.new(basic_geoblacklight) }
8
9
  describe '#initialize' do
@@ -10,9 +11,9 @@ RSpec.describe GeoCombine::Geoblacklight do
10
11
  expect(basic_geobl.instance_variable_get(:@metadata)).to be_an Hash
11
12
  end
12
13
  describe 'merges fields argument into metadata' do
13
- let(:basic_geobl) { GeoCombine::Geoblacklight.new(basic_geoblacklight, 'uuid' => 'new one', "extra_field" => true)}
14
+ let(:basic_geobl) { GeoCombine::Geoblacklight.new(basic_geoblacklight, 'dc_identifier_s' => 'new one', "extra_field" => true)}
14
15
  it 'overwrites existing metadata fields' do
15
- expect(basic_geobl.metadata['uuid']).to eq 'new one'
16
+ expect(basic_geobl.metadata['dc_identifier_s']).to eq 'new one'
16
17
  end
17
18
  it 'adds in new fields' do
18
19
  expect(basic_geobl.metadata['extra_field']).to be true
@@ -22,7 +23,7 @@ RSpec.describe GeoCombine::Geoblacklight do
22
23
  describe '#metadata' do
23
24
  it 'reads the metadata instance variable' do
24
25
  expect(basic_geobl.metadata).to be_an Hash
25
- expect(basic_geobl.metadata).to have_key 'uuid'
26
+ expect(basic_geobl.metadata).to have_key 'dc_identifier_s'
26
27
  end
27
28
  end
28
29
  describe '#to_json' do
@@ -31,11 +32,10 @@ RSpec.describe GeoCombine::Geoblacklight do
31
32
  expect(valid_json?(basic_geobl.to_json)).to be_truthy
32
33
  end
33
34
  end
35
+ let(:enhanced_geobl) { GeoCombine::Geoblacklight.new(basic_geoblacklight, 'layer_geom_type_s' => 'esriGeometryPolygon') }
36
+ before { enhanced_geobl.enhance_metadata }
34
37
  describe '#enhance_metadata' do
35
- let(:enhanced_geobl) { GeoCombine::Geoblacklight.new(basic_geoblacklight, 'dct_references_s' => '', 'layer_geom_type_s' => 'esriGeometryPolygon') }
36
- before { enhanced_geobl.enhance_metadata }
37
38
  it 'calls enhancement methods to validate document' do
38
- expect { basic_geobl.valid? }.to raise_error JSON::Schema::ValidationError
39
39
  expect(enhanced_geobl.valid?).to be true
40
40
  end
41
41
  it 'enhances the dc_subject_sm field' do
@@ -52,8 +52,103 @@ RSpec.describe GeoCombine::Geoblacklight do
52
52
  it 'a valid geoblacklight-schema document should be valid' do
53
53
  expect(full_geobl.valid?).to be true
54
54
  end
55
+ context 'must have required fields' do
56
+ %w(
57
+ dc_title_s
58
+ dc_identifier_s
59
+ dc_rights_s
60
+ dct_provenance_s
61
+ layer_slug_s
62
+ solr_geom
63
+ ).each do |field|
64
+ it field do
65
+ full_geobl.metadata.delete field
66
+ expect { full_geobl.valid? }.to raise_error(JSON::Schema::ValidationError, /#{field}/)
67
+ end
68
+ end
69
+ end
70
+ context 'need not have optional fields' do
71
+ %w(
72
+ dc_description_s
73
+ dc_format_s
74
+ dc_language_s
75
+ dc_publisher_s
76
+ dc_source_sm
77
+ dc_subject_sm
78
+ dct_isPartOf_sm
79
+ dct_issued_dt
80
+ dct_references_s
81
+ dct_spatial_sm
82
+ dct_temporal_sm
83
+ geoblacklight_version
84
+ layer_geom_type_s
85
+ layer_id_s
86
+ layer_modified_dt
87
+ solr_year_i
88
+ ).each do |field|
89
+ it field do
90
+ full_geobl.metadata.delete field
91
+ expect { full_geobl.valid? }.not_to raise_error
92
+ end
93
+ end
94
+ end
95
+ context 'need not have deprecated fields' do
96
+ %w(
97
+ dc_relation_sm
98
+ dc_type_s
99
+ georss_box_s
100
+ georss_point_s
101
+ uuid
102
+ ).each do |field|
103
+ it field do
104
+ full_geobl.metadata.delete field
105
+ expect { full_geobl.valid? }.not_to raise_error
106
+ end
107
+ end
108
+ end
55
109
  it 'an invalid document' do
56
110
  expect { basic_geobl.valid? }.to raise_error JSON::Schema::ValidationError
57
111
  end
112
+ it 'calls the dct_references_s validator' do
113
+ expect(enhanced_geobl).to receive(:dct_references_validate!)
114
+ enhanced_geobl.valid?
115
+ end
116
+ end
117
+ describe '#dct_references_validate!' do
118
+ context 'with valid document' do
119
+ it 'is valid' do
120
+ expect(full_geobl.dct_references_validate!).to be true
121
+ end
122
+ end
123
+ context 'with invalid document' do
124
+ let(:unparseable_json) do
125
+ <<-JSON
126
+ {
127
+ \"http://schema.org/url\":\"http://example.com/abc123\",,
128
+ \"http://schema.org/downloadUrl\":\"http://example.com/abc123/data.zip\"
129
+ }
130
+ JSON
131
+ end
132
+ let(:bad_ref) do
133
+ GeoCombine::Geoblacklight.new(
134
+ basic_geoblacklight, 'dct_references_s' => unparseable_json, 'layer_geom_type_s' => 'esriGeometryPolygon'
135
+ )
136
+ end
137
+ let(:not_hash) do
138
+ GeoCombine::Geoblacklight.new(
139
+ basic_geoblacklight, 'dct_references_s' => '[{}]', 'layer_geom_type_s' => 'esriGeometryPolygon'
140
+ )
141
+ end
142
+ before do
143
+ bad_ref.enhance_metadata
144
+ not_hash.enhance_metadata
145
+ end
146
+ it 'unparseable json' do
147
+ expect { bad_ref.dct_references_validate! }.to raise_error JSON::ParserError
148
+ end
149
+ it 'not a hash' do
150
+ expect { not_hash.dct_references_validate! }.to raise_error GeoCombine::Exceptions::InvalidDCTReferences
151
+ end
152
+ end
58
153
  end
59
154
  end