ilcd

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 11, 2023 License: MIT Imports: 7 Imported by: 2

README

ilcd

This is a Go package for reading ILCD data sets. It currently supports only a subset of the ILCD format but allows very fast and memory efficient extraction of information from the different ILCD data set types.

Usage

Iterating over each data set in an ILCD package

The ilcd.ZipReader provides methods for extracting each data set of a specific type via the Each* functions:

zip, err := ilcd.NewZipReader("an_ILCD_package.zip")
// check err ...
err = zip.EachProcess(func(p *ilcd.Process) bool {
  fmt.Println(p.FullName("en"))
  return true // returning false will stop the iteration
})
Transforming and ILCD package
reader, err := ilcd.NewZipReader("input.zip")
check(err)
writer, err := ilcd.NewZipWriter("output.zip")
check(err)

reader.Map(writer, func(entry *ilcd.ZipFile) (string, []byte) {
  if entry.Type() == ilcd.FlowDataSet {
    data, err := entry.Read()
    check(err)
    return entry.Path(), data
  }
  return "", nil // ignore other data sets
})

check(reader.Close())
check(writer.Close())

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDataSetNotFound indicates that a data set could not be found
	ErrDataSetNotFound = errors.New("data set not found")
)

Functions

func FindUUID

func FindUUID(path string) string

FindUUID returns the UUID from the given path or an empty string if it cannot find it.

func IsContactPath

func IsContactPath(path string) bool

IsContactPath returns true if the given file path or zip entry name is probably a contact data set.

func IsExternalDoc

func IsExternalDoc(path string) bool

IsExternalDoc returns true if the given path is something in the `external_docs` folder.

func IsFlowPath

func IsFlowPath(path string) bool

IsFlowPath returns true if the given file path or zip entry name is probably a flow data set.

func IsFlowPropertyPath

func IsFlowPropertyPath(path string) bool

IsFlowPropertyPath returns true if the given file path or zip entry name is probably a flow property data set.

func IsMethodPath

func IsMethodPath(path string) bool

IsMethodPath returns true if the given file path or zip entry name is probably a LCIA method data set.

func IsModelPath

func IsModelPath(path string) bool

IsModelPath returns true if the given file path or zip entry name is probably a life cycle model data set (of the extended ILCD format).

func IsProcessPath

func IsProcessPath(path string) bool

IsProcessPath returns true if the given file path or zip entry name is probably a process data set.

func IsSourcePath

func IsSourcePath(path string) bool

IsSourcePath returns true if the given file path or zip entry name is probably a source data set.

func IsUnitGroupPath

func IsUnitGroupPath(path string) bool

IsUnitGroupPath returns true if the given file path or zip entry name is probably a unit group data set.

Types

type Category

type Category struct {
	ID     string     `xml:"id,attr,omitempty"`
	Name   string     `xml:"name,attr,omitempty"`
	Childs []Category `xml:"category"`
}

Category contains the information of a category in a category system.

type CategoryList

type CategoryList struct {
	DataType   string     `xml:"dataType,attr,omitempty"`
	Categories []Category `xml:"category"`
}

CategoryList contains the root categories of a category system for a data set type.

type CategorySystem

type CategorySystem struct {
	XMLName       xml.Name       `xml:"CategorySystem"`
	Name          string         `xml:"name,attr,omitempty"`
	CategoryLists []CategoryList `xml:"categories"`
}

CategorySystem contains categories that can be used in the data sets.

func ReadCategoryFile

func ReadCategoryFile(filePath string) (*CategorySystem, error)

ReadCategoryFile reads a category system from the given file.

type Class

type Class struct {
	Level int    `xml:"level,attr"`
	ID    string `xml:"classId1,attr"`
	Name  string `xml:",chardata"`
}

Class is a category in an ILCD data set classification.

type Classification

type Classification struct {
	Name    string  `xml:"name,attr"`
	Classes []Class `xml:"class"`
}

Classification describes an ILCD classification entry in a data set

func (*Classification) GetClass

func (c *Classification) GetClass(level int) *Class

GetClass returns the class with the given level from the classification.

type CommonDataEntry

