geo_combine 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ module GeoCombine
2
+ class Railtie < Rails::Railtie
3
+ rake_tasks do
4
+ load 'tasks/geo_combine.rake'
5
+ end
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module GeoCombine
2
- VERSION = '0.3.1'
2
+ VERSION = '0.4.0'
3
3
  end
@@ -1,39 +1,63 @@
1
- require 'find'
2
1
  require 'net/http'
3
2
  require 'json'
4
3
  require 'rsolr'
4
+ require 'find'
5
5
 
6
6
  namespace :geocombine do
7
+ commit_within = (ENV['SOLR_COMMIT_WITHIN'] || 5000).to_i
7
8
  ogm_path = ENV['OGM_PATH'] || 'tmp/opengeometadata'
8
9
  solr_url = ENV['SOLR_URL'] || 'http://127.0.0.1:8983/solr/blacklight-core'
9
- desc 'Clone all OpenGeoMetadata repositories'
10
- task :clone do
11
- ogm_api_uri = URI('https://api.github.com/orgs/opengeometadata/repos')
12
- ogm_repos = JSON.parse(Net::HTTP.get(ogm_api_uri)).map{ |repo| repo['git_url']}
10
+ whitelist = %w[
11
+ https://github.com/OpenGeoMetadata/big-ten.git
12
+ ]
13
+
14
+ desc 'Clone OpenGeoMetadata repositories'
15
+ task :clone, [:repo] do |_t, args|
16
+ if args.repo
17
+ ogm_repos = ["https://github.com/OpenGeoMetadata/#{args.repo}.git"]
18
+ else
19
+ ogm_api_uri = URI('https://api.github.com/orgs/opengeometadata/repos')
20
+ ogm_repos = JSON.parse(Net::HTTP.get(ogm_api_uri)).map do |repo|
21
+ repo['clone_url'] if repo['size'] > 0
22
+ end.compact
23
+ ogm_repos.select! { |repo| whitelist.include?(repo) || repo =~ /(edu|org|uk)\..*\.git$/ }
24
+ end
13
25
  ogm_repos.each do |repo|
14
- if repo =~ /^git:\/\/github.com\/OpenGeoMetadata\/(edu|org|uk)\..*/
15
- system "mkdir -p #{ogm_path} && cd #{ogm_path} && git clone --depth 1 #{repo}"
16
- end
26
+ system "echo #{repo} && mkdir -p #{ogm_path} && cd #{ogm_path} && git clone --depth 1 #{repo}"
17
27
  end
18
28
  end
29
+
19
30
  desc '"git pull" OpenGeoMetadata repositories'
20
- task :pull do
21
- Dir.glob("#{ogm_path}/*").map{ |dir| system "cd #{dir} && git pull origin master" if dir =~ /.*(edu|org|uk)\..*./ }
31
+ task :pull, [:repo] do |_t, args|
32
+ paths = if args.repo
33
+ [File.join(ogm_path, args.repo)]
34
+ else
35
+ Dir.glob("#{ogm_path}/*")
36
+ end
37
+ paths.each do |path|
38
+ next unless File.directory?(path)
39
+ system "echo #{path} && cd #{path} && git pull origin"
40
+ end
22
41
  end
23
- desc 'Index all of the GeoBlacklight documents'
42
+
43
+ desc 'Index all of the GeoBlacklight JSON documents'
24
44
  task :index do
25
- solr = RSolr.connect :url => solr_url
45
+ puts "Indexing #{ogm_path} into #{solr_url}"
46
+ solr = RSolr.connect url: solr_url, adapter: :net_http_persistent
26
47
  Find.find(ogm_path) do |path|
27
- next unless path =~ /.*geoblacklight.json$/
48
+ next unless File.basename(path) == 'geoblacklight.json'
28
49
  doc = JSON.parse(File.read(path))
29
- begin
30
- solr.update params: { commitWithin: 500, overwrite: true },
31
- data: [doc].to_json,
32
- headers: { 'Content-Type' => 'application/json' }
33
-
34
- rescue RSolr::Error::Http => error
35
- puts error
50
+ [doc].flatten.each do |record|
51
+ begin
52
+ puts "Indexing #{record['layer_slug_s']}: #{path}" if $DEBUG
53
+ solr.update params: { commitWithin: commit_within, overwrite: true },
54
+ data: [record].to_json,
55
+ headers: { 'Content-Type' => 'application/json' }
56
+ rescue RSolr::Error::Http => error
57
+ puts error
58
+ end
36
59
  end
