isoxml
Version:
JavaScript library to parse and generate ISOXML (ISO11783-10) files
81 lines (80 loc) • 2.54 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Polygon = exports.PolygonPolygonTypeEnum = void 0;
const constants_1 = require("./constants");
const classRegistry_1 = require("../classRegistry");
const utils_1 = require("../utils");
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 || (exports.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 },
};
class Polygon {
constructor(attributes, isoxmlManager) {
this.attributes = attributes;
this.isoxmlManager = isoxmlManager;
this.tag = constants_1.TAGS.Polygon;
}
static fromXML(xml, isoxmlManager, internalId, targetClass = Polygon) {
return (0, utils_1.fromXML)(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId);
}
toXML() {
return (0, utils_1.toXML)(this, ATTRIBUTES, CHILD_TAGS);
}
}
exports.Polygon = Polygon;
(0, classRegistry_1.registerEntityClass)('main', constants_1.TAGS.Polygon, Polygon);