geohydra 0.3.1 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +2 -1
  3. data/.travis.yml +1 -2
  4. data/Gemfile +1 -8
  5. data/Gemfile.lock +87 -102
  6. data/README.md +2 -2
  7. data/VERSION +1 -1
  8. data/bin/accession.rb +99 -89
  9. data/bin/assemble.rb +288 -247
  10. data/bin/assemble_data.rb +54 -51
  11. data/bin/assemble_placenames.rb +85 -85
  12. data/bin/build_stage_options.rb +24 -18
  13. data/bin/derive_wgs84.rb +65 -66
  14. data/bin/extract_thumbnail.rb +38 -37
  15. data/bin/geo2mods.rb +78 -0
  16. data/bin/geohydra +14 -5
  17. data/bin/ingest_arcgis.rb +80 -60
  18. data/bin/iso2geo.rb +64 -0
  19. data/bin/loader_postgis.rb +121 -227
  20. data/bin/run_task.rb +23 -0
  21. data/bin/sync_geoserver_metadata.rb +132 -127
  22. data/bin/xsltproc-saxon +6 -0
  23. data/geohydra.gemspec +6 -4
  24. data/lib/geohydra.rb +5 -0
  25. data/lib/geohydra/accession.rb +24 -13
  26. data/lib/geohydra/{arcgis_to_iso19139_fc.xsl → arcgis_to_iso19110.xsl} +0 -0
  27. data/lib/geohydra/gazetteer.csv +842 -36
  28. data/lib/geohydra/gazetteer.rb +48 -24
  29. data/lib/geohydra/mods2geoblacklight.xsl +248 -0
  30. data/lib/geohydra/mods2ogp.xsl +5 -8
  31. data/lib/geohydra/transform.rb +8 -2
  32. data/lib/geohydra/utils.rb +6 -0
  33. data/lib/geohydra/workflow/gisAssemblyWF.rb +109 -0
  34. data/lib/geohydra/workflow/gisAssemblyWF.xml +85 -0
  35. data/lib/geohydra/workflow/gisDeliveryWF.rb +33 -0
  36. data/lib/geohydra/workflow/gisDeliveryWF.xml +36 -0
  37. data/lib/geohydra/workflow/gisDiscoveryWF.rb +55 -0
  38. data/lib/geohydra/workflow/gisDiscoveryWF.xml +28 -0
  39. data/lib/geohydra/workflow/task.rb +82 -0
  40. data/ogp/README.md +350 -0
  41. data/ogp/download.rb +92 -0
  42. data/ogp/fgdc2mods.sh +9 -0
  43. data/ogp/fgdc2mods.xsl +884 -0
  44. data/ogp/ingest.rb +48 -0
  45. data/ogp/select.rb +20 -0
  46. data/ogp/transform.rb +354 -0
  47. data/ogp/validate.rb +182 -0
  48. data/{bin → scripts}/ingest_tufts.rb +0 -0
  49. data/scripts/iso2html/doit.sh +15 -0
  50. data/scripts/iso2html/main.css +66 -0
  51. data/scripts/iso2html/pacioos-iso-html.xsl +1749 -0
  52. data/scripts/iso2html/utils/replace-newlines.xsl +97 -0
  53. data/scripts/iso2html/utils/replace-string.xsl +80 -0
  54. data/scripts/iso2html/utils/strip-digits.xsl +60 -0
  55. data/{bin → scripts}/loader.rb +0 -0
  56. data/scripts/rename_shapefiles.rb +5 -0
  57. data/scripts/render_gazetteer.rb +36 -0
  58. data/{bin → scripts}/seed.rb +0 -0
  59. data/{bin → scripts}/solr_indexer.rb +0 -0
  60. data/scripts/status.csv +253 -0
  61. data/scripts/status.rb +32 -0
  62. data/{bin → scripts}/validate_data.rb +1 -1
  63. data/solr/kurma-app-dev/conf/lang/stopwords_en.txt +34 -0
  64. data/solr/kurma-app-dev/conf/protwords.txt +21 -0
  65. data/solr/kurma-app-dev/conf/schema.xml +156 -0
  66. data/solr/kurma-app-dev/conf/solrconfig.xml +161 -0
  67. data/solr/kurma-app-dev/conf/synonyms.txt +29 -0
  68. data/solr/kurma-app-dev/purge.sh +8 -0
  69. data/solr/kurma-app-test/conf/lang/stopwords_en.txt +34 -0
  70. data/solr/kurma-app-test/conf/protwords.txt +21 -0
  71. data/solr/kurma-app-test/conf/schema.xml +158 -0
  72. data/solr/kurma-app-test/conf/solrconfig.xml +161 -0
  73. data/solr/kurma-app-test/conf/synonyms.txt +29 -0
  74. data/solr/kurma-app-test/deploy.sh +15 -0
  75. data/solr/kurma-app-test/purge.sh +8 -0
  76. data/solr/ogp-dev/purge.sh +1 -2
  77. data/spec/fixtures/bw938nk9584/temp/{TRIPURA-iso19139-fc.xml → TRIPURA-iso19110.xml} +0 -0
  78. data/spec/fixtures/cc142xj8436/temp/{HARYANA-iso19139-fc.xml → HARYANA-iso19110.xml} +0 -0
  79. data/spec/fixtures/cg716wc7949/temp/{metadata.iso19139-fc.xml → metadata.iso19110.xml} +0 -0
  80. data/spec/fixtures/cm007pv9601/temp/{MEGHALAYA-iso19139-fc.xml → MEGHALAYA-iso19110.xml} +0 -0
  81. data/spec/fixtures/cp055nb0189/temp/{metadata.iso19139-fc.xml → metadata.iso19110.xml} +0 -0
  82. data/spec/fixtures/cs838pw3418/temp/{OIL_GAS_FIELDS-iso19139-fc.xml → OIL_GAS_FIELDS-iso19110.xml} +0 -0
  83. data/spec/fixtures/dd308sy5843/temp/{ORISSA-iso19139-fc.xml → ORISSA-iso19110.xml} +0 -0
  84. data/spec/fixtures/dd452vk1873/temp/{metadata.iso19139-fc.xml → metadata.iso19110.xml} +0 -0
  85. data/spec/fixtures/dg850pt1796/temp/{STATE1951-iso19139-fc.xml → STATE1951-iso19110.xml} +0 -0
  86. data/spec/fixtures/dn744tf5427/temp/{DISTRICT1991-iso19139-fc.xml → DISTRICT1991-iso19110.xml} +0 -0
  87. data/spec/fixtures/dq603nz8402/temp/{STATE2001-iso19139-fc.xml → STATE2001-iso19110.xml} +0 -0
  88. data/spec/fixtures/dv609zt4699/temp/{ASSAM-iso19139-fc.xml → ASSAM-iso19110.xml} +0 -0
  89. data/spec/fixtures/dz222hw0585/temp/{PUNJAB-iso19139-fc.xml → PUNJAB-iso19110.xml} +0 -0
  90. data/spec/fixtures/fd673qb9705/temp/{STATE1971-iso19139-fc.xml → STATE1971-iso19110.xml} +0 -0
  91. data/spec/fixtures/fg451wp8917/temp/{SIKKIM-iso19139-fc.xml → SIKKIM-iso19110.xml} +0 -0
  92. data/spec/fixtures/fh247yz0156/temp/{RAJASTHAN-iso19139-fc.xml → RAJASTHAN-iso19110.xml} +0 -0
  93. data/spec/fixtures/fs487vd1465/temp/{CHHATTISGARH-iso19139-fc.xml → CHHATTISGARH-iso19110.xml} +0 -0
  94. data/spec/fixtures/fs591bn3317/temp/{HIMACHAL_PRADESH-iso19139-fc.xml → HIMACHAL_PRADESH-iso19110.xml} +0 -0
  95. data/spec/fixtures/fw920bc5473/temp/{PLSS_TWN-iso19139-fc.xml → PLSS_TWN-iso19110.xml} +0 -0
  96. data/spec/fixtures/gj831wj3625/temp/{metadata.iso19139-fc.xml → metadata.iso19110.xml} +0 -0
  97. data/spec/fixtures/gp075nv3265/temp/{PONDICHERRY-iso19139-fc.xml → PONDICHERRY-iso19110.xml} +0 -0
  98. data/spec/fixtures/gv800hj8141/temp/{BIHAR-iso19139-fc.xml → BIHAR-iso19110.xml} +0 -0
  99. data/spec/fixtures/gw520gz6339/temp/{DADRA_NAGAR_HAVELI_PT-iso19139-fc.xml → DADRA_NAGAR_HAVELI_PT-iso19110.xml} +0 -0
  100. data/spec/fixtures/gy054hz1045/temp/{HARYANA-iso19139-fc.xml → HARYANA-iso19110.xml} +0 -0
  101. data/spec/fixtures/gz352mw6982/temp/{metadata.iso19139-fc.xml → metadata.iso19110.xml} +0 -0
  102. data/spec/fixtures/hb489vm9892/temp/{DISTRICT1981-iso19139-fc.xml → DISTRICT1981-iso19110.xml} +0 -0
  103. data/spec/fixtures/hw125dq0418/temp/{DELHI-iso19139-fc.xml → DELHI-iso19110.xml} +0 -0
  104. data/spec/fixtures/hw892mn4587/temp/{KERALA-iso19139-fc.xml → KERALA-iso19110.xml} +0 -0
  105. data/spec/fixtures/jb371hz3868/temp/{INCOME-iso19139-fc.xml → INCOME-iso19110.xml} +0 -0
  106. data/spec/fixtures/jc017yk9928/temp/{KARNATAKA-iso19139-fc.xml → KARNATAKA-iso19110.xml} +0 -0
  107. data/spec/fixtures/jf841ys4828/temp/{ANDHRA_PRADESH-iso19139-fc.xml → ANDHRA_PRADESH-iso19110.xml} +0 -0
  108. data/spec/fixtures/jh802mp2160/temp/{DELHI_PT-iso19139-fc.xml → DELHI_PT-iso19110.xml} +0 -0
  109. data/spec/fixtures/jj806fc3801/temp/{metadata.iso19139-fc.xml → metadata.iso19110.xml} +0 -0
  110. data/spec/fixtures/jq835yn7161/temp/{HIMACHAL_PRADESH-iso19139-fc.xml → HIMACHAL_PRADESH-iso19110.xml} +0 -0
  111. data/spec/fixtures/jr455pt6676/temp/{TAMILNADU-iso19139-fc.xml → TAMILNADU-iso19110.xml} +0 -0
  112. data/spec/fixtures/js637zp2537/temp/{BIHAR-iso19139-fc.xml → BIHAR-iso19110.xml} +0 -0
  113. data/spec/fixtures/jv502wg9611/temp/{GOA-iso19139-fc.xml → GOA-iso19110.xml} +0 -0
  114. data/spec/fixtures/jw462ck6560/temp/{JAMMU_KASHMIR-iso19139-fc.xml → JAMMU_KASHMIR-iso19110.xml} +0 -0
  115. data/spec/fixtures/kj800fb6273/temp/{STATE2011-iso19139-fc.xml → STATE2011-iso19110.xml} +0 -0
  116. data/spec/fixtures/km504zq3948/temp/{HIMACHAL_PRADESH-iso19139-fc.xml → HIMACHAL_PRADESH-iso19110.xml} +0 -0
  117. data/spec/fixtures/ks297fy1411/temp/{OFFSH_BLOCKS-iso19139-fc.xml → OFFSH_BLOCKS-iso19110.xml} +0 -0
  118. data/spec/fixtures/md358hy5049/temp/{MIZORAM-iso19139-fc.xml → MIZORAM-iso19110.xml} +0 -0
  119. data/spec/fixtures/mg745bq0193/temp/{MADHYA_PRADESH-iso19139-fc.xml → MADHYA_PRADESH-iso19110.xml} +0 -0
  120. data/spec/fixtures/mh187yx3536/temp/{WEST_BENGAL-iso19139-fc.xml → WEST_BENGAL-iso19110.xml} +0 -0
  121. data/spec/fixtures/mk488yn6694/temp/{GUJARAT-iso19139-fc.xml → GUJARAT-iso19110.xml} +0 -0
  122. data/spec/fixtures/my216kp3008/temp/{DELHI-iso19139-fc.xml → DELHI-iso19110.xml} +0 -0
  123. data/spec/fixtures/my504nz9827/temp/{JAMMU_KASHMIR-iso19139-fc.xml → JAMMU_KASHMIR-iso19110.xml} +0 -0
  124. data/spec/fixtures/ng819jm8700/temp/{MANIPUR-iso19139-fc.xml → MANIPUR-iso19110.xml} +0 -0
  125. data/spec/fixtures/np020jq2139/temp/{metadata.iso19139-fc.xml → metadata.iso19110.xml} +0 -0
  126. data/spec/fixtures/ns377mt1608/temp/{STATE1991-iso19139-fc.xml → STATE1991-iso19110.xml} +0 -0
  127. data/spec/fixtures/nw926np8508/temp/{metadata.iso19139-fc.xml → metadata.iso19110.xml} +0 -0
  128. data/spec/fixtures/ny358rm8559/temp/{TRIPURA-iso19139-fc.xml → TRIPURA-iso19110.xml} +0 -0
  129. data/spec/fixtures/nz176rm8192/temp/{DISTRICT2011-iso19139-fc.xml → DISTRICT2011-iso19110.xml} +0 -0
  130. data/spec/fixtures/nz252rq2252/temp/{UTTAR_PRADESH-iso19139-fc.xml → UTTAR_PRADESH-iso19110.xml} +0 -0
  131. data/spec/fixtures/pd902kb3348/temp/{MADHYA_PRADESH-iso19139-fc.xml → MADHYA_PRADESH-iso19110.xml} +0 -0
  132. data/spec/fixtures/pz792fz1776/temp/{MAHARASHTRA-iso19139-fc.xml → MAHARASHTRA-iso19110.xml} +0 -0
  133. data/spec/fixtures/qb767ss4042/temp/{UTTAR_PRADESH-iso19139-fc.xml → UTTAR_PRADESH-iso19110.xml} +0 -0
  134. data/spec/fixtures/qc091qw0570/temp/{GUJARAT-iso19139-fc.xml → GUJARAT-iso19110.xml} +0 -0
  135. data/spec/fixtures/qc652vr7204/temp/{ANDHRA_PRADESH_PT-iso19139-fc.xml → ANDHRA_PRADESH_PT-iso19110.xml} +0 -0
  136. data/spec/fixtures/qk786js7484/temp/{DISTRICT1961-iso19139-fc.xml → DISTRICT1961-iso19110.xml} +0 -0
  137. data/spec/fixtures/qn676pg6767/temp/{GOA-iso19139-fc.xml → GOA-iso19110.xml} +0 -0
  138. data/spec/fixtures/qr255jh4074/temp/{LOKSABHA_14-iso19139-fc.xml → LOKSABHA_14-iso19110.xml} +0 -0
  139. data/spec/fixtures/qr374kj4827/temp/{ASSAM-iso19139-fc.xml → ASSAM-iso19110.xml} +0 -0
  140. data/spec/fixtures/qy162js1748/temp/{CHHATTISGARH-iso19139-fc.xml → CHHATTISGARH-iso19110.xml} +0 -0
  141. data/spec/fixtures/rd446vf2633/temp/{NAGALAND-iso19139-fc.xml → NAGALAND-iso19110.xml} +0 -0
  142. data/spec/fixtures/rf389hf2983/temp/{CHHATTISGARH_PT-iso19139-fc.xml → CHHATTISGARH_PT-iso19110.xml} +0 -0
  143. data/spec/fixtures/rf859ff4582/temp/{JHARKHAND-iso19139-fc.xml → JHARKHAND-iso19110.xml} +0 -0
  144. data/spec/fixtures/rh343ds8931/temp/{BIHAR-iso19139-fc.xml → BIHAR-iso19110.xml} +0 -0
  145. data/spec/fixtures/rn815xk8157/temp/{SIKKIM-iso19139-fc.xml → SIKKIM-iso19110.xml} +0 -0
  146. data/spec/fixtures/rq653sz4470/temp/{CHHATTISGARH-iso19139-fc.xml → CHHATTISGARH-iso19110.xml} +0 -0
  147. data/spec/fixtures/rt625ws6022/temp/{GULF_FAIRWAYS-iso19139-fc.xml → GULF_FAIRWAYS-iso19110.xml} +0 -0
  148. data/spec/fixtures/sc330vf4259/temp/{JHARKHAND-iso19139-fc.xml → JHARKHAND-iso19110.xml} +0 -0
  149. data/spec/fixtures/sq479mx3086/temp/{OFFSH_PLATF-iso19139-fc.xml → OFFSH_PLATF-iso19110.xml} +0 -0
  150. data/spec/fixtures/sr686bm4098/temp/{DAMAN_DIU_PT-iso19139-fc.xml → DAMAN_DIU_PT-iso19110.xml} +0 -0
  151. data/spec/fixtures/sv303sh5583/temp/{ARUNACHAL_PRADESH-iso19139-fc.xml → ARUNACHAL_PRADESH-iso19110.xml} +0 -0
  152. data/spec/fixtures/sy319nh8520/temp/{GUJARAT-iso19139-fc.xml → GUJARAT-iso19110.xml} +0 -0
  153. data/spec/fixtures/td363vx2792/temp/{HIMACHAL_PRADESH_PT-iso19139-fc.xml → HIMACHAL_PRADESH_PT-iso19110.xml} +0 -0
  154. data/spec/fixtures/tf374bd2484/temp/{DISTRICT1951-iso19139-fc.xml → DISTRICT1951-iso19110.xml} +0 -0
  155. data/spec/fixtures/tj797mj7877/temp/{LOKSABHA_15-iso19139-fc.xml → LOKSABHA_15-iso19110.xml} +0 -0
  156. data/spec/fixtures/tv060wq5179/temp/{ASSAM-iso19139-fc.xml → ASSAM-iso19110.xml} +0 -0
  157. data/spec/fixtures/tv536bn1915/temp/{ARUNACHAL_PRADESH-iso19139-fc.xml → ARUNACHAL_PRADESH-iso19110.xml} +0 -0
  158. data/spec/fixtures/tz359cc2977/temp/{MANIPUR-iso19139-fc.xml → MANIPUR-iso19110.xml} +0 -0
  159. data/spec/fixtures/vb525my6511/temp/{UTTARAKHAND-iso19139-fc.xml → UTTARAKHAND-iso19110.xml} +0 -0
  160. data/spec/fixtures/vh802fs4240/temp/{PONDICHERRY-iso19139-fc.xml → PONDICHERRY-iso19110.xml} +0 -0
  161. data/spec/fixtures/vk120xn2474/temp/{PLSS_SEC-iso19139-fc.xml → PLSS_SEC-iso19110.xml} +0 -0
  162. data/spec/fixtures/vn439bc7316/temp/{KERALA-iso19139-fc.xml → KERALA-iso19110.xml} +0 -0
  163. data/spec/fixtures/vq745jk0695/temp/{MEGHALAYA-iso19139-fc.xml → MEGHALAYA-iso19110.xml} +0 -0
  164. data/spec/fixtures/vr593vj7147/temp/{ANDHRA_PRADESH-iso19139-fc.xml → ANDHRA_PRADESH-iso19110.xml} +0 -0
  165. data/spec/fixtures/vw911qb5271/temp/{DISTRICT2001-iso19139-fc.xml → DISTRICT2001-iso19110.xml} +0 -0
  166. data/spec/fixtures/wg680pz0365/temp/{ANDHRA_PRADESH-iso19139-fc.xml → ANDHRA_PRADESH-iso19110.xml} +0 -0
  167. data/spec/fixtures/wg761xn1926/temp/{HARYANA-iso19139-fc.xml → HARYANA-iso19110.xml} +0 -0
  168. data/spec/fixtures/wh870qw1934/temp/{PUNJAB-iso19139-fc.xml → PUNJAB-iso19110.xml} +0 -0
  169. data/spec/fixtures/wk775mm4673/temp/{MAHARASHTRA-iso19139-fc.xml → MAHARASHTRA-iso19110.xml} +0 -0
  170. data/spec/fixtures/ws171yz2165/temp/{ARUNACHAL_PRADESH_PT-iso19139-fc.xml → ARUNACHAL_PRADESH_PT-iso19110.xml} +0 -0
  171. data/spec/fixtures/wt473hz7153/temp/{CHANDIGARH_PT-iso19139-fc.xml → CHANDIGARH_PT-iso19110.xml} +0 -0
  172. data/spec/fixtures/ww217dj0457/temp/{CO2_PIPE-iso19139-fc.xml → CO2_PIPE-iso19110.xml} +0 -0
  173. data/spec/fixtures/wy875pk9849/temp/{STATE1961-iso19139-fc.xml → STATE1961-iso19110.xml} +0 -0
  174. data/spec/fixtures/xb018tk2042/temp/{STATE1981-iso19139-fc.xml → STATE1981-iso19110.xml} +0 -0
  175. data/spec/fixtures/xg539vw8586/temp/{ORISSA-iso19139-fc.xml → ORISSA-iso19110.xml} +0 -0
  176. data/spec/fixtures/xv475kp4644/temp/{ASSAM_PT-iso19139-fc.xml → ASSAM_PT-iso19110.xml} +0 -0
  177. data/spec/fixtures/xy096gc2959/temp/{GOA-iso19139-fc.xml → GOA-iso19110.xml} +0 -0
  178. data/spec/fixtures/xz518gz3362/temp/{UTTARAKHAND-iso19139-fc.xml → UTTARAKHAND-iso19110.xml} +0 -0
  179. data/spec/fixtures/yh986wy4737/temp/{NAGALAND-iso19139-fc.xml → NAGALAND-iso19110.xml} +0 -0
  180. data/spec/fixtures/yn187fq4474/temp/{KARNATAKA-iso19139-fc.xml → KARNATAKA-iso19110.xml} +0 -0
  181. data/spec/fixtures/yn236mw3250/temp/{TAMILNADU-iso19139-fc.xml → TAMILNADU-iso19110.xml} +0 -0
  182. data/spec/fixtures/yz596nz0112/temp/{WEST_BENGAL-iso19139-fc.xml → WEST_BENGAL-iso19110.xml} +0 -0
  183. data/spec/fixtures/zk596gy7380/temp/{DISTRICT1971-iso19139-fc.xml → DISTRICT1971-iso19110.xml} +0 -0
  184. data/spec/fixtures/zn452hh7431/temp/{RAJASTHAN-iso19139-fc.xml → RAJASTHAN-iso19110.xml} +0 -0
  185. data/spec/fixtures/zt093fw6519/temp/{MIZORAM-iso19139-fc.xml → MIZORAM-iso19110.xml} +0 -0
  186. data/spec/fixtures/zv925hd6723/temp/{OGWELLS-iso19139-fc.xml → OGWELLS-iso19110.xml} +0 -0
  187. data/spec/fixtures/zy658cr1728/temp/{ANDAMAAN_NICOBAR_PT-iso19139-fc.xml → ANDAMAAN_NICOBAR_PT-iso19110.xml} +0 -0
  188. data/spec/fixtures/zz943vx1492/temp/{BASINS-iso19139-fc.xml → BASINS-iso19110.xml} +0 -0
  189. data/spec/unit/gazetteer_spec.rb +100 -35
  190. data/spec/unit/task_spec.rb +68 -0
  191. data/spec/unit/transform_spec.rb +1 -1
  192. data/spec/unit/utils_spec.rb +17 -3
  193. data/workflow.rb +35 -0
  194. metadata +323 -316
@@ -3,6 +3,9 @@
3
3
  require 'csv'
4
4
  require 'awesome_print'
5
5
 
6
+ # Gazetteer data look like this:
7
+ # "l_kw","geonames_kw","geonames_id","lc_kw","lc_id"
8
+ # "Ahmadābād District (India)","Ahmadābād",1279234,"Ahmadābād (India : District)","n78019943"
6
9
  module GeoHydra
7
10
  class Gazetteer
8
11
 
@@ -10,64 +13,85 @@ module GeoHydra
10
13
 
11
14
  def initialize
12
15
  @registry = {}
13
- CSV.foreach(CSV_FN, :encoding => 'UTF-8') do |v|
14
- @registry[v[0]] = {
15
- :id => v[1].to_i,
16
- :lc => v[2],
17
- :lcid => v[3]
16
+ CSV.foreach(CSV_FN, :encoding => 'UTF-8', :headers => true) do |v|
17
+ v = v.each { |k,v| v.to_s.strip }
18
+ k = v[0]
19
+ k = v[1] if k.nil? or k.empty?
20
+ @registry[k] = {
21
+ :geonames_placename => v[1],
22
+ :geonames_id => v[2].to_i,
23
+ :loc_keyword => (v[3].nil? or v[3].empty?)? nil : v[3],
24
+ :loc_id => (v[4].nil? or v[4].empty?)? nil : v[4]
18
25
  }
19
26
  end
20
27
  end
21
-
22
- def _get(k, i)
23
- return nil unless @registry.include?(k)
24
- @registry[k][i]
28
+
29
+ def each
30
+ @registry.each_key.to_a.sort.each {|k| yield k }
31
+ end
32
+
33
+ # @return [String] geonames name
34
+ def find_placename(k)
35
+ _get(k, :geonames_placename)
25
36
  end
26
37
 
27
38
  # @return [Integer] geonames id
28
- def find_id_by_keyword(k)
29
- _get(k, :id)
39
+ def find_id(k)
40
+ _get(k, :geonames_id)
30
41
  end
31
42
 
32
43
  # @return [String] library of congress name
33
- def find_lc_by_keyword(k)
34
- _get(k, :lc)
44
+ def find_loc_keyword(k)
45
+ _get(k, :loc_keyword)
35
46
  end
36
47
 
37
48
  # @return [String] library of congress valueURI
38
- def find_lcuri_by_keyword(k)
39
- lcid = _get(k, :lcid)
40
- if lcid =~ /^lcsh:(\d+)$/
49
+ def find_loc_uri(k)
50
+ lcid = _get(k, :loc_id)
51
+ if lcid =~ /^lcsh:(\d+)$/ or lcid =~ /^sh(\d+)$/
41
52
  "http://id.loc.gov/authorities/subjects/sh#{$1}"
42
- elsif lcid =~ /^lcnaf:(\d+)$/
53
+ elsif lcid =~ /^lcnaf:(\d+)$/ or lcid =~ /^n(\d+)$/
43
54
  "http://id.loc.gov/authorities/names/n#{$1}"
55
+ elsif lcid =~ /^no(\d+)$/
56
+ "http://id.loc.gov/authorities/names/no#{$1}"
44
57
  else
45
58
  nil
46
59
  end
47
60
  end
48
61
 
49
- def find_lcauth_by_keyword(k)
50
- lcid = _get(k, :lcid)
62
+ # @return [String] authority name
63
+ def find_loc_authority(k)
64
+ lcid = _get(k, :loc_id)
51
65
  return $1 if lcid =~ /^(lcsh|lcnaf):/
52
- return 'lcsh' unless find_lc_by_keyword(k).nil? # default to lcsh if present
66
+ return 'lcsh' if lcid =~ /^sh\d+$/
67
+ return 'lcnaf' if lcid =~ /^(n|no)\d+$/
68
+ return 'lcsh' unless find_loc_keyword(k).nil? # default to lcsh if present
53
69
  nil
54
70
  end
55
71
 
56
72
 
57
73
  # @see http://www.geonames.org/ontology/documentation.html
58
74
  # @return [String] geonames uri (includes trailing / as specified)
59
- def find_uri_by_keyword(k)
60
- return nil if _get(k, :id).nil?
61
- "http://sws.geonames.org/#{_get(k, :id)}/"
75
+ def find_placename_uri(k)
76
+ return nil if _get(k, :geonames_id).nil?
77
+ "http://sws.geonames.org/#{_get(k, :geonames_id)}/"
62
78
  end
63
79
 
64
80
  # @return [String] The keyword
65
81
  def find_keyword_by_id(id)
66
82
  @registry.each do |k,v|
67
- return k if v[:id] == id
83
+ return k if v[:geonames_id] == id
68
84
  end
69
85
  nil
70
86
  end
87
+
88
+ private
89
+ def _get(k, i)
90
+ return nil unless @registry.include?(k)
91
+ raise ArgumentError unless i.is_a? Symbol
92
+ @registry[k][i]
93
+ end
94
+
71
95
  end
72
96
  end
73
97
 
@@ -0,0 +1,248 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ mods2geoblacklight.xsl - Transforms MODS with GML extensions into a GeoBlacklight document
4
+
5
+ Copyright 2014, Stanford University Libraries.
6
+
7
+ Created by Darren Hardy.
8
+
9
+ Example usage:
10
+
11
+ xsltproc -stringparam geoserver_root 'http://kurma-podd1.stanford.edu/geoserver'
12
+ -stringparam purl 'http://purl-dev.stanford.edu/fw920bc5473'
13
+ -output '/var/geomdtk/current/workspace/fw/920/bc/5473/fw920bc5473/temp/geoblacklightSolr.xml'
14
+ '/home/geostaff/geomdtk/current/lib/geomdtk/mods2geoblacklight.xsl'
15
+ '/var/geomdtk/current/workspace/fw/920/bc/5473/fw920bc5473/metadata/descMetadata.xml'
16
+
17
+ Requires parameters:
18
+
19
+ - geoserver_root - URL prefix to the geoserver
20
+ - purl - complete URL with aa111bb1111 (len = 11)
21
+
22
+ -->
23
+ <xsl:stylesheet xmlns="http://lucene.apache.org/solr/4/document" xmlns:gml="http://www.opengis.net/gml/3.2/" xmlns:mods="http://www.loc.gov/mods/v3" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" exclude-result-prefixes="gml mods rdf xsl">
24
+ <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
25
+ <xsl:strip-space elements="*"/>
26
+ <xsl:template match="/mods:mods">
27
+ <!-- XXX: Handle other institution naming schemes -->
28
+ <xsl:variable name="druid" select="substring($purl, string-length($purl)-10)"/>
29
+ <add>
30
+ <doc>
31
+ <field name="uuid">
32
+ <xsl:value-of select="$purl"/>
33
+ </field>
34
+ <field name="dc_identifier_s">
35
+ <xsl:value-of select="$purl"/>
36
+ </field>
37
+ <!-- XXX: handle multivalued relations -->
38
+ <field name="dct_isPartOf_sm">
39
+ <xsl:value-of select="mods:relatedItem/mods:titleInfo/mods:title"/>
40
+ </field>
41
+ <!-- XXX: handle GeoTIFF -->
42
+ <field name="dc_format_s">
43
+ <xsl:text>Shapefile</xsl:text>
44
+ </field>
45
+ <field name="dc_language_s">
46
+ <xsl:text>English</xsl:text>
47
+ </field>
48
+ <field name="dc_rights_s">
49
+ <xsl:text>Restricted</xsl:text>
50
+ </field>
51
+ <!-- XXX: Handle other institutions -->
52
+ <field name="dct_provenance_s">
53
+ <xsl:text>Stanford</xsl:text>
54
+ </field>
55
+ <field name="dc_type_s">
56
+ <xsl:text>Dataset</xsl:text>
57
+ </field>
58
+ <!-- XXX: Handle other institution naming schemes -->
59
+ <field name="layer_id_s">
60
+ <xsl:text>druid:</xsl:text><xsl:value-of select="$druid"/>
61
+ </field>
62
+ <!-- XXX: Handle other institutions -->
63
+ <field name="layer_slug_s">
64
+ <xsl:text>stanford-</xsl:text><xsl:value-of select="$druid"/>
65
+ </field>
66
+ <xsl:choose>
67
+ <xsl:when test="mods:originInfo/mods:dateIssued">
68
+ <field name="dct_issued_s">
69
+ <xsl:value-of select="mods:originInfo/mods:dateIssued"/>
70
+ </field>
71
+ <field name="solr_year_i">
72
+ <xsl:value-of select="substring(mods:originInfo/mods:dateIssued, 1, 4)"/>
73
+ </field>
74
+ </xsl:when>
75
+ </xsl:choose>
76
+ <field name="dct_temporal_sm">
77
+ <xsl:choose>
78
+ <xsl:when test="mods:subject/mods:temporal">
79
+ <xsl:value-of select="mods:subject/mods:temporal"/>
80
+ </xsl:when>
81
+ </xsl:choose>
82
+ </field>
83
+ <field name="dc_title_s">
84
+ <xsl:value-of select="mods:titleInfo/mods:title[not(@type)]"/>
85
+ </field>
86
+ <xsl:for-each select="mods:extension[@displayLabel='geo']/rdf:RDF/rdf:Description/dc:type">
87
+ <field name="layer_geom_type_s">
88
+ <xsl:choose>
89
+ <xsl:when test="substring(., 9)='LineString'">
90
+ <xsl:text>Line</xsl:text>
91
+ </xsl:when>
92
+ <xsl:otherwise>
93
+ <xsl:value-of select='substring(., 9)'/><!-- strip Dataset# prefix -->
94
+ </xsl:otherwise>
95
+ </xsl:choose>
96
+ </field>
97
+ </xsl:for-each>
98
+ <field name="dc_publisher_s">
99
+ <xsl:value-of select="mods:originInfo/mods:publisher"/>
100
+ </field>
101
+ <xsl:for-each select="mods:name">
102
+ <field name="dc_creator_sm">
103
+ <xsl:value-of select="mods:namePart"/>
104
+ </field>
105
+ </xsl:for-each>
106
+ <field name="dc_description_s">
107
+ <xsl:for-each select="mods:abstract[@displayLabel='Abstract' or @displayLabel='Purpose']/text()">
108
+ <xsl:value-of select="."/>
109
+ </xsl:for-each>
110
+ </field>
111
+ <xsl:for-each select="mods:subject/mods:topic">
112
+ <field name="dc_subject_sm">
113
+ <xsl:choose>
114
+ <xsl:when test="@authority='ISO19115topicCategory'">
115
+ <xsl:value-of select="@valueURI"/>
116
+ </xsl:when>
117
+ <xsl:otherwise>
118
+ <xsl:value-of select="text()"/>
119
+ </xsl:otherwise>
120
+ </xsl:choose>
121
+ </field>
122
+ </xsl:for-each>
123
+ <xsl:for-each select="mods:subject/mods:geographic">
124
+ <field name="dc_spatial_sm">
125
+ <xsl:value-of select="text()"/>
126
+ </field>
127
+ </xsl:for-each>
128
+ <field name="dct_references_sm">
129
+ <xlink type="simple" role="http://schema.org/url">
130
+ <xsl:attribute name="href">
131
+ <xsl:value-of select="$purl"/>
132
+ </xsl:attribute>
133
+ </xlink>
134
+ <xlink type="simple" role="http://www.opengis.net/def/serviceType/ogc/wms">
135
+ <xsl:attribute name="href">
136
+ <xsl:value-of select="$geoserver_root"/>
137
+ <xsl:text>/wms</xsl:text>
138
+ </xsl:attribute>
139
+ </xlink>
140
+ <xlink type="simple" role="http://www.opengis.net/def/serviceType/ogc/wfs">
141
+ <xsl:attribute name="href">
142
+ <xsl:value-of select="$geoserver_root"/>
143
+ <xsl:text>/wfs</xsl:text>
144
+ </xsl:attribute>
145
+ </xlink>
146
+ <xlink type="simple" role="http://www.opengis.net/def/serviceType/ogc/wcs">
147
+ <xsl:attribute name="href">
148
+ <xsl:value-of select="$geoserver_root"/>
149
+ <xsl:text>/wcs</xsl:text>
150
+ </xsl:attribute>
151
+ </xlink>
152
+ </field>
153
+ <xsl:for-each select="mods:extension[@displayLabel='geo']/rdf:RDF/rdf:Description/gml:boundedBy/gml:Envelope">
154
+ <xsl:variable name="x2" select="number(substring-before(gml:upperCorner/text(), ' '))"/><!-- E -->
155
+ <xsl:variable name="x1" select="number(substring-before(gml:lowerCorner/text(), ' '))"/><!-- W -->
156
+ <xsl:variable name="y2" select="number(substring-after(gml:upperCorner/text(), ' '))"/><!-- N -->
157
+ <xsl:variable name="y1" select="number(substring-after(gml:lowerCorner/text(), ' '))"/><!-- S -->
158
+ <field name="georss_polygon_s">
159
+ <xsl:text></xsl:text>
160
+ <xsl:value-of select="$y1"/>
161
+ <xsl:text> </xsl:text>
162
+ <xsl:value-of select="$x1"/>
163
+ <xsl:text> </xsl:text>
164
+ <xsl:value-of select="$y2"/>
165
+ <xsl:text> </xsl:text>
166
+ <xsl:value-of select="$x1"/>
167
+ <xsl:text> </xsl:text>
168
+ <xsl:value-of select="$y2"/>
169
+ <xsl:text> </xsl:text>
170
+ <xsl:value-of select="$x2"/>
171
+ <xsl:text> </xsl:text>
172
+ <xsl:value-of select="$y1"/>
173
+ <xsl:text> </xsl:text>
174
+ <xsl:value-of select="$x2"/>
175
+ <xsl:text> </xsl:text>
176
+ <xsl:value-of select="$y1"/>
177
+ <xsl:text> </xsl:text>
178
+ <xsl:value-of select="$x1"/>
179
+ </field>
180
+ <field name="solr_geom">
181
+ <xsl:text>POLYGON((</xsl:text>
182
+ <xsl:value-of select="$x1"/>
183
+ <xsl:text> </xsl:text>
184
+ <xsl:value-of select="$y1"/>
185
+ <xsl:text>, </xsl:text>
186
+ <xsl:value-of select="$x2"/>
187
+ <xsl:text> </xsl:text>
188
+ <xsl:value-of select="$y1"/>
189
+ <xsl:text>, </xsl:text>
190
+ <xsl:value-of select="$x2"/>
191
+ <xsl:text> </xsl:text>
192
+ <xsl:value-of select="$y2"/>
193
+ <xsl:text>, </xsl:text>
194
+ <xsl:value-of select="$x1"/>
195
+ <xsl:text> </xsl:text>
196
+ <xsl:value-of select="$y2"/>
197
+ <xsl:text>, </xsl:text>
198
+ <xsl:value-of select="$x1"/>
199
+ <xsl:text> </xsl:text>
200
+ <xsl:value-of select="$y1"/>
201
+ <xsl:text>))</xsl:text>
202
+ </field>
203
+ <field name="georss_box_s">
204
+ <xsl:value-of select="$y1"/>
205
+ <xsl:text> </xsl:text>
206
+ <xsl:value-of select="$x1"/>
207
+ <xsl:text> </xsl:text>
208
+ <xsl:value-of select="$y2"/>
209
+ <xsl:text> </xsl:text>
210
+ <xsl:value-of select="$x2"/>
211
+ </field>
212
+ <field name="solr_bbox">
213
+ <xsl:value-of select="$x1"/>
214
+ <xsl:text> </xsl:text>
215
+ <xsl:value-of select="$y1"/>
216
+ <xsl:text> </xsl:text>
217
+ <xsl:value-of select="$x2"/>
218
+ <xsl:text> </xsl:text>
219
+ <xsl:value-of select="$y2"/>
220
+ </field>
221
+ <field name="solr_sw_pt">
222
+ <xsl:value-of select="$y1"/>
223
+ <xsl:text>,</xsl:text>
224
+ <xsl:value-of select="$x1"/>
225
+ </field>
226
+ <field name="solr_ne_pt">
227
+ <xsl:value-of select="$y2"/>
228
+ <xsl:text>,</xsl:text>
229
+ <xsl:value-of select="$x2"/>
230
+ </field>
231
+ <!-- <field name="solr_srs_s">
232
+ <xsl:value-of select="@gml:srsName"/>
233
+ </field> -->
234
+ </xsl:for-each>
235
+ <field name="solr_wms_url">
236
+ <xsl:value-of select="$geoserver_root"/>
237
+ <xsl:text>/wms</xsl:text>
238
+ </field>
239
+ <!-- XXX: need to check for WFS vs WCS -->
240
+ <field name="solr_wfs_url">
241
+ <xsl:value-of select="$geoserver_root"/>
242
+ <xsl:text>/wfs</xsl:text>
243
+ </field>
244
+ </doc>
245
+ </add>
246
+ </xsl:template>
247
+ <xsl:template match="*"/>
248
+ </xsl:stylesheet>
@@ -24,12 +24,11 @@
24
24
  - purl - complete URL with aa111bb1111 (len = 11)
25
25
 
26
26
  -->
27
- <xsl:stylesheet xmlns="http://lucene.apache.org/solr/4/document" xmlns:gco="http://www.isotc211.org/2005/gco" xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:mods="http://www.loc.gov/mods/v3" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" exclude-result-prefixes="gmd gco gml mods rdf xsl">
27
+ <xsl:stylesheet xmlns="http://lucene.apache.org/solr/4/document" xmlns:gml="http://www.opengis.net/gml/3.2/" xmlns:mods="http://www.loc.gov/mods/v3" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" exclude-result-prefixes="gml mods rdf xsl">
28
28
  <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
29
29
  <xsl:strip-space elements="*"/>
30
30
  <xsl:template match="/mods:mods">
31
31
  <xsl:variable name="druid" select="substring($purl, string-length($purl)-10)"/>
32
- <xsl:variable name="datatype" select="substring-after(mods:extension/rdf:RDF[@rdf:type='geo']/rdf:Description[@rdf:type='geo#geometryType']/text(), 'gml:')"/>
33
32
  <add>
34
33
  <doc>
35
34
  <field name="LayerId">
@@ -47,8 +46,8 @@
47
46
  <xsl:value-of select="mods:relatedItem/mods:titleInfo/mods:title"/>
48
47
  </field>
49
48
  <field name="Access">
50
- <!-- REQUIRED -->
51
- <xsl:text>Restricted</xsl:text>
49
+ <!-- REQUIRED: Uses Public due to GIS-7 -->
50
+ <xsl:text>Public</xsl:text>
52
51
  </field>
53
52
  <field name="Institution">
54
53
  <!-- REQUIRED -->
@@ -129,12 +128,10 @@
129
128
  <field name="PlaceKeywords">
130
129
  <xsl:for-each select="mods:subject/mods:geographic">
131
130
  <xsl:value-of select="text()"/>
132
- <xsl:if test="position()!=last()">
133
- <xsl:text>; </xsl:text>
134
- </xsl:if>
131
+ <xsl:text>; </xsl:text>
135
132
  </xsl:for-each>
136
133
  </field>
137
- <xsl:for-each select="mods:extension/rdf:RDF[@rdf:type='geo']/rdf:Description[@rdf:type='geo#boundingBox']/gml:Envelope">
134
+ <xsl:for-each select="mods:extension[@displayLabel='geo']/rdf:RDF/rdf:Description/gml:boundedBy/gml:Envelope">
138
135
  <xsl:variable name="x2" select="number(substring-before(gml:upperCorner/text(), ' '))"/>
139
136
  <xsl:variable name="x1" select="number(substring-before(gml:lowerCorner/text(), ' '))"/>
140
137
  <xsl:variable name="y2" select="number(substring-after(gml:upperCorner/text(), ' '))"/>
@@ -9,6 +9,7 @@ module GeoHydra
9
9
  def self.search_for_xsl(filename)
10
10
  path = %w{
11
11
  lib
12
+ lib/geohydra
12
13
  lib/geomdtk
13
14
  /usr/share/tomcat6/webapps/geonetwork/xsl/conversion/import
14
15
  /var/geonetwork/2.8.0/lib
@@ -27,7 +28,8 @@ module GeoHydra
27
28
  # XSLT file locations
28
29
  XSLT = {
29
30
  :arcgis => self.search_for_xsl('ArcGIS2ISO19139.xsl'),
30
- :arcgis_fc => self.search_for_xsl('arcgis_to_iso19139_fc.xsl')
31
+ :arcgis_fc => self.search_for_xsl('arcgis_to_iso19110.xsl'),
32
+ :arcgis_fgdc=> self.search_for_xsl('ArcGIS2FGDC.xsl')
31
33
  }
32
34
 
33
35
  # XSLT processor
@@ -48,11 +50,15 @@ module GeoHydra
48
50
  # @param [String] fn Input file
49
51
  # @param [String] ofn Output file
50
52
  # @param [String] ofn_fc Output file for the Feature Catalog (optional)
51
- def self.from_arcgis fn, ofn, ofn_fc = nil
53
+ def self.from_arcgis fn, ofn, ofn_fc = nil, ofn_fgdc = nil
52
54
  system("#{XSLTPROC} #{XSLT[:arcgis]} '#{fn}' | #{XMLLINT} -o '#{ofn}' -")
53
55
  unless ofn_fc.nil?
54
56
  system("#{XSLTPROC} #{XSLT[:arcgis_fc]} '#{fn}' | #{XMLLINT} -o '#{ofn_fc}' -")
55
57
  end
58
+ unless ofn_fgdc.nil?
59
+ system("#{XSLTPROC} #{XSLT[:arcgis_fgdc]} '#{fn}' | #{XMLLINT} -o '#{ofn_fgdc}' -")
60
+ end
61
+
56
62
  end
57
63
 
58
64
  # @return [Hash]
@@ -1,6 +1,12 @@
1
1
  require 'druid-tools'
2
2
 
3
3
  module GeoHydra
4
+ class Process
5
+ def run(args)
6
+ raise NotImplementedError
7
+ end
8
+ end
9
+
4
10
  class Utils
5
11
  def self.find_druid_folders(dir = '.')
6
12
  # requires extra * for symlinks to directories