37
60
  end
61
+ solr.commit
38
62
  end
39
63
  end
@@ -1,12 +1,15 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
3
- <!--
4
- fgdc2html.xsl - Transformation from CDSDGM/FGDC into HTML
3
+ <xsl:output method="html" encoding="utf-8" indent="yes" />
4
+ <!--
5
+ fgdc2html.xsl - Transformation from CSDGM/FGDC into HTML
5
6
  Created by Kim Durante, Stanford University Libraries
6
7
 
7
- -->
8
+ Modified by Keith Jenkins, Cornell University Library, 2018-01-25
9
+ to render attributes in a more readable form.
10
+ -->
8
11
  <xsl:template match="/">
9
- <xsl:text disable-output-escaping='yes'>&lt;!DOCTYPE html></xsl:text>
12
+ <xsl:text disable-output-escaping='yes'>&lt;!DOCTYPE html&gt;</xsl:text>
10
13
  <html>
11
14
  <head>
12
15
  <title>
@@ -64,6 +67,7 @@
64
67
  </body>
65
68
  </html>
66
69
  </xsl:template>
70
+
67
71
  <!-- Identification -->
68
72
  <xsl:template match="idinfo">
69
73
  <div id="fgdc-identification-info">
@@ -335,6 +339,7 @@
335
339
  </dl>
336
340
  </div>
337
341
  </xsl:template>
342
+
338
343
  <!-- Data Quality -->
339
344
  <xsl:template match="dataqual">
340
345
  <div id="fgdc-data-quality-info">
@@ -524,6 +529,7 @@
524
529
  </dl>
525
530
  </div>
526
531
  </xsl:template>
532
+
527
533
  <!-- Spatial Data Organization -->
528
534
  <xsl:template match="spdoinfo">
529
535
  <div id="fgdc-spatialdataorganization-info">
@@ -637,6 +643,7 @@
637
643
  </dl>
638
644
  </div>
639
645
  </xsl:template>
646
+
640
647
  <!-- Spatial Reference -->
641
648
  <xsl:template match="spref">
642
649
  <div id="fgdc-spatialreference-info">
@@ -1112,6 +1119,7 @@
1112
1119
  </dl>
1113
1120
  </div>
1114
1121
  </xsl:template>
1122
+
1115
1123
  <!-- Entity and Attribute -->
1116
1124
  <xsl:template match="eainfo">
1117
1125
  <div id="fgdc-entityattribute-info">
@@ -1145,7 +1153,7 @@
1145
1153
  </dl>
1146
1154
  </dd>
1147
1155
  </xsl:for-each>
1148
- <xsl:apply-templates select="attr" />
1156
+ <xsl:call-template name='attributes' />
1149
1157
  </xsl:for-each>
1150
1158
  <xsl:for-each select="overview">
1151
1159
  <xsl:for-each select="eaover">
@@ -1166,6 +1174,94 @@
1166
1174
  </dl>
1167
1175
  </div>
1168
1176
  </xsl:template>
