isoxml
Version:
JavaScript library to parse and generate ISOXML (ISO11783-10) files
77 lines (76 loc) • 2.29 kB
JavaScript
import { TAGS } from './constants';
import { registerEntityClass } from '../classRegistry';
import { fromXML, toXML } from '../utils';
export var PolygonPolygonTypeEnum;
(function (PolygonPolygonTypeEnum) {
PolygonPolygonTypeEnum["PartfieldBoundary"] = "1";
PolygonPolygonTypeEnum["TreatmentZone"] = "2";
PolygonPolygonTypeEnum["WaterSurface"] = "3";
PolygonPolygonTypeEnum["Building"] = "4";
PolygonPolygonTypeEnum["Road"] = "5";
PolygonPolygonTypeEnum["Obstacle"] = "6";
PolygonPolygonTypeEnum["Flag"] = "7";
PolygonPolygonTypeEnum["Other"] = "8";
PolygonPolygonTypeEnum["Mainfield"] = "9";
PolygonPolygonTypeEnum["Headland"] = "10";
PolygonPolygonTypeEnum["BufferZone"] = "11";
PolygonPolygonTypeEnum["Windbreak"] = "12";
})(PolygonPolygonTypeEnum || (PolygonPolygonTypeEnum = {}));
const ATTRIBUTES = {
A: {
name: 'PolygonType',
type: 'xs:NMTOKEN',
isPrimaryId: false,
isOptional: false,
isOnlyV4: false,
},
B: {
name: 'PolygonDesignator',
type: 'xs:string',
isPrimaryId: false,
isOptional: true,
isOnlyV4: false,
},
C: {
name: 'PolygonArea',
type: 'xs:unsignedLong',
isPrimaryId: false,
isOptional: true,
isOnlyV4: false,
minValue: 0,
maxValue: 4294967294,
},
D: {
name: 'PolygonColour',
type: 'xs:unsignedByte',
isPrimaryId: false,
isOptional: true,
isOnlyV4: false,
minValue: 0,
maxValue: 254,
},
E: {
name: 'PolygonId',
type: 'xs:ID',
isPrimaryId: true,
isOptional: true,
isOnlyV4: true,
},
};
const CHILD_TAGS = {
LSG: { name: 'LineString', isOnlyV4: false },
};
export class Polygon {
constructor(attributes, isoxmlManager) {
this.attributes = attributes;
this.isoxmlManager = isoxmlManager;
this.tag = TAGS.Polygon;
}
static fromXML(xml, isoxmlManager, internalId, targetClass = Polygon) {
return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId);
}
toXML() {
return toXML(this, ATTRIBUTES, CHILD_TAGS);
}
}
registerEntityClass('main', TAGS.Polygon, Polygon);