type CommonDataEntry struct {
	TimeStamp   string `xml:"timeStamp"`
	DataFormats []Ref  `xml:"referenceToDataSetFormat"`
}

CommonDataEntry <dataEntryBy>

type CommonPublication

type CommonPublication struct {
	Version string `xml:"dataSetVersion"`
	URI     string `xml:"permanentDataSetURI"`
}

CommonPublication <publicationAndOwnership>

type Compartment

type Compartment struct {
	Level int    `xml:"level,attr"`
	Name  string `xml:",chardata"`
}

A Compartment is a category in an ILCD elementary flow categorization. Note that the tag names in ILCD are elementaryFlowCategorization > category

type Contact

type Contact struct {
	XMLName     xml.Name           `xml:"contactDataSet"`
	Info        *ContactInfo       `xml:"contactInformation>dataSetInformation"`
	DataEntry   *CommonDataEntry   `xml:"administrativeInformation>dataEntryBy"`
	Publication *CommonPublication `xml:"administrativeInformation>publicationAndOwnership"`
}

Contact represents an ILCD contact data set

func ReadContact

func ReadContact(data []byte) (*Contact, error)

ReadContact reads a contact data set from the given data

func ReadContactFile

func ReadContactFile(filePath string) (*Contact, error)

ReadContactFile reads a contact data set from the given file

func (*Contact) UUID

func (c *Contact) UUID() string

UUID returns the UUID of the data set.

func (*Contact) Version

func (c *Contact) Version() string

Version returns the version of the data set.

type ContactInfo

type ContactInfo struct {
	UUID            string           `xml:"UUID"`
	ShortName       LangString       `xml:"shortName"`
	Name            LangString       `xml:"name"`
	Classifications []Classification `xml:"classificationInformation>classification"`
	Address         LangString       `xml:"contactAddress"`
	Email           string           `xml:"email,omitempty"`
	URL             string           `xml:"WWWAddress,omitempty"`
	Comment         LangString       `xml:"contactDescriptionOrComment"`
}

ContactInfo <dataSetInformation>

type DataSet

type DataSet interface {
	UUID() string
	Version() string
}

DataSet contains the common functions of all data set types.

type DataSetType

type DataSetType int

DataSetType is an enumeration type of the different ILCD data set types.

const (
	ModelDataSet DataSetType = iota + 1
	ProcessDataSet
	MethodDataSet
	FlowDataSet
	FlowPropertyDataSet
	UnitGroupDataSet
	SourceDataSet
	ContactDataSet

	// External documents that can be linked to source data sets.
	ExternalDoc

	// Assets are all the additional things that may occur in an ILCD package
	// like XML schemas, style sheets, etc.
	Asset
)

The ILCD data set types

func DataSetTypes

func DataSetTypes() []DataSetType

DataSetTypes returns a list with all possible data set types.

func Type

func Type(ds DataSet) DataSetType

Type returns the type of the given data set.

func (DataSetType) Folder

func (t DataSetType) Folder() string

Folder returns the name of the folder where data sets of the given type are stored in an ILCD package.

func (DataSetType) String

func (t DataSetType) String() string
type DownstreamLink struct {
	InputFlow  string `xml:"flowUUID,attr"`
	ProcessID  int    `xml:"id,attr"`
	Location   string `xml:"location,attr,omitempty"`
	IsDominant *bool  `xml:"dominant,attr,omitempty"`
}

A DownstreamLink links the output of a process to an input of another process in a life cylce model.

type Exchange

type Exchange struct {
	InternalID      int     `xml:"dataSetInternalID,attr"`
	Flow            *Ref    `xml:"referenceToFlowDataSet"`
	Direction       string  `xml:"exchangeDirection"`
	MeanAmount      float64 `xml:"meanAmount"`
	Variable        string  `xml:"referenceToVariable,omitempty"`
	ResultingAmount float64 `xml:"resultingAmount"`
	Location        string  `xml:"location"`
}

Exchange is an input or output of an ILCD process data set. Note that an exchange has a MeanAmount and ResultingAmount. Both values are the same if the exchange has no reference to a variable. Otherwise the ResultingAmount is calculated via the formula: ResultingAmount = MeanAmount * Variable.

