adiwg-mdtranslator 1.3.0 → 1.4.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/.jsbeautifyrc +8 -0
  3. data/Rakefile +1 -3
  4. data/adiwg-mdtranslator.gemspec +2 -0
  5. data/bin/mdtranslator +2 -2
  6. data/lib/adiwg/mdtranslator.rb +2 -0
  7. data/lib/adiwg/mdtranslator/internal/internal_metadata_obj.rb +6 -3
  8. data/lib/adiwg/mdtranslator/internal/module_geoFormat.rb +183 -190
  9. data/lib/adiwg/mdtranslator/internal/module_lineString.rb +18 -0
  10. data/lib/adiwg/mdtranslator/internal/module_point.rb +18 -0
  11. data/lib/adiwg/mdtranslator/readers/mdJson/modules_v1/module_contacts.rb +3 -1
  12. data/lib/adiwg/mdtranslator/readers/mdJson/modules_v1/module_geographicElement.rb +18 -10
  13. data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_additionalDocumentation.rb +52 -0
  14. data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_boundingBox.rb +54 -0
  15. data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_browseGraphic.rb +66 -0
  16. data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_citation.rb +125 -0
  17. data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_contacts.rb +144 -0
  18. data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_dateTime.rb +31 -0
  19. data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_distributionInfo.rb +64 -0
  20. data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_extent.rb +61 -0
  21. data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_geoCoordSystem.rb +50 -0
  22. data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_geoProperties.rb +91 -0
  23. data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_geographicElement.rb +161 -0
  24. data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_metadata.rb +70 -0
  25. data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_metadataInfo.rb +131 -0
  26. data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_onlineResource.rb +71 -0
  27. data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_resourceIdentifier.rb +73 -0
  28. data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_resourceInfo.rb +437 -0
  29. data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_responsibleParty.rb +53 -0
  30. data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_sbJson.rb +52 -0
  31. data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/version.rb +12 -0
  32. data/lib/adiwg/mdtranslator/readers/sbJson/readme.md +12 -0
  33. data/lib/adiwg/mdtranslator/readers/sbJson/sbJson_reader.rb +205 -0
  34. data/lib/adiwg/mdtranslator/readers/sbJson/sbJson_validator.rb +44 -0
  35. data/lib/adiwg/mdtranslator/version.rb +1 -2
  36. data/lib/adiwg/mdtranslator/writers/html/sections/html_browseGraphic.rb +2 -1
  37. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_multiGeometry.rb +5 -5
  38. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_responsibleParty.rb +1 -1
  39. data/lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb +42 -0
  40. data/lib/adiwg/mdtranslator/writers/mdJson/readme.md +19 -0
  41. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_additionalDoc.rb +19 -0
  42. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_address.rb +22 -0
  43. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_associatedResource.rb +22 -0
  44. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_attribute.rb +27 -0
  45. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_base.rb +19 -0
  46. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_citation.rb +33 -0
  47. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_constraint.rb +28 -0
  48. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_contact.rb +31 -0
  49. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_coverageInfo.rb +30 -0
  50. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_coverageItem.rb +44 -0
  51. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_dataQuality.rb +32 -0
  52. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_dateTime.rb +18 -0
  53. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_dictionary.rb +33 -0
  54. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_distributionInfo.rb +31 -0
  55. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_domain.rb +25 -0
  56. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_entity.rb +37 -0
  57. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_extent.rb +26 -0
  58. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_format.rb +19 -0
  59. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_geographicElement.rb +81 -0
  60. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_graphicOverview.rb +20 -0
  61. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_gridInfo.rb +27 -0
  62. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_imageInfo.rb +28 -0
  63. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_keyword.rb +20 -0
  64. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_locale.rb +19 -0
  65. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_metadata.rb +30 -0
  66. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_metadataInfo.rb +36 -0
  67. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_onlineResource.rb +21 -0
  68. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_phone.rb +19 -0
  69. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_processStep.rb +25 -0
  70. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_resourceIdentifier.rb +23 -0
  71. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_resourceInfo.rb +69 -0
  72. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_resourceMaintenance.rb +23 -0
  73. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_responsibleParty.rb +18 -0
  74. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_spatialreference.rb +19 -0
  75. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_taxon.rb +19 -0
  76. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_taxonomy.rb +32 -0
  77. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_temporalElement.rb +38 -0
  78. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_timePeriod.rb +20 -0
  79. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_transferOption.rb +33 -0
  80. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_usage.rb +23 -0
  81. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_verticalElement.rb +20 -0
  82. data/lib/adiwg/mdtranslator/writers/mdJson/version.rb +13 -0
  83. data/lib/adiwg/mdtranslator/writers/sbJson/readme.md +12 -0
  84. data/lib/adiwg/mdtranslator/writers/sbJson/sbJson_writer.rb +126 -0
  85. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_base.rb +19 -0
  86. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_contact.rb +42 -0
  87. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_identifier.rb +22 -0
  88. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_spatial.rb +49 -0
  89. data/lib/adiwg/mdtranslator/writers/sbJson/version.rb +13 -0
  90. data/test/readers/mdJson/v1/tc_reader_mdjson_translation.rb +83 -0
  91. data/test/readers/sbJson/v0/tc_reader_sbjson_translation.rb +79 -0
  92. data/test/readers/sbJson/v0/test.json +431 -0
  93. data/test/readers/sbJson/v0/test1.json +383 -0
  94. data/test/writers/mdJson/v1/tc_writer_mdJson.rb +60 -0
  95. data/test/writers/sbJson/v0/tc_writer_sbJson.rb +60 -0
  96. metadata +121 -7
  97. data/test/readers/mdJson/v1/tc_translation_19115_2.rb +0 -67
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0c9c38bce8eb28f8f717ca37d09e30519bbef40d
4
- data.tar.gz: 85551feb2d6388a9debe63352b6bcd38d209d4f5
3
+ metadata.gz: 56bda3f3511b60925b18d584816a3e469f25dd58
4
+ data.tar.gz: 98af01b9951ab6ff0232efe89c6f968c3a7ce802
5
5
  SHA512:
6
- metadata.gz: c3c61a184344ed5340fad65398fac03bd5efb7f8e1f368a20717a3931d9bd4c0d784e7283d57473b72d0580ff8789b0fc157930bc061b49d9da3f9c644d6639c
7
- data.tar.gz: 6027a62b7c3116e947c32dc6dbd9602243fc7748ecf5c3a9d228da28acd183228850ad1885ba5d26c79d3cd510e043ca1925ed8efd629ae8203603a6816e3af2
6
+ metadata.gz: 857ac692fabf61fa0fb52ef7edfe74c1d02ef8c4f5e85a5214321a1a0fd52131dde74bf5c5b70ce61944ccf1aad16b34c1b5add0f134ad6bbe227e37c057ea5d
7
+ data.tar.gz: d2b571310bd60303d4f4155b9ca792cc9925fcd77de58186ed2d2f94d25b2394b241536cda288fd58e4c57d60ba0186444ae158b033cfbfaf936cef962f6d7a6
@@ -0,0 +1,8 @@
1
+ {
2
+ "ruby": {
3
+ "indent_size": 2,
4
+ "indent_char": " ",
5
+ "indent_level": 0,
6
+ "indent_with_tabs": false
7
+ }
8
+ }
data/Rakefile CHANGED
@@ -4,12 +4,10 @@ require 'rake/testtask'
4
4
  Rake::TestTask.new do |t|
5
5
  t.libs << 'test'
6
6
  t.test_files = FileList[
7
- 'test/readers/mdJson/v1/tc*.rb'
7
+ 'test/**/tc*.rb'
8
8
  ]
9
9
  t.verbose = true
10
10
  end
11
11
 
