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.
- checksums.yaml +4 -4
- data/.jsbeautifyrc +8 -0
- data/Rakefile +1 -3
- data/adiwg-mdtranslator.gemspec +2 -0
- data/bin/mdtranslator +2 -2
- data/lib/adiwg/mdtranslator.rb +2 -0
- data/lib/adiwg/mdtranslator/internal/internal_metadata_obj.rb +6 -3
- data/lib/adiwg/mdtranslator/internal/module_geoFormat.rb +183 -190
- data/lib/adiwg/mdtranslator/internal/module_lineString.rb +18 -0
- data/lib/adiwg/mdtranslator/internal/module_point.rb +18 -0
- data/lib/adiwg/mdtranslator/readers/mdJson/modules_v1/module_contacts.rb +3 -1
- data/lib/adiwg/mdtranslator/readers/mdJson/modules_v1/module_geographicElement.rb +18 -10
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_additionalDocumentation.rb +52 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_boundingBox.rb +54 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_browseGraphic.rb +66 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_citation.rb +125 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_contacts.rb +144 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_dateTime.rb +31 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_distributionInfo.rb +64 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_extent.rb +61 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_geoCoordSystem.rb +50 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_geoProperties.rb +91 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_geographicElement.rb +161 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_metadata.rb +70 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_metadataInfo.rb +131 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_onlineResource.rb +71 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_resourceIdentifier.rb +73 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_resourceInfo.rb +437 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_responsibleParty.rb +53 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_sbJson.rb +52 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/version.rb +12 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/readme.md +12 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/sbJson_reader.rb +205 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/sbJson_validator.rb +44 -0
- data/lib/adiwg/mdtranslator/version.rb +1 -2
- data/lib/adiwg/mdtranslator/writers/html/sections/html_browseGraphic.rb +2 -1
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_multiGeometry.rb +5 -5
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_responsibleParty.rb +1 -1
- data/lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb +42 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/readme.md +19 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_additionalDoc.rb +19 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_address.rb +22 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_associatedResource.rb +22 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_attribute.rb +27 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_base.rb +19 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_citation.rb +33 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_constraint.rb +28 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_contact.rb +31 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_coverageInfo.rb +30 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_coverageItem.rb +44 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_dataQuality.rb +32 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_dateTime.rb +18 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_dictionary.rb +33 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_distributionInfo.rb +31 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_domain.rb +25 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_entity.rb +37 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_extent.rb +26 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_format.rb +19 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_geographicElement.rb +81 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_graphicOverview.rb +20 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_gridInfo.rb +27 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_imageInfo.rb +28 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_keyword.rb +20 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_locale.rb +19 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_metadata.rb +30 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_metadataInfo.rb +36 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_onlineResource.rb +21 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_phone.rb +19 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_processStep.rb +25 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_resourceIdentifier.rb +23 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_resourceInfo.rb +69 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_resourceMaintenance.rb +23 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_responsibleParty.rb +18 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_spatialreference.rb +19 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_taxon.rb +19 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_taxonomy.rb +32 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_temporalElement.rb +38 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_timePeriod.rb +20 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_transferOption.rb +33 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_usage.rb +23 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_verticalElement.rb +20 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/version.rb +13 -0
- data/lib/adiwg/mdtranslator/writers/sbJson/readme.md +12 -0
- data/lib/adiwg/mdtranslator/writers/sbJson/sbJson_writer.rb +126 -0
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_base.rb +19 -0
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_contact.rb +42 -0
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_identifier.rb +22 -0
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_spatial.rb +49 -0
- data/lib/adiwg/mdtranslator/writers/sbJson/version.rb +13 -0
- data/test/readers/mdJson/v1/tc_reader_mdjson_translation.rb +83 -0
- data/test/readers/sbJson/v0/tc_reader_sbjson_translation.rb +79 -0
- data/test/readers/sbJson/v0/test.json +431 -0
- data/test/readers/sbJson/v0/test1.json +383 -0
- data/test/writers/mdJson/v1/tc_writer_mdJson.rb +60 -0
- data/test/writers/sbJson/v0/tc_writer_sbJson.rb +60 -0
- metadata +121 -7
- 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56bda3f3511b60925b18d584816a3e469f25dd58
|
4
|
+
data.tar.gz: 98af01b9951ab6ff0232efe89c6f968c3a7ce802
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 857ac692fabf61fa0fb52ef7edfe74c1d02ef8c4f5e85a5214321a1a0fd52131dde74bf5c5b70ce61944ccf1aad16b34c1b5add0f134ad6bbe227e37c057ea5d
|
7
|
+
data.tar.gz: d2b571310bd60303d4f4155b9ca792cc9925fcd77de58186ed2d2f94d25b2394b241536cda288fd58e4c57d60ba0186444ae158b033cfbfaf936cef962f6d7a6
|
data/.jsbeautifyrc
ADDED
data/Rakefile
CHANGED
data/adiwg-mdtranslator.gemspec
CHANGED
@@ -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
|
data/bin/mdtranslator
CHANGED
@@ -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'
|
data/lib/adiwg/mdtranslator.rb
CHANGED
@@ -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
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
37
|
+
# add polygon
|
38
|
+
if geoType == 'Polygon'
|
39
|
+
hGeoJson[:coordinates] = polygon_to_coords(hGeometry)
|
40
|
+
end
|
43
41
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
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
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
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
|
-
|
69
|
+
end
|
74
70
|
|
75
|
-
|
76
|
-
|
77
|
-
|
71
|
+
# return GeoJSON
|
72
|
+
geojson ? hGeoJson.to_json : hGeoJson
|
73
|
+
end
|
78
74
|
|
79
|
-
|
80
|
-
|
75
|
+
# convert internal object polygon format to coordinates
|
76
|
+
def self.polygon_to_coords(hPolygon)
|
77
|
+
aCoordinates = []
|
81
78
|
|
82
|
-
|
83
|
-
|
84
|
-
aCoordinates << aExRing
|
85
|
-
end
|
79
|
+
# add exterior ring
|
80
|
+
aCoordinates << hPolygon[:exteriorRing]
|
86
81
|
|
87
|
-
|
88
|
-
|
82
|
+
# add exclusion rings
|
83
|
+
hPolygon[:exclusionRings].each do |aExRing|
|
84
|
+
aCoordinates << aExRing
|
85
|
+
end
|
89
86
|
|
90
|
-
|
91
|
-
|
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
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
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
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
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
|
-
|
118
|
-
|
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
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
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
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
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
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
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
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
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
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
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
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
end
|
196
|
+
wktString += '), '
|
197
|
+
end
|
198
|
+
wktString.chomp!(', ')
|
199
|
+
wktString += ')'
|
200
|
+
end
|
221
201
|
|
222
|
-
|
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
|