geohydra 0.3.1 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -1
- data/.travis.yml +1 -2
- data/Gemfile +1 -8
- data/Gemfile.lock +87 -102
- data/README.md +2 -2
- data/VERSION +1 -1
- data/bin/accession.rb +99 -89
- data/bin/assemble.rb +288 -247
- data/bin/assemble_data.rb +54 -51
- data/bin/assemble_placenames.rb +85 -85
- data/bin/build_stage_options.rb +24 -18
- data/bin/derive_wgs84.rb +65 -66
- data/bin/extract_thumbnail.rb +38 -37
- data/bin/geo2mods.rb +78 -0
- data/bin/geohydra +14 -5
- data/bin/ingest_arcgis.rb +80 -60
- data/bin/iso2geo.rb +64 -0
- data/bin/loader_postgis.rb +121 -227
- data/bin/run_task.rb +23 -0
- data/bin/sync_geoserver_metadata.rb +132 -127
- data/bin/xsltproc-saxon +6 -0
- data/geohydra.gemspec +6 -4
- data/lib/geohydra.rb +5 -0
- data/lib/geohydra/accession.rb +24 -13
- data/lib/geohydra/{arcgis_to_iso19139_fc.xsl → arcgis_to_iso19110.xsl} +0 -0
- data/lib/geohydra/gazetteer.csv +842 -36
- data/lib/geohydra/gazetteer.rb +48 -24
- data/lib/geohydra/mods2geoblacklight.xsl +248 -0
- data/lib/geohydra/mods2ogp.xsl +5 -8
- data/lib/geohydra/transform.rb +8 -2
- data/lib/geohydra/utils.rb +6 -0
- data/lib/geohydra/workflow/gisAssemblyWF.rb +109 -0
- data/lib/geohydra/workflow/gisAssemblyWF.xml +85 -0
- data/lib/geohydra/workflow/gisDeliveryWF.rb +33 -0
- data/lib/geohydra/workflow/gisDeliveryWF.xml +36 -0
- data/lib/geohydra/workflow/gisDiscoveryWF.rb +55 -0
- data/lib/geohydra/workflow/gisDiscoveryWF.xml +28 -0
- data/lib/geohydra/workflow/task.rb +82 -0
- data/ogp/README.md +350 -0
- data/ogp/download.rb +92 -0
- data/ogp/fgdc2mods.sh +9 -0
- data/ogp/fgdc2mods.xsl +884 -0
- data/ogp/ingest.rb +48 -0
- data/ogp/select.rb +20 -0
- data/ogp/transform.rb +354 -0
- data/ogp/validate.rb +182 -0
- data/{bin → scripts}/ingest_tufts.rb +0 -0
- data/scripts/iso2html/doit.sh +15 -0
- data/scripts/iso2html/main.css +66 -0
- data/scripts/iso2html/pacioos-iso-html.xsl +1749 -0
- data/scripts/iso2html/utils/replace-newlines.xsl +97 -0
- data/scripts/iso2html/utils/replace-string.xsl +80 -0
- data/scripts/iso2html/utils/strip-digits.xsl +60 -0
- data/{bin → scripts}/loader.rb +0 -0
- data/scripts/rename_shapefiles.rb +5 -0
- data/scripts/render_gazetteer.rb +36 -0
- data/{bin → scripts}/seed.rb +0 -0
- data/{bin → scripts}/solr_indexer.rb +0 -0
- data/scripts/status.csv +253 -0
- data/scripts/status.rb +32 -0
- data/{bin → scripts}/validate_data.rb +1 -1
- data/solr/kurma-app-dev/conf/lang/stopwords_en.txt +34 -0
- data/solr/kurma-app-dev/conf/protwords.txt +21 -0
- data/solr/kurma-app-dev/conf/schema.xml +156 -0
- data/solr/kurma-app-dev/conf/solrconfig.xml +161 -0
- data/solr/kurma-app-dev/conf/synonyms.txt +29 -0
- data/solr/kurma-app-dev/purge.sh +8 -0
- data/solr/kurma-app-test/conf/lang/stopwords_en.txt +34 -0
- data/solr/kurma-app-test/conf/protwords.txt +21 -0
- data/solr/kurma-app-test/conf/schema.xml +158 -0
- data/solr/kurma-app-test/conf/solrconfig.xml +161 -0
- data/solr/kurma-app-test/conf/synonyms.txt +29 -0
- data/solr/kurma-app-test/deploy.sh +15 -0
- data/solr/kurma-app-test/purge.sh +8 -0
- data/solr/ogp-dev/purge.sh +1 -2
- data/spec/fixtures/bw938nk9584/temp/{TRIPURA-iso19139-fc.xml → TRIPURA-iso19110.xml} +0 -0
- data/spec/fixtures/cc142xj8436/temp/{HARYANA-iso19139-fc.xml → HARYANA-iso19110.xml} +0 -0
- data/spec/fixtures/cg716wc7949/temp/{metadata.iso19139-fc.xml → metadata.iso19110.xml} +0 -0
- data/spec/fixtures/cm007pv9601/temp/{MEGHALAYA-iso19139-fc.xml → MEGHALAYA-iso19110.xml} +0 -0
- data/spec/fixtures/cp055nb0189/temp/{metadata.iso19139-fc.xml → metadata.iso19110.xml} +0 -0
- data/spec/fixtures/cs838pw3418/temp/{OIL_GAS_FIELDS-iso19139-fc.xml → OIL_GAS_FIELDS-iso19110.xml} +0 -0
- data/spec/fixtures/dd308sy5843/temp/{ORISSA-iso19139-fc.xml → ORISSA-iso19110.xml} +0 -0
- data/spec/fixtures/dd452vk1873/temp/{metadata.iso19139-fc.xml → metadata.iso19110.xml} +0 -0
- data/spec/fixtures/dg850pt1796/temp/{STATE1951-iso19139-fc.xml → STATE1951-iso19110.xml} +0 -0
- data/spec/fixtures/dn744tf5427/temp/{DISTRICT1991-iso19139-fc.xml → DISTRICT1991-iso19110.xml} +0 -0
- data/spec/fixtures/dq603nz8402/temp/{STATE2001-iso19139-fc.xml → STATE2001-iso19110.xml} +0 -0
- data/spec/fixtures/dv609zt4699/temp/{ASSAM-iso19139-fc.xml → ASSAM-iso19110.xml} +0 -0
- data/spec/fixtures/dz222hw0585/temp/{PUNJAB-iso19139-fc.xml → PUNJAB-iso19110.xml} +0 -0
- data/spec/fixtures/fd673qb9705/temp/{STATE1971-iso19139-fc.xml → STATE1971-iso19110.xml} +0 -0
- data/spec/fixtures/fg451wp8917/temp/{SIKKIM-iso19139-fc.xml → SIKKIM-iso19110.xml} +0 -0
- data/spec/fixtures/fh247yz0156/temp/{RAJASTHAN-iso19139-fc.xml → RAJASTHAN-iso19110.xml} +0 -0
- data/spec/fixtures/fs487vd1465/temp/{CHHATTISGARH-iso19139-fc.xml → CHHATTISGARH-iso19110.xml} +0 -0
- data/spec/fixtures/fs591bn3317/temp/{HIMACHAL_PRADESH-iso19139-fc.xml → HIMACHAL_PRADESH-iso19110.xml} +0 -0
- data/spec/fixtures/fw920bc5473/temp/{PLSS_TWN-iso19139-fc.xml → PLSS_TWN-iso19110.xml} +0 -0
- data/spec/fixtures/gj831wj3625/temp/{metadata.iso19139-fc.xml → metadata.iso19110.xml} +0 -0
- data/spec/fixtures/gp075nv3265/temp/{PONDICHERRY-iso19139-fc.xml → PONDICHERRY-iso19110.xml} +0 -0
- data/spec/fixtures/gv800hj8141/temp/{BIHAR-iso19139-fc.xml → BIHAR-iso19110.xml} +0 -0
- data/spec/fixtures/gw520gz6339/temp/{DADRA_NAGAR_HAVELI_PT-iso19139-fc.xml → DADRA_NAGAR_HAVELI_PT-iso19110.xml} +0 -0
- data/spec/fixtures/gy054hz1045/temp/{HARYANA-iso19139-fc.xml → HARYANA-iso19110.xml} +0 -0
- data/spec/fixtures/gz352mw6982/temp/{metadata.iso19139-fc.xml → metadata.iso19110.xml} +0 -0
- data/spec/fixtures/hb489vm9892/temp/{DISTRICT1981-iso19139-fc.xml → DISTRICT1981-iso19110.xml} +0 -0
- data/spec/fixtures/hw125dq0418/temp/{DELHI-iso19139-fc.xml → DELHI-iso19110.xml} +0 -0
- data/spec/fixtures/hw892mn4587/temp/{KERALA-iso19139-fc.xml → KERALA-iso19110.xml} +0 -0
- data/spec/fixtures/jb371hz3868/temp/{INCOME-iso19139-fc.xml → INCOME-iso19110.xml} +0 -0
- data/spec/fixtures/jc017yk9928/temp/{KARNATAKA-iso19139-fc.xml → KARNATAKA-iso19110.xml} +0 -0
- data/spec/fixtures/jf841ys4828/temp/{ANDHRA_PRADESH-iso19139-fc.xml → ANDHRA_PRADESH-iso19110.xml} +0 -0
- data/spec/fixtures/jh802mp2160/temp/{DELHI_PT-iso19139-fc.xml → DELHI_PT-iso19110.xml} +0 -0
- data/spec/fixtures/jj806fc3801/temp/{metadata.iso19139-fc.xml → metadata.iso19110.xml} +0 -0
- data/spec/fixtures/jq835yn7161/temp/{HIMACHAL_PRADESH-iso19139-fc.xml → HIMACHAL_PRADESH-iso19110.xml} +0 -0
- data/spec/fixtures/jr455pt6676/temp/{TAMILNADU-iso19139-fc.xml → TAMILNADU-iso19110.xml} +0 -0
- data/spec/fixtures/js637zp2537/temp/{BIHAR-iso19139-fc.xml → BIHAR-iso19110.xml} +0 -0
- data/spec/fixtures/jv502wg9611/temp/{GOA-iso19139-fc.xml → GOA-iso19110.xml} +0 -0
- data/spec/fixtures/jw462ck6560/temp/{JAMMU_KASHMIR-iso19139-fc.xml → JAMMU_KASHMIR-iso19110.xml} +0 -0
- data/spec/fixtures/kj800fb6273/temp/{STATE2011-iso19139-fc.xml → STATE2011-iso19110.xml} +0 -0
- data/spec/fixtures/km504zq3948/temp/{HIMACHAL_PRADESH-iso19139-fc.xml → HIMACHAL_PRADESH-iso19110.xml} +0 -0
- data/spec/fixtures/ks297fy1411/temp/{OFFSH_BLOCKS-iso19139-fc.xml → OFFSH_BLOCKS-iso19110.xml} +0 -0
- data/spec/fixtures/md358hy5049/temp/{MIZORAM-iso19139-fc.xml → MIZORAM-iso19110.xml} +0 -0
- data/spec/fixtures/mg745bq0193/temp/{MADHYA_PRADESH-iso19139-fc.xml → MADHYA_PRADESH-iso19110.xml} +0 -0
- data/spec/fixtures/mh187yx3536/temp/{WEST_BENGAL-iso19139-fc.xml → WEST_BENGAL-iso19110.xml} +0 -0
- data/spec/fixtures/mk488yn6694/temp/{GUJARAT-iso19139-fc.xml → GUJARAT-iso19110.xml} +0 -0
- data/spec/fixtures/my216kp3008/temp/{DELHI-iso19139-fc.xml → DELHI-iso19110.xml} +0 -0
- data/spec/fixtures/my504nz9827/temp/{JAMMU_KASHMIR-iso19139-fc.xml → JAMMU_KASHMIR-iso19110.xml} +0 -0
- data/spec/fixtures/ng819jm8700/temp/{MANIPUR-iso19139-fc.xml → MANIPUR-iso19110.xml} +0 -0
- data/spec/fixtures/np020jq2139/temp/{metadata.iso19139-fc.xml → metadata.iso19110.xml} +0 -0
- data/spec/fixtures/ns377mt1608/temp/{STATE1991-iso19139-fc.xml → STATE1991-iso19110.xml} +0 -0
- data/spec/fixtures/nw926np8508/temp/{metadata.iso19139-fc.xml → metadata.iso19110.xml} +0 -0
- data/spec/fixtures/ny358rm8559/temp/{TRIPURA-iso19139-fc.xml → TRIPURA-iso19110.xml} +0 -0
- data/spec/fixtures/nz176rm8192/temp/{DISTRICT2011-iso19139-fc.xml → DISTRICT2011-iso19110.xml} +0 -0
- data/spec/fixtures/nz252rq2252/temp/{UTTAR_PRADESH-iso19139-fc.xml → UTTAR_PRADESH-iso19110.xml} +0 -0
- data/spec/fixtures/pd902kb3348/temp/{MADHYA_PRADESH-iso19139-fc.xml → MADHYA_PRADESH-iso19110.xml} +0 -0
- data/spec/fixtures/pz792fz1776/temp/{MAHARASHTRA-iso19139-fc.xml → MAHARASHTRA-iso19110.xml} +0 -0
- data/spec/fixtures/qb767ss4042/temp/{UTTAR_PRADESH-iso19139-fc.xml → UTTAR_PRADESH-iso19110.xml} +0 -0
- data/spec/fixtures/qc091qw0570/temp/{GUJARAT-iso19139-fc.xml → GUJARAT-iso19110.xml} +0 -0
- data/spec/fixtures/qc652vr7204/temp/{ANDHRA_PRADESH_PT-iso19139-fc.xml → ANDHRA_PRADESH_PT-iso19110.xml} +0 -0
- data/spec/fixtures/qk786js7484/temp/{DISTRICT1961-iso19139-fc.xml → DISTRICT1961-iso19110.xml} +0 -0
- data/spec/fixtures/qn676pg6767/temp/{GOA-iso19139-fc.xml → GOA-iso19110.xml} +0 -0
- data/spec/fixtures/qr255jh4074/temp/{LOKSABHA_14-iso19139-fc.xml → LOKSABHA_14-iso19110.xml} +0 -0
- data/spec/fixtures/qr374kj4827/temp/{ASSAM-iso19139-fc.xml → ASSAM-iso19110.xml} +0 -0
- data/spec/fixtures/qy162js1748/temp/{CHHATTISGARH-iso19139-fc.xml → CHHATTISGARH-iso19110.xml} +0 -0
- data/spec/fixtures/rd446vf2633/temp/{NAGALAND-iso19139-fc.xml → NAGALAND-iso19110.xml} +0 -0
- data/spec/fixtures/rf389hf2983/temp/{CHHATTISGARH_PT-iso19139-fc.xml → CHHATTISGARH_PT-iso19110.xml} +0 -0
- data/spec/fixtures/rf859ff4582/temp/{JHARKHAND-iso19139-fc.xml → JHARKHAND-iso19110.xml} +0 -0
- data/spec/fixtures/rh343ds8931/temp/{BIHAR-iso19139-fc.xml → BIHAR-iso19110.xml} +0 -0
- data/spec/fixtures/rn815xk8157/temp/{SIKKIM-iso19139-fc.xml → SIKKIM-iso19110.xml} +0 -0
- data/spec/fixtures/rq653sz4470/temp/{CHHATTISGARH-iso19139-fc.xml → CHHATTISGARH-iso19110.xml} +0 -0
- data/spec/fixtures/rt625ws6022/temp/{GULF_FAIRWAYS-iso19139-fc.xml → GULF_FAIRWAYS-iso19110.xml} +0 -0
- data/spec/fixtures/sc330vf4259/temp/{JHARKHAND-iso19139-fc.xml → JHARKHAND-iso19110.xml} +0 -0
- data/spec/fixtures/sq479mx3086/temp/{OFFSH_PLATF-iso19139-fc.xml → OFFSH_PLATF-iso19110.xml} +0 -0
- data/spec/fixtures/sr686bm4098/temp/{DAMAN_DIU_PT-iso19139-fc.xml → DAMAN_DIU_PT-iso19110.xml} +0 -0
- data/spec/fixtures/sv303sh5583/temp/{ARUNACHAL_PRADESH-iso19139-fc.xml → ARUNACHAL_PRADESH-iso19110.xml} +0 -0
- data/spec/fixtures/sy319nh8520/temp/{GUJARAT-iso19139-fc.xml → GUJARAT-iso19110.xml} +0 -0
- data/spec/fixtures/td363vx2792/temp/{HIMACHAL_PRADESH_PT-iso19139-fc.xml → HIMACHAL_PRADESH_PT-iso19110.xml} +0 -0
- data/spec/fixtures/tf374bd2484/temp/{DISTRICT1951-iso19139-fc.xml → DISTRICT1951-iso19110.xml} +0 -0
- data/spec/fixtures/tj797mj7877/temp/{LOKSABHA_15-iso19139-fc.xml → LOKSABHA_15-iso19110.xml} +0 -0
- data/spec/fixtures/tv060wq5179/temp/{ASSAM-iso19139-fc.xml → ASSAM-iso19110.xml} +0 -0
- data/spec/fixtures/tv536bn1915/temp/{ARUNACHAL_PRADESH-iso19139-fc.xml → ARUNACHAL_PRADESH-iso19110.xml} +0 -0
- data/spec/fixtures/tz359cc2977/temp/{MANIPUR-iso19139-fc.xml → MANIPUR-iso19110.xml} +0 -0
- data/spec/fixtures/vb525my6511/temp/{UTTARAKHAND-iso19139-fc.xml → UTTARAKHAND-iso19110.xml} +0 -0
- data/spec/fixtures/vh802fs4240/temp/{PONDICHERRY-iso19139-fc.xml → PONDICHERRY-iso19110.xml} +0 -0
- data/spec/fixtures/vk120xn2474/temp/{PLSS_SEC-iso19139-fc.xml → PLSS_SEC-iso19110.xml} +0 -0
- data/spec/fixtures/vn439bc7316/temp/{KERALA-iso19139-fc.xml → KERALA-iso19110.xml} +0 -0
- data/spec/fixtures/vq745jk0695/temp/{MEGHALAYA-iso19139-fc.xml → MEGHALAYA-iso19110.xml} +0 -0
- data/spec/fixtures/vr593vj7147/temp/{ANDHRA_PRADESH-iso19139-fc.xml → ANDHRA_PRADESH-iso19110.xml} +0 -0
- data/spec/fixtures/vw911qb5271/temp/{DISTRICT2001-iso19139-fc.xml → DISTRICT2001-iso19110.xml} +0 -0
- data/spec/fixtures/wg680pz0365/temp/{ANDHRA_PRADESH-iso19139-fc.xml → ANDHRA_PRADESH-iso19110.xml} +0 -0
- data/spec/fixtures/wg761xn1926/temp/{HARYANA-iso19139-fc.xml → HARYANA-iso19110.xml} +0 -0
- data/spec/fixtures/wh870qw1934/temp/{PUNJAB-iso19139-fc.xml → PUNJAB-iso19110.xml} +0 -0
- data/spec/fixtures/wk775mm4673/temp/{MAHARASHTRA-iso19139-fc.xml → MAHARASHTRA-iso19110.xml} +0 -0
- data/spec/fixtures/ws171yz2165/temp/{ARUNACHAL_PRADESH_PT-iso19139-fc.xml → ARUNACHAL_PRADESH_PT-iso19110.xml} +0 -0
- data/spec/fixtures/wt473hz7153/temp/{CHANDIGARH_PT-iso19139-fc.xml → CHANDIGARH_PT-iso19110.xml} +0 -0
- data/spec/fixtures/ww217dj0457/temp/{CO2_PIPE-iso19139-fc.xml → CO2_PIPE-iso19110.xml} +0 -0
- data/spec/fixtures/wy875pk9849/temp/{STATE1961-iso19139-fc.xml → STATE1961-iso19110.xml} +0 -0
- data/spec/fixtures/xb018tk2042/temp/{STATE1981-iso19139-fc.xml → STATE1981-iso19110.xml} +0 -0
- data/spec/fixtures/xg539vw8586/temp/{ORISSA-iso19139-fc.xml → ORISSA-iso19110.xml} +0 -0
- data/spec/fixtures/xv475kp4644/temp/{ASSAM_PT-iso19139-fc.xml → ASSAM_PT-iso19110.xml} +0 -0
- data/spec/fixtures/xy096gc2959/temp/{GOA-iso19139-fc.xml → GOA-iso19110.xml} +0 -0
- data/spec/fixtures/xz518gz3362/temp/{UTTARAKHAND-iso19139-fc.xml → UTTARAKHAND-iso19110.xml} +0 -0
- data/spec/fixtures/yh986wy4737/temp/{NAGALAND-iso19139-fc.xml → NAGALAND-iso19110.xml} +0 -0
- data/spec/fixtures/yn187fq4474/temp/{KARNATAKA-iso19139-fc.xml → KARNATAKA-iso19110.xml} +0 -0
- data/spec/fixtures/yn236mw3250/temp/{TAMILNADU-iso19139-fc.xml → TAMILNADU-iso19110.xml} +0 -0
- data/spec/fixtures/yz596nz0112/temp/{WEST_BENGAL-iso19139-fc.xml → WEST_BENGAL-iso19110.xml} +0 -0
- data/spec/fixtures/zk596gy7380/temp/{DISTRICT1971-iso19139-fc.xml → DISTRICT1971-iso19110.xml} +0 -0
- data/spec/fixtures/zn452hh7431/temp/{RAJASTHAN-iso19139-fc.xml → RAJASTHAN-iso19110.xml} +0 -0
- data/spec/fixtures/zt093fw6519/temp/{MIZORAM-iso19139-fc.xml → MIZORAM-iso19110.xml} +0 -0
- data/spec/fixtures/zv925hd6723/temp/{OGWELLS-iso19139-fc.xml → OGWELLS-iso19110.xml} +0 -0
- data/spec/fixtures/zy658cr1728/temp/{ANDAMAAN_NICOBAR_PT-iso19139-fc.xml → ANDAMAAN_NICOBAR_PT-iso19110.xml} +0 -0
- data/spec/fixtures/zz943vx1492/temp/{BASINS-iso19139-fc.xml → BASINS-iso19110.xml} +0 -0
- data/spec/unit/gazetteer_spec.rb +100 -35
- data/spec/unit/task_spec.rb +68 -0
- data/spec/unit/transform_spec.rb +1 -1
- data/spec/unit/utils_spec.rb +17 -3
- data/workflow.rb +35 -0
- metadata +323 -316
data/bin/assemble_data.rb
CHANGED
@@ -3,64 +3,67 @@
|
|
3
3
|
require File.expand_path(File.dirname(__FILE__) + '/../config/boot')
|
4
4
|
require 'optparse'
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
class AssembleData < GeoHydra::Process
|
7
|
+
def assemble(path, flags)
|
8
|
+
ap({:path => path, :flags => flags}) if flags[:debug]
|
9
|
+
File.umask(002)
|
10
|
+
Dir.glob(File.join(path, '**', '*.shp')) do |shp|
|
11
|
+
raise ArgumentError, "SyntaxError: Not a shapefile #{shp}" unless GeoHydra::Utils.shapefile?(shp)
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
13
|
+
ap({:shp => shp}) if flags[:debug]
|
14
|
+
geometry_type = GeoHydra::Transform.geometry_type(shp)
|
15
|
+
ap({:geometry_type => geometry_type}) if flags[:debug]
|
16
|
+
puts ['Scanned', File.basename(shp), geometry_type].join("\t") if flags[:verbose]
|
17
|
+
|
18
|
+
basename = File.basename(shp, '.shp')
|
19
|
+
zipfn = File.join(path, 'content', 'data.zip')
|
20
|
+
puts "Compressing #{basename} into #{zipfn}" if flags[:verbose]
|
21
|
+
fns = Dir.glob(File.join(File.dirname(shp), "#{basename}.*")).select do |fn|
|
22
|
+
fn !~ /\.zip$/
|
23
|
+
end
|
24
|
+
metadata_fns = []
|
25
|
+
Dir.glob(File.join(File.dirname(shp), "#{basename}-iso19*.xml")).each do |fn|
|
26
|
+
metadata_fns << fn
|
27
|
+
end
|
28
|
+
system "mkdir -p #{File.dirname(zipfn)}" unless File.directory?(File.dirname(zipfn))
|
29
|
+
cmd = "zip -vj '#{zipfn}' #{fns.join(' ')} #{metadata_fns.join(' ')}"
|
30
|
+
ap({:cmd => cmd, :fns => fns}) if flags[:debug]
|
31
|
+
system cmd
|
32
|
+
fns.each {|fn| FileUtils.rm(fn)} unless flags[:debug]
|
26
33
|
end
|
27
|
-
cmd = "zip -vj '#{zipfn}' #{fns.join(' ')} #{metadata_fns.join(' ')}"
|
28
|
-
ap({:cmd => cmd, :fns => fns}) if flags[:debug]
|
29
|
-
system cmd
|
30
|
-
fns.each {|fn| FileUtils.rm(fn)} unless flags[:debug]
|
31
34
|
end
|
32
|
-
end
|
33
35
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
}
|
36
|
+
def run(args)
|
37
|
+
flags = {
|
38
|
+
:debug => false,
|
39
|
+
:verbose => false,
|
40
|
+
:srcdir => GeoHydra::Config.geohydra.stage || '/var/geomdtk/current/stage'
|
41
|
+
}
|
41
42
|
|
42
|
-
|
43
|
-
|
44
|
-
Usage: #{File.basename(__FILE__)} [options] [srcdir]
|
43
|
+
OptionParser.new do |opts|
|
44
|
+
opts.banner = <<EOM
|
45
|
+
Usage: #{File.basename(__FILE__)} [options] [srcdir]
|
45
46
|
EOM
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
47
|
+
opts.on("-v", "--verbose", "Run verbosely") do |v|
|
48
|
+
flags[:debug] = true if flags[:verbose]
|
49
|
+
flags[:verbose] = true
|
50
|
+
end
|
51
|
+
end.parse!(args)
|
51
52
|
|
52
|
-
|
53
|
-
flags[:srcdir] = ARGV.pop unless File.directory?(flags[:srcdir])
|
54
|
-
raise ArgumentError, "Missing directory #{flags[:srcdir]}" unless flags[:srcdir] and File.directory?(flags[:srcdir])
|
55
53
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
n =
|
54
|
+
flags[:srcdir] = args.pop if args.size > 0
|
55
|
+
raise ArgumentError, "Missing directory #{flags[:srcdir]}" unless flags[:srcdir] and File.directory?(flags[:srcdir])
|
56
|
+
|
57
|
+
puts "Searching for druid folders in #{flags[:srcdir]}..." if flags[:verbose]
|
58
|
+
n = 0
|
59
|
+
Dir.glob(File.join(flags[:srcdir], DruidTools::Druid.glob + '/')).sort.collect do |p|
|
60
|
+
assemble p, flags
|
61
|
+
n = n + 1
|
62
|
+
end
|
63
|
+
puts "Processed #{n} folders."
|
61
64
|
end
|
62
|
-
puts "Processed #{n} folders."
|
63
|
-
rescue SystemCallError => e
|
64
|
-
$stderr.puts "ERROR: #{e.message}"
|
65
|
-
exit(-1)
|
66
65
|
end
|
66
|
+
|
67
|
+
|
68
|
+
# __MAIN__
|
69
|
+
AssembleData.new.run(ARGV)
|
data/bin/assemble_placenames.rb
CHANGED
@@ -5,106 +5,106 @@ require 'druid-tools'
|
|
5
5
|
require 'optparse'
|
6
6
|
require 'json'
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
# *
|
14
|
-
# * Adds
|
15
|
-
#
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
k = i.content
|
8
|
+
class AssemblePlacenames < GeoHydra::Process
|
9
|
+
#
|
10
|
+
# Resolves placenames using local gazetteer
|
11
|
+
#
|
12
|
+
# * Changes subject/geographic with GeoNames as authority to have the correct valueURI
|
13
|
+
# * Adds correct rdf:resource to geo extension
|
14
|
+
# * Adds a LCSH or LCNAF keyword if needed
|
15
|
+
#
|
16
|
+
def resolve_placenames(g, modsFn, flags)
|
17
|
+
puts "Processing #{modsFn}" if flags[:verbose]
|
18
|
+
mods = Nokogiri::XML(File.open(modsFn, 'rb'))
|
19
|
+
r = mods.xpath('//mods:geographic', { 'mods' => 'http://www.loc.gov/mods/v3' })
|
20
|
+
r.each do |i|
|
21
|
+
ap({:i => i}) if flags[:debug]
|
22
|
+
k = i.content
|
24
23
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
24
|
+
# Verify Gazetteer keyword
|
25
|
+
uri = g.find_placename_uri(k)
|
26
|
+
if uri.nil?
|
27
|
+
puts "WARNING: Missing gazetteer entry for '#{k}'" if flags[:verbose]
|
28
|
+
next
|
29
|
+
end
|
31
30
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
# Ensure correct valueURI for subject/geographic for GeoNames
|
32
|
+
i['valueURI'] = uri
|
33
|
+
i['authority'] = 'geonames'
|
34
|
+
i['authorityURI'] = 'http://www.geonames.org/ontology#'
|
36
35
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
36
|
+
# Correct any linkages for placenames in the geo extension
|
37
|
+
coverages = mods.xpath('//mods:extension//dc:coverage', { 'mods' => 'http://www.loc.gov/mods/v3', 'dc' => 'http://purl.org/dc/elements/1.1/' })
|
38
|
+
coverages.each do |j|
|
39
|
+
if j['dc:title'] == k
|
40
|
+
puts "Correcting dc:coverage@rdf:resource for #{k}" if flags[:debug]
|
41
|
+
j['rdf:resource'] = uri + 'about.rdf'
|
42
|
+
end
|
43
43
|
end
|
44
|
-
end
|
45
44
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
45
|
+
# Add a LC heading if needed
|
46
|
+
lc = g.find_loc_keyword(k)
|
47
|
+
ap({:lc => lc}) if flags[:debug]
|
48
|
+
unless lc.nil? or k == lc
|
49
|
+
puts "Adding Library of Congress entry to end of MODS record" if flags[:verbose]
|
50
|
+
lcauth = g.find_loc_authority(k)
|
51
|
+
unless lcauth.nil?
|
52
|
+
lcuri = g.find_loc_authority(k)
|
53
|
+
unless lcuri.nil?
|
54
|
+
lcuri = " valueURI='#{lcuri}'"
|
55
|
+
end
|
56
|
+
i.parent.parent << Nokogiri::XML("
|
57
|
+
<subject>
|
58
|
+
<geographic authority='#{lcauth}'#{lcuri}>#{lc}</geographic>
|
59
|
+
</subject>
|
60
|
+
").root
|
56
61
|
end
|
57
|
-
i.parent.parent << Nokogiri::XML("
|
58
|
-
<subject>
|
59
|
-
<geographic authority='#{lcauth}'#{lcuri}>#{lc}</geographic>
|
60
|
-
</subject>
|
61
|
-
").root
|
62
62
|
end
|
63
|
+
ap({:i => i}) if flags[:debug]
|
63
64
|
end
|
64
|
-
ap({:i => i}) if flags[:debug]
|
65
|
-
end
|
66
65
|
|
67
|
-
|
68
|
-
|
69
|
-
end
|
66
|
+
# Save XML tree
|
67
|
+
mods.write_to(File.open(modsFn, 'wb'), :encoding => 'UTF-8', :indent => 2)
|
68
|
+
end
|
70
69
|
|
71
|
-
def main(flags)
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
70
|
+
def main(flags)
|
71
|
+
g = GeoHydra::Gazetteer.new
|
72
|
+
File.umask(002)
|
73
|
+
puts "Searching for MODS records..." if flags[:verbose]
|
74
|
+
Dir.glob(flags[:workspacedir] + '/**/' + DruidTools::Druid.glob + '/metadata/descMetadata.xml') do |modsFn|
|
75
|
+
resolve_placenames(g, modsFn, flags)
|
76
|
+
end
|
76
77
|
end
|
77
|
-
end
|
78
78
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
}
|
79
|
+
def run(args)
|
80
|
+
flags = {
|
81
|
+
:debug => false,
|
82
|
+
:verbose => false,
|
83
|
+
:workspacedir => GeoHydra::Config.geohydra.workspace || 'workspace'
|
84
|
+
}
|
86
85
|
|
87
|
-
|
88
|
-
|
89
|
-
Usage: #{File.basename(__FILE__)} [options]
|
86
|
+
OptionParser.new do |opts|
|
87
|
+
opts.banner = <<EOM
|
88
|
+
Usage: #{File.basename(__FILE__)} [options]
|
90
89
|
EOM
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
90
|
+
opts.on('-v', '--verbose', 'Run verbosely') do |v|
|
91
|
+
flags[:debug] = true if flags[:verbose]
|
92
|
+
flags[:verbose] = true
|
93
|
+
end
|
94
|
+
opts.on('--workspace DIR', "Workspace directory for assembly (default: #{flags[:workspacedir]})") do |v|
|
95
|
+
flags[:workspacedir] = v
|
96
|
+
end
|
97
|
+
end.parse!(args)
|
98
|
+
|
99
|
+
%w{workspacedir}.each do |k|
|
100
|
+
d = flags[k.to_sym]
|
101
|
+
raise ArgumentError, "Missing directory #{d}" unless d.nil? or File.directory? d
|
97
102
|
end
|
98
|
-
end.parse!
|
99
103
|
|
100
|
-
|
101
|
-
|
102
|
-
raise ArgumentError, "Missing directory #{d}" unless d.nil? or File.directory? d
|
104
|
+
ap({:flags => flags}) if flags[:debug]
|
105
|
+
main flags
|
103
106
|
end
|
104
|
-
|
105
|
-
ap({:flags => flags}) if flags[:debug]
|
106
|
-
main flags
|
107
|
-
rescue SystemCallError => e
|
108
|
-
$stderr.puts "ERROR: #{e.message}"
|
109
|
-
exit(-1)
|
110
107
|
end
|
108
|
+
|
109
|
+
# __MAIN__
|
110
|
+
AssemblePlacenames.new.run(ARGV)
|
data/bin/build_stage_options.rb
CHANGED
@@ -3,25 +3,31 @@
|
|
3
3
|
require 'geohydra'
|
4
4
|
require 'json'
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
6
|
+
class BuildStageOptions < GeoHydra::Process
|
7
|
+
# @param [String] shp assumes foo/bar/aa111bb1111/temp/shapefile.shp
|
8
|
+
def doit(shp)
|
9
|
+
r = {}
|
10
|
+
r['druid'] = File.basename(File.dirname(File.dirname(shp)))
|
11
|
+
raise ArgumentError, "SyntaxError: Not a shapefile: #{shp}" unless GeoHydra::Utils.shapefile?(shp)
|
12
|
+
r['geometryType'] = GeoHydra::Transform.geometry_type(shp)
|
13
|
+
r['filename'] = File.basename(shp)
|
14
|
+
File.open(File.join(File.dirname(shp), 'geoOptions.json'), 'w') do |f|
|
15
|
+
f.puts r.to_json.to_s
|
16
|
+
end
|
14
17
|
end
|
15
|
-
|
16
|
-
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
19
|
+
def run(args)
|
20
|
+
if args.empty?
|
21
|
+
Dir.glob('/var/geomdtk/current/stage/**/temp/*.shp') do |shp|
|
22
|
+
doit(shp)
|
23
|
+
end
|
24
|
+
else
|
25
|
+
args.each do |shp|
|
26
|
+
doit(shp)
|
27
|
+
end
|
28
|
+
end
|
25
29
|
end
|
26
|
-
|
27
30
|
end
|
31
|
+
|
32
|
+
# __MAIN__
|
33
|
+
BuildStageOptions.new.run(ARGV)
|
data/bin/derive_wgs84.rb
CHANGED
@@ -4,82 +4,81 @@ require 'druid-tools'
|
|
4
4
|
require 'fileutils'
|
5
5
|
require 'optparse'
|
6
6
|
|
7
|
+
class DeriveWGS84 < GeoHydra::Process
|
8
|
+
def run(args)
|
9
|
+
File.umask(002)
|
10
|
+
flags = {
|
11
|
+
:overwrite_prj => true,
|
12
|
+
:verbose => false,
|
13
|
+
:workspacedir => GeoHydra::Config.geohydra.workspace || 'workspace',
|
14
|
+
:tmpdir => GeoHydra::Config.geohydra.tmpdir || 'tmp',
|
15
|
+
# ogr2ogr is using a different WKT than GeoServer -- this one is from GeoServer 2.3.1.
|
16
|
+
# As implemented by EPSG database on HSQL:
|
17
|
+
# http://docs.geotools.org/latest/userguide/library/referencing/hsql.html
|
18
|
+
# Also see:
|
19
|
+
# http://spatialreference.org/ref/epsg/4326/prettywkt/
|
20
|
+
:wkt => {
|
21
|
+
'4326' => %Q{
|
22
|
+
GEOGCS["WGS 84",
|
23
|
+
DATUM["WGS_1984",
|
24
|
+
SPHEROID["WGS 84",6378137,298.257223563,
|
25
|
+
AUTHORITY["EPSG","7030"]],
|
26
|
+
AUTHORITY["EPSG","6326"]],
|
27
|
+
PRIMEM["Greenwich",0,
|
28
|
+
AUTHORITY["EPSG","8901"]],
|
29
|
+
UNIT["degree",0.01745329251994328,
|
30
|
+
AUTHORITY["EPSG","9122"]],
|
31
|
+
AUTHORITY["EPSG","4326"]]
|
32
|
+
}.split.join.freeze
|
33
|
+
}
|
7
34
|
|
35
|
+
}
|
8
36
|
|
9
|
-
|
10
|
-
|
11
|
-
File.
|
12
|
-
flags = {
|
13
|
-
:overwrite_prj => true,
|
14
|
-
:verbose => false,
|
15
|
-
:workspacedir => GeoHydra::Config.geohydra.workspace || 'workspace',
|
16
|
-
:tmpdir => GeoHydra::Config.geohydra.tmpdir || 'tmp',
|
17
|
-
# ogr2ogr is using a different WKT than GeoServer -- this one is from GeoServer 2.3.1.
|
18
|
-
# As implemented by EPSG database on HSQL:
|
19
|
-
# http://docs.geotools.org/latest/userguide/library/referencing/hsql.html
|
20
|
-
# Also see:
|
21
|
-
# http://spatialreference.org/ref/epsg/4326/prettywkt/
|
22
|
-
:wkt => {
|
23
|
-
'4326' => %Q{
|
24
|
-
GEOGCS["WGS 84",
|
25
|
-
DATUM["WGS_1984",
|
26
|
-
SPHEROID["WGS 84",6378137,298.257223563,
|
27
|
-
AUTHORITY["EPSG","7030"]],
|
28
|
-
AUTHORITY["EPSG","6326"]],
|
29
|
-
PRIMEM["Greenwich",0,
|
30
|
-
AUTHORITY["EPSG","8901"]],
|
31
|
-
UNIT["degree",0.01745329251994328,
|
32
|
-
AUTHORITY["EPSG","9122"]],
|
33
|
-
AUTHORITY["EPSG","4326"]]
|
34
|
-
}.split.join.freeze
|
35
|
-
}
|
36
|
-
|
37
|
-
}
|
38
|
-
|
39
|
-
OptionParser.new do |opts|
|
40
|
-
opts.banner = <<EOM
|
41
|
-
Usage: #{File.basename(__FILE__)} [options] [druid...]
|
37
|
+
OptionParser.new do |opts|
|
38
|
+
opts.banner = <<EOM
|
39
|
+
Usage: #{File.basename(__FILE__)} [options] [druid...]
|
42
40
|
EOM
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
end
|
49
|
-
opts.on("--tmpdir DIR", "Temporary directory for assembly (default: #{flags[:tmpdir]})") do |v|
|
50
|
-
flags[:tmpdir] = v
|
51
|
-
end
|
52
|
-
opts.on("--wkt SRID FILE", "Read WKT for SRID from FILE") do |srid, f|
|
53
|
-
flags[:wkt][srid.to_s] = File.read(f).split.join.freeze
|
54
|
-
end
|
55
|
-
end.parse!
|
56
|
-
|
57
|
-
[flags[:tmpdir], flags[:workspacedir]].each do |d|
|
58
|
-
raise ArgumentError, "Missing directory #{d}" unless File.directory? d
|
59
|
-
end
|
60
|
-
|
61
|
-
if ARGV.empty?
|
62
|
-
# matches druid workspace structure
|
63
|
-
Dir.glob(flags[:workspacedir] + '/??/???/??/????/???????????/content/*.zip').each do |fn|
|
64
|
-
id = File.basename(File.dirname(File.dirname(fn)))
|
65
|
-
druid = DruidTools::Druid.new(id, flags[:workspacedir])
|
66
|
-
unless fn =~ %r{_EPSG_}i
|
67
|
-
puts "Processing #{druid.id} #{fn}"
|
68
|
-
GeoHydra::Transform.reproject druid, fn, flags
|
41
|
+
opts.on("-v", "--verbose", "Run verbosely") do |v|
|
42
|
+
flags[:verbose] = true
|
43
|
+
end
|
44
|
+
opts.on("--workspace DIR", "Workspace directory for assembly (default: #{flags[:workspacedir]})") do |v|
|
45
|
+
flags[:workspacedir] = v
|
69
46
|
end
|
47
|
+
opts.on("--tmpdir DIR", "Temporary directory for assembly (default: #{flags[:tmpdir]})") do |v|
|
48
|
+
flags[:tmpdir] = v
|
49
|
+
end
|
50
|
+
opts.on("--wkt SRID FILE", "Read WKT for SRID from FILE") do |srid, f|
|
51
|
+
flags[:wkt][srid.to_s] = File.read(f).split.join.freeze
|
52
|
+
end
|
53
|
+
end.parse!(args)
|
54
|
+
|
55
|
+
[flags[:tmpdir], flags[:workspacedir]].each do |d|
|
56
|
+
raise ArgumentError, "Missing directory #{d}" unless File.directory? d
|
70
57
|
end
|
71
|
-
|
72
|
-
|
73
|
-
druid
|
74
|
-
Dir.glob(
|
58
|
+
|
59
|
+
if args.empty?
|
60
|
+
# matches druid workspace structure
|
61
|
+
Dir.glob(flags[:workspacedir] + '/??/???/??/????/???????????/content/data.zip').each do |fn|
|
62
|
+
id = File.basename(File.dirname(File.dirname(fn)))
|
63
|
+
druid = DruidTools::Druid.new(id, flags[:workspacedir])
|
75
64
|
unless fn =~ %r{_EPSG_}i
|
76
65
|
puts "Processing #{druid.id} #{fn}"
|
77
66
|
GeoHydra::Transform.reproject druid, fn, flags
|
78
67
|
end
|
79
68
|
end
|
69
|
+
else
|
70
|
+
args.each do |id|
|
71
|
+
druid = DruidTools::Druid.new(id, flags[:workspacedir])
|
72
|
+
Dir.glob(druid.content_dir + '/data.zip').each do |fn|
|
73
|
+
unless fn =~ %r{_EPSG_}i
|
74
|
+
puts "Processing #{druid.id} #{fn}"
|
75
|
+
GeoHydra::Transform.reproject druid, fn, flags
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
80
79
|
end
|
81
80
|
end
|
82
|
-
rescue SystemCallError => e
|
83
|
-
$stderr.puts "ERROR: #{e.message}"
|
84
|
-
exit(-1)
|
85
81
|
end
|
82
|
+
|
83
|
+
# __MAIN__
|
84
|
+
DeriveWGS84.new.run(ARGV)
|