12
12
  desc 'Run tests'
13
13
  task :default => :test
14
-
15
-
@@ -32,5 +32,7 @@ Gem::Specification.new do |spec|
32
32
  spec.add_runtime_dependency "json-schema", "~> 2.4.0", "< 2.5.0"
33
33
  spec.add_runtime_dependency "adiwg-mdjson_schemas", "~> 1.0"
34
34
  spec.add_runtime_dependency "adiwg-mdcodes", "~> 1.0"
35
+ spec.add_runtime_dependency "jbuilder", "~> 2.5"
36
+ spec.add_runtime_dependency "rgeo", "~> 0.5"
35
37
 
36
38
  end
@@ -30,8 +30,8 @@ file with options to select the input reader format, writer output format, displ
30
30
  in XML outputs, and choose level of validation for mdJson input files.
31
31
  LONGDESC
32
32
  # define cli options
33
- method_option :reader, :aliases => '-r', :desc => 'Reader to read your input metadata file', :enum => %w{mdJson}, :required => true
34
- method_option :writer, :aliases => '-w', :desc => 'Writer to create your output metadata file, leave blank to validate input only', :enum => %w{iso19115_2 iso19110 html}
33
+ method_option :reader, :aliases => '-r', :desc => 'Reader to read your input metadata file', :enum => %w{mdJson sbJson}, :required => true
34
+ method_option :writer, :aliases => '-w', :desc => 'Writer to create your output metadata file, leave blank to validate input only', :enum => %w{iso19115_2 iso19110 html mdJson sbJson}
35
35
  method_option :validate, :aliases => '-v', :desc => 'Specify level of validation to be performed', :enum => %w{none normal strict}, :default => 'normal'
36
36
  method_option :showAllTags, :aliases => '-s', :desc => 'Include tags for unused attributes', :type => :boolean, :default => false
37
37
  method_option :messages, :aliases => '-m', :desc => 'On error return messages as formatted text or json object', :enum => %w{json text}, :default => 'text'
@@ -31,6 +31,8 @@ require 'adiwg/mdtranslator/internal/internal_metadata_obj'
31
31
  require 'adiwg/mdtranslator/internal/module_dateTimeFun'
32
32
  require 'adiwg/mdtranslator/internal/module_geoFormat'
33
33
  require 'adiwg/mdtranslator/internal/module_coordinates'
34
+ require 'adiwg/mdtranslator/internal/module_point'
35
+ require 'adiwg/mdtranslator/internal/module_lineString'
34
36
 
35
37
  module ADIWG
36
38
  module Mdtranslator
@@ -92,7 +92,8 @@ class InternalMetadata
92
92
  phones: [],
93
93
  address: {},
94
94
  onlineRes: [],
95
- contactInstructions: nil
95
+ contactInstructions: nil,
96
+ internal: false
96
97
  }
97
98
  end
98
99
 
@@ -330,6 +331,7 @@ class InternalMetadata
330
331
  def newGeoElement
331
332
  intObj = {
332
333
  elementId: nil,
334
+ elementType: nil,
333
335
  elementIncludeData: nil,
334
336
  elementName: nil,
335
337
  elementDescription: nil,
@@ -530,7 +532,8 @@ class InternalMetadata
530
532
  dictCitation: {},
531
533
  dictDescription: nil,
532
534
  dictResourceType: nil,
533
- dictLanguage: nil
535
+ dictLanguage: nil,
536
+ includedWithDataset: nil
534
537
  }
535
538
  end
536
539
 
@@ -695,4 +698,4 @@ class InternalMetadata
695
698
  }
696
699
  end
697
700
 
698
- end
701
+ end
@@ -6,221 +6,214 @@
6
6
  # Stan Smith 2015-04-10 mapped bounding box as geojson feature and wkt polygon
7
7
 
8
8
  module AdiwgGeoFormat