1177
+
1178
+ <xsl:template name='attributes'>
1179
+ <xsl:if test='attr'>
1180
+ <dt>Attributes</dt>
1181
+ <dd>
1182
+ <dl>
1183
+ <xsl:for-each select="attr">
1184
+ <dt><xsl:value-of select="attrlabl" /></dt>
1185
+ <dd>
1186
+ <xsl:value-of select="attrdef" />
1187
+ <xsl:apply-templates select="attrdomv" />
1188
+ <dl>
1189
+ <xsl:for-each select="begdatea">
1190
+ <dt>Beginning Date of Attribute Values</dt>
1191
+ <dd>
1192
+ <xsl:value-of select="." />
1193
+ </dd>
1194
+ </xsl:for-each>
1195
+ <xsl:for-each select="enddatea">
1196
+ <dt>Ending Date of Attribute Values</dt>
1197
+ <dd>
1198
+ <xsl:value-of select="." />
1199
+ </dd>
1200
+ </xsl:for-each>
1201
+ <xsl:for-each select="attrvai">
1202
+ <xsl:for-each select="attrva">
1203
+ <dt>Attribute Value Accuracy</dt>
1204
+ <dd>
1205
+ <xsl:value-of select="." />
1206
+ </dd>
1207
+ </xsl:for-each>
1208
+ <xsl:for-each select="attrvae">
1209
+ <dt>Attribute Value Accuracy Explanation</dt>
1210
+ <dd>
1211
+ <xsl:value-of select="." />
1212
+ </dd>
1213
+ </xsl:for-each>
1214
+ </xsl:for-each>
1215
+ <xsl:for-each select="attrmfrq">
1216
+ <dt>Attribute Measurement Frequency</dt>
1217
+ <dd>
1218
+ <xsl:value-of select="." />
1219
+ </dd>
1220
+ </xsl:for-each>
1221
+ </dl>
1222
+ </dd>
1223
+ </xsl:for-each>
1224
+ </dl>
1225
+ </dd>
1226
+ </xsl:if>
1227
+ </xsl:template>
1228
+
1229
+ <xsl:template match="attrdomv[codesetd]">
1230
+ <xsl:text> (</xsl:text>
1231
+ <xsl:value-of select="codesetd/codesetn" />
1232
+ <xsl:apply-templates select="codesetd/codesets/text()" />
1233
+ <xsl:text>)</xsl:text>
1234
+ </xsl:template>
1235
+
1236
+ <xsl:template match="attrdomv[edom]">
1237
+ <br />
1238
+ <button onclick="this.nextElementSibling.style.display = (this.nextElementSibling.style.display==='none') ? '' : 'none';">show/hide coded values</button>
1239
+ <dl style="display:none">
1240
+ <xsl:for-each select="edom">
1241
+ <dt><xsl:value-of select="edomv" /></dt>
1242
+ <dd><xsl:value-of select="edomvd" /></dd>
1243
+ </xsl:for-each>
1244
+ </dl>
1245
+ </xsl:template>
1246
+
1247
+ <xsl:template match="attrdomv[rdom]">
1248
+ <xsl:text> (</xsl:text>
1249
+ <xsl:value-of select="rdom/rdommin" />
1250
+ <xsl:text> to </xsl:text>
1251
+ <xsl:value-of select="rdom/rdommax" />
1252
+ <xsl:if test="rdom/attrunit">
1253
+ <xsl:text> </xsl:text>
1254
+ <xsl:value-of select="rdom/attrunit" />
1255
+ </xsl:if>
1256
+ <xsl:text>)</xsl:text>
1257
+ </xsl:template>
1258
+
1259
+ <xsl:template match="attrdomv[udom]">
1260
+ <xsl:text> (</xsl:text>
1261
+ <xsl:value-of select="udom" />
1262
+ <xsl:text>)</xsl:text>
1263
+ </xsl:template>
1264
+
1169
1265
  <!-- Distribution -->
1170
1266
  <xsl:template match="distinfo">
1171
1267
  <div id="fgdc-distribution-info">
@@ -1202,6 +1298,7 @@
1202
1298
  </dl>
1203
1299
  </div>
1204
1300
  </xsl:template>
1301
+
1205
1302
  <!-- Metadata -->
1206
1303
  <xsl:template match="metainfo">
1207
1304
  <div id="fgdc-metadata-reference-info">
@@ -1265,6 +1362,7 @@
1265
1362
  </dl>
1266
1363
  </div>
1267
1364
  </xsl:template>
1365
+
1268
1366
  <!-- Citation -->
1269
1367
  <xsl:template match="citeinfo">
1270
1368
  <dl>
@@ -1362,6 +1460,7 @@
1362
1460
  </xsl:for-each>
1363
1461
  </dl>
1364
1462
  </xsl:template>
1463
+
1365
1464
  <!-- Contact -->
1366
1465
  <xsl:template match="cntinfo">
1367
1466
  <dt>Contact Information</dt>
@@ -1478,6 +1577,7 @@
1478
1577
  </dl>
1479
1578
  </dd>
1480
1579
  </xsl:template>
1580
+
1481
1581
  <!-- Time Period Info -->
1482
1582
  <xsl:template match="timeinfo">
1483
1583
  <dt>Time Period Information</dt>
