Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FGDC CSDGM 1998 reader #131

Merged
merged 23 commits into from
Sep 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d9743a9
Add fgdc reader module 'lineage'
stansmith907 Aug 31, 2017
fd59a38
Add fgdc reader module 'dataQuality'
stansmith907 Aug 31, 2017
4e6593a
Merge remote-tracking branch 'upstream/dev' into dev
stansmith907 Aug 31, 2017
4b1a5ce
Add fgdc reader module 'spatialOrganization'
stansmith907 Sep 4, 2017
4d0415c
Add fgdc reader module 'raster'
stansmith907 Sep 4, 2017
2c27044
Add fgdc reader module 'pointVector'
stansmith907 Sep 4, 2017
659beb7
Add fgdc reader module 'entityAttribute'
stansmith907 Sep 7, 2017
d993e4b
Add fgdc reader module 'attribute'
stansmith907 Sep 7, 2017
463a247
Add fgdc reader module 'entity'
stansmith907 Sep 7, 2017
beb69e0
Add fgdc reader module 'enumerated'
stansmith907 Sep 7, 2017
033f8c0
Add fgdc reader module 'entityOverview'
stansmith907 Sep 7, 2017
19fb748
Add fgdc reader module 'range'
stansmith907 Sep 7, 2017
4ad3ee3
Add fgdc reader module 'digitalForm'
stansmith907 Sep 10, 2017
b8ef15e
Add fgdc reader module 'distribution'
stansmith907 Sep 10, 2017
cff9137
Add fgdc reader module 'offlineOption'
stansmith907 Sep 10, 2017
89a3e36
Add fgdc reader module 'online'
stansmith907 Sep 10, 2017
2c3795f
Add fgdc reader module 'orderProcess'
stansmith907 Sep 10, 2017
4765f19
Add fgdc reader module 'transferInfo'
stansmith907 Sep 10, 2017
739ce6d
Add fgdc reader module 'metadataInfo'
stansmith907 Sep 11, 2017
fcd8221
Add fgdc reader module 'fgdc'
stansmith907 Sep 11, 2017
e911869
Fix missing fgdc schema for HTML writer
stansmith907 Sep 12, 2017
5becf1e
Merge remote-tracking branch 'upstream/dev' into dev
stansmith907 Sep 12, 2017
fe9b802
Bump version
stansmith907 Sep 12, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions lib/adiwg/mdtranslator/internal/internal_metadata_obj.rb
Original file line number Diff line number Diff line change
Expand Up @@ -436,29 +436,6 @@ def newGraphic
}
end

def newSpatialReferenceSystem
{
systemType: nil,
systemIdentifier: {}
}
end

def newSpatialResolution
{
scaleFactor: nil,
measure: {},
levelOfDetail: nil
}
end

def newMeasure
{
type: nil,
value: nil,
unitOfMeasure: nil
}
end

def newExtent
{
description: nil,
Expand Down Expand Up @@ -793,6 +770,29 @@ def newEntityForeignKey
}
end

def newSpatialReferenceSystem
{
systemType: nil,
systemIdentifier: {}
}
end

def newSpatialResolution
{
scaleFactor: nil,
measure: {},
levelOfDetail: nil
}
end

def newMeasure
{
type: nil,
value: nil,
unitOfMeasure: nil
}
end

def newSpatialRepresentation
{
gridRepresentation: {},
Expand Down
1 change: 1 addition & 0 deletions lib/adiwg/mdtranslator/readers/fgdc/fgdc_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Stan Smith 2017-08-10 original script

require 'nokogiri'
require_relative 'version'
require_relative 'modules/module_fgdc'

module ADIWG
Expand Down
110 changes: 110 additions & 0 deletions lib/adiwg/mdtranslator/readers/fgdc/modules/module_attribute.rb
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 lib/adiwg/mdtranslator/readers/fgdc/modules/module_digitalForm.rb
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

require 'nokogiri'
require 'adiwg/mdtranslator/internal/internal_metadata_obj'
require_relative 'module_contact'
require_relative 'module_orderProcess'
require_relative 'module_timePeriod'

module ADIWG
module Mdtranslator
Expand All @@ -14,9 +17,87 @@ module Fgdc

module Distribution

def self.unpack(xDistribution, hResponseObj)
def self.unpack(xDistribution, hResourceInfo, hResponseObj)

# instance classes needed in script
intMetadataClass = InternalMetadata.new
hDistribution = intMetadataClass.newDistribution
hDistributor = intMetadataClass.newDistributor

# distribution 6.1 (distrib) - distributor {contact}
# -> distribution.distributor.contact.responsibility(distributor)
xContact = xDistribution.xpath('./distrib')
unless xContact.empty?
hResponsibility = Contact.unpack(xContact, hResponseObj)
unless hResponsibility.nil?
hResponsibility[:roleName] = 'distributor'
hDistributor[:contact] = hResponsibility
end
end

# distribution 6.2 (resdesc) - resource description
# -> distribution.description
description = xDistribution.xpath('./resdesc').text
unless description.empty?
hDistribution[:description] = description
end

# distribution 6.3 (distliab) - distribution liability
# -> resourceInfo.constraints.legal.otherConstraint
constraint = xDistribution.xpath('./distliab').text
unless constraint.empty?
hConstraint = intMetadataClass.newConstraint
hConstraint[:type] = 'legal'
hLegal = intMetadataClass.newLegalConstraint
hLegal[:otherCons] << constraint
hConstraint[:legalConstraint] = hLegal
hResourceInfo[:constraints] << hConstraint
end

# distribution 6.4 (stdorder) - standard order process []
axOrders = xDistribution.xpath('./stdorder')
unless axOrders.empty?
axOrders.each do |xOrder|
OrderProcess.unpack(xOrder, hDistributor, hResponseObj)
end
end

# distribution 6.5 (custom) - custom order process
# -> distribution.distributor.orderProcess.orderingInstructions
custom = xDistribution.xpath('./custom').text
unless custom.empty?
hOrder = intMetadataClass.newOrderProcess
hOrder[:orderingInstructions] = custom
hDistributor[:orderProcess] << hOrder
end

# distribution 6.6 (techpreq) - technical prerequisites
# -> distribution.description {+=}
techPre = xDistribution.xpath('./techpreq').text
unless techPre.empty?
hDistribution[:description] += '\n\n Technical Prerequisites: ' + techPre
end

# distribution 6.7 (availabl) - available time period {time period}
# -> distribution.distributor.orderProcess.plannedAvailability
xTimePeriod = xDistribution.xpath('./availabl')
unless xTimePeriod.empty?
hTimePeriod = TimePeriod.unpack(xTimePeriod, hResponseObj)
unless hTimePeriod.nil?
if hTimePeriod[:startDateTime].empty?
hDateTime = hTimePeriod[:endDateTime]
else
hDateTime = hTimePeriod[:startDateTime]
end
hDistributor[:orderProcess].each do |hOrder|
hOrder[:plannedAvailability] = hDateTime
end
end
end

hDistribution[:distributor] << hDistributor

return hDistribution

end

Expand Down
Loading