9
+ def self.internal_to_geoJson(hGeoEle, geojson = true)
10
+ geoType = hGeoEle[:elementGeometry][:geoType]
11
+ hGeometry = hGeoEle[:elementGeometry][:geometry]
12
+ hSRS = hGeoEle[:elementSrs]
13
+
14
+ # GeoJson structure as hash
15
+ hGeoJson = {}
16
+
17
+ # add type
18
+ hGeoJson[:type] = geoType
19
+
20
+ # add bounding box
21
+ if geoType == 'BoundingBox'
22
+ hGeoJson[:type] = 'Feature'
23
+ hGeoJson[:bbox] = [hGeometry[:westLong], hGeometry[:southLat],
24
+ hGeometry[:eastLong], hGeometry[:northLat]]
25
+ hGeoJson[:geometry] = nil
26
+ hGeoJson[:properties] = nil
27
+ end
9
28
 
10
- def self.internal_to_geoJson(hGeoEle)
11
-
12
- geoType = hGeoEle[:elementGeometry][:geoType]
13
- hGeometry = hGeoEle[:elementGeometry][:geometry]
14
- hSRS = hGeoEle[:elementSrs]
15
-
16
- # GeoJson structure as hash
17
- hGeoJson = Hash.new()
18
-
19
- # add type
20
- hGeoJson[:type] = geoType
21
-
22
- # add bounding box
23
- if geoType == 'BoundingBox'
24
- hGeoJson[:type] = 'Feature'
25
- hGeoJson[:bbox] = [hGeometry[:westLong],hGeometry[:southLat],
26
- hGeometry[:eastLong],hGeometry[:northLat]]
27
- hGeoJson[:geometry] = nil
28
- hGeoJson[:properties] = nil
29
- end
30
-
31
- # add point, multi-point, linestring, multi-linestring
32
- if geoType == 'Point' ||
33
- geoType == 'MultiPoint' ||
34
- geoType == 'LineString' ||
35
- geoType == 'MultiLineString'
36
- hGeoJson[:coordinates] = hGeometry
37
- end
29
+ # add point, multi-point, linestring, multi-linestring
30
+ if geoType == 'Point' ||
31
+ geoType == 'MultiPoint' ||
32
+ geoType == 'LineString' ||
33
+ geoType == 'MultiLineString'
34
+ hGeoJson[:coordinates] = hGeometry
35
+ end
38
36
 
39
- # add polygon
40
- if geoType == 'Polygon'
41
- hGeoJson[:coordinates] = polygon_to_coords(hGeometry)
42
- end
37
+ # add polygon
38
+ if geoType == 'Polygon'
39
+ hGeoJson[:coordinates] = polygon_to_coords(hGeometry)
40
+ end
43
41
 
44
- # add multi-polygon
45
- if geoType == 'MultiPolygon'
46
- hGeoJson[:coordinates] = []
47
- hGeometry.each do |hPolygon|
48
- hGeoJson[:coordinates] << polygon_to_coords(hPolygon)
49
- end
50
- end
42
+ # add multi-polygon
43
+ if geoType == 'MultiPolygon'
44
+ hGeoJson[:coordinates] = []
45
+ hGeometry.each do |hPolygon|
46
+ hGeoJson[:coordinates] << polygon_to_coords(hPolygon)
47
+ end
48
+ end
51
49
 