type Flow

type Flow struct {
	XMLName        xml.Name           `xml:"flowDataSet"`
	Info           *FlowInfo          `xml:"flowInformation>dataSetInformation"`
	QRef           int                `xml:"flowInformation>quantitativeReference>referenceToReferenceFlowProperty"`
	Type           string             `xml:"modellingAndValidation>LCIMethod>typeOfDataSet"`
	DataEntry      *CommonDataEntry   `xml:"administrativeInformation>dataEntryBy"`
	Publication    *CommonPublication `xml:"administrativeInformation>publicationAndOwnership"`
	FlowProperties []FlowPropertyRef  `xml:"flowProperties>flowProperty"`
}

Flow represents an ILCD flow data set

func ReadFlow

func ReadFlow(data []byte) (*Flow, error)

ReadFlow reads a LCIA method data set from the given data.

func ReadFlowFile

func ReadFlowFile(filePath string) (*Flow, error)

ReadFlowFile reads a flow data set from the given file.

func (*Flow) FlowType

func (f *Flow) FlowType() FlowType

FlowType returns the flow type constant of the flow.

func (*Flow) ReferenceFlowProperty

func (f *Flow) ReferenceFlowProperty() *FlowPropertyRef

ReferenceFlowProperty returns the reference to the reference flow property of the flow.

func (*Flow) UUID

func (f *Flow) UUID() string

UUID returns the UUID of the data set.

func (*Flow) Version

func (f *Flow) Version() string

Version returns the version of the data set.

type FlowInfo

type FlowInfo struct {
	UUID            string           `xml:"UUID"`
	Name            *FlowName        `xml:"name"`
	Synonyms        LangString       `xml:"synonyms"`
	Classifications []Classification `xml:"classificationInformation>classification"`
	Compartments    []Compartment    `xml:"classificationInformation>elementaryFlowCategorization>category"`
	CAS             string           `xml:"CASNumber"`
	Comment         LangString       `xml:"generalComment"`
}

FlowInfo contains the general flow information

type FlowName

type FlowName struct {
	BaseName       LangString `xml:"baseName"`
	Treatment      LangString `xml:"treatmentStandardsRoutes"`
	MixAndLocation LangString `xml:"mixAndLocationTypes"`
	Properties     LangString `xml:"flowProperties"`
}

FlowName contains the name fields of a flow.

type FlowProperty

type FlowProperty struct {
	XMLName     xml.Name           `xml:"flowPropertyDataSet"`
	Info        *FlowPropertyInfo  `xml:"flowPropertiesInformation>dataSetInformation"`
	UnitGroup   *Ref               `xml:"flowPropertiesInformation>quantitativeReference>referenceToReferenceUnitGroup"`
	DataEntry   *CommonDataEntry   `xml:"administrativeInformation>dataEntryBy"`
	Publication *CommonPublication `xml:"administrativeInformation>publicationAndOwnership"`
}

FlowProperty represents an ILCD flow property data set.

func ReadFlowProperty

func ReadFlowProperty(data []byte) (*FlowProperty, error)

ReadFlowProperty reads a flow property data set from the given data.

func ReadFlowPropertyFile

func ReadFlowPropertyFile(filePath string) (*FlowProperty, error)

ReadFlowPropertyFile reads a flow property data set from the given file.

func (*FlowProperty) UUID

func (fp *FlowProperty) UUID() string

UUID returns the UUID of the data set.

func (*FlowProperty) Version

func (fp *FlowProperty) Version() string

Version returns the version of the data set.

type FlowPropertyInfo

type FlowPropertyInfo struct {
	UUID            string           `xml:"UUID"`
	Name            LangString       `xml:"name"`
	Classifications []Classification `xml:"classificationInformation>classification"`
	Comment         LangString       `xml:"generalComment"`
}

FlowPropertyInfo contains the general flow property information

type FlowPropertyRef

type FlowPropertyRef struct {
	ID           int        `xml:"dataSetInternalID,attr"`
	FlowProperty *Ref       `xml:"referenceToFlowPropertyDataSet"`
	Mean         float64    `xml:"meanValue"`
	Comment      LangString `xml:"generalComment"`
}

FlowPropertyRef describes a flow property of a flow.

type FlowType

type FlowType int

FlowType is an enumeration type of the different ILCD flow types.

const (
	ElementaryFlow FlowType = iota + 1
	ProductFlow
	WasteFlow
	OtherFlow
)

Enumaration constants for the ILCD flow types.

func (FlowType) String

func (ft FlowType) String() string

type ImpactFactor

type ImpactFactor struct {
	Flow           *Ref    `xml:"referenceToFlowDataSet"`
	Direction      string  `xml:"exchangeDirection"`
	MeanValue      float64 `xml:"meanValue"`
	DataDerivation string  `xml:"dataDerivationTypeStatus"`
	Location       string  `xml:"location"`
}

ImpactFactor :<characterisationFactors/factor>

type LangString

type LangString []LangStringItem

LangString is an ILCD multi-language string

func (LangString) Default

func (ls LangString) Default() string

Default returns the default value of a multi-language string which is the English string (code = "en") or the first string in the list.

func (LangString) Get

func (ls LangString) Get(lang string) string

Get returns the value for the given language code

type LangStringItem

type LangStringItem struct {
	Value string `xml:",chardata"`
	Lang  string `xml:"lang,attr"`
}

LangStringItem represents an item in an ILCD multi-language string

type MemStore

type MemStore struct {
	// contains filtered or unexported fields
}

func NewMemStore

func NewMemStore() *MemStore

func (*MemStore) Contact

func (store *MemStore) Contact(id string) *Contact

func (*MemStore) Contacts

func (store *MemStore) Contacts() []*Contact

func (*MemStore) EachContact

func (store *MemStore) EachContact(fn func(*Contact) bool)

func (*MemStore) EachFlow

func (store *MemStore) EachFlow(fn func(*Flow) bool)

func (*MemStore) EachFlowProperty

func (store *MemStore) EachFlowProperty(fn func(*FlowProperty) bool)

func (*MemStore) EachMethod

func (store *MemStore) EachMethod(fn func(*Method) bool)

func (*MemStore) EachModel

func (store *MemStore) EachModel(fn func(*Model) bool)

func (*MemStore) EachProcess

func (store *MemStore) EachProcess(fn func(*Process) bool)

func (*MemStore) EachSource

func (store *MemStore) EachSource(fn func(*Source) bool)

func (*MemStore) EachUnitGroup

func (store *MemStore) EachUnitGroup(fn func(*UnitGroup) bool)

func (*MemStore) FillFromZip

func (store *MemStore) FillFromZip(reader *ZipReader) error

func (*MemStore) Flow

func (store *MemStore) Flow(id string) *Flow

func (*MemStore) FlowProperties

func (store *MemStore) FlowProperties() []*FlowProperty

func (*MemStore) FlowProperty

func (store *MemStore) FlowProperty(id string) *FlowProperty

func (*MemStore) Flows

func (store *MemStore) Flows() []*Flow

func (*MemStore) Method

func (store *MemStore) Method(id string) *Method

func (*MemStore) Methods

func (store *MemStore) Methods() []*Method

func (*MemStore) Model

func (store *MemStore) Model(id string) *Model

func (*MemStore) Models

func (store *MemStore) Models() []*Model

func (*MemStore) Process

func (store *MemStore) Process(id string) *Process

func (*MemStore) Processes

func (store *MemStore) Processes() []*Process

func (*MemStore) Source

func (store *MemStore) Source(id string) *Source

func (*MemStore) Sources

func (store *MemStore) Sources() []*Source

func (*MemStore) UnitGroup

func (store *MemStore) UnitGroup(id string) *UnitGroup

func (*MemStore) UnitGroups

func (store *MemStore) UnitGroups() []*UnitGroup

type Method

type Method struct {
	XMLName     xml.Name           `xml:"LCIAMethodDataSet"`
	Info        *MethodInfo        `xml:"LCIAMethodInformation>dataSetInformation"`
	RefQuantity *Ref               `xml:"LCIAMethodInformation>quantitativeReference>referenceQuantity"`
	DataEntry   *CommonDataEntry   `xml:"administrativeInformation>dataEntryBy"`
	Publication *CommonPublication `xml:"administrativeInformation>publicationAndOwnership"`
	Factors     []ImpactFactor     `xml:"characterisationFactors>factor"`
}

Method contains the information of an ILCD LCIA method data set.

func ReadMethod

func ReadMethod(data []byte) (*Method, error)

ReadMethod reads a LCIA method data set from the given data.

func ReadMethodFile

func ReadMethodFile(filePath string) (*Method, error)

ReadMethodFile reads a LCIA method data set from the given file.

func (*Method) UUID

func (m *Method) UUID() string

UUID returns the UUID of the data set.

func (*Method) Version

func (m *Method) Version() string

Version returns the version of the data set.

type MethodInfo

type MethodInfo struct {
	UUID            string     `xml:"UUID"`
	Name            LangString `xml:"name"`
	Methodology     string     `xml:"methodology"`
	ImpactCategory  string     `xml:"impactCategory"`
	ImpactIndicator string     `xml:"impactIndicator"`
	Comment         LangString `xml:"generalComment"`
	ExternalDocs    []Ref      `xml:"referenceToExternalDocumentation"`
}

MethodInfo :<dataSetInformation>

type Model

type Model struct {
	XMLName     xml.Name           `xml:"lifeCycleModelDataSet"`
	Info        *ProcessInfo       `xml:"lifeCycleModelInformation>dataSetInformation"`
	QRef        *int               `xml:"lifeCycleModelInformation>quantitativeReference>referenceToReferenceProcess"`
	Processes   []ProcessInstance  `xml:"lifeCycleModelInformation>technology>processes>processInstance"`
	DataEntry   *CommonDataEntry   `xml:"administrativeInformation>dataEntryBy"`
	Publication *CommonPublication `xml:"administrativeInformation>publicationAndOwnership"`
}

Model represents a life cycle model data set of the extended ILCD (eILCD) format.

func ReadModel

func ReadModel(data []byte) (*Model, error)

ReadModel reads a life cycle model from the given data.

func ReadModelFile

func ReadModelFile(filePath string) (*Model, error)

ReadModelFile reads a life cycle model from the given file.

func (*Model) FindProviders

func (m *Model) FindProviders(pi *ProcessInstance) []*ProcessInstance

FindProviders searches for the processes that are linked to the inputs of the given process in the life cycle model.

In the eILCD format, the output (downstream) connections of a process are stored. This method searches for connections in the other (upstream) direction: processes that provide an input to the given process.

func (*Model) FullName

func (m *Model) FullName(lang string) string

FullName returns the full name of the life cylce model for the given language whith all name parts concatenated to a single string.

func (*Model) RefProcess

func (m *Model) RefProcess() *ProcessInstance

RefProcess returns the reference process (instance) of the life cycle model.

func (*Model) UUID

func (m *Model) UUID() string

UUID returns the UUID of the data set.

func (*Model) Version

func (m *Model) Version() string

Version returns the version of the data set.

type ModelParameter

type ModelParameter struct {
	Name  string  `xml:"name,attr"`
	Value float64 `xml:",chardata"`
}

A ModelParameter is a parameter of a process instance in a life cycle model.

type Parameter

type Parameter struct {
	Name    string     `xml:"name,attr"`
	Formula string     `xml:"formula,omitempty"`
	Value   float64    `xml:"meanValue"`
	SD95    float64    `xml:"relativeStandardDeviation95In"`
	Comment LangString `xml:"comment"`
}

Parameter contains the information of a process parameter or variable under the tag <variableParameter>

type Process

type Process struct {
	XMLName     xml.Name           `xml:"processDataSet"`
	Info        *ProcessInfo       `xml:"processInformation>dataSetInformation"`
	QRefs       []int              `xml:"processInformation>quantitativeReference>referenceToReferenceFlow"`
	Location    *ProcessLocation   `xml:"processInformation>geography>locationOfOperationSupplyOrProduction"`
	Parameters  []Parameter        `xml:"processInformation>mathematicalRelations>variableParameter"`
	DataEntry   *CommonDataEntry   `xml:"administrativeInformation>dataEntryBy"`
	Publication *CommonPublication `xml:"administrativeInformation>publicationAndOwnership"`
	Exchanges   []Exchange         `xml:"exchanges>exchange"`
}

Process represents an ILCD process data set

func ReadProcess

func ReadProcess(data []byte) (*Process, error)

ReadProcess reads a process data set from the given data

func ReadProcessFile

func ReadProcessFile(filePath string) (*Process, error)

ReadProcessFile reads a process data set from the given file.

func (*Process) FullName

func (p *Process) FullName(lang string) string

FullName returns the full name of the process for the given language whith all name parts concatenated to a single string.

func (*Process) RefFlows

func (p *Process) RefFlows() []*Exchange

RefFlows returns the exchanges that are defined as quantitative refeferences of the process. In most cases this should be just one exchange.

func (*Process) UUID

func (p *Process) UUID() string

UUID returns the UUID of the data set.

func (*Process) Version

func (p *Process) Version() string

Version returns the version of the data set.

type ProcessConnection

type ProcessConnection struct {
	OutputFlow string           `xml:"flowUUID,attr"`
	IsDominant *bool            `xml:"dominant,attr,omitempty"`
	Links      []DownstreamLink `xml:"downstreamProcess"`
}

ProcessConnection describes a connection between two processes in a life cycle model.

type ProcessInfo

type ProcessInfo struct {
	UUID            string           `xml:"UUID"`
	Name            *ProcessName     `xml:"name"`
	Synonyms        LangString       `xml:"synonyms"`
	Classifications []Classification `xml:"classificationInformation>classification"`
	Comment         LangString       `xml:"generalComment"`
}

ProcessInfo contains the general process information

type ProcessInstance

type ProcessInstance struct {
	InternalID           int                 `xml:"dataSetInternalID,attr"`
	MultiplicationFactor float64             `xml:"multiplicationFactor,attr"`
	Process              *Ref                `xml:"referenceToProcess"`
	ScalingFactor        *float64            `xml:"scalingFactor,omitempty"`
	Connections          []ProcessConnection `xml:"connections>outputExchange"`
	Parameters           []ModelParameter    `xml:"parameters>parameter"`
}

ProcessInstance describes a process reference together with its connections in a life cycle model.

type ProcessLocation

type ProcessLocation struct {
	Code        string     `xml:"location,attr"`
	LatLong     string     `xml:"latitudeAndLongitude,attr"`
	Description LangString `xml:"descriptionOfRestrictions"`
}

ProcessLocation contains the information of a process location.

type ProcessName

type ProcessName struct {
	BaseName       LangString `xml:"baseName"`
	Treatment      LangString `xml:"treatmentStandardsRoutes"`
	MixAndLocation LangString `xml:"mixAndLocationTypes"`
	Properties     LangString `xml:"functionalUnitFlowProperties"`
}

ProcessName contains the name fields of a process.

type Ref

type Ref struct {
	UUID    string     `xml:"refObjectId,attr"`
	Type    string     `xml:"type,attr"`
	URI     string     `xml:"uri,attr"`
	Version string     `xml:"version,attr"`
	Name    LangString `xml:"shortDescription"`
}

Ref is a data set reference to an ILCD data set.

func (*Ref) DataSetType

func (ref *Ref) DataSetType() DataSetType

DataSetType returns the type of the data set referenced as defined in the ILCD schema.

type Source

type Source struct {
	XMLName     xml.Name           `xml:"sourceDataSet"`
	Info        *SourceInfo        `xml:"sourceInformation>dataSetInformation"`
	DataEntry   *CommonDataEntry   `xml:"administrativeInformation>dataEntryBy"`
	Publication *CommonPublication `xml:"administrativeInformation>publicationAndOwnership"`
}

Source represents an ILCD source data set

func ReadSource

func ReadSource(data []byte) (*Source, error)

ReadSource reads a source data set from the given data

func ReadSourceFile

func ReadSourceFile(filePath string) (*Source, error)

ReadSourceFile reads a source data set from the given file

func (*Source) UUID

func (s *Source) UUID() string

UUID returns the UUID of the data set.

func (*Source) Version

func (s *Source) Version() string

Version returns the version of the data set.

type SourceInfo

type SourceInfo struct {
	UUID            string           `xml:"UUID"`
	ShortName       LangString       `xml:"shortName"`
	Classifications []Classification `xml:"classificationInformation>classification"`
	Citation        string           `xml:"sourceCitation,omitempty"`
	PublicationType string           `xml:"publicationType,omitempty"`
}

SourceInfo <dataSetInformation>

type Unit

type Unit struct {
	InternalID int     `xml:"dataSetInternalID,attr"`
	Name       string  `xml:"name"`
	Factor     float64 `xml:"meanValue"`
}

Unit contains the information of a <unit> element in an unit group data set.

type UnitGroup

type UnitGroup struct {
	XMLName     xml.Name           `xml:"unitGroupDataSet"`
	Info        *UnitGroupInfo     `xml:"unitGroupInformation>dataSetInformation"`
	QRef        int                `xml:"unitGroupInformation>quantitativeReference>referenceToReferenceUnit"`
	DataEntry   *CommonDataEntry   `xml:"administrativeInformation>dataEntryBy"`
	Publication *CommonPublication `xml:"administrativeInformation>publicationAndOwnership"`
	Units       []Unit             `xml:"units>unit"`
}

UnitGroup represents an ILCD unit group data set

func ReadUnitGroup

func ReadUnitGroup(data []byte) (*UnitGroup, error)

ReadUnitGroup reads a unit group data set from the given data

func ReadUnitGroupFile

func ReadUnitGroupFile(filePath string) (*UnitGroup, error)

ReadUnitGroupFile reads a unit group data set from the given file

func (*UnitGroup) ReferenceUnit

func (ug *UnitGroup) ReferenceUnit() *Unit

ReferenceUnit returns the reference unit of an unit group.

func (*UnitGroup) UUID

func (ug *UnitGroup) UUID() string

UUID returns the UUID of the data set.

func (*UnitGroup) Version

func (ug *UnitGroup) Version() string

Version returns the version of the data set.

type UnitGroupInfo

type UnitGroupInfo struct {
	UUID            string           `xml:"UUID"`
	Name            LangString       `xml:"name"`
	Classifications []Classification `xml:"classificationInformation>classification"`
	Comment         LangString       `xml:"generalComment"`
}

UnitGroupInfo <dataSetInformation>

type ZipFile

type ZipFile struct {
	// contains filtered or unexported fields
}

ZipFile embedds the type `File` from the `archive/zip` package and provides additional ILCD specific methods.

func (*ZipFile) Path

func (f *ZipFile) Path() string

Path returns the path of the zip file within the zip package.

func (*ZipFile) Read

func (f *ZipFile) Read() ([]byte, error)

Reads the decompressed data from the zip file.

func (*ZipFile) ReadContact

func (f *ZipFile) ReadContact() (*Contact, error)

ReadContact reads a Contact data set from the zip file.

func (*ZipFile) ReadFlow

func (f *ZipFile) ReadFlow() (*Flow, error)

ReadFlow reads a Flow data set from the zip file.

func (*ZipFile) ReadFlowProperty

func (f *ZipFile) ReadFlowProperty() (*FlowProperty, error)

ReadFlowProperty reads a FlowProperty data set from the zip file.

func (*ZipFile) ReadMethod

func (f *ZipFile) ReadMethod() (*Method, error)

ReadMethod reads a Method data set from the zip file.

func (*ZipFile) ReadModel

func (f *ZipFile) ReadModel() (*Model, error)

ReadModel reads a life cycle model data set from the zip file.

func (*ZipFile) ReadProcess

func (f *ZipFile) ReadProcess() (*Process, error)

ReadProcess reads a Process data set from the zip file.

func (*ZipFile) ReadSource

func (f *ZipFile) ReadSource() (*Source, error)

ReadSource reads a Source data set from the zip file.

func (*ZipFile) ReadUnitGroup

func (f *ZipFile) ReadUnitGroup() (*UnitGroup, error)

ReadUnitGroup reads a UnitGroup data set from the zip file.

func (*ZipFile) Type

func (f *ZipFile) Type() DataSetType

Type returns the ILCD data set type of the zip file which is inferred from the path of the zip file.

type ZipReader

type ZipReader struct {
	// contains filtered or unexported fields
}

ZipReader can read data sets from ILCD packages.

func NewZipReader

func NewZipReader(filePath string) (*ZipReader, error)

NewZipReader creates a new package reader.

func (*ZipReader) Close

func (r *ZipReader) Close() error

Close closes the pack reader.

func (*ZipReader) EachContact

func (r *ZipReader) EachContact(fn func(*Contact) bool) error

EachContact iterates over each Contact data set in the package unless the given handler returns false.

func (*ZipReader) EachFile

func (r *ZipReader) EachFile(fn func(f *ZipFile) bool)

EachFile calls the given function for each file in the zip package. It stops when the function returns false or when there are no more files in the package.

func (*ZipReader) EachFlow

func (r *ZipReader) EachFlow(fn func(*Flow) bool) error

EachFlow iterates over each Flow data set in the package unless the given handler returns false.

func (*ZipReader) EachFlowProperty

func (r *ZipReader) EachFlowProperty(fn func(*FlowProperty) bool) error

EachFlowProperty iterates over each FlowProperty data set in the package unless the given handler returns false.

func (*ZipReader) EachMethod

func (r *ZipReader) EachMethod(fn func(*Method) bool) error

EachMethod iterates over each Method data set in the package unless the given handler returns false.

func (*ZipReader) EachModel

func (r *ZipReader) EachModel(fn func(*Model) bool) error

EachModel iterates over each life cycle model in the package unless the given handler returns false.

func (*ZipReader) EachProcess

func (r *ZipReader) EachProcess(fn func(*Process) bool) error

EachProcess iterates over each Process data set in the package unless the given handler returns false.

func (*ZipReader) EachSource

func (r *ZipReader) EachSource(fn func(*Source) bool) error

EachSource iterates over each Source data set in the package unless the given handler returns false.

func (*ZipReader) EachUnitGroup

func (r *ZipReader) EachUnitGroup(fn func(*UnitGroup) bool) error

EachUnitGroup iterates over each UnitGroup data set in the package unless the given handler returns false.

func (*ZipReader) FindDataSet

func (r *ZipReader) FindDataSet(dsType DataSetType, uuid string) *ZipFile

FindDataSet searches for a data set of the give type and with the given uuid and returns the corresponding zip file. If nothing is found, it returns nil.

func (*ZipReader) Map

func (r *ZipReader) Map(w *ZipWriter, fn func(file *ZipFile) (string, []byte))

Map applies the given function to all entries in the zip file and writes the function's output to the given writer.

The result of a function call is the path and the data that should be written to the writer. If the path or data are empty, nothing will be written. The given function is executed in a separate Go routine.

type ZipWriter

type ZipWriter struct {
	// contains filtered or unexported fields
}

ZipWriter provides functions to write ILCD zip packages

func NewZipWriter

func NewZipWriter(filePath string) (*ZipWriter, error)

NewZipWriter creates a new ZipWriter.

func (*ZipWriter) Close

func (w *ZipWriter) Close() error

Close closes the underlying zip file.

func (*ZipWriter) Path

func (w *ZipWriter) Path(ds DataSet) string

Path calculates the path of the zip entry of the given data set.

func (*ZipWriter) Write

func (w *ZipWriter) Write(path string, data []byte) error

Write writes the given data under the given path into the zip package.

func (*ZipWriter) WriteDataSet

func (w *ZipWriter) WriteDataSet(ds DataSet) error

WriteDataSet writes the given data set to the zip package.

func (*ZipWriter) WriteFile

func (w *ZipWriter) WriteFile(f *ZipFile) error

WriteFile writes the data from the given ZipFile to this package. It also takes the path of the given ZipFile as storage location.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL