-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #131 from stansmith907/dev
Add FGDC CSDGM 1998 reader
- Loading branch information
Showing
48 changed files
with
2,593 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
lib/adiwg/mdtranslator/readers/fgdc/modules/module_attribute.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
# Reader - fgdc to internal data structure | ||
# unpack fgdc entity attribute | ||
|
||
# History: | ||
# Stan Smith 2017-09-06 original script | ||
|
||
require 'uuidtools' | ||
require 'nokogiri' | ||
require 'adiwg/mdtranslator/internal/internal_metadata_obj' | ||
require_relative 'module_enumerated' | ||
require_relative 'module_range' | ||
|
||
module ADIWG | ||
module Mdtranslator | ||
module Readers | ||
module Fgdc | ||
|
||
module Attribute | ||
|
||
def self.unpack(xAttribute, hDictionary, hResponseObj) | ||
|
||
# instance classes needed in script | ||
intMetadataClass = InternalMetadata.new | ||
hAttribute = intMetadataClass.newEntityAttribute | ||
|
||
# entity attribute 5.1.2.1 (attrlabl) - attribute name | ||
# -> dataDictionary.entities.attributes.attributeCode | ||
code = xAttribute.xpath('./attrlabl').text | ||
unless code.empty? | ||
hAttribute[:attributeName] = code | ||
hAttribute[:attributeCode] = code | ||
end | ||
|
||
# entity attribute 5.1.2.2 (attrdef) - attribute definition | ||
# -> dataDictionary.entities.attributes.attributeDefinition | ||
definition = xAttribute.xpath('./attrdef').text | ||
unless definition.empty? | ||
hAttribute[:attributeDefinition] = definition | ||
end | ||
|
||
# entity attribute 5.1.2.3 (attrdefs) - attribute definition source | ||
# -> not mapped | ||
|
||
# entity attribute 5.1.2.4 (attrdomv) - attribute domain value | ||
axDomain = xAttribute.xpath('./attrdomv') | ||
unless axDomain.empty? | ||
hDomain = intMetadataClass.newDictionaryDomain | ||
hDomain[:domainId] = UUIDTools::UUID.random_create.to_s | ||
hDomain[:domainCode] = code | ||
hDomain[:domainDescription] = 'FGDC enumerated domain' | ||
|
||
axDomain.each do |xDomain| | ||
|
||
# entity attribute 5.1.2.4.1 (edom) - enumerated domain | ||
xEnumeration = xDomain.xpath('./edom') | ||
unless xEnumeration.empty? | ||
hItem = Enumerated.unpack(xEnumeration, hResponseObj) | ||
hDomain[:domainItems] << hItem | ||
end | ||
|
||
# entity attribute 5.1.2.4.2 (rdom) - range domain | ||
xRange = xDomain.xpath('./rdom') | ||
unless xRange.empty? | ||
Range.unpack(xRange, hAttribute, hResponseObj) | ||
end | ||
|
||
# entity attribute 5.1.2.4.3 (codesetd) - codeset domain | ||
|
||
# entity attribute 5.1.2.4.3.1 (codesetn) - codeset name | ||
# -> not mapped | ||
|
||
# entity attribute 5.1.2.4.3.2 (codesets) - codeset source | ||
# -> not mapped | ||
|
||
# entity attribute 5.1.2.4.4 (udom) - unrepresentable domain | ||
# -> not mapped | ||
|
||
end | ||
|
||
unless hDomain[:domainItems].empty? | ||
hAttribute[:domainId] = hDomain[:domainId] | ||
hDictionary[:domains] << hDomain | ||
end | ||
|
||
end | ||
|
||
# entity attribute 5.1.2.5 (begdatea) - beginning date of attribute values | ||
# -> not mapped | ||
|
||
# entity attribute 5.1.2.6 (enddatea) - ending date of attribute values | ||
# -> not mapped | ||
|
||
# entity attribute 5.1.2.7 (attrvai) - attribute value accuracy information | ||
|
||
# entity attribute 5.1.2.7.1 (attrva) - attribute value accuracy | ||
# -> not mapped | ||
|
||
# entity attribute 5.1.2.7.2 (attrvae) - attribute value accuracy explanation | ||
# -> not mapped | ||
|
||
hAttribute | ||
|
||
end | ||
|
||
end | ||
|
||
end | ||
end | ||
end | ||
end |
69 changes: 69 additions & 0 deletions
69
lib/adiwg/mdtranslator/readers/fgdc/modules/module_digitalForm.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Reader - fgdc to internal data structure | ||
# unpack fgdc distribution digital form | ||
|
||
# History: | ||
# Stan Smith 2017-09-08 original script | ||
|
||
require 'nokogiri' | ||
require 'adiwg/mdtranslator/internal/internal_metadata_obj' | ||
require_relative 'module_date' | ||
require_relative 'module_transferInfo' | ||
require_relative 'module_onlineOption' | ||
require_relative 'module_offlineOption' | ||
|
||
module ADIWG | ||
module Mdtranslator | ||
module Readers | ||
module Fgdc | ||
|
||
module DigitalForm | ||
|
||
def self.unpack(xDigiForm, hResponseObj) | ||
|
||
# instance classes needed in script | ||
intMetadataClass = InternalMetadata.new | ||
hTransfer = intMetadataClass.newTransferOption | ||
|
||
# distribution 6.4.2.1 (digtinfo) - digital transfer information | ||
xTranInfo = xDigiForm.xpath('./digtinfo') | ||
unless xTranInfo.empty? | ||
TransferInfo.unpack(xTranInfo, hTransfer, hResponseObj) | ||
end | ||
|
||
# distribution 6.4.2.2 (digtopt) - digital transfer option | ||
xDigiOption = xDigiForm.xpath('./digtopt') | ||
unless xDigiOption.empty? | ||
|
||
# distribution 6.4.2.2.1 (onlinopt) - online option [] | ||
axOnlines = xDigiOption.xpath('./onlinopt') | ||
unless axOnlines.empty? | ||
axOnlines.each do |xOnline| | ||
aOnlines = OnlineOption.unpack(xOnline, hResponseObj) | ||
aOnlines.each do |hOnline| | ||
hTransfer[:onlineOptions] << hOnline | ||
end | ||
end | ||
end | ||
|
||
# distribution 6.4.2.2.2 (offoptn) - offline option [] | ||
axOfflines = xDigiOption.xpath('./offoptn') | ||
unless axOfflines.empty? | ||
axOfflines.each do |xOffline| | ||
aOffline = OfflineOption.unpack(xOffline, hResponseObj) | ||
aOffline.each do |hOffline| | ||
hTransfer[:offlineOptions] << hOffline | ||
end | ||
end | ||
end | ||
|
||
end | ||
|
||
return hTransfer | ||
|
||
end | ||
end | ||
|
||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.