52
- # add coordinate reference system
53
- if !hSRS.empty?
54
- hGeoJson[:crs] = {}
55
-
56
- # if srs name is provided use crs name format
57
- sName = hSRS[:srsName]
58
- sLink = hSRS[:srsHref]
59
- if !sName.nil?
60
- hGeoJson[:crs][:type] = 'name'
61
- hGeoJson[:crs][:properties]= {}
62
- hGeoJson[:crs][:properties][:name] = sName
63
- elsif !sLink.nil?
64
- hGeoJson[:crs][:type] = 'link'
65
- hGeoJson[:crs][:properties]= {}
66
- hGeoJson[:crs][:properties][:href] = sLink
67
- sType = hSRS[:srsType]
68
- if !sType.nil?
69
- hGeoJson[:crs][:properties][:type] = sType
70
- end
71
- end
50
+ # add coordinate reference system
51
+ unless hSRS.empty?
52
+ hGeoJson[:crs] = {}
53
+
54
+ # if srs name is provided use crs name format
55
+ sName = hSRS[:srsName]
56
+ sLink = hSRS[:srsHref]
57
+ if !sName.nil?
58
+ hGeoJson[:crs][:type] = 'name'
59
+ hGeoJson[:crs][:properties] = {}
60
+ hGeoJson[:crs][:properties][:name] = sName
61
+ elsif !sLink.nil?
62
+ hGeoJson[:crs][:type] = 'link'
63
+ hGeoJson[:crs][:properties] = {}
64
+ hGeoJson[:crs][:properties][:href] = sLink
65
+ sType = hSRS[:srsType]
66
+ hGeoJson[:crs][:properties][:type] = sType unless sType.nil?
67
+ end
72
68
 
73
- end
69
+ end
74
70
 
75
- # convert internal object polygon format to coordinates
76
- def self.polygon_to_coords(hPolygon)
77
- aCoordinates = []
71
+ # return GeoJSON
72
+ geojson ? hGeoJson.to_json : hGeoJson
73
+ end
78
74
 
79
- # add exterior ring
80
- aCoordinates << hPolygon[:exteriorRing]
75
+ # convert internal object polygon format to coordinates
76
+ def self.polygon_to_coords(hPolygon)
77
+ aCoordinates = []
81
78
 
82
- # add exclusion rings
83
- hPolygon[:exclusionRings].each do |aExRing|
84
- aCoordinates << aExRing
85
- end
79
+ # add exterior ring
80
+ aCoordinates << hPolygon[:exteriorRing]
86
81
 
87
- return aCoordinates
88
- end
82
+ # add exclusion rings
83
+ hPolygon[:exclusionRings].each do |aExRing|
84
+ aCoordinates << aExRing
85
+ end
89
86
 
90
- # return GeoJSON
91
- return hGeoJson.to_json
87
+ aCoordinates
88
+ end
89
+
90
+ def self.internal_to_wkt(hGeoEle)
91
+ geoType = hGeoEle[:geoType]
92
+ hGeometry = hGeoEle[:geometry]
93
+ dimension = hGeoEle[:dimension]
94
+ wktString = ''
95
+
96
+ if geoType == 'BoundingBox'
97
+ wktString = 'POLYGON ('
98
+ wktString += '(' + hGeometry[:westLong].to_s + ' ' + hGeometry[:northLat].to_s + '), '
99
+ wktString += '(' + hGeometry[:eastLong].to_s + ' ' + hGeometry[:northLat].to_s + '), '
100
+ wktString += '(' + hGeometry[:eastLong].to_s + ' ' + hGeometry[:southLat].to_s + '), '
101
+ wktString += '(' + hGeometry[:westLong].to_s + ' ' + hGeometry[:southLat].to_s + '), '
102
+ wktString += '(' + hGeometry[:westLong].to_s + ' ' + hGeometry[:northLat].to_s + ')'
103
+ wktString += ')'
104
+ end
92
105
 
106
+ if geoType == 'Point'
107
+ wktString = 'POINT ' + wkt_dimension(dimension) + '('
108
+ wktString += point_string(hGeometry)
109
+ wktString += ')'
93
110
  end
94
111
 
