geo_combine 0.10.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +35 -12
- data/.rubocop.yml +4 -0
- data/.rubocop_todo.yml +2 -10
- data/Gemfile +3 -0
- data/README.md +203 -137
- data/geo_combine.gemspec +1 -1
- data/lib/geo_combine/exceptions.rb +3 -0
- data/lib/geo_combine/fgdc.rb +7 -0
- data/lib/geo_combine/geoblacklight_aardvark.rb +70 -0
- data/lib/geo_combine/harvester.rb +106 -28
- data/lib/geo_combine/indexer.rb +49 -4
- data/lib/geo_combine/iso19139.rb +7 -0
- data/lib/geo_combine/migrators/v1_aardvark_migrator.rb +1 -2
- data/lib/geo_combine/schema.rb +32 -0
- data/lib/geo_combine/version.rb +1 -1
- data/lib/geo_combine/withdrawals.rb +125 -0
- data/lib/geo_combine.rb +25 -1
- data/lib/tasks/geo_combine.rake +11 -12
- data/lib/xslt/fgdc2Aardvark.xsl +1512 -0
- data/lib/xslt/iso2Aardvark.xsl +1634 -0
- data/spec/fixtures/docs/arizona_reservations_iso.xml +1183 -0
- data/spec/fixtures/docs/arizona_topo_iso.xml +560 -0
- data/spec/fixtures/docs/cornell_agdistricts_fgdc.xml +572 -0
- data/spec/fixtures/docs/duplicate_values_fgdc.xml +116 -0
- data/spec/fixtures/docs/gbl_keywords_fgdc.xml +105 -0
- data/spec/fixtures/docs/harvard_euratlas_fgdc.xml +449 -0
- data/spec/fixtures/docs/harvard_glb_fgdc.xml +455 -0
- data/spec/fixtures/docs/harvard_kng_fgdc.xml +403 -0
- data/spec/fixtures/docs/harvard_mapa_fgdc.xml +356 -0
- data/spec/fixtures/docs/harvard_nhgis_fgdc.xml +1706 -0
- data/spec/fixtures/docs/harvard_usgs_fgdc.xml +393 -0
- data/spec/fixtures/docs/nyu_colleges_iso.xml +616 -0
- data/spec/fixtures/docs/services_fgdc.xml +227 -0
- data/spec/fixtures/docs/services_iso.xml +433 -0
- data/spec/fixtures/indexing/no_schema.json +5 -0
- data/spec/fixtures/indexing/restricted_aardvark.json +34 -0
- data/spec/fixtures/indexing/restricted_geoblacklight.json +42 -0
- data/spec/fixtures/withdrawal/edu.example-a/metadata-aardvark/a-contradicted.json +8 -0
- data/spec/fixtures/withdrawal/edu.example-a/metadata-aardvark/a-live.json +8 -0
- data/spec/fixtures/withdrawal/edu.example-a/withdrawn.json +13 -0
- data/spec/fixtures/withdrawal/edu.example-b/metadata-aardvark/b-live.json +8 -0
- data/spec/fixtures/withdrawal/edu.example-b/withdrawn.json +7 -0
- data/spec/fixtures/withdrawal/edu.example-broken/withdrawn.json +4 -0
- data/spec/fixtures/withdrawal/edu.example-skipped/withdrawn.json +7 -0
- data/spec/fixtures/xml_docs.rb +110 -0
- data/spec/integration/withdrawals_spec.rb +47 -0
- data/spec/lib/geo_combine/ckan_metadata_spec.rb +44 -0
- data/spec/lib/geo_combine/fgdc_spec.rb +520 -0
- data/spec/lib/geo_combine/geoblacklight_aardvark_spec.rb +85 -0
- data/spec/lib/geo_combine/harvester_spec.rb +255 -11
- data/spec/lib/geo_combine/indexer_spec.rb +140 -2
- data/spec/lib/geo_combine/iso19139_spec.rb +540 -1
- data/spec/lib/geo_combine/logger_spec.rb +38 -0
- data/spec/lib/geo_combine/ogp_spec.rb +37 -0
- data/spec/lib/geo_combine/schema_spec.rb +74 -0
- data/spec/lib/geo_combine/withdrawals_spec.rb +294 -0
- data/spec/lib/tasks/geo_combine_spec.rb +51 -0
- data/spec/spec_helper.rb +4 -1
- metadata +72 -12
- data/lib/.DS_Store +0 -0
- data/lib/geo_combine/geo_blacklight_harvester.rb +0 -216
- data/lib/xslt/isoAardvark.xsl +0 -738
- data/spec/lib/geo_combine/geo_blacklight_harvester_spec.rb +0 -195
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d06fb38092cd8d8db20f1c9dfa14c82c19162d23415d1c34d92a2edf3826ff56
|
|
4
|
+
data.tar.gz: c2f2e35183978ec29e04d976438c9c5c567dc05341b128074366359d6164b027
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 13720c277a1d399d83a882df36eaad9f6c5cbef537fd2753f8391cc8ec73ab9f524308b2adc9c2b1b3bcefff44b928bd4d6b3fa5d05973b492e90bf79c0d524e
|
|
7
|
+
data.tar.gz: b9a42c999193d944a4c0b9fb309bcbb27a0f66bd8a022ea894cf7594acaf4370d66d1ed2a6d8b7601a1f8b6af1965dc343b823ebcf920790e5fe5e2a14de748d
|
data/.github/workflows/ruby.yml
CHANGED
|
@@ -6,11 +6,11 @@ jobs:
|
|
|
6
6
|
rubocop:
|
|
7
7
|
runs-on: ubuntu-latest
|
|
8
8
|
steps:
|
|
9
|
-
- uses: actions/checkout@
|
|
9
|
+
- uses: actions/checkout@v7
|
|
10
10
|
- name: Set up Ruby and install dependencies
|
|
11
11
|
uses: ruby/setup-ruby@v1
|
|
12
12
|
with:
|
|
13
|
-
ruby-version: 3.
|
|
13
|
+
ruby-version: 3.3
|
|
14
14
|
bundler-cache: true
|
|
15
15
|
- name: Run linter
|
|
16
16
|
run: bundle exec rubocop
|
|
@@ -18,27 +18,50 @@ jobs:
|
|
|
18
18
|
test:
|
|
19
19
|
runs-on: ubuntu-latest
|
|
20
20
|
strategy:
|
|
21
|
+
fail-fast: false
|
|
21
22
|
matrix:
|
|
22
|
-
ruby: [3.
|
|
23
|
-
faraday_version: ['', '~> 1.0'] # Defaults to whatever's the most recent version.
|
|
23
|
+
ruby: [3.3, 3.4, 4.0]
|
|
24
24
|
steps:
|
|
25
|
-
- uses: actions/checkout@
|
|
25
|
+
- uses: actions/checkout@v7
|
|
26
26
|
|
|
27
27
|
- name: Set up Ruby and install dependencies
|
|
28
28
|
uses: ruby/setup-ruby@v1
|
|
29
29
|
with:
|
|
30
30
|
ruby-version: ${{ matrix.ruby }}
|
|
31
31
|
bundler-cache: true
|
|
32
|
-
env:
|
|
33
|
-
FARADAY_VERSION: ${{ matrix.faraday_version }}
|
|
34
32
|
|
|
35
|
-
- name: "Run tests for Ruby ${{ matrix.ruby }}
|
|
33
|
+
- name: "Run tests for Ruby ${{ matrix.ruby }}"
|
|
36
34
|
run: bundle exec rake spec
|
|
37
|
-
env:
|
|
38
|
-
FARADAY_VERSION: ${{ matrix.faraday_version }}
|
|
39
35
|
|
|
40
36
|
- name: Upload coverage artifacts
|
|
41
|
-
uses: actions/upload-artifact@
|
|
37
|
+
uses: actions/upload-artifact@v7
|
|
42
38
|
with:
|
|
43
|
-
name: "coverage-${{ matrix.ruby }}
|
|
39
|
+
name: "coverage-${{ matrix.ruby }}"
|
|
44
40
|
path: coverage/
|
|
41
|
+
|
|
42
|
+
# Runs the specs that need a real Solr, using the GeoBlacklight schema
|
|
43
|
+
integration:
|
|
44
|
+
runs-on: ubuntu-latest
|
|
45
|
+
env:
|
|
46
|
+
GEOBLACKLIGHT_VERSION: v5.4.0
|
|
47
|
+
SOLR_INTEGRATION_URL: http://localhost:8983/solr/blacklight-core
|
|
48
|
+
steps:
|
|
49
|
+
- uses: actions/checkout@v7
|
|
50
|
+
|
|
51
|
+
- name: Start Solr with the GeoBlacklight ${{ env.GEOBLACKLIGHT_VERSION }} configuration
|
|
52
|
+
run: |
|
|
53
|
+
mkdir -p tmp/solr-conf
|
|
54
|
+
curl -sfL "https://github.com/geoblacklight/geoblacklight/archive/refs/tags/${GEOBLACKLIGHT_VERSION}.tar.gz" \
|
|
55
|
+
| tar -xz -C tmp/solr-conf --strip-components=3 "geoblacklight-${GEOBLACKLIGHT_VERSION#v}/solr/conf"
|
|
56
|
+
rm tmp/solr-conf/core.properties
|
|
57
|
+
docker run -d -p 8983:8983 -v "$PWD/tmp/solr-conf:/gbl-conf:ro" solr:9 solr-precreate blacklight-core /gbl-conf
|
|
58
|
+
timeout 120 sh -c 'until curl -sf "$SOLR_INTEGRATION_URL/get?id=ready" > /dev/null; do sleep 2; done'
|
|
59
|
+
|
|
60
|
+
- name: Set up Ruby and install dependencies
|
|
61
|
+
uses: ruby/setup-ruby@v1
|
|
62
|
+
with:
|
|
63
|
+
ruby-version: 3.4
|
|
64
|
+
bundler-cache: true
|
|
65
|
+
|
|
66
|
+
- name: Run tests, including integration tests against Solr
|
|
67
|
+
run: bundle exec rake spec
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
|
@@ -64,7 +64,6 @@ RSpec/ExampleLength:
|
|
|
64
64
|
# Offense count: 4
|
|
65
65
|
RSpec/ExpectInHook:
|
|
66
66
|
Exclude:
|
|
67
|
-
- 'spec/lib/geo_combine/geo_blacklight_harvester_spec.rb'
|
|
68
67
|
- 'spec/lib/geo_combine/geoblacklight_spec.rb'
|
|
69
68
|
|
|
70
69
|
# Offense count: 23
|
|
@@ -73,7 +72,6 @@ RSpec/ExpectInHook:
|
|
|
73
72
|
RSpec/MessageSpies:
|
|
74
73
|
Exclude:
|
|
75
74
|
- 'spec/lib/geo_combine/esri_open_data_spec.rb'
|
|
76
|
-
- 'spec/lib/geo_combine/geo_blacklight_harvester_spec.rb'
|
|
77
75
|
- 'spec/lib/geo_combine/geoblacklight_spec.rb'
|
|
78
76
|
- 'spec/lib/geo_combine/ogp_spec.rb'
|
|
79
77
|
- 'spec/lib/geo_combine_spec.rb'
|
|
@@ -121,7 +119,6 @@ RSpec/SpecFilePathFormat:
|
|
|
121
119
|
RSpec/StubbedMock:
|
|
122
120
|
Exclude:
|
|
123
121
|
- 'spec/lib/geo_combine/esri_open_data_spec.rb'
|
|
124
|
-
- 'spec/lib/geo_combine/geo_blacklight_harvester_spec.rb'
|
|
125
122
|
- 'spec/lib/geo_combine/geoblacklight_spec.rb'
|
|
126
123
|
- 'spec/lib/geo_combine/ogp_spec.rb'
|
|
127
124
|
- 'spec/lib/geo_combine_spec.rb'
|
|
@@ -131,16 +128,11 @@ RSpec/SubjectStub:
|
|
|
131
128
|
Exclude:
|
|
132
129
|
- 'spec/lib/geo_combine/ogp_spec.rb'
|
|
133
130
|
|
|
134
|
-
# Offense count: 1
|
|
135
|
-
# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
|
|
136
|
-
RSpec/VerifiedDoubles:
|
|
137
|
-
Exclude:
|
|
138
|
-
- 'spec/lib/geo_combine/geo_blacklight_harvester_spec.rb'
|
|
139
|
-
|
|
140
131
|
# Offense count: 1
|
|
141
132
|
Security/Open:
|
|
142
133
|
Exclude:
|
|
143
134
|
- 'lib/geo_combine/geoblacklight.rb'
|
|
135
|
+
- 'lib/geo_combine/geoblacklight_aardvark.rb'
|
|
144
136
|
|
|
145
137
|
# Offense count: 6
|
|
146
138
|
# Configuration parameters: AllowedConstants.
|
|
@@ -150,8 +142,8 @@ Style/Documentation:
|
|
|
150
142
|
- 'test/**/*'
|
|
151
143
|
- 'lib/geo_combine/bounding_box.rb'
|
|
152
144
|
- 'lib/geo_combine/ckan_metadata.rb'
|
|
153
|
-
- 'lib/geo_combine/geo_blacklight_harvester.rb'
|
|
154
145
|
- 'lib/geo_combine/geoblacklight.rb'
|
|
146
|
+
- 'lib/geo_combine/geoblacklight_aardvark.rb'
|
|
155
147
|
- 'lib/geo_combine/geometry_types.rb'
|
|
156
148
|
- 'lib/geo_combine/iso19139.rb'
|
|
157
149
|
|
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
# GeoCombine
|
|
2
2
|
|
|
3
3
|

|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
[]()
|
|
5
|
+
[](https://github.com/OpenGeoMetadata/GeoCombine/releases)
|
|
6
6
|
|
|
7
7
|
A Ruby toolkit for managing geospatial metadata, including:
|
|
8
8
|
|
|
9
|
-
-
|
|
10
|
-
-
|
|
9
|
+
- harvesting and indexing records from OpenGeoMetadata
|
|
10
|
+
- converting geospatial metadata records between standards
|
|
11
|
+
- migrating OpenGeoMetadata records from older to newer schema versions
|
|
11
12
|
|
|
12
13
|
## Installation
|
|
13
14
|
|
|
15
|
+
> [!TIP]
|
|
16
|
+
> If you're using GeoBlacklight, GeoCombine is already bundled with your installation – you can skip this section.
|
|
17
|
+
|
|
14
18
|
Add this line to your application's `Gemfile`:
|
|
15
19
|
|
|
16
20
|
```ruby
|
|
@@ -20,127 +24,72 @@ gem 'geo_combine'
|
|
|
20
24
|
And then execute:
|
|
21
25
|
|
|
22
26
|
```sh
|
|
23
|
-
|
|
27
|
+
bundle install
|
|
24
28
|
```
|
|
25
29
|
|
|
26
30
|
Or install it yourself as:
|
|
27
31
|
|
|
28
32
|
```sh
|
|
29
|
-
|
|
33
|
+
gem install geo_combine
|
|
30
34
|
```
|
|
31
35
|
|
|
32
36
|
## Usage
|
|
33
37
|
|
|
34
|
-
###
|
|
35
|
-
|
|
36
|
-
#### Converting metadata into GeoBlacklight JSON
|
|
37
|
-
|
|
38
|
-
GeoCombine provides several classes representing different metadata standards that implement the `#to_geoblacklight` method for generating records in the [GeoBlacklight JSON format](https://opengeometadata.org/reference/):
|
|
39
|
-
|
|
40
|
-
```ruby
|
|
41
|
-
GeoCombine::Iso19139 # ISO 19139 XML
|
|
42
|
-
GeoCombine::OGP # OpenGeoPortal JSON
|
|
43
|
-
GeoCombine::Fgdc # FGDC XML
|
|
44
|
-
GeoCombine::EsriOpenData # Esri Open Data Portal JSON
|
|
45
|
-
GeoCombine::CkanMetadata # CKAN JSON
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
An example for converting an ISO 19139 XML record:
|
|
49
|
-
|
|
50
|
-
```ruby
|
|
51
|
-
# Create a new ISO19139 object
|
|
52
|
-
> iso_metadata = GeoCombine::Iso19139.new('./tmp/opengeometadata/edu.stanford.purl/bb/338/jh/0716/iso19139.xml')
|
|
53
|
-
|
|
54
|
-
# Convert to GeoBlacklight's metadata format
|
|
55
|
-
> iso_metadata.to_geoblacklight
|
|
56
|
-
|
|
57
|
-
# Output it as JSON instead of a Ruby hash
|
|
58
|
-
> iso_metadata.to_geoblacklight.to_json
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
Some formats also support conversion into HTML for display in a web browser:
|
|
62
|
-
|
|
63
|
-
```ruby
|
|
64
|
-
# Create a new ISO19139 object
|
|
65
|
-
> iso_metadata = GeoCombine::Iso19139.new('./tmp/opengeometadata/edu.stanford.purl/bb/338/jh/0716/iso19139.xml')
|
|
66
|
-
|
|
67
|
-
# Convert ISO to HTML
|
|
68
|
-
> iso_metadata.to_html
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
### Migrating metadata
|
|
72
|
-
|
|
73
|
-
You can use the `GeoCombine::Migrators` to migrate metadata from one schema to another.
|
|
74
|
-
|
|
75
|
-
Currently, the only migrator is `GeoCombine::Migrators::V1AardvarkMigrator` which migrates from the [GeoBlacklight v1 schema](https://github.com/OpenGeoMetadata/opengeometadata.github.io/blob/main/docs/gbl-1.0.md) to the [Aardvark schema](https://github.com/OpenGeoMetadata/opengeometadata.github.io/blob/main/docs/ogm-aardvark.md)
|
|
76
|
-
|
|
77
|
-
```ruby
|
|
78
|
-
# Load a record in geoblacklight v1 schema
|
|
79
|
-
record = JSON.parse(File.read('.spec/fixtures/docs/full_geoblacklight.json'))
|
|
80
|
-
|
|
81
|
-
# Migrate it to Aardvark schema
|
|
82
|
-
GeoCombine::Migrators::V1AardvarkMigrator.new(v1_hash: record).run
|
|
83
|
-
```
|
|
38
|
+
### Downloading metadata from OpenGeoMetadata
|
|
84
39
|
|
|
85
|
-
|
|
40
|
+
#### Schema version
|
|
86
41
|
|
|
87
|
-
|
|
88
|
-
# You can store this mapping as a JSON or CSV file and load it into a hash
|
|
89
|
-
id_map = {
|
|
90
|
-
'My Collection 1' => 'institution:my-collection-1',
|
|
91
|
-
'My Collection 2' => 'institution:my-collection-2'
|
|
92
|
-
}
|
|
42
|
+
By default, GeoCombine will only fetch and index records using the current schema version. If you instead want to index records using an older schema (e.g. because your GeoBlacklight instance is an older version), you can set the `SCHEMA_VERSION` environment variable:
|
|
93
43
|
|
|
94
|
-
|
|
44
|
+
```sh
|
|
45
|
+
# Only fetch and index schema version 1.0 records
|
|
46
|
+
export SCHEMA_VERSION=1.0
|
|
95
47
|
```
|
|
96
48
|
|
|
97
|
-
|
|
49
|
+
#### Restricted records
|
|
98
50
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
Some of the tools and scripts in this gem use Ruby's `Logger` class to print information to `$stderr`. By default, the log level is set to `Logger::INFO`. For more verbose information, you can set the `LOG_LEVEL` environment variable to `DEBUG`:
|
|
51
|
+
By default, GeoCombine will only fetch and index records that are not marked as restricted. If you want to include restricted records, you can set the `OGM_SKIP_RESTRICTED` environment variable to `false`:
|
|
102
52
|
|
|
103
53
|
```sh
|
|
104
|
-
|
|
54
|
+
export OGM_SKIP_RESTRICTED=false
|
|
105
55
|
```
|
|
106
56
|
|
|
107
|
-
####
|
|
57
|
+
#### GitHub API token
|
|
108
58
|
|
|
109
|
-
|
|
59
|
+
GeoCombine uses the GitHub API to find OpenGeoMetadata repositories. Unauthenticated requests are limited to 60 per hour, and `geocombine:clone` makes one for each repository. If you hit the limit, set the `GITHUB_TOKEN` environment variable to a GitHub personal access token to raise it; the token only needs read access to public repositories:
|
|
110
60
|
|
|
111
61
|
```sh
|
|
112
|
-
|
|
113
|
-
$ export SCHEMA_VERSION=1.0
|
|
62
|
+
export GITHUB_TOKEN=your-token
|
|
114
63
|
```
|
|
115
64
|
|
|
116
65
|
#### Clone OpenGeoMetadata repositories locally
|
|
117
66
|
|
|
118
67
|
```sh
|
|
119
|
-
|
|
68
|
+
bundle exec rake geocombine:clone
|
|
120
69
|
```
|
|
121
70
|
|
|
122
71
|
Will clone all OpenGeoMetadata repositories containing metadata matching the `SCHEMA_VERSION` into `./tmp/opengeometadata`. Location of the OpenGeoMetadata repositories can be configured using the `OGM_PATH` environment variable.
|
|
123
72
|
|
|
124
73
|
```sh
|
|
125
|
-
|
|
74
|
+
OGM_PATH='my/custom/location' bundle exec rake geocombine:clone
|
|
126
75
|
```
|
|
127
76
|
|
|
128
77
|
You can also specify a single repository:
|
|
129
78
|
|
|
130
79
|
```sh
|
|
131
|
-
|
|
80
|
+
bundle exec rake geocombine:clone[edu.stanford.purl]
|
|
132
81
|
```
|
|
133
82
|
|
|
134
83
|
_Note: If you are using zsh, you will need to use escape characters in front of the brackets:_
|
|
135
84
|
|
|
136
85
|
```sh
|
|
137
|
-
|
|
86
|
+
bundle exec rake geocombine:clone\[edu.stanford.purl\]
|
|
138
87
|
```
|
|
139
88
|
|
|
140
89
|
#### Update local OpenGeoMetadata repositories
|
|
141
90
|
|
|
142
91
|
```sh
|
|
143
|
-
|
|
92
|
+
bundle exec rake geocombine:pull
|
|
144
93
|
```
|
|
145
94
|
|
|
146
95
|
Runs `git pull origin master` on all cloned repositories in `./tmp/opengeometadata` (or custom path with configured environment variable `OGM_PATH`).
|
|
@@ -148,22 +97,25 @@ Runs `git pull origin master` on all cloned repositories in `./tmp/opengeometada
|
|
|
148
97
|
You can also specify a single repository:
|
|
149
98
|
|
|
150
99
|
```sh
|
|
151
|
-
|
|
100
|
+
bundle exec rake geocombine:pull[edu.stanford.purl]
|
|
152
101
|
```
|
|
153
102
|
|
|
154
103
|
_Note: If you are using zsh, you will need to use escape characters in front of the brackets:_
|
|
155
104
|
|
|
156
105
|
```sh
|
|
157
|
-
|
|
106
|
+
bundle exec rake geocombine:pull\[edu.stanford.purl\]
|
|
158
107
|
```
|
|
159
108
|
|
|
160
109
|
#### Index GeoBlacklight documents
|
|
161
110
|
|
|
111
|
+
> [!TIP]
|
|
112
|
+
> If you're using GeoBlacklight, GeoCombine will automatically detect the path to your Solr index if you run it in the directory where GeoBlacklight is installed.
|
|
113
|
+
|
|
162
114
|
To index into Solr, GeoCombine requires a Solr instance that is running the
|
|
163
115
|
[GeoBlacklight schema](https://github.com/geoblacklight/geoblacklight):
|
|
164
116
|
|
|
165
117
|
```sh
|
|
166
|
-
|
|
118
|
+
bundle exec rake geocombine:index
|
|
167
119
|
```
|
|
168
120
|
|
|
169
121
|
If Blacklight is installed in the ruby environment and a solr index is configured, the rake task will use the solr index configured in the Blacklight application (this is the case when invoking GeoCombine from your GeoBlacklight installation). If Blacklight is unavailable, the rake task will try to find a Solr instance running at `http://localhost:8983/solr/blacklight-core`.
|
|
@@ -171,86 +123,194 @@ If Blacklight is installed in the ruby environment and a solr index is configure
|
|
|
171
123
|
You can also set the Solr instance URL using `SOLR_URL`:
|
|
172
124
|
|
|
173
125
|
```sh
|
|
174
|
-
|
|
126
|
+
SOLR_URL=http://www.example.com:1234/solr/collection bundle exec rake geocombine:index
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
#### Withdrawn records
|
|
130
|
+
|
|
131
|
+
An OpenGeoMetadata repository can withdraw records by listing them in a `withdrawn.json` file at its root:
|
|
132
|
+
|
|
133
|
+
```json
|
|
134
|
+
{
|
|
135
|
+
"$schema": "https://opengeometadata.org/schema/ogm-withdrawals-1.0.json",
|
|
136
|
+
"ogm_version": "1.0",
|
|
137
|
+
"withdrawn": [
|
|
138
|
+
{ "id": "stanford-bb058zh0946", "date": "2026-03-14", "reason": "superseded" }
|
|
139
|
+
]
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
After indexing, `geocombine:index` deletes the records these files list from your Solr index. It is careful about what it deletes:
|
|
144
|
+
|
|
145
|
+
- A record is only deleted if a `withdrawn.json` lists its `id` (or `layer_slug_s`, for `SCHEMA_VERSION=1.0`). Removing a record's file from a repository does not delete it from your index.
|
|
146
|
+
- A record that is still present in the repository is never deleted, even if it is also listed as withdrawn. GeoCombine logs a warning instead.
|
|
147
|
+
- A `withdrawn.json` that can't be read is logged and skipped; it doesn't stop indexing.
|
|
148
|
+
- Repositories listed in `OGM_SKIP_REPOS` can't delete anything.
|
|
149
|
+
- If the harvest stops before it has walked every record, nothing is deleted.
|
|
150
|
+
|
|
151
|
+
GeoCombine keeps no record of what it has deleted. Every run deletes every withdrawn record again, which changes nothing for records that are already gone. Deletes match by `id` alone, so a withdrawn `id` that matches a record you indexed from somewhere other than OpenGeoMetadata will delete that record too.
|
|
152
|
+
|
|
153
|
+
To delete withdrawn records without reindexing everything, run:
|
|
154
|
+
|
|
155
|
+
```sh
|
|
156
|
+
bundle exec rake geocombine:withdraw
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
#### Logging
|
|
160
|
+
|
|
161
|
+
Some of the tools and scripts in this gem use Ruby's `Logger` class to print information to `$stderr`. By default, the log level is set to `Logger::INFO`. For more verbose information, you can set the `LOG_LEVEL` environment variable to `DEBUG`:
|
|
162
|
+
|
|
163
|
+
```sh
|
|
164
|
+
export LOG_LEVEL=DEBUG
|
|
175
165
|
```
|
|
176
166
|
|
|
177
167
|
### Indexing local documents
|
|
178
168
|
|
|
179
|
-
To index
|
|
169
|
+
To index a collection of records in a local directory, you can pass the directory as a `rake` argument:
|
|
170
|
+
|
|
171
|
+
```sh
|
|
172
|
+
bundle exec rake geocombine:index\[/path/to/your/files\]
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Or you can provide it as `OGM_PATH`:
|
|
180
176
|
|
|
181
177
|
```sh
|
|
182
|
-
rake geocombine:index\[/path/to/your/files\]
|
|
183
178
|
OGM_PATH=/path/to/your/files rake geocombine:index
|
|
184
179
|
```
|
|
185
180
|
|
|
186
|
-
|
|
181
|
+
For a single file, it works the same way:
|
|
182
|
+
|
|
183
|
+
```sh
|
|
184
|
+
bundle exec rake geocombine:index\[/path/to/your/file.json\]
|
|
185
|
+
```
|
|
187
186
|
|
|
188
|
-
|
|
187
|
+
Or:
|
|
189
188
|
|
|
190
189
|
```sh
|
|
191
|
-
rake geocombine:index\[/path/to/your/file.json\]
|
|
192
190
|
OGM_PATH=/path/to/your/file.json rake geocombine:index
|
|
193
191
|
```
|
|
194
192
|
|
|
195
|
-
###
|
|
193
|
+
### Converting metadata
|
|
194
|
+
|
|
195
|
+
#### Converting metadata into GeoBlacklight JSON
|
|
196
196
|
|
|
197
|
-
GeoCombine provides
|
|
197
|
+
GeoCombine provides several classes representing different metadata standards that implement the `#to_geoblacklight` method for generating records in the [GeoBlacklight JSON format](https://opengeometadata.org/reference/):
|
|
198
198
|
|
|
199
|
-
```
|
|
200
|
-
|
|
199
|
+
```ruby
|
|
200
|
+
GeoCombine::Iso19139 # ISO 19139 XML
|
|
201
|
+
GeoCombine::OGP # OpenGeoPortal JSON
|
|
202
|
+
GeoCombine::Fgdc # FGDC XML
|
|
203
|
+
GeoCombine::EsriOpenData # Esri Open Data Portal JSON
|
|
204
|
+
GeoCombine::CkanMetadata # CKAN JSON
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
An example for converting an ISO 19139 XML record:
|
|
208
|
+
|
|
209
|
+
```ruby
|
|
210
|
+
# Create a new ISO19139 object
|
|
211
|
+
> iso_metadata = GeoCombine::Iso19139.new('./tmp/opengeometadata/edu.stanford.purl/bb/338/jh/0716/iso19139.xml')
|
|
212
|
+
|
|
213
|
+
# Convert to GeoBlacklight's metadata format
|
|
214
|
+
> iso_metadata.to_geoblacklight
|
|
215
|
+
|
|
216
|
+
# Output it as JSON instead of a Ruby hash
|
|
217
|
+
> iso_metadata.to_geoblacklight.to_json
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
Some formats also support conversion into HTML for display in a web browser:
|
|
221
|
+
|
|
222
|
+
```ruby
|
|
223
|
+
# Create a new ISO19139 object
|
|
224
|
+
> iso_metadata = GeoCombine::Iso19139.new('./tmp/opengeometadata/edu.stanford.purl/bb/338/jh/0716/iso19139.xml')
|
|
225
|
+
|
|
226
|
+
# Convert ISO to HTML
|
|
227
|
+
> iso_metadata.to_html
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
#### Converting metadata into Aardvark JSON
|
|
231
|
+
|
|
232
|
+
`GeoCombine::Fgdc` and `GeoCombine::Iso19139` also implement `#to_aardvark`, which converts FGDC or ISO 19139 XML into the [OGM Aardvark schema](https://opengeometadata.org/ogm-aardvark/) and returns a `GeoCombine::GeoblacklightAardvark`:
|
|
233
|
+
|
|
234
|
+
```ruby
|
|
235
|
+
# Create a new Fgdc object
|
|
236
|
+
> fgdc_metadata = GeoCombine::Fgdc.new('./tmp/opengeometadata/edu.tufts/0/108/220/208/fgdc.xml')
|
|
237
|
+
|
|
238
|
+
# Convert to the Aardvark schema
|
|
239
|
+
> aardvark = fgdc_metadata.to_aardvark
|
|
240
|
+
|
|
241
|
+
# Validate it against the Aardvark JSON schema
|
|
242
|
+
> aardvark.valid?
|
|
243
|
+
=> true
|
|
244
|
+
|
|
245
|
+
# Output it as JSON instead of a Ruby hash
|
|
246
|
+
> aardvark.to_json
|
|
201
247
|
```
|
|
202
248
|
|
|
203
|
-
|
|
249
|
+
Aardvark defines some fields that FGDC and ISO have no source for, such as `gbl_suppressed_b`, and the links in a record may not be the ones you want to publish. Pass fields in and they are merged into the transformed record, replacing any derived values:
|
|
250
|
+
|
|
251
|
+
```ruby
|
|
252
|
+
> fgdc_metadata.to_aardvark(
|
|
253
|
+
'id' => 'tufts-ecuador-drilling-towers',
|
|
254
|
+
'schema_provider_s' => 'Tufts',
|
|
255
|
+
'dct_references_s' => { 'http://schema.org/url' => 'https://example.edu/catalog/tufts-1' }.to_json
|
|
256
|
+
)
|
|
257
|
+
```
|
|
204
258
|
|
|
205
|
-
|
|
259
|
+
Note about `schema_provider_s` and `id`:
|
|
206
260
|
|
|
207
261
|
```ruby
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
params: {
|
|
225
|
-
q: '*'
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
end
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
##### Crawl Delays (default: none)
|
|
233
|
-
|
|
234
|
-
Crawl delays can be configured (in seconds) either globally for all sites or on a per-site basis. This will cause a delay for that number of seconds between each search results page (note that Blacklight 7 necessitates a lot of requests per results page and this only causes the delay per page of results)
|
|
235
|
-
|
|
236
|
-
##### Solr's commitWithin (default: 5000 milliseconds)
|
|
237
|
-
|
|
238
|
-
Solr's commitWithin option can be configured (in milliseconds) by passing a value under the commit_within key.
|
|
239
|
-
|
|
240
|
-
#### Transforming Documents
|
|
241
|
-
|
|
242
|
-
You may need to transform documents that are harvested for various purposes (removing fields, adding fields, omitting a document all together, etc). You can configure some ruby code (a proc) that will take the document in, transform it, and return the transformed document. By default the indexer will remove the `score`, `timestamp`, and `_version_` fields from the documents harvested. If you provide your own transformer, you'll likely want to remove these fields in addition to the other transformations you provide.
|
|
262
|
+
# Without a provider, id and provider are derived from the record
|
|
263
|
+
> fgdc_metadata.to_aardvark.metadata['id']
|
|
264
|
+
=> "tufts-university-gis-center-ecuador50kdrillingtower11"
|
|
265
|
+
|
|
266
|
+
# With one, the provider is used as the id prefix
|
|
267
|
+
> fgdc_metadata.to_aardvark('schema_provider_s' => 'Tufts').metadata['id']
|
|
268
|
+
=> "tufts-ecuador50kdrillingtower11"
|
|
269
|
+
|
|
270
|
+
# Or set the id yourself
|
|
271
|
+
> fgdc_metadata.to_aardvark('id' => 'tufts-ecuador-drilling-towers').metadata['id']
|
|
272
|
+
=> "tufts-ecuador-drilling-towers"
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
The FGDC transformation fills in `dct_references_s` from the citation's online linkage and the network resources of each digital form, classified by URL and by the format they're distributed in: a landing page, downloads (a labeled list when there's more than one), FGDC and HTML metadata, and OGC (WMS, WFS, WCS, WMTS) and Esri service endpoints. A browse graphic URL becomes the thumbnail, and `gbl_wxsIdentifier_s` is the layer an OGC request asks for. References you pass in replace the derived ones.
|
|
276
|
+
|
|
277
|
+
ISO 19139 records (including ISO 19115-2 `gmi:MI_Metadata`) work the same way. Their ids use the last segment of the `fileIdentifier`, falling back to the `dataSetURI`, the citation identifier and the title:
|
|
243
278
|
|
|
244
279
|
```ruby
|
|
245
|
-
GeoCombine::
|
|
246
|
-
# Removes "bogus_field" from the content we're harvesting
|
|
247
|
-
# in addition to some other solr fields we don't want
|
|
248
|
-
%w[_version_ score timestamp bogus_field].each do |field|
|
|
249
|
-
document.delete(field)
|
|
250
|
-
end
|
|
280
|
+
> iso_metadata = GeoCombine::Iso19139.new('./tmp/opengeometadata/edu.stanford.purl/bb/338/jh/0716/iso19139.xml')
|
|
251
281
|
|
|
252
|
-
|
|
253
|
-
|
|
282
|
+
> iso_metadata.to_aardvark('schema_provider_s' => 'Stanford').metadata['id']
|
|
283
|
+
=> "stanford-bb338jh0716"
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
The ISO transformation also fills in `dct_references_s`, from the dataset URI, downloads, and OGC (WMS, WFS, WCS, WMTS) and Esri service links, along with `gbl_wxsIdentifier_s` from the name of an OGC link. References you pass in replace the derived ones.
|
|
287
|
+
|
|
288
|
+
Some values can't be derived reliably and are left for you to pass in: `gbl_resourceType_sm` for vector data whose geometry is only described as `composite` (used for both lines and polygons), and `pcdm_memberOf_sm` and `dct_isPartOf_sm`, which take the ids of other Aardvark records.
|
|
289
|
+
|
|
290
|
+
### Migrating metadata
|
|
291
|
+
|
|
292
|
+
You can use the `GeoCombine::Migrators` to migrate metadata from one schema to another.
|
|
293
|
+
|
|
294
|
+
Currently, the only migrator is `GeoCombine::Migrators::V1AardvarkMigrator` which migrates from the [GeoBlacklight v1 schema](https://github.com/OpenGeoMetadata/opengeometadata.github.io/blob/main/docs/gbl-1.0.md) to the [Aardvark schema](https://github.com/OpenGeoMetadata/opengeometadata.github.io/blob/main/docs/ogm-aardvark.md)
|
|
295
|
+
|
|
296
|
+
```ruby
|
|
297
|
+
# Load a record in geoblacklight v1 schema
|
|
298
|
+
record = JSON.parse(File.read('.spec/fixtures/docs/full_geoblacklight.json'))
|
|
299
|
+
|
|
300
|
+
# Migrate it to Aardvark schema
|
|
301
|
+
GeoCombine::Migrators::V1AardvarkMigrator.new(v1_hash: record).run
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
Some fields cannot be migrated automatically. To handle the migration of collection names to IDs when migrating from v1 to Aardvark, you can provide a mapping of collection names to IDs to the migrator:
|
|
305
|
+
|
|
306
|
+
```ruby
|
|
307
|
+
# You can store this mapping as a JSON or CSV file and load it into a hash
|
|
308
|
+
id_map = {
|
|
309
|
+
'My Collection 1' => 'institution:my-collection-1',
|
|
310
|
+
'My Collection 2' => 'institution:my-collection-2'
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
GeoCombine::Migrators::V1AardvarkMigrator.new(v1_hash: record, collection_id_map: id_map).run
|
|
254
314
|
```
|
|
255
315
|
|
|
256
316
|
## Tests
|
|
@@ -258,7 +318,13 @@ end
|
|
|
258
318
|
To run the tests, use:
|
|
259
319
|
|
|
260
320
|
```sh
|
|
261
|
-
|
|
321
|
+
bundle exec rake spec
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
Some tests need a real Solr core running the GeoBlacklight schema. They delete documents, so they only run when `SOLR_INTEGRATION_URL` points at a core you don't mind them changing:
|
|
325
|
+
|
|
326
|
+
```sh
|
|
327
|
+
SOLR_INTEGRATION_URL=http://localhost:8983/solr/blacklight-core bundle exec rake spec
|
|
262
328
|
```
|
|
263
329
|
|
|
264
330
|
## Contributing
|
data/geo_combine.gemspec
CHANGED
|
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
|
|
|
25
25
|
spec.add_dependency 'sanitize'
|
|
26
26
|
spec.add_dependency 'thor'
|
|
27
27
|
spec.add_dependency 'faraday-net_http_persistent', '~> 2.0'
|
|
28
|
-
spec.add_dependency 'git'
|
|
28
|
+
spec.add_dependency 'git', '~> 6.0'
|
|
29
29
|
spec.add_dependency 'faraday-retry', '~> 2.2'
|
|
30
30
|
|
|
31
31
|
spec.add_development_dependency 'bundler'
|
data/lib/geo_combine/fgdc.rb
CHANGED
|
@@ -11,6 +11,13 @@ module GeoCombine
|
|
|
11
11
|
Nokogiri::XSLT(File.open(File.join(File.dirname(__FILE__), '../xslt/fgdc2geoBL.xsl')))
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
+
##
|
|
15
|
+
# Returns a Nokogiri::XSLT object containing the FGDC to Aardvark XSL
|
|
16
|
+
# @return [Nokogiri::XSLT]
|
|
17
|
+
def xsl_aardvark
|
|
18
|
+
Nokogiri::XSLT(File.open(File.join(File.dirname(__FILE__), '../xslt/fgdc2Aardvark.xsl')))
|
|
19
|
+
end
|
|
20
|
+
|
|
14
21
|
##
|
|
15
22
|
# Returns a Nokogiri::XSLT object containing the ISO19139 to HTML XSL
|
|
16
23
|
# @return [Nokogiri:XSLT]
|