isoxml
Version:
JavaScript library to parse and generate ISOXML (ISO11783-10) files
69 lines (68 loc) • 1.8 kB
JavaScript
import { TAGS } from './constants';
import { registerEntityClass } from '../classRegistry';
import { fromXML, toXML } from '../utils';
const ATTRIBUTES = {
A: {
name: 'ValuePresentationId',
type: 'xs:ID',
isPrimaryId: true,
isOptional: false,
isOnlyV4: false,
},
B: {
name: 'Offset',
type: 'xs:long',
isPrimaryId: false,
isOptional: false,
isOnlyV4: false,
minValue: -2147483648,
maxValue: 2147483647,
},
C: {
name: 'Scale',
type: 'xs:decimal',
isPrimaryId: false,
isOptional: false,
isOnlyV4: false,
minValue: 1e-9,
maxValue: 100000000,
},
D: {
name: 'NumberOfDecimals',
type: 'xs:unsignedByte',
isPrimaryId: false,
isOptional: false,
isOnlyV4: false,
minValue: 0,
maxValue: 7,
},
E: {
name: 'UnitDesignator',
type: 'xs:string',
isPrimaryId: false,
isOptional: true,
isOnlyV4: false,
},
F: {
name: 'ColourLegendIdRef',
type: 'xs:IDREF',
isPrimaryId: false,
isOptional: true,
isOnlyV4: false,
},
};
const CHILD_TAGS = {};
export class ValuePresentation {
constructor(attributes, isoxmlManager) {
this.attributes = attributes;
this.isoxmlManager = isoxmlManager;
this.tag = TAGS.ValuePresentation;
}
static fromXML(xml, isoxmlManager, internalId, targetClass = ValuePresentation) {
return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId);
}
toXML() {
return toXML(this, ATTRIBUTES, CHILD_TAGS);
}
}
registerEntityClass('main', TAGS.ValuePresentation, ValuePresentation);