@@ -1771,156 +1871,4 @@
1771
1871
  <xsl:value-of select="." />
1772
1872
  </dd>
1773
1873
  </xsl:template>
1774
- <xsl:template match="attr">
1775
- <dt>Attribute</dt>
1776
- <dd>
1777
- <dl>
1778
- <xsl:for-each select="attrlabl">
1779
- <dt>Attribute Label</dt>
1780
- <dd>
1781
- <xsl:value-of select="." />
1782
- </dd>
1783
- </xsl:for-each>
1784
- <xsl:for-each select="attrdef">
1785
- <dt>Attribute Definition</dt>
1786
- <dd>
1787
- <xsl:value-of select="." />
1788
- </dd>
1789
- </xsl:for-each>
1790
- <xsl:for-each select="attrdefs">
1791
- <dt>Attribute Definition Source</dt>
1792
- <dd>
1793
- <xsl:value-of select="." />
1794
- </dd>
1795
- </xsl:for-each>
1796
- <xsl:for-each select="attrdomv">
1797
- <dt>Attribute Domain Values</dt>
1798
- <dd>
1799
- <dl>
1800
- <xsl:for-each select="edom">
1801
- <dt>Enumerated Domain</dt>
1802
- <dd>
1803
- <dl>
1804
- <xsl:for-each select="edomv">
1805
- <dt>Enumerated Domain Value</dt>
1806
- <dd>
1807
- <xsl:value-of select="." />
1808
- </dd>
1809
- </xsl:for-each>
1810
- <xsl:for-each select="edomvd">
1811
- <dt>Enumerated Domain Value Definition</dt>
1812
- <dd>
1813
- <xsl:value-of select="." />
1814
- </dd>
1815
- </xsl:for-each>
1816
- <xsl:for-each select="edomvds">
1817
- <dt>Enumerated Domain Value Definition Source</dt>
1818
- <dd>
1819
- <xsl:value-of select="." />
1820
- </dd>
1821
- </xsl:for-each>
1822
- <xsl:apply-templates select="attr" />
1823
- </dl>
1824
- </dd>
1825
- </xsl:for-each>
1826
- <xsl:for-each select="rdom">
1827
- <dt>Range Domain</dt>
1828
- <dd>
1829
- <dl>
1830
- <xsl:for-each select="rdommin">
1831
- <dt>Range Domain Minimum</dt>
1832
- <dd>
1833
- <xsl:value-of select="." />
1834
- </dd>
1835
- </xsl:for-each>
1836
- <xsl:for-each select="rdommax">
1837
- <dt>Range Domain Maximum</dt>
1838
- <dd>
1839
- <xsl:value-of select="." />
1840
- </dd>
1841
- </xsl:for-each>
1842
- <xsl:for-each select="attrunit">
1843
- <dt>Attribute Units of Measure</dt>
1844
- <dd>
1845
- <xsl:value-of select="." />
1846
- </dd>
1847
- </xsl:for-each>
1848
- <xsl:for-each select="attrmres">
1849
- <dt>Attribute Measurement Resolution</dt>
1850
- <dd>
1851
- <xsl:value-of select="." />
1852
- </dd>
1853
- </xsl:for-each>
1854
- <xsl:apply-templates select="attr" />
1855
- </dl>
1856
- </dd>
1857
- </xsl:for-each>
1858
- <xsl:for-each select="codesetd">
1859
- <dt>Codeset Domain</dt>
1860
- <dd>
1861
- <dl>
1862
- <xsl:for-each select="codesetn">
1863
- <dt>Codeset Name</dt>
1864
- <dd>
1865
- <xsl:value-of select="." />
1866
- </dd>
1867
- </xsl:for-each>
1868
- <xsl:for-each select="codesets">
1869
- <dt>Codeset Source</dt>
1870
- <dd>
1871
- <xsl:value-of select="." />
1872
- </dd>
1873
- </xsl:for-each>
1874
- </dl>
1875
- </dd>
1876
- </xsl:for-each>
1877
- <xsl:for-each select="udom">
1878
- <dt>Unrepresentable Domain</dt>
1879
- <dd>
1880
- <xsl:value-of select="." />
1881
- </dd>
1882
- </xsl:for-each>
1883
- </dl>
1884
- </dd>
1885
- </xsl:for-each>
1886
- <xsl:for-each select="begdatea">
1887
- <dt>Beginning Date of Attribute Values</dt>
1888
- <dd>
1889
- <xsl:value-of select="." />
1890
- </dd>
1891
- </xsl:for-each>
1892
- <xsl:for-each select="enddatea">
1893
- <dt>Ending Date of Attribute Values</dt>
1894
- <dd>
1895
- <xsl:value-of select="." />
1896
- </dd>
1897
- </xsl:for-each>
1898
- <xsl:for-each select="attrvai">
1899
- <dt>Attribute Value Accuracy Information</dt>
1900
- <dd>
1901
- <dl>
1902
- <xsl:for-each select="attrva">
1903
- <dt>Attribute Value Accuracy</dt>
1904
- <dd>
1905
- <xsl:value-of select="." />
1906
- </dd>
1907
- </xsl:for-each>
1908
- <xsl:for-each select="attrvae">
1909
- <dt>Attribute Value Accuracy Explanation</dt>
1910
- <dd>
1911
- <xsl:value-of select="." />
1912
- </dd>
1913
- </xsl:for-each>
1914
- </dl>
1915
- </dd>
1916
- </xsl:for-each>
1917
- <xsl:for-each select="attrmfrq">
1918
- <dt>Attribute Measurement Frequency</dt>
1919
- <dd>
1920
- <xsl:value-of select="." />
1921
- </dd>
1922
- </xsl:for-each>
1923
- </dl>
1924
- </dd>
1925
- </xsl:template>
1926
1874
  </xsl:stylesheet>
@@ -0,0 +1,37 @@
1
+ {
2
+ "uuid": "urn:columbia.edu:Columbia.ESRI_Arcatlas_snow_ln",
3
+ "dc_identifier_s": "urn:columbia.edu:Columbia.ESRI_Arcatlas_snow_ln",
4
+ "dc_title_s": "Worldwide Snow Cover (Polygon), 1996",
5
+ "dc_description_s": "Snow Cover (Polygon) is a polyline theme representing rates or snowcover worldwide.",
6
+ "dc_rights_s": "Restricted",
7
+ "dct_provenance_s": "Columbia",
8
+ "dct_references_s": "{\"http://schema.org/downloadUrl\":\"https://www1.columbia.edu/sec/acis/eds/dgate/studies/C1301/data/snow_poly.zip\",\"http://www.w3.org/1999/xhtml\":\"https://geoblacklight-prod.cul.columbia.edu/metadata/fgdc/html/ESRI_Arcatlas_snow_ln.html\",\"http://www.isotc211.org/schemas/2005/gmd/\":\"https://geoblacklight-prod.cul.columbia.edu/metadata/fgdc/current/ESRI_Arcatlas_snow_ln.xml\"}",
9
+ "georss_box_s": "-85.0 -180.0 85.0 180.0",
10
+ "layer_id_s": "sde:columbia.ESRI_Arcatlas_snow_ln",
11
+ "layer_geom_type_s": "Polygon",
12
+ "layer_modified_dt": "2009-06-16T00:00:00Z",
13
+ "layer_slug_s": "sde-columbia-esri_arcatlas_snow_ln",
14
+ "solr_geom": "ENVELOPE(-180.0, 180.0, 85.0, -85.0)",
15
+ "solr_year_i": 1996,
16
+ "dc_creator_sm": [
17
+ "Environmental Systems Research Institute (Redlands, Calif.)"
18
+ ],
19
+ "dc_format_s": "Shapefile",
20
+ "dc_language_s": "",
21
+ "dc_publisher_s": "ESRI",
22
+ "dc_subject_sm": [
23
+ "climatologyMeteorologyAtmosphere"
24
+ ],
25
+ "dc_type_s": "Dataset",
26
+ "dct_spatial_sm": [
27
+ "Earth"
28
+ ],
29
+ "dct_temporal_sm": [
30
+ "1996"
31
+ ],
32
+ "dct_issued_s": "",
33
+ "dct_isPartOf_sm": [
34
+ "ArcAtlas"
35
+ ],
36
+ "georss_polygon_s": "85.0 -180.0 85.0 180.0 -85.0 180.0 -85.0 -180.0 85.0 -180.0"
37
+ }