95
- def self.internal_to_wkt(hGeoEle)
96
- geoType = hGeoEle[:geoType]
97
- hGeometry = hGeoEle[:geometry]
98
- dimension = hGeoEle[:dimension]
99
- wktString = ''
100
-
101
- if geoType == 'BoundingBox'
102
- wktString = 'POLYGON ('
103
- wktString += '(' + hGeometry[:westLong].to_s + ' ' + hGeometry[:northLat].to_s + '), '
104
- wktString += '(' + hGeometry[:eastLong].to_s + ' ' + hGeometry[:northLat].to_s + '), '
105
- wktString += '(' + hGeometry[:eastLong].to_s + ' ' + hGeometry[:southLat].to_s + '), '
106
- wktString += '(' + hGeometry[:westLong].to_s + ' ' + hGeometry[:southLat].to_s + '), '
107
- wktString += '(' + hGeometry[:westLong].to_s + ' ' + hGeometry[:northLat].to_s + ')'
108
- wktString += ')'
109
- end
112
+ if geoType == 'LineString'
113
+ wktString = 'LINESTRING ' + wkt_dimension(dimension) + '('
114
+ hGeometry.each do |point|
115
+ wktString += point_string(point) + ', '
116
+ end
117
+ wktString.chomp!(', ')
118
+ wktString += ')'
119
+ end
110
120
 
111
- if geoType == 'Point'
112
- wktString = 'POINT ' + wkt_dimension(dimension) + '('
113
- wktString += point_string(hGeometry)
114
- wktString += ')'
121
+ if geoType == 'Polygon'
122
+ wktString = 'POLYGON ' + wkt_dimension(dimension) + '('
123
+
124
+ # add exterior ring - required
125
+ wktString += '('
126
+ aExtRing = hGeometry[:exteriorRing]
127
+ aExtRing.each do |point|
128
+ wktString += point_string(point) + ', '
129
+ end
130
+ wktString.chomp!(', ')
131
+ wktString += ')'
132
+
133
+ # add any exclusion rings
134
+ aExcRings = hGeometry[:exclusionRings]
135
+ aExcRings.each do |excPolygon|
136
+ wktString += ', ('
137
+ excPolygon.each do |point|
138
+ wktString += point_string(point) + ', '
115
139
  end
140
+ wktString.chomp!(', ')
141
+ wktString += ')'
142
+ end
116
143
 
117
- if geoType == 'LineString'
118
- wktString = 'LINESTRING ' + wkt_dimension(dimension) + '('
119
- hGeometry.each do |point|
120
- wktString += point_string(point) + ', '
121
- end
122
- wktString.chomp!(', ')
123
- wktString += ')'
124
- end
144
+ wktString += ')'
145
+ end
125
146
 
126
- if geoType == 'Polygon'
127
- wktString = 'POLYGON ' + wkt_dimension(dimension) + '('
128
-
129
- # add exterior ring - required
130
- wktString += '('
131
- aExtRing = hGeometry[:exteriorRing]
132
- aExtRing.each do |point|
133
- wktString += point_string(point) + ', '
134
- end
135
- wktString.chomp!(', ')
136
- wktString += ')'
137
-
138
- # add any exclusion rings
139
- aExcRings = hGeometry[:exclusionRings]
140
- aExcRings.each do |excPolygon|
141
- wktString += ', ('
142
- excPolygon.each do |point|
143
- wktString += point_string(point) + ', '
144
- end
145
- wktString.chomp!(', ')
146
- wktString += ')'
147
- end
148
-
149
- wktString += ')'
150
- end
147
+ if geoType == 'MultiPoint'
148
+ wktString = 'MULTIPOINT ' + wkt_dimension(dimension) + '('
149
+ hGeometry.each do |point|
150
+ wktString += '('
151
+ wktString += point_string(point) + '), '
152
+ end
153
+ wktString.chomp!(', ')
154
+ wktString += ')'
155
+ end
151
156
 
152
- if geoType == 'MultiPoint'
153
- wktString = 'MULTIPOINT ' + wkt_dimension(dimension) + '('
154
- hGeometry.each do |point|
155
- wktString += '('
156
- wktString += point_string(point) + '), '
157
- end
158
- wktString.chomp!(', ')
159
- wktString += ')'
157
+ if geoType == 'MultiLineString'
158
+ wktString = 'MULTILINESTRING ' + wkt_dimension(dimension) + '('
159
+ hGeometry.each do |line|
160
+ wktString += '('
161
+ line.each do |point|
162
+ wktString += point_string(point) + ', '
160
163
  end
164
+ wktString.chomp!(', ')
165
+ wktString += '), '
166
+ end
167
+ wktString.chomp!(', ')
168
+ wktString += ')'
169
+ end
161
170
 
162
- if geoType == 'MultiLineString'
163
- wktString = 'MULTILINESTRING ' + wkt_dimension(dimension) + '('
164
- hGeometry.each do |line|
165
- wktString += '('
166
- line.each do |point|
167
- wktString += point_string(point) + ', '
168
- end
169
- wktString.chomp!(', ')
170
- wktString += '), '
171
- end
172
- wktString.chomp!(', ')
173
- wktString += ')'
174
- end
171
+ if geoType == 'MultiPolygon'
172
+ wktString = 'MULTIPOLYGON ' + wkt_dimension(dimension) + '('
173
+ hGeometry.each do |polygon|
174
+ wktString += '('
175
175
 
176
- if geoType == 'MultiPolygon'
177
- wktString = 'MULTIPOLYGON ' + wkt_dimension(dimension) + '('
178
- hGeometry.each do |polygon|
179
- wktString += '('
180
-
181
- # add exterior ring - required
182
- wktString += '('
183
- aExtRing = polygon[:exteriorRing]
184
- aExtRing.each do |point|
185
- wktString += point_string(point) + ', '
186
- end
187
- wktString.chomp!(', ')
188
- wktString += ')'
189
-
190
- # add any exclusion rings
191
- aExcRings = polygon[:exclusionRings]
192
- aExcRings.each do |excPolygon|
193
- wktString += ', ('
194
- excPolygon.each do |point|
195
- wktString += point_string(point) + ', '
196
- end
197
- wktString.chomp!(', ')
198
- wktString += ')'
199
- end
200
-
201
- wktString += '), '
202
- end
203
- wktString.chomp!(', ')
204
- wktString += ')'
176
+ # add exterior ring - required
177
+ wktString += '('
178
+ aExtRing = polygon[:exteriorRing]
179
+ aExtRing.each do |point|
180
+ wktString += point_string(point) + ', '
205
181
  end
206
-
207
- def self.point_string(aTuple)
208
- sTuple = ''
209
- aTuple.each do |element|
210
- sTuple += element.to_s + ' '
211
- end
212
- return sTuple.chomp(' ')
182
+ wktString.chomp!(', ')
183
+ wktString += ')'
184
+
185
+ # add any exclusion rings
186
+ aExcRings = polygon[:exclusionRings]
187
+ aExcRings.each do |excPolygon|
188
+ wktString += ', ('
189
+ excPolygon.each do |point|
190
+ wktString += point_string(point) + ', '
191
+ end
192
+ wktString.chomp!(', ')
193
+ wktString += ')'
213
194
  end
214
195
 
215
- def self.wkt_dimension(dim)
216
- sDim = ''
217
- sDim += 'Z ' if dim == 3
218
- sDim += 'ZM ' if dim == 4
219
- return sDim
220
- end
196
+ wktString += '), '
197
+ end
198
+ wktString.chomp!(', ')
199
+ wktString += ')'
200
+ end
221
201
 
222
- return wktString
202
+ wktString
203
+ end
223
204
 
205
+ def self.point_string(aTuple)
206
+ sTuple = ''
207
+ aTuple.each do |element|
208
+ sTuple += element.to_s + ' '
224
209
  end
225
-
210
+ sTuple.chomp(' ')
211
+ end
212
+
213
+ def self.wkt_dimension(dim)
214
+ sDim = ''
215
+ sDim += 'Z ' if dim == 3
216
+ sDim += 'ZM ' if dim == 4
217
+ sDim
218
+ end
226
219
  end