geo_combine 0.0.5 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.coveralls.yml +1 -0
- data/README.md +24 -4
- data/bin/geocombine +5 -0
- data/geo_combine.gemspec +4 -0
- data/lib/geo_combine/cli.rb +25 -0
- data/lib/geo_combine/esri_open_data.rb +97 -0
- data/lib/geo_combine/formats.rb +11 -0
- data/lib/geo_combine/formatting.rb +29 -0
- data/lib/geo_combine/geoblacklight.rb +79 -13
- data/lib/geo_combine/geometry_types.rb +11 -0
- data/lib/geo_combine/subjects.rb +29 -0
- data/lib/geo_combine/version.rb +1 -1
- data/lib/geo_combine.rb +21 -3
- data/lib/schema/geoblacklight-schema.json +169 -0
- data/lib/tasks/geo_combine.rake +16 -13
- data/lib/xslt/fgdc2geoBL.xsl +361 -418
- data/lib/xslt/fgdc2html.xsl +1917 -1025
- data/lib/xslt/iso2geoBL.xsl +173 -306
- data/lib/xslt/iso2html.xsl +1059 -1734
- data/spec/features/fgdc2html_spec.rb +42 -0
- data/spec/features/iso2html_spec.rb +50 -0
- data/spec/fixtures/docs/basic_geoblacklight.json +29 -0
- data/spec/fixtures/docs/esri_open_data.json +53 -0
- data/spec/fixtures/docs/full_geoblacklight.json +39 -0
- data/spec/fixtures/json_docs.rb +21 -0
- data/spec/fixtures/xml_docs.rb +0 -44
- data/spec/helpers.rb +4 -0
- data/spec/lib/geo_combine/esri_open_data_spec.rb +96 -0
- data/spec/lib/geo_combine/fgdc_spec.rb +77 -2
- data/spec/lib/geo_combine/formatting_spec.rb +22 -0
- data/spec/lib/geo_combine/geoblacklight_spec.rb +48 -5
- data/spec/lib/geo_combine/iso19139_spec.rb +14 -1
- data/spec/spec_helper.rb +3 -0
- metadata +85 -3
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
#TODO Provide additional expectations on html structure
|
4
|
+
describe 'FGDC to html' do
|
5
|
+
include XmlDocs
|
6
|
+
let(:page) { GeoCombine::Fgdc.new(tufts_fgdc).to_html }
|
7
|
+
describe 'Identification Information' do
|
8
|
+
it 'has sections' do
|
9
|
+
expect(page).to have_tag '#fgdc-identification-info' do
|
10
|
+
with_tag 'dt', text: /Citation/
|
11
|
+
with_tag 'dt', text: /Title/
|
12
|
+
with_tag 'dd', text: /Drilling Towers 50k Scale Ecuador 2011/
|
13
|
+
with_tag 'dt', text: /Abstract/
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
describe 'Data Quality Information' do
|
18
|
+
it 'has sections' do
|
19
|
+
expect(page).to have_tag '#fgdc-data-quality-info'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
describe 'Spatial Data Organization Information' do
|
23
|
+
it 'has sections' do
|
24
|
+
expect(page).to have_tag '#fgdc-spatialdataorganization-info'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
describe 'Entity and Attribute Information' do
|
28
|
+
it 'has sections' do
|
29
|
+
expect(page).to have_tag '#fgdc-spatialreference-info'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
describe 'Distribution Information' do
|
33
|
+
it 'has sections' do
|
34
|
+
expect(page).to have_tag '#fgdc-distribution-info'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
describe 'Metadata Reference Information' do
|
38
|
+
it 'has sections' do
|
39
|
+
expect(page).to have_tag '#fgdc-metadata-reference-info'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
#TODO Provide additional expectations on html structure
|
4
|
+
describe 'ISO 19139 to html' do
|
5
|
+
include XmlDocs
|
6
|
+
let(:page) { GeoCombine::Iso19139.new(stanford_iso).to_html }
|
7
|
+
describe 'Identification Information' do
|
8
|
+
it 'has sections' do
|
9
|
+
expect(page).to have_tag '#iso-identification-info' do
|
10
|
+
with_tag 'dt', text: /Citation/
|
11
|
+
with_tag 'dt', text: /Title/
|
12
|
+
with_tag 'dd', text: /Hydrologic Sub-Area Boundaries: Russian River Watershed, California, 1999/
|
13
|
+
with_tag 'dt', text: /Originator/
|
14
|
+
with_tag 'dd', text: trim('Circuit Rider Productions'), count: 4
|
15
|
+
with_tag 'dt', text: /Place of Publication/
|
16
|
+
with_tag 'dd', text: /Windsor/
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
describe 'Spatial Reference Information' do
|
21
|
+
it 'has sections' do
|
22
|
+
expect(page).to have_tag '#iso-spatial-reference-info'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
describe 'Data Quality Information' do
|
26
|
+
it 'has sections' do
|
27
|
+
expect(page).to have_tag '#iso-data-quality-info'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
describe 'Distribution Information' do
|
31
|
+
it 'has sections' do
|
32
|
+
expect(page).to have_tag '#iso-distribution-info'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
describe 'Content Information' do
|
36
|
+
it 'has sections' do
|
37
|
+
expect(page).to have_tag '#iso-distribution-info'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
describe 'Spatial Representation Information' do
|
41
|
+
it 'has sections' do
|
42
|
+
expect(page).to have_tag '#iso-spatial-representation-info'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
describe 'Metadata Reference Information' do
|
46
|
+
it 'has sections' do
|
47
|
+
expect(page).to have_tag '#iso-metadata-reference-info'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
{
|
2
|
+
"uuid":"http://purl.stanford.edu/bb338jh0716",
|
3
|
+
"dc_identifier_s":"http://purl.stanford.edu/bb338jh0716",
|
4
|
+
"dc_title_s":"Hydrologic Sub-Area Boundaries: Russian River Watershed, California, 1999",
|
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). ",
|
6
|
+
"dc_rights_s":"Public",
|
7
|
+
"dct_provenance_s":"Stanford",
|
8
|
+
"layer_id_s":"druid:bb338jh0716",
|
9
|
+
"layer_slug_s":"Stanford-bb338jh0716",
|
10
|
+
"layer_geom_type_s":"",
|
11
|
+
"layer_modified_dt":"2014-10-08",
|
12
|
+
"dc_format_s":"application/x-esri-shapefile",
|
13
|
+
"dc_type_s":"Dataset",
|
14
|
+
"dc_subject_sm":[
|
15
|
+
"boundaries",
|
16
|
+
"inlandWaters"
|
17
|
+
],
|
18
|
+
"dc_spatial_sm":[
|
19
|
+
"Sonoma County (Calif.)",
|
20
|
+
"Mendocino County (Calif.)",
|
21
|
+
"Russian River Watershed (Calif.)"
|
22
|
+
],
|
23
|
+
"dct_issued_s":"2002-09-01",
|
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
|
+
"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
|
+
"solr_year_i":1999
|
29
|
+
}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
{
|
2
|
+
"object_id_field": null,
|
3
|
+
"supported_extensions": "",
|
4
|
+
"advanced_query_capabilities": {
|
5
|
+
"use_standardized_queries": true,
|
6
|
+
"supports_statistics": true,
|
7
|
+
"supports_order_by": true,
|
8
|
+
"supports_distinct": true,
|
9
|
+
"supports_pagination": true,
|
10
|
+
"supports_true_curve": true,
|
11
|
+
"supports_returning_query_extent": true,
|
12
|
+
"supports_query_with_distance": true
|
13
|
+
},
|
14
|
+
"supports_advanced_queries": true,
|
15
|
+
"display_field": "ETC_STATUS.ETC_CODE",
|
16
|
+
"max_record_count": 1000,
|
17
|
+
"record_count": 50,
|
18
|
+
"geometry_type": "esriGeometryPoint",
|
19
|
+
"landing_page": "https://www.arcgis.com/home/item.html?id=267b6c8cdee749bf90bb2737d9e07fc8",
|
20
|
+
"description": "\u003cspan style='color: rgb(77, 77, 77); font-family: ;'\u003eEbola Treatment Centers (ETCs)\u003c/span\u003e\u003cdiv\u003e\u003cspan style='color: rgb(77, 77, 77); font-family: ;'\u003e\u003cbr /\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv\u003e\u003cspan style='color: rgb(77, 77, 77); font-family: ;'\u003e\u003cbr /\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv\u003e\u003cspan style='color: rgb(77, 77, 77); font-family: ;'\u003e\u003cbr /\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv\u003e\u003cspan style='color: rgb(77, 77, 77); font-family: ;'\u003e\u003cbr /\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv\u003e\u003cp style='margin: 0cm 0cm 6pt; mso-add-space: auto;'\u003e\u003cfont face='Calibri, sans-serif' size='4'\u003e\u003cspan style='line-height: 22.15px;'\u003e\u003cb\u003e\u003cu\u003eAttribute Information\u003c/u\u003e\u003c/b\u003e\u003c/span\u003e\u003c/font\u003e\u003c/p\u003e\u003cp\u003e\u003cb\u003eAdmin2:\u003c/b\u003e\u003cbr /\u003e\r\n Guinea – Prefecture\u003cbr /\u003e Liberia – County\u003cbr /\u003e\u003cspan style='line-height: 1.3846;'\u003e Sierra Leone – District\u003c/span\u003e\u003c/p\u003e\u003cp\u003e\u003cb\u003eCountryISO:\u003c/b\u003e 3-character ISO Country Code\u003c/p\u003e\u003cp\u003e\u003cb\u003eETC Code:\u003c/b\u003e Unique code\u003c/p\u003e\u003cp\u003e\u003cb\u003eSiteName:\u003c/b\u003e ETC Site Name\u003c/p\u003e\u003cp style='margin: 0cm 0cm 6pt; mso-add-space: auto;'\u003e\r\n\r\n\r\n\r\n\r\n\r\n\u003c/p\u003e\u003cp\u003e\u003cb\u003eStatus: \u003c/b\u003e\u003ci\u003e\u003cspan style='background: white; color: rgb(4, 4, 4); mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-bidi-font-family: Calibri;'\u003eETCs scheduled for closure will be decommissioned only when\r\nand where the epidemiological situation and the strength of referral pathways\r\nthrough non-EVD facilities allow. Several ETCs will be unstaffed but remain on\r\na stand-by level of readiness, whereby stocks of protective equipment and\r\nessential medicines will be kept on-site such that the facility can become\r\noperational within 48 hours. This transition would be triggered by higher\r\noccupancy rates in nearby ETCs. Strategically located core ETCs will remain\r\nfully operational at their current capacity (Maintain) or a slightly reduced\r\ncapacity (Scale Down and Maintain).\u003c/span\u003e\u003c/i\u003e\u003c/p\u003e\u003c/div\u003e",
|
21
|
+
"extent": {
|
22
|
+
"coordinates": [
|
23
|
+
[-13.6832, 4.3934],
|
24
|
+
[-7.6925, 10.374]
|
25
|
+
]
|
26
|
+
},
|
27
|
+
"id": "267b6c8cdee749bf90bb2737d9e07fc8_0",
|
28
|
+
"item_name": "Ebola Treatment Centers",
|
29
|
+
"type": "ItemLayer",
|
30
|
+
"item_type": "Feature Layer",
|
31
|
+
"license": "\u003cspan style='color: rgb(0, 0, 0); line-height: normal; font-family: monospace; font-size: medium; white-space: pre-wrap; background-color: rgb(255, 255, 255);'\u003eData are based on situation reports provided by countries. The boundaries and names shown and the designations used on this site do not imply the expression of any opinion whatsoever on the part of the World Health Organization concerning the legal status of any country, territory, city or area or of its authorities, or concerning the delimitation of its frontiers or boundaries. Dotted and dashed lines on maps represent approximate border lines for which there may not yet be full agreement.\u003c/span\u003e",
|
32
|
+
"main_group_description": "Open Data hosting site",
|
33
|
+
"main_group_thumbnail_url": "https://www.arcgis.com/sharing/rest/community/groups/bdccbf91281c4144914e765b1fe0c692/info/EbolaResponseHomeOpenData.png",
|
34
|
+
"main_group_title": "Open Data Sharing",
|
35
|
+
"name": "Ebola Treatment Centers",
|
36
|
+
"owner": "er_admin",
|
37
|
+
"tags": ["Open Data", "ETC", "Ebola Treatment Center", "Ebola", "WHO"],
|
38
|
+
"thumbnail_url": "https://www.arcgis.com/sharing/rest/content/items/267b6c8cdee749bf90bb2737d9e07fc8/info/thumbnail/outputimageETCLYR.png",
|
39
|
+
"sites": [{
|
40
|
+
"title": "Ebola Response",
|
41
|
+
"url": "http://home.ebolaresponse.opendata.arcgis.com",
|
42
|
+
"logo": "http://ebolaresponse.opendata.arcgis.com/favicon.ico"
|
43
|
+
}],
|
44
|
+
"public": null,
|
45
|
+
"created_at": "2015-04-07T10:08:55.000+00:00",
|
46
|
+
"updated_at": "2015-06-04T15:59:16.000+00:00",
|
47
|
+
"url": "http://maps.who.int/arcgis/rest/services/OpenData/CurrentItems/MapServer/0",
|
48
|
+
"views": null,
|
49
|
+
"quality": 85,
|
50
|
+
"coverage": "regional",
|
51
|
+
"current_version": 10.31,
|
52
|
+
"use_standardized_queries": true
|
53
|
+
}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
{
|
2
|
+
"uuid":"http://purl.stanford.edu/cz128vq0535",
|
3
|
+
"dc_identifier_s":"http://purl.stanford.edu/cz128vq0535",
|
4
|
+
"dc_title_s":"2005 Rural Poverty GIS Database: Uganda",
|
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.",
|
6
|
+
"dc_rights_s":"Public",
|
7
|
+
"dct_provenance_s":"Stanford",
|
8
|
+
"dct_references_s":"{\"http://schema.org/url\":\"http://purl.stanford.edu/cz128vq0535\",\"http://schema.org/downloadUrl\":\"http://stacks.stanford.edu/file/druid:cz128vq0535/data.zip\",\"http://www.loc.gov/mods/v3\":\"http://purl.stanford.edu/cz128vq0535.mods\",\"http://www.isotc211.org/schemas/2005/gmd/\":\"http://opengeometadata.stanford.edu/metadata/edu.stanford.purl/druid:cz128vq0535/iso19139.xml\",\"http://www.w3.org/1999/xhtml\":\"http://opengeometadata.stanford.edu/metadata/edu.stanford.purl/druid:cz128vq0535/default.html\",\"http://www.opengis.net/def/serviceType/ogc/wfs\":\"https://geowebservices.stanford.edu/geoserver/wfs\",\"http://www.opengis.net/def/serviceType/ogc/wms\":\"https://geowebservices.stanford.edu/geoserver/wms\"}",
|
9
|
+
"layer_id_s":"druid:cz128vq0535",
|
10
|
+
"layer_slug_s":"stanford-cz128vq0535",
|
11
|
+
"layer_geom_type_s":"Polygon",
|
12
|
+
"layer_modified_dt":"2015-01-13T18:46:38Z",
|
13
|
+
"dc_format_s":"Shapefile",
|
14
|
+
"dc_language_s":"English",
|
15
|
+
"dc_type_s":"Dataset",
|
16
|
+
"dc_publisher_s":"Uganda Bureau of Statistics",
|
17
|
+
"dc_creator_sm":[
|
18
|
+
"Uganda Bureau of Statistics"
|
19
|
+
],
|
20
|
+
"dc_subject_sm":[
|
21
|
+
"Poverty",
|
22
|
+
"Statistics"
|
23
|
+
],
|
24
|
+
"dct_issued_s":"2005",
|
25
|
+
"dct_temporal_sm":[
|
26
|
+
"2005"
|
27
|
+
],
|
28
|
+
"dct_spatial_sm":[
|
29
|
+
"Uganda"
|
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
|
+
"solr_geom":"ENVELOPE(29.572742, 35.000308, 4.234077, -1.478794)",
|
37
|
+
"solr_bbox":"29.572742 -1.478794 35.000308 4.234077",
|
38
|
+
"solr_year_i":2005
|
39
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
##
|
2
|
+
# JSON docs that can be included into specs
|
3
|
+
module JsonDocs
|
4
|
+
##
|
5
|
+
# A basic incomplete, non-compliant GeoBlacklight-Schema json document
|
6
|
+
def basic_geoblacklight
|
7
|
+
File.read(File.join(File.dirname(__FILE__), './docs/basic_geoblacklight.json'))
|
8
|
+
end
|
9
|
+
|
10
|
+
##
|
11
|
+
# A fully compliant GeoBlacklight-Schema json document
|
12
|
+
def full_geoblacklight
|
13
|
+
File.read(File.join(File.dirname(__FILE__), './docs/full_geoblacklight.json'))
|
14
|
+
end
|
15
|
+
|
16
|
+
##
|
17
|
+
# A sample Esri OpenData metadata record
|
18
|
+
def esri_opendata_metadata
|
19
|
+
File.read(File.join(File.dirname(__FILE__), './docs/esri_open_data.json'))
|
20
|
+
end
|
21
|
+
end
|
data/spec/fixtures/xml_docs.rb
CHANGED
@@ -697,50 +697,6 @@ module XmlDocs
|
|
697
697
|
xml
|
698
698
|
end
|
699
699
|
|
700
|
-
##
|
701
|
-
# Example GeoBlacklight XML from
|
702
|
-
def stanford_geobl
|
703
|
-
<<-xml
|
704
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
705
|
-
<add xmlns="http://lucene.apache.org/solr/4/document">
|
706
|
-
<doc>
|
707
|
-
<field name="uuid">http://purl.stanford.edu/bb338jh0716</field>
|
708
|
-
<field name="dc_identifier_s">http://purl.stanford.edu/bb338jh0716</field>
|
709
|
-
<field name="dc_title_s">Hydrologic Sub-Area Boundaries: Russian River Watershed, California, 1999</field>
|
710
|
-
<field name="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). This shapefile can be used to map and analyze data at the Hydrologic Sub-Area scale.</field>
|
711
|
-
<field name="dc_rights_s">Restricted</field>
|
712
|
-
<field name="dct_provenance_s">Stanford</field>
|
713
|
-
<field name="dct_references_s">{"http://schema.org/url":"http://opengeometadata.stanford.edu/metadata/edu.stanford.purl/druid:bb338jh0716/default.html","http://www.loc.gov/mods/v3":"http://purl.stanford.edu/bb338jh0716.mods","http://www.isotc211.org/schemas/2005/gmd/":"http://opengeometadata.stanford.edu/metadata/edu.stanford.purl/druid:bb338jh0716/iso19139.xml","http://www.w3.org/1999/xhtml":"http://opengeometadata.stanford.edu/metadata/edu.stanford.purl/druid:bb338jh0716/default.html","http://www.opengis.net/def/serviceType/ogc/wfs":"https://geowebservices-restricted.stanford.edu/geoserver/wfs","http://www.opengis.net/def/serviceType/ogc/wms":"https://geowebservices-restricted.stanford.edu/geoserver/wms"}</field>
|
714
|
-
<field name="layer_id_s">druid:bb338jh0716</field>
|
715
|
-
<field name="layer_slug_s">stanford-bb338jh0716</field>
|
716
|
-
<field name="layer_geom_type_s">Polygon</field>
|
717
|
-
<field name="layer_modified_dt">2014-12-16T19:30:53Z</field>
|
718
|
-
<field name="dc_format_s">Shapefile</field>
|
719
|
-
<field name="dc_language_s">English</field>
|
720
|
-
<field name="dc_type_s">Dataset</field>
|
721
|
-
<field name="dc_publisher_s">Circuit Rider Productions</field>
|
722
|
-
<field name="dc_creator_sm">Circuit Rider Productions</field>
|
723
|
-
<field name="dc_subject_sm">Hydrology</field>
|
724
|
-
<field name="dc_subject_sm">Watersheds</field>
|
725
|
-
<field name="dc_subject_sm">Boundaries</field>
|
726
|
-
<field name="dc_subject_sm">Inland Waters</field>
|
727
|
-
<field name="dct_issued_s">2002</field>
|
728
|
-
<field name="dct_temporal_sm">1999</field>
|
729
|
-
<field name="dct_spatial_sm">Sonoma County (Calif.)</field>
|
730
|
-
<field name="dct_spatial_sm">Mendocino County (Calif.)</field>
|
731
|
-
<field name="dct_spatial_sm">Russian River Watershed (Calif.)</field>
|
732
|
-
<field name="dc_relation_sm">http://sws.geonames.org/5397100/about.rdf</field>
|
733
|
-
<field name="dc_relation_sm">http://sws.geonames.org/5372163/about.rdf</field>
|
734
|
-
<field name="georss_box_s">38.298673 -123.387626 39.399103 -122.528843</field>
|
735
|
-
<field name="georss_polygon_s">38.298673 -123.387626 39.399103 -123.387626 39.399103 -122.528843 38.298673 -122.528843 38.298673 -123.387626</field>
|
736
|
-
<field name="solr_geom">ENVELOPE(-123.387626, -122.528843, 39.399103, 38.298673)</field>
|
737
|
-
<field name="solr_bbox">-123.387626 38.298673 -122.528843 39.399103</field>
|
738
|
-
<field name="solr_year_i">1999</field>
|
739
|
-
</doc>
|
740
|
-
</add>
|
741
|
-
xml
|
742
|
-
end
|
743
|
-
|
744
700
|
##
|
745
701
|
# Example FGDC XML from https://github.com/OpenGeoMetadata/edu.tufts/blob/master/0/108/220/208/fgdc.xml
|
746
702
|
def tufts_fgdc
|
data/spec/helpers.rb
CHANGED
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe GeoCombine::EsriOpenData do
|
4
|
+
include JsonDocs
|
5
|
+
let(:esri_sample) { GeoCombine::EsriOpenData.new(esri_opendata_metadata) }
|
6
|
+
let(:metadata) { esri_sample.instance_variable_get(:@metadata) }
|
7
|
+
describe '#initialize' do
|
8
|
+
it 'parses metadata argument JSON to Hash' do
|
9
|
+
expect(esri_sample.instance_variable_get(:@metadata)).to be_an Hash
|
10
|
+
end
|
11
|
+
it 'puts extend data into @geometry' do
|
12
|
+
expect(esri_sample.instance_variable_get(:@geometry)).to be_an Array
|
13
|
+
end
|
14
|
+
end
|
15
|
+
describe '#to_geoblacklight' do
|
16
|
+
it 'calls geoblacklight_terms to create a GeoBlacklight object' do
|
17
|
+
expect(esri_sample).to receive(:geoblacklight_terms).and_return({})
|
18
|
+
expect(esri_sample.to_geoblacklight).to be_an GeoCombine::Geoblacklight
|
19
|
+
end
|
20
|
+
end
|
21
|
+
describe '#geoblacklight_terms' do
|
22
|
+
describe 'builds a hash which maps metadata' do
|
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
|
+
it 'with dc_identifier_s' do
|
28
|
+
expect(esri_sample.geoblacklight_terms).to include(dc_identifier_s: metadata['id'])
|
29
|
+
end
|
30
|
+
it 'with dc_title_s' do
|
31
|
+
expect(esri_sample.geoblacklight_terms).to include(dc_title_s: metadata['name'])
|
32
|
+
end
|
33
|
+
it 'with dc_description_s sanitized' do
|
34
|
+
expect(esri_sample).to receive(:sanitize_and_remove_lines).and_return 'sanitized'
|
35
|
+
expect(esri_sample.geoblacklight_terms).to include(dc_description_s: 'sanitized')
|
36
|
+
end
|
37
|
+
it 'with dc_rights_s' do
|
38
|
+
expect(esri_sample.geoblacklight_terms).to include(dc_rights_s: 'Public')
|
39
|
+
end
|
40
|
+
it 'with dct_provenance_s' do
|
41
|
+
expect(esri_sample.geoblacklight_terms).to include(dct_provenance_s: metadata['owner'])
|
42
|
+
end
|
43
|
+
it 'with dct_references_s' do
|
44
|
+
expect(esri_sample).to receive(:references).and_return ''
|
45
|
+
expect(esri_sample.geoblacklight_terms).to include(:dct_references_s)
|
46
|
+
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
|
+
it 'with layer_id_s that is blank' do
|
52
|
+
expect(esri_sample.geoblacklight_terms).to include(layer_id_s: '')
|
53
|
+
end
|
54
|
+
it 'with layer_geom_type_s' do
|
55
|
+
expect(esri_sample.geoblacklight_terms).to include(layer_geom_type_s: metadata['geometry_type'])
|
56
|
+
end
|
57
|
+
it 'with layer_modified_dt' do
|
58
|
+
expect(esri_sample.geoblacklight_terms).to include(layer_modified_dt: metadata['updated_at'])
|
59
|
+
end
|
60
|
+
it 'with layer_slug_s' do
|
61
|
+
expect(esri_sample.geoblacklight_terms).to include(layer_slug_s: metadata['id'])
|
62
|
+
end
|
63
|
+
it 'with solr_geom' do
|
64
|
+
expect(esri_sample).to receive(:envelope).and_return ''
|
65
|
+
expect(esri_sample.geoblacklight_terms).to include(solr_geom: '')
|
66
|
+
end
|
67
|
+
it 'with dc_subject_sm' do
|
68
|
+
expect(esri_sample.geoblacklight_terms).to include(dc_subject_sm: metadata['tags'])
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
describe '#references' do
|
73
|
+
it 'converts references to a JSON string' do
|
74
|
+
expect(esri_sample).to receive(:references_hash).and_return({})
|
75
|
+
expect(esri_sample.references).to be_an String
|
76
|
+
end
|
77
|
+
end
|
78
|
+
describe '#references_hash' do
|
79
|
+
it 'builds out references' do
|
80
|
+
expect(esri_sample.references_hash).to include('http://schema.org/url' => metadata['landing_page'])
|
81
|
+
expect(esri_sample.references_hash).to include('http://resources.arcgis.com/en/help/arcgis-rest-api' => metadata['url'])
|
82
|
+
end
|
83
|
+
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
|
+
describe '#envelope' do
|
91
|
+
it 'creates an envelope for use in Solr' do
|
92
|
+
expect(esri_sample.envelope).to be_an String
|
93
|
+
expect(esri_sample.envelope).to match /ENVELOPE\(/
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -19,9 +19,84 @@ 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
23
|
it 'returns a GeoCombine::Geoblacklight object' do
|
23
|
-
|
24
|
-
|
24
|
+
expect(fgdc_geobl).to be_an GeoCombine::Geoblacklight
|
25
|
+
end
|
26
|
+
it 'is not valid' do
|
27
|
+
expect { fgdc_geobl.valid? }.to raise_error
|
28
|
+
end
|
29
|
+
describe 'with GeoBlacklight-Schema fields' do
|
30
|
+
it 'uuid' do
|
31
|
+
expect(fgdc_geobl.metadata['uuid']).to eq 'Ecuador50KDrillingTower11'
|
32
|
+
end
|
33
|
+
it 'dc_identifier_s' do
|
34
|
+
expect(fgdc_geobl.metadata['dc_identifier_s']).to eq 'http://www.geoportaligm.gob.ec/portal/'
|
35
|
+
end
|
36
|
+
it 'dc_title_s' do
|
37
|
+
expect(fgdc_geobl.metadata['dc_title_s']).to eq 'Drilling Towers 50k Scale Ecuador 2011'
|
38
|
+
end
|
39
|
+
it 'dc_description_s' do
|
40
|
+
expect(fgdc_geobl.metadata['dc_description_s']).to match /Ecuador created from/
|
41
|
+
end
|
42
|
+
it 'dc_rights_s' do
|
43
|
+
expect(fgdc_geobl.metadata['dc_rights_s']).to eq 'Public'
|
44
|
+
end
|
45
|
+
it 'dct_provenance_s' do
|
46
|
+
expect(fgdc_geobl.metadata['dct_provenance_s']).to eq 'Tufts'
|
47
|
+
end
|
48
|
+
it 'layer_id_s' do
|
49
|
+
expect(fgdc_geobl.metadata['layer_id_s']).to eq 'urn:Ecuador50KDrillingTower11'
|
50
|
+
end
|
51
|
+
it 'layer_slug_s' do
|
52
|
+
expect(fgdc_geobl.metadata['layer_slug_s']).to eq 'Tufts-Ecuador50KDrillingTower11'
|
53
|
+
end
|
54
|
+
it 'layer_modified_dt' do
|
55
|
+
expect(fgdc_geobl.metadata['layer_modified_dt']).to eq '2013-08-13'
|
56
|
+
end
|
57
|
+
it 'dc_creator_sm' do
|
58
|
+
expect(fgdc_geobl.metadata['dc_creator_sm']).to be_an Array
|
59
|
+
expect(fgdc_geobl.metadata['dc_creator_sm']).to include 'Instituto Geografico Militar (Ecuador)'
|
60
|
+
end
|
61
|
+
it 'dc_format_s' do
|
62
|
+
expect(fgdc_geobl.metadata['dc_format_s']).to eq 'application/x-esri-shapefile'
|
63
|
+
end
|
64
|
+
it 'dc_language_s' do
|
65
|
+
expect(fgdc_geobl.metadata['dc_language_s']).to eq 'English'
|
66
|
+
end
|
67
|
+
it 'dc_type_s' do
|
68
|
+
expect(fgdc_geobl.metadata['dc_type_s']).to eq 'Dataset'
|
69
|
+
end
|
70
|
+
it 'dc_subject_sm' do
|
71
|
+
expect(fgdc_geobl.metadata['dc_subject_sm']).to be_an Array
|
72
|
+
expect(fgdc_geobl.metadata['dc_subject_sm']).to include 'point', 'structure', 'economy', 'Drilling platforms', 'Oil well drilling'
|
73
|
+
end
|
74
|
+
it 'dc_spatial_sm' do
|
75
|
+
expect(fgdc_geobl.metadata['dc_spatial_sm']).to be_an Array
|
76
|
+
expect(fgdc_geobl.metadata['dc_spatial_sm']).to include 'Ecuador', 'República del Ecuador', 'Northern Hemisphere', 'Southern Hemisphere', 'Western Hemisphere', 'South America'
|
77
|
+
end
|
78
|
+
it 'dct_issued_s' do
|
79
|
+
expect(fgdc_geobl.metadata['dct_issued_s']).to eq '2011'
|
80
|
+
end
|
81
|
+
it 'dct_temporal_sm' do
|
82
|
+
expect(fgdc_geobl.metadata['dct_temporal_sm']).to eq '2011'
|
83
|
+
end
|
84
|
+
it 'dct_isPartOf_sm' do
|
85
|
+
expect(fgdc_geobl.metadata['dct_isPartOf_sm']).to be_an Array
|
86
|
+
expect(fgdc_geobl.metadata['dct_isPartOf_sm']).to include 'Ecuador', 'Instituto Geografico Militar Data'
|
87
|
+
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
|
+
it 'solr_geom' do
|
92
|
+
expect(fgdc_geobl.metadata['solr_geom']).to eq 'ENVELOPE(-79.904768, -79.904768, -1.377743, -1.377743)'
|
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
|
+
it 'solr_year_i' do
|
98
|
+
expect(fgdc_geobl.metadata['solr_year_i']).to eq '2011'
|
99
|
+
end
|
25
100
|
end
|
26
101
|
end
|
27
102
|
describe '#to_html' do
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe GeoCombine::Formatting do
|
4
|
+
let(:dirty) { "<p>paragraph</p> \n on a new line" }
|
5
|
+
subject { Object.new.extend(GeoCombine::Formatting) }
|
6
|
+
describe '#sanitize' do
|
7
|
+
it 'sanitizes a fragment' do
|
8
|
+
expect(subject.sanitize(dirty)).to_not match('<p>')
|
9
|
+
end
|
10
|
+
end
|
11
|
+
describe '#remove_lines' do
|
12
|
+
it 'removes new lines' do
|
13
|
+
expect(subject.remove_lines(dirty)).to_not match(/\n/)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
describe '#sanitize_and_remove_lines' do
|
17
|
+
it 'returns a corrected string' do
|
18
|
+
expect(subject.sanitize_and_remove_lines(dirty)).to_not match('<p>')
|
19
|
+
expect(subject.sanitize_and_remove_lines(dirty)).to_not match(/\n/)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -2,15 +2,58 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
RSpec.describe GeoCombine::Geoblacklight do
|
4
4
|
include XmlDocs
|
5
|
-
|
5
|
+
include JsonDocs
|
6
|
+
let(:full_geobl) { GeoCombine::Geoblacklight.new(full_geoblacklight) }
|
7
|
+
let(:basic_geobl) { GeoCombine::Geoblacklight.new(basic_geoblacklight) }
|
8
|
+
describe '#initialize' do
|
9
|
+
it 'parses metadata argument JSON to Hash' do
|
10
|
+
expect(basic_geobl.instance_variable_get(:@metadata)).to be_an Hash
|
11
|
+
end
|
12
|
+
describe 'merges fields argument into metadata' do
|
13
|
+
let(:basic_geobl) { GeoCombine::Geoblacklight.new(basic_geoblacklight, 'uuid' => 'new one', "extra_field" => true)}
|
14
|
+
it 'overwrites existing metadata fields' do
|
15
|
+
expect(basic_geobl.metadata['uuid']).to eq 'new one'
|
16
|
+
end
|
17
|
+
it 'adds in new fields' do
|
18
|
+
expect(basic_geobl.metadata['extra_field']).to be true
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
describe '#metadata' do
|
23
|
+
it 'reads the metadata instance variable' do
|
24
|
+
expect(basic_geobl.metadata).to be_an Hash
|
25
|
+
expect(basic_geobl.metadata).to have_key 'uuid'
|
26
|
+
end
|
27
|
+
end
|
6
28
|
describe '#to_json' do
|
7
29
|
it 'returns valid json' do
|
8
|
-
expect(valid_json?(
|
30
|
+
expect(valid_json?(full_geobl.to_json)).to be_truthy
|
31
|
+
expect(valid_json?(basic_geobl.to_json)).to be_truthy
|
9
32
|
end
|
10
33
|
end
|
11
|
-
describe '#
|
12
|
-
|
13
|
-
|
34
|
+
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
|
+
it 'calls enhancement methods to validate document' do
|
38
|
+
expect { basic_geobl.valid? }.to raise_error JSON::Schema::ValidationError
|
39
|
+
expect(enhanced_geobl.valid?).to be true
|
40
|
+
end
|
41
|
+
it 'enhances the dc_subject_sm field' do
|
42
|
+
expect(enhanced_geobl.metadata['dc_subject_sm']).to include 'Boundaries', 'Inland Waters'
|
43
|
+
end
|
44
|
+
it 'formats the date properly as ISO8601' do
|
45
|
+
expect(enhanced_geobl.metadata['layer_modified_dt']).to match(/Z$/)
|
46
|
+
end
|
47
|
+
it 'formats the geometry type field' do
|
48
|
+
expect(enhanced_geobl.metadata['layer_geom_type_s']).to eq 'Polygon'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
describe '#valid?' do
|
52
|
+
it 'a valid geoblacklight-schema document should be valid' do
|
53
|
+
expect(full_geobl.valid?).to be true
|
54
|
+
end
|
55
|
+
it 'an invalid document' do
|
56
|
+
expect { basic_geobl.valid? }.to raise_error JSON::Schema::ValidationError
|
14
57
|
end
|
15
58
|
end
|
16
59
|
end
|
@@ -19,9 +19,22 @@ RSpec.describe GeoCombine::Iso19139 do
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
describe '#to_geoblacklight' do
|
22
|
+
let(:valid_geoblacklight) { iso_object.to_geoblacklight('layer_geom_type_s' => 'Polygon', 'dct_references_s' => '') }
|
22
23
|
it 'should create a GeoCombine::Geoblacklight object' do
|
23
|
-
expect(
|
24
|
+
expect(valid_geoblacklight).to be_an GeoCombine::Geoblacklight
|
24
25
|
end
|
26
|
+
it 'is valid GeoBlacklight-Schema' do
|
27
|
+
valid_geoblacklight.enhance_metadata
|
28
|
+
expect(valid_geoblacklight.valid?).to be_truthy
|
29
|
+
end
|
30
|
+
it 'should have dc_creator_sm' do
|
31
|
+
expect(valid_geoblacklight.metadata["dc_creator_sm"]).to be_an Array
|
32
|
+
expect(valid_geoblacklight.metadata["dc_creator_sm"]).to eq ["Circuit Rider Productions"]
|
33
|
+
end
|
34
|
+
it 'should have dc_publisher_sm' do
|
35
|
+
expect(valid_geoblacklight.metadata["dc_publisher_sm"]).to be_an Array
|
36
|
+
expect(valid_geoblacklight.metadata["dc_publisher_sm"]).to eq ["Circuit Rider Productions"]
|
37
|
+
end
|
25
38
|
end
|
26
39
|
describe '#to_html' do
|
27
40
|
it 'should create a transformation of the metadata as a String' do
|
data/spec/spec_helper.rb
CHANGED
@@ -21,10 +21,13 @@ Coveralls.wear!
|
|
21
21
|
|
22
22
|
require 'geo_combine'
|
23
23
|
require 'fixtures/xml_docs'
|
24
|
+
require 'fixtures/json_docs'
|
24
25
|
require 'helpers'
|
26
|
+
require 'rspec-html-matchers'
|
25
27
|
|
26
28
|
RSpec.configure do |config|
|
27
29
|
config.include Helpers
|
30
|
+
config.include RSpecHtmlMatchers
|
28
31
|
# rspec-expectations config goes here. You can use an alternate
|
29
32
|
# assertion/expectation library such as wrong or the stdlib/minitest
|
30
33
|
# assertions if you prefer.
|