geo_concerns 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.rubocop.yml +101 -0
- data/.travis.yml +17 -0
- data/Gemfile +46 -0
- data/LICENSE +202 -0
- data/README.md +46 -0
- data/Rakefile +21 -0
- data/app/actors/geo_concerns/file_actor.rb +20 -0
- data/app/actors/geo_concerns/file_set_actor.rb +7 -0
- data/app/assets/images/geo_concerns/.keep +0 -0
- data/app/assets/images/geo_concerns/images/geocoder.png +0 -0
- data/app/assets/images/geo_concerns/images/throbber.gif +0 -0
- data/app/assets/images/geo_concerns/img/filter-icon.png +0 -0
- data/app/assets/images/geo_concerns/img/move-handle.png +0 -0
- data/app/assets/images/geo_concerns/img/resize-handle.png +0 -0
- data/app/assets/javascripts/geo_concerns/Control.Geocoder.js +1056 -0
- data/app/assets/javascripts/geo_concerns/application.js +5 -0
- data/app/assets/javascripts/geo_concerns/bounding_box_selector.js +100 -0
- data/app/assets/javascripts/geo_concerns/leaflet-boundingbox.js +467 -0
- data/app/assets/stylesheets/geo_concerns/Control.Geocoder.css +104 -0
- data/app/assets/stylesheets/geo_concerns/application.css +18 -0
- data/app/assets/stylesheets/geo_concerns/bounding_box.scss +7 -0
- data/app/assets/stylesheets/geo_concerns/leaflet-boundingbox.css +17 -0
- data/app/controllers/concerns/geo_concerns/file_sets_controller_behavior.rb +19 -0
- data/app/controllers/concerns/geo_concerns/image_works_controller_behavior.rb +13 -0
- data/app/controllers/concerns/geo_concerns/raster_works_controller_behavior.rb +23 -0
- data/app/controllers/concerns/geo_concerns/vector_works_controller_behavior.rb +23 -0
- data/app/forms/geo_concerns/basic_geo_metadata_form.rb +8 -0
- data/app/forms/geo_concerns/external_metadata_file_form.rb +8 -0
- data/app/forms/geo_concerns/georeferenced_form.rb +9 -0
- data/app/forms/geo_concerns/image_work_form.rb +9 -0
- data/app/forms/geo_concerns/raster_work_form.rb +8 -0
- data/app/forms/geo_concerns/vector_work_form.rb +8 -0
- data/app/helpers/bounding_box_helper.rb +24 -0
- data/app/helpers/geo_concerns/application_helper.rb +4 -0
- data/app/models/concerns/geo_concerns/basic_geo_metadata.rb +21 -0
- data/app/models/concerns/geo_concerns/external_metadata_file_behavior.rb +31 -0
- data/app/models/concerns/geo_concerns/extractors/fgdc_helper.rb +9 -0
- data/app/models/concerns/geo_concerns/extractors/fgdc_metadata_extractor.rb +114 -0
- data/app/models/concerns/geo_concerns/extractors/iso19139_helper.rb +50 -0
- data/app/models/concerns/geo_concerns/extractors/mods_helper.rb +15 -0
- data/app/models/concerns/geo_concerns/file_set/derivatives.rb +60 -0
- data/app/models/concerns/geo_concerns/file_set_presenter_behavior.rb +7 -0
- data/app/models/concerns/geo_concerns/geo_file_format_behavior.rb +37 -0
- data/app/models/concerns/geo_concerns/geo_file_set_behavior.rb +11 -0
- data/app/models/concerns/geo_concerns/georeferenced_behavior.rb +18 -0
- data/app/models/concerns/geo_concerns/image_file_behavior.rb +14 -0
- data/app/models/concerns/geo_concerns/image_work_behavior.rb +69 -0
- data/app/models/concerns/geo_concerns/metadata_extraction_helper.rb +28 -0
- data/app/models/concerns/geo_concerns/raster_file_behavior.rb +14 -0
- data/app/models/concerns/geo_concerns/raster_work_behavior.rb +82 -0
- data/app/models/concerns/geo_concerns/solr_document_behavior.rb +25 -0
- data/app/models/concerns/geo_concerns/vector_file_behavior.rb +14 -0
- data/app/models/concerns/geo_concerns/vector_work_behavior.rb +78 -0
- data/app/presenters/geo_concerns/geo_concerns_show_presenter.rb +30 -0
- data/app/presenters/geo_concerns/image_work_show_presenter.rb +18 -0
- data/app/presenters/geo_concerns/raster_work_show_presenter.rb +18 -0
- data/app/presenters/geo_concerns/vector_work_show_presenter.rb +10 -0
- data/app/processors/geo_concerns/processors/base_geo_processor.rb +86 -0
- data/app/processors/geo_concerns/processors/raster.rb +11 -0
- data/app/processors/geo_concerns/processors/raster/aig.rb +44 -0
- data/app/processors/geo_concerns/processors/raster/base.rb +74 -0
- data/app/processors/geo_concerns/processors/raster/dem.rb +46 -0
- data/app/processors/geo_concerns/processors/raster/processor.rb +27 -0
- data/app/processors/geo_concerns/processors/vector.rb +11 -0
- data/app/processors/geo_concerns/processors/vector/base.rb +68 -0
- data/app/processors/geo_concerns/processors/vector/processor.rb +25 -0
- data/app/processors/geo_concerns/processors/vector/shapefile.rb +20 -0
- data/app/processors/geo_concerns/processors/zip.rb +31 -0
- data/app/renderers/coverage_renderer.rb +34 -0
- data/app/runners/geo_concerns/runners/raster_derivatives.rb +9 -0
- data/app/runners/geo_concerns/runners/vector_derivatives.rb +9 -0
- data/app/schemas/geo_concerns/basic_geo_metadata_optional.rb +39 -0
- data/app/schemas/geo_concerns/basic_geo_metadata_required.rb +25 -0
- data/app/services/authority_service.rb +23 -0
- data/app/services/geo_concerns/derivative_path.rb +16 -0
- data/app/services/image_format_service.rb +4 -0
- data/app/services/metadata_format_service.rb +4 -0
- data/app/services/raster_format_service.rb +4 -0
- data/app/services/vector_format_service.rb +4 -0
- data/app/values/geo_concerns/coverage.rb +36 -0
- data/app/values/geo_concerns/time_period.rb +31 -0
- data/app/views/curation_concerns/file_sets/_form.html.erb +48 -0
- data/app/views/curation_concerns/image_works/_form.html.erb +23 -0
- data/app/views/curation_concerns/image_works/_image_work.html.erb +2 -0
- data/app/views/curation_concerns/image_works/_members.html.erb +30 -0
- data/app/views/curation_concerns/image_works/_related_image_files.html.erb +24 -0
- data/app/views/curation_concerns/image_works/_show_actions.html.erb +16 -0
- data/app/views/curation_concerns/image_works/show.html.erb +17 -0
- data/app/views/curation_concerns/raster_works/_form.html.erb +25 -0
- data/app/views/curation_concerns/raster_works/_members.html.erb +30 -0
- data/app/views/curation_concerns/raster_works/_raster_work.html.erb +2 -0
- data/app/views/curation_concerns/raster_works/_related_raster_files.html.erb +24 -0
- data/app/views/curation_concerns/raster_works/_show_actions.html.erb +16 -0
- data/app/views/curation_concerns/raster_works/show.html.erb +17 -0
- data/app/views/curation_concerns/vector_works/_form.html.erb +25 -0
- data/app/views/curation_concerns/vector_works/_related_vector_files.html.erb +24 -0
- data/app/views/curation_concerns/vector_works/_show_actions.html.erb +15 -0
- data/app/views/curation_concerns/vector_works/_vector_work.html.erb +2 -0
- data/app/views/curation_concerns/vector_works/show.html.erb +15 -0
- data/app/views/geo_concerns/_attribute_rows.html.erb +11 -0
- data/app/views/geo_concerns/_attributes.html.erb +13 -0
- data/app/views/geo_concerns/_form_additional_information.html.erb +11 -0
- data/app/views/geo_concerns/_form_bounding_box.html.erb +9 -0
- data/app/views/geo_concerns/_form_descriptive_fields.html.erb +9 -0
- data/app/views/geo_concerns/_form_files_and_links.html.erb +0 -0
- data/app/views/geo_concerns/_form_populate_metadata.html.erb +8 -0
- data/app/views/geo_concerns/_form_required_information.html.erb +12 -0
- data/app/views/geo_concerns/_form_supplementary_fields.html.erb +15 -0
- data/app/views/geo_concerns/_related_external_metadata_files.html.erb +24 -0
- data/app/vocabs/geo_concerns/geo_terms.rb +12 -0
- data/bin/rails +12 -0
- data/config/routes.rb +6 -0
- data/geo_concerns.gemspec +36 -0
- data/lib/generators/geo_concerns/install_generator.rb +119 -0
- data/lib/generators/geo_concerns/templates/actors/curation_concerns/image_work_actor.rb +4 -0
- data/lib/generators/geo_concerns/templates/actors/curation_concerns/raster_work_actor.rb +4 -0
- data/lib/generators/geo_concerns/templates/actors/curation_concerns/vector_work_actor.rb +4 -0
- data/lib/generators/geo_concerns/templates/config/authorities/image_formats.yml +5 -0
- data/lib/generators/geo_concerns/templates/config/authorities/metadata_formats.yml +7 -0
- data/lib/generators/geo_concerns/templates/config/authorities/raster_formats.yml +9 -0
- data/lib/generators/geo_concerns/templates/config/authorities/vector_formats.yml +5 -0
- data/lib/generators/geo_concerns/templates/controllers/curation_concerns/file_sets_controller.rb +6 -0
- data/lib/generators/geo_concerns/templates/controllers/curation_concerns/image_works_controller.rb +5 -0
- data/lib/generators/geo_concerns/templates/controllers/curation_concerns/raster_works_controller.rb +6 -0
- data/lib/generators/geo_concerns/templates/controllers/curation_concerns/vector_works_controller.rb +6 -0
- data/lib/generators/geo_concerns/templates/geo_concerns.js +1 -0
- data/lib/generators/geo_concerns/templates/geo_concerns.scss +3 -0
- data/lib/generators/geo_concerns/templates/jobs/characterize_job.rb +12 -0
- data/lib/generators/geo_concerns/templates/models/file_set.rb +4 -0
- data/lib/generators/geo_concerns/templates/models/image_work.rb +6 -0
- data/lib/generators/geo_concerns/templates/models/raster_work.rb +7 -0
- data/lib/generators/geo_concerns/templates/models/vector_work.rb +7 -0
- data/lib/generators/geo_concerns/templates/presenters/file_set_presenter.rb +3 -0
- data/lib/generators/geo_concerns/templates/spec/actor_spec.rb.erb +9 -0
- data/lib/generators/geo_concerns/templates/spec/controller_spec.rb.erb +9 -0
- data/lib/generators/geo_concerns/templates/spec/model_spec.rb.erb +9 -0
- data/lib/geo_concerns.rb +6 -0
- data/lib/geo_concerns/engine.rb +4 -0
- data/lib/geo_concerns/version.rb +3 -0
- data/lib/tasks/geo_concerns_tasks.rake +4 -0
- data/solr/config/_rest_managed.json +3 -0
- data/solr/config/admin-extra.html +31 -0
- data/solr/config/elevate.xml +36 -0
- data/solr/config/mapping-ISOLatin1Accent.txt +246 -0
- data/solr/config/protwords.txt +21 -0
- data/solr/config/schema.xml +372 -0
- data/solr/config/scripts.conf +24 -0
- data/solr/config/solrconfig.xml +312 -0
- data/solr/config/spellings.txt +2 -0
- data/solr/config/stopwords.txt +58 -0
- data/solr/config/stopwords_en.txt +58 -0
- data/solr/config/synonyms.txt +31 -0
- data/solr/config/xslt/example.xsl +132 -0
- data/solr/config/xslt/example_atom.xsl +67 -0
- data/solr/config/xslt/example_rss.xsl +66 -0
- data/solr/config/xslt/luke.xsl +337 -0
- data/spec/actors/geo_concerns/file_actor_spec.rb +26 -0
- data/spec/controllers/image_works_controller_spec.rb +25 -0
- data/spec/controllers/raster_works_controller_spec.rb +50 -0
- data/spec/controllers/vector_works_controller_spec.rb +50 -0
- data/spec/factories/external_metadata_files.rb +20 -0
- data/spec/factories/image_files.rb +32 -0
- data/spec/factories/image_works.rb +68 -0
- data/spec/factories/raster_files.rb +35 -0
- data/spec/factories/raster_works.rb +86 -0
- data/spec/factories/users.rb +26 -0
- data/spec/factories/vector_files.rb +31 -0
- data/spec/factories/vector_works.rb +83 -0
- data/spec/features/create_raster_work_spec.rb +49 -0
- data/spec/forms/geo_concerns/basic_geo_metadata_form_spec.rb +27 -0
- data/spec/forms/geo_concerns/external_metadata_file_form_spec.rb +27 -0
- data/spec/forms/geo_concerns/georeferenced_form_spec.rb +29 -0
- data/spec/forms/geo_concerns/image_work_form_spec.rb +11 -0
- data/spec/forms/geo_concerns/raster_work_form_spec.rb +15 -0
- data/spec/forms/geo_concerns/vector_work_form_spec.rb +15 -0
- data/spec/helpers/bounding_box_helper_spec.rb +34 -0
- data/spec/models/concerns/basic_geo_metadata_spec.rb +21 -0
- data/spec/models/concerns/geo_concerns/file_set/derivatives_spec.rb +108 -0
- data/spec/models/concerns/geo_concerns/file_set/geo_file_format_behavior_spec.rb +56 -0
- data/spec/models/external_metadata_file_spec.rb +118 -0
- data/spec/models/file_set_spec.rb +9 -0
- data/spec/models/image_file_spec.rb +48 -0
- data/spec/models/image_work_spec.rb +71 -0
- data/spec/models/raster_file_spec.rb +48 -0
- data/spec/models/raster_work_spec.rb +122 -0
- data/spec/models/solr_document_spec.rb +35 -0
- data/spec/models/vector_file_spec.rb +48 -0
- data/spec/models/vector_work_spec.rb +113 -0
- data/spec/presenters/file_set_presenter_spec.rb +13 -0
- data/spec/presenters/geo_concerns_show_presenter_spec.rb +56 -0
- data/spec/presenters/image_work_show_presenter_spec.rb +52 -0
- data/spec/presenters/raster_work_show_presenter_spec.rb +52 -0
- data/spec/presenters/vector_work_show_presenter_spec.rb +41 -0
- data/spec/processors/geo_concerns/processors/base_geo_processor_spec.rb +109 -0
- data/spec/processors/geo_concerns/processors/raster/aig_spec.rb +28 -0
- data/spec/processors/geo_concerns/processors/raster/base_spec.rb +86 -0
- data/spec/processors/geo_concerns/processors/raster/dem_spec.rb +26 -0
- data/spec/processors/geo_concerns/processors/raster/processor_spec.rb +39 -0
- data/spec/processors/geo_concerns/processors/vector/base_spec.rb +67 -0
- data/spec/processors/geo_concerns/processors/vector/processor_spec.rb +28 -0
- data/spec/processors/geo_concerns/processors/vector/shapefile_spec.rb +17 -0
- data/spec/processors/geo_concerns/processors/zip_spec.rb +39 -0
- data/spec/renderers/coverage_renderer_spec.rb +21 -0
- data/spec/services/derivative_path_spec.rb +12 -0
- data/spec/services/raster_format_service_spec.rb +13 -0
- data/spec/spec_helper.rb +34 -0
- data/spec/support/controllers/engine_helpers.rb +7 -0
- data/spec/support/database_cleaner.rb +18 -0
- data/spec/support/devise.rb +10 -0
- data/spec/support/devise_helpers.rb +6 -0
- data/spec/support/factory_girl.rb +3 -0
- data/spec/support/features.rb +14 -0
- data/spec/support/features/session_helpers.rb +40 -0
- data/spec/support/fixture_reader.rb +7 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +20 -0
- data/spec/values/coverage_spec.rb +40 -0
- data/tasks/ci.rake +49 -0
- metadata +527 -0
@@ -0,0 +1,50 @@
|
|
1
|
+
module GeoConcerns
|
2
|
+
module Extractors
|
3
|
+
module Iso19139Helper
|
4
|
+
NS = {
|
5
|
+
'xmlns:gmd' => 'http://www.isotc211.org/2005/gmd',
|
6
|
+
'xmlns:gco' => 'http://www.isotc211.org/2005/gco'
|
7
|
+
}.freeze
|
8
|
+
|
9
|
+
# TODO: Migrate this code into an XSLT?
|
10
|
+
# TODO: Need to support multivalued fields
|
11
|
+
def extract_iso19139_metadata(doc)
|
12
|
+
h = {}
|
13
|
+
doc.at_xpath('//gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:title/gco:CharacterString', NS).tap do |node|
|
14
|
+
h[:title] = [node.text.strip]
|
15
|
+
end
|
16
|
+
|
17
|
+
doc.at_xpath('//gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:geographicElement/gmd:EX_GeographicBoundingBox', NS).tap do |node|
|
18
|
+
w = node.at_xpath('gmd:westBoundLongitude/gco:Decimal', NS).text.to_f
|
19
|
+
e = node.at_xpath('gmd:eastBoundLongitude/gco:Decimal', NS).text.to_f
|
20
|
+
n = node.at_xpath('gmd:northBoundLatitude/gco:Decimal', NS).text.to_f
|
21
|
+
s = node.at_xpath('gmd:southBoundLatitude/gco:Decimal', NS).text.to_f
|
22
|
+
h[:coverage] = GeoConcerns::Coverage.new(n, e, s, w).to_s
|
23
|
+
end
|
24
|
+
|
25
|
+
doc.at_xpath('//gmd:identificationInfo/gmd:MD_DataIdentification/gmd:abstract/gco:CharacterString', NS).tap do |node|
|
26
|
+
h[:description] = [node.text.strip]
|
27
|
+
end
|
28
|
+
|
29
|
+
doc.xpath('//gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:citedResponsibleParty/gmd:CI_ResponsibleParty/gmd:role/gmd:CI_RoleCode[@codeListValue=\'originator\']', NS).each do |node|
|
30
|
+
h[:creator] = begin
|
31
|
+
[node.at_xpath('ancestor-or-self::*/gmd:individualName', NS).text.strip]
|
32
|
+
rescue
|
33
|
+
[node.at_xpath('ancestor-or-self::*/gmd:organisationName', NS).text.strip]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# TODO: Not sure if custodian is the same as source
|
38
|
+
doc.xpath('//gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:citedResponsibleParty/gmd:CI_ResponsibleParty/gmd:role/gmd:CI_RoleCode[@codeListValue=\'custodian\']', NS).each do |node|
|
39
|
+
h[:source] = begin
|
40
|
+
[node.at_xpath('ancestor-or-self::*/gmd:individualName', NS).text.strip]
|
41
|
+
rescue
|
42
|
+
[node.at_xpath('ancestor-or-self::*/gmd:organisationName', NS).text.strip]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
h
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module GeoConcerns
|
2
|
+
module Extractors
|
3
|
+
module ModsHelper
|
4
|
+
NS = {
|
5
|
+
'xmlns:mods' => 'http://www.loc.gov/mods/v3'
|
6
|
+
}.freeze
|
7
|
+
def extract_mods_metadata(doc)
|
8
|
+
{
|
9
|
+
title: [doc.at_xpath('//mods:mods/mods:titleInfo/mods:title', NS).text],
|
10
|
+
description: [doc.at_xpath('//mods:mods/mods:abstract', NS).text]
|
11
|
+
}
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module GeoConcerns
|
2
|
+
module FileSet
|
3
|
+
module Derivatives
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
def create_derivatives(filename)
|
7
|
+
case mime_type
|
8
|
+
when *ImageFormatService.select_options.map(&:last)
|
9
|
+
image_derivatives(filename)
|
10
|
+
when *RasterFormatService.select_options.map(&:last)
|
11
|
+
raster_derivatives(filename)
|
12
|
+
when *VectorFormatService.select_options.map(&:last)
|
13
|
+
vector_derivatives(filename)
|
14
|
+
end
|
15
|
+
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
def image_derivatives(filename)
|
20
|
+
Hydra::Derivatives::ImageDerivatives
|
21
|
+
.create(filename, outputs: [{ label: :thumbnail,
|
22
|
+
format: 'png',
|
23
|
+
size: '200x150>',
|
24
|
+
url: derivative_url('thumbnail') }])
|
25
|
+
end
|
26
|
+
|
27
|
+
def raster_derivatives(filename)
|
28
|
+
GeoConcerns::Runners::RasterDerivatives
|
29
|
+
.create(filename, outputs: [{ input_format: mime_type,
|
30
|
+
label: :display_raster,
|
31
|
+
format: 'tif',
|
32
|
+
url: derivative_url('display_raster') },
|
33
|
+
{ input_format: mime_type,
|
34
|
+
label: :thumbnail,
|
35
|
+
format: 'png',
|
36
|
+
size: '150x150',
|
37
|
+
url: derivative_url('thumbnail') }])
|
38
|
+
end
|
39
|
+
|
40
|
+
def vector_derivatives(filename)
|
41
|
+
GeoConcerns::Runners::VectorDerivatives
|
42
|
+
.create(filename, outputs: [{ input_format: mime_type,
|
43
|
+
label: :display_vector,
|
44
|
+
format: 'zip',
|
45
|
+
url: derivative_url('display_vector') },
|
46
|
+
{ input_format: mime_type,
|
47
|
+
label: :thumbnail,
|
48
|
+
format: 'png',
|
49
|
+
size: '150x150',
|
50
|
+
url: derivative_url('thumbnail') }])
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def derivative_path_factory
|
56
|
+
GeoConcerns::DerivativePath
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module GeoConcerns
|
2
|
+
module GeoFileFormatBehavior
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
def image_file?
|
6
|
+
ImageFormatService.include?(mime_type)
|
7
|
+
end
|
8
|
+
|
9
|
+
def raster_file?
|
10
|
+
RasterFormatService.include?(mime_type)
|
11
|
+
end
|
12
|
+
|
13
|
+
def vector_file?
|
14
|
+
VectorFormatService.include?(mime_type)
|
15
|
+
end
|
16
|
+
|
17
|
+
def external_metadata_file?
|
18
|
+
MetadataFormatService.include?(mime_type)
|
19
|
+
end
|
20
|
+
|
21
|
+
def geo_file_format?
|
22
|
+
image_file? || raster_file? || vector_file? || external_metadata_file?
|
23
|
+
end
|
24
|
+
|
25
|
+
def image_work?
|
26
|
+
false
|
27
|
+
end
|
28
|
+
|
29
|
+
def raster_work?
|
30
|
+
false
|
31
|
+
end
|
32
|
+
|
33
|
+
def vector_work?
|
34
|
+
false
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module GeoConcerns
|
2
|
+
module GeoFileSetBehavior
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
include ::GeoConcerns::GeoFileFormatBehavior
|
5
|
+
include ::GeoConcerns::ImageFileBehavior
|
6
|
+
include ::GeoConcerns::RasterFileBehavior
|
7
|
+
include ::GeoConcerns::VectorFileBehavior
|
8
|
+
include ::GeoConcerns::ExternalMetadataFileBehavior
|
9
|
+
include ::GeoConcerns::FileSet::Derivatives
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module GeoConcerns
|
2
|
+
# Attributes and methods for georeferenced files
|
3
|
+
module GeoreferencedBehavior
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
# Defines the OGC coordinate reference system (CRS) identifier for the resource
|
8
|
+
# @see http://www.opengeospatial.org/ogcna OGC Naming Authority
|
9
|
+
# @example
|
10
|
+
# raster_file.cartographic_projection = "urn:ogc:def:crs:EPSG:6.3:26986"
|
11
|
+
property :cartographic_projection,
|
12
|
+
predicate: ::RDF::Vocab::Bibframe.cartographicProjection,
|
13
|
+
multiple: false do |index|
|
14
|
+
index.as :stored_searchable
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module GeoConcerns
|
2
|
+
# Attributes and methods for image files
|
3
|
+
module ImageFileBehavior
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
# Retrieve the Image Work of which this Object is a member
|
7
|
+
# @return [GeoConcerns::ImageWork]
|
8
|
+
def image_work
|
9
|
+
generic_works.select do |parent|
|
10
|
+
parent.class.included_modules.include?(::GeoConcerns::ImageWorkBehavior)
|
11
|
+
end.to_a
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module GeoConcerns
|
2
|
+
# Attributes and methods for image works
|
3
|
+
module ImageWorkBehavior
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
include ::GeoConcerns::MetadataExtractionHelper
|
6
|
+
|
7
|
+
included do
|
8
|
+
type [Hydra::PCDM::Vocab::PCDMTerms.Object,
|
9
|
+
Hydra::Works::Vocab::WorksTerms.GenericWork,
|
10
|
+
::GeoConcerns::GeoTerms.ImageWork]
|
11
|
+
end
|
12
|
+
|
13
|
+
def image_file
|
14
|
+
members.select(&:image_file?).to_a.first
|
15
|
+
end
|
16
|
+
|
17
|
+
def metadata_files
|
18
|
+
members.select(&:external_metadata_file?)
|
19
|
+
end
|
20
|
+
|
21
|
+
def raster_works
|
22
|
+
members.select(&:raster_work?)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Defines type by what it is and isn't
|
26
|
+
|
27
|
+
# This is an Image Resource
|
28
|
+
# @return [Boolean]
|
29
|
+
def image_work?
|
30
|
+
true
|
31
|
+
end
|
32
|
+
|
33
|
+
# This is not an ImageFile Resource
|
34
|
+
# @return [Boolean]
|
35
|
+
def image_file?
|
36
|
+
false
|
37
|
+
end
|
38
|
+
|
39
|
+
# This is not an ImageFile Resource
|
40
|
+
# @return [Boolean]
|
41
|
+
def raster_work?
|
42
|
+
false
|
43
|
+
end
|
44
|
+
|
45
|
+
# This is not an ImageFile Resource
|
46
|
+
# @return [Boolean]
|
47
|
+
def raster_file?
|
48
|
+
false
|
49
|
+
end
|
50
|
+
|
51
|
+
# This is not an ImageFile Resource
|
52
|
+
# @return [Boolean]
|
53
|
+
def vector_work?
|
54
|
+
false
|
55
|
+
end
|
56
|
+
|
57
|
+
# This is not an ImageFile Resource
|
58
|
+
# @return [Boolean]
|
59
|
+
def vector_file?
|
60
|
+
false
|
61
|
+
end
|
62
|
+
|
63
|
+
# This is not an ExternalMetadataFile Resource
|
64
|
+
# @return [Boolean]
|
65
|
+
def external_metadata_file?
|
66
|
+
false
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module GeoConcerns
|
2
|
+
module MetadataExtractionHelper
|
3
|
+
# Extracts properties from the constitutent external metadata file
|
4
|
+
# @return [Hash]
|
5
|
+
def extract_metadata
|
6
|
+
return {} if metadata_files.blank?
|
7
|
+
# TODO: Does not support multiple external metadata files
|
8
|
+
raise NotImplementedError if metadata_files.length > 1
|
9
|
+
metadata_files.first.extract_metadata
|
10
|
+
end
|
11
|
+
|
12
|
+
# Sets properties from the constitutent external metadata file
|
13
|
+
def populate_metadata
|
14
|
+
extract_metadata.each do |k, v|
|
15
|
+
send("#{k}=".to_sym, v) # set each property
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
attr_accessor :should_populate_metadata
|
20
|
+
|
21
|
+
def should_populate_metadata=(args)
|
22
|
+
@should_populate_metadata = args.present?
|
23
|
+
return unless should_populate_metadata
|
24
|
+
populate_metadata
|
25
|
+
save
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module GeoConcerns
|
2
|
+
# Attributes and methods for raster files
|
3
|
+
module RasterFileBehavior
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
include ::GeoConcerns::GeoreferencedBehavior
|
6
|
+
# Retrieve the Raster Work of which this Object is a member
|
7
|
+
# @return [GeoConcerns::Raster]
|
8
|
+
def raster_work
|
9
|
+
generic_works.select do |parent|
|
10
|
+
parent.class.included_modules.include?(::GeoConcerns::RasterWorkBehavior)
|
11
|
+
end.to_a
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# Attributes and methods for raster works
|
2
|
+
module GeoConcerns
|
3
|
+
module RasterWorkBehavior
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
include ::GeoConcerns::MetadataExtractionHelper
|
6
|
+
|
7
|
+
included do
|
8
|
+
type [Hydra::PCDM::Vocab::PCDMTerms.Object,
|
9
|
+
Hydra::Works::Vocab::WorksTerms.GenericWork,
|
10
|
+
::GeoConcerns::GeoTerms.RasterWork]
|
11
|
+
end
|
12
|
+
|
13
|
+
def raster_files
|
14
|
+
members.select(&:raster_file?)
|
15
|
+
end
|
16
|
+
|
17
|
+
def metadata_files
|
18
|
+
members.select(&:external_metadata_file?)
|
19
|
+
end
|
20
|
+
|
21
|
+
def vector_works
|
22
|
+
members.select(&:vector_work?)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Defines type by what it is and isn't
|
26
|
+
# @return [Boolean]
|
27
|
+
def image_work?
|
28
|
+
false
|
29
|
+
end
|
30
|
+
|
31
|
+
def image_file?
|
32
|
+
false
|
33
|
+
end
|
34
|
+
|
35
|
+
def raster_work?
|
36
|
+
true
|
37
|
+
end
|
38
|
+
|
39
|
+
def raster_file?
|
40
|
+
false
|
41
|
+
end
|
42
|
+
|
43
|
+
def vector_work?
|
44
|
+
false
|
45
|
+
end
|
46
|
+
|
47
|
+
def vector_file?
|
48
|
+
false
|
49
|
+
end
|
50
|
+
|
51
|
+
def external_metadata_file?
|
52
|
+
false
|
53
|
+
end
|
54
|
+
|
55
|
+
# Retrieve all Image Works for which georeferencing generates this Raster Work
|
56
|
+
# @return [Array]
|
57
|
+
def image_works
|
58
|
+
ordered_by.select do |parent|
|
59
|
+
parent.class.included_modules.include?(::GeoConcerns::ImageWorkBehavior)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# Retrieve the only Image Works for which georeferencing generates this Raster Work
|
64
|
+
# @return [GeoConcerns::ImageWork]
|
65
|
+
def image_work
|
66
|
+
image_works.first
|
67
|
+
end
|
68
|
+
|
69
|
+
def to_solr(solr_doc = {})
|
70
|
+
super.tap do |doc|
|
71
|
+
doc[solr_name("ordered_by", :symbol)] ||= []
|
72
|
+
doc[solr_name("ordered_by", :symbol)] += send(:ordered_by_ids)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
def solr_name(*args)
|
79
|
+
ActiveFedora.index_field_mapper.solr_name(*args)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module GeoConcerns
|
2
|
+
module SolrDocumentBehavior
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
def spatial
|
6
|
+
fetch(Solrizer.solr_name('spatial'), [])
|
7
|
+
end
|
8
|
+
|
9
|
+
def temporal
|
10
|
+
fetch(Solrizer.solr_name('temporal'), [])
|
11
|
+
end
|
12
|
+
|
13
|
+
def issued
|
14
|
+
fetch(Solrizer.solr_name('issued'), nil)
|
15
|
+
end
|
16
|
+
|
17
|
+
def coverage
|
18
|
+
fetch(Solrizer.solr_name('coverage'), nil)
|
19
|
+
end
|
20
|
+
|
21
|
+
def provenance
|
22
|
+
fetch(Solrizer.solr_name('provenance'), nil)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|