Comparing version 1.9.8 to 1.10.0
@@ -10,5 +10,15 @@ import { ISOXMLManager } from '../ISOXMLManager'; | ||
static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId: string): Promise<Entity>; | ||
addGridFromGeoJSON(geoJSON: FeatureCollection, DDI: number, deviceElemRef?: ISOXMLReference, vpnRef?: ISOXMLReference): void; | ||
private findFreeTZNCode; | ||
/** Adds Grid and corresponding TreatmentZones to the Task. | ||
* | ||
* Implementation notes: | ||
* - this function doesn't remove any existing TreatmentZones from the task, it just adds new TZNs. | ||
* - TZN codes are generated automatically. | ||
* - if OutOfFieldTreatmentZone in the task is not defined, | ||
* it will be created using outOfFieldValue (which is 0 by default) | ||
* - if defaultTreatmentValue or positionLostValue are defined, corresponding TZNs will be created and used | ||
*/ | ||
addGridFromGeoJSON(geoJSON: FeatureCollection, DDI: number, deviceElemRef?: ISOXMLReference, vpnRef?: ISOXMLReference, defaultTreatmentValue?: number, positionLostValue?: number, outOfFieldValue?: number): void; | ||
getGridAsGeoJSON(): FeatureCollection; | ||
getGridValuesDescription(): ValueInformation[]; | ||
} |
@@ -14,18 +14,53 @@ import { registerEntityClass } from '../classRegistry'; | ||
} | ||
addGridFromGeoJSON(geoJSON, DDI, deviceElemRef, vpnRef) { | ||
const processDataVariable = this.isoxmlManager.createEntityFromAttributes(TAGS.ProcessDataVariable, Object.assign(Object.assign({ ProcessDataDDI: DDIToString(DDI), ProcessDataValue: 0 }, deviceElemRef && { DeviceElementIdRef: deviceElemRef }), vpnRef && { ValuePresentationIdRef: vpnRef })); | ||
this.attributes.TreatmentZone = [ | ||
this.isoxmlManager.createEntityFromAttributes(TAGS.TreatmentZone, { | ||
TreatmentZoneCode: 0, | ||
ProcessDataVariable: [processDataVariable] | ||
}), | ||
this.isoxmlManager.createEntityFromAttributes(TAGS.TreatmentZone, { | ||
TreatmentZoneCode: 1, | ||
ProcessDataVariable: [processDataVariable] | ||
}) | ||
]; | ||
this.attributes.OutOfFieldTreatmentZoneCode = 0; | ||
findFreeTZNCode() { | ||
var _a; | ||
const tznCodes = new Set((_a = this.attributes.TreatmentZone) === null || _a === void 0 ? void 0 : _a.map(tzn => tzn.attributes.TreatmentZoneCode)); | ||
for (let i = 0; i < 255; i++) { | ||
if (!tznCodes.has(i)) { | ||
return i; | ||
} | ||
} | ||
} | ||
/** Adds Grid and corresponding TreatmentZones to the Task. | ||
* | ||
* Implementation notes: | ||
* - this function doesn't remove any existing TreatmentZones from the task, it just adds new TZNs. | ||
* - TZN codes are generated automatically. | ||
* - if OutOfFieldTreatmentZone in the task is not defined, | ||
* it will be created using outOfFieldValue (which is 0 by default) | ||
* - if defaultTreatmentValue or positionLostValue are defined, corresponding TZNs will be created and used | ||
*/ | ||
addGridFromGeoJSON(geoJSON, DDI, deviceElemRef, vpnRef, defaultTreatmentValue, positionLostValue, outOfFieldValue) { | ||
var _a; | ||
const createPDV = (value) => this.isoxmlManager.createEntityFromAttributes(TAGS.ProcessDataVariable, Object.assign(Object.assign({ ProcessDataDDI: DDIToString(DDI), ProcessDataValue: value }, deviceElemRef && { DeviceElementIdRef: deviceElemRef }), vpnRef && { ValuePresentationIdRef: vpnRef })); | ||
this.attributes.TreatmentZone = (_a = this.attributes.TreatmentZone) !== null && _a !== void 0 ? _a : []; | ||
if (this.attributes.OutOfFieldTreatmentZoneCode === undefined || outOfFieldValue !== undefined) { | ||
this.attributes.OutOfFieldTreatmentZoneCode = this.findFreeTZNCode(); | ||
this.attributes.TreatmentZone.push(this.isoxmlManager.createEntityFromAttributes(TAGS.TreatmentZone, { | ||
TreatmentZoneCode: this.attributes.OutOfFieldTreatmentZoneCode, | ||
ProcessDataVariable: [createPDV(outOfFieldValue !== null && outOfFieldValue !== void 0 ? outOfFieldValue : 0)] | ||
})); | ||
} | ||
const gridTZNCode = this.findFreeTZNCode(); | ||
this.attributes.TreatmentZone.push(this.isoxmlManager.createEntityFromAttributes(TAGS.TreatmentZone, { | ||
TreatmentZoneCode: gridTZNCode, | ||
ProcessDataVariable: [createPDV(0)] | ||
})); | ||
this.attributes.Grid = [ | ||
ExtendedGrid.fromGeoJSON(geoJSON, this.isoxmlManager, 1) | ||
ExtendedGrid.fromGeoJSON(geoJSON, this.isoxmlManager, gridTZNCode) | ||
]; | ||
if (defaultTreatmentValue !== undefined) { | ||
this.attributes.DefaultTreatmentZoneCode = this.findFreeTZNCode(); | ||
this.attributes.TreatmentZone.push(this.isoxmlManager.createEntityFromAttributes(TAGS.TreatmentZone, { | ||
TreatmentZoneCode: this.attributes.DefaultTreatmentZoneCode, | ||
ProcessDataVariable: [createPDV(defaultTreatmentValue)] | ||
})); | ||
} | ||
if (positionLostValue !== undefined) { | ||
this.attributes.PositionLostTreatmentZoneCode = this.findFreeTZNCode(); | ||
this.attributes.TreatmentZone.push(this.isoxmlManager.createEntityFromAttributes(TAGS.TreatmentZone, { | ||
TreatmentZoneCode: this.attributes.PositionLostTreatmentZoneCode, | ||
ProcessDataVariable: [createPDV(positionLostValue)] | ||
})); | ||
} | ||
} | ||
@@ -32,0 +67,0 @@ getGridAsGeoJSON() { |
@@ -10,5 +10,15 @@ import { ISOXMLManager } from '../ISOXMLManager'; | ||
static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId: string): Promise<Entity>; | ||
addGridFromGeoJSON(geoJSON: FeatureCollection, DDI: number, deviceElemRef?: ISOXMLReference, vpnRef?: ISOXMLReference): void; | ||
private findFreeTZNCode; | ||
/** Adds Grid and corresponding TreatmentZones to the Task. | ||
* | ||
* Implementation notes: | ||
* - this function doesn't remove any existing TreatmentZones from the task, it just adds new TZNs. | ||
* - TZN codes are generated automatically. | ||
* - if OutOfFieldTreatmentZone in the task is not defined, | ||
* it will be created using outOfFieldValue (which is 0 by default) | ||
* - if defaultTreatmentValue or positionLostValue are defined, corresponding TZNs will be created and used | ||
*/ | ||
addGridFromGeoJSON(geoJSON: FeatureCollection, DDI: number, deviceElemRef?: ISOXMLReference, vpnRef?: ISOXMLReference, defaultTreatmentValue?: number, positionLostValue?: number, outOfFieldValue?: number): void; | ||
getGridAsGeoJSON(): FeatureCollection; | ||
getGridValuesDescription(): ValueInformation[]; | ||
} |
@@ -17,18 +17,53 @@ "use strict"; | ||
} | ||
addGridFromGeoJSON(geoJSON, DDI, deviceElemRef, vpnRef) { | ||
const processDataVariable = this.isoxmlManager.createEntityFromAttributes(constants_1.TAGS.ProcessDataVariable, Object.assign(Object.assign({ ProcessDataDDI: (0, utils_1.DDIToString)(DDI), ProcessDataValue: 0 }, deviceElemRef && { DeviceElementIdRef: deviceElemRef }), vpnRef && { ValuePresentationIdRef: vpnRef })); | ||
this.attributes.TreatmentZone = [ | ||
this.isoxmlManager.createEntityFromAttributes(constants_1.TAGS.TreatmentZone, { | ||
TreatmentZoneCode: 0, | ||
ProcessDataVariable: [processDataVariable] | ||
}), | ||
this.isoxmlManager.createEntityFromAttributes(constants_1.TAGS.TreatmentZone, { | ||
TreatmentZoneCode: 1, | ||
ProcessDataVariable: [processDataVariable] | ||
}) | ||
]; | ||
this.attributes.OutOfFieldTreatmentZoneCode = 0; | ||
findFreeTZNCode() { | ||
var _a; | ||
const tznCodes = new Set((_a = this.attributes.TreatmentZone) === null || _a === void 0 ? void 0 : _a.map(tzn => tzn.attributes.TreatmentZoneCode)); | ||
for (let i = 0; i < 255; i++) { | ||
if (!tznCodes.has(i)) { | ||
return i; | ||
} | ||
} | ||
} | ||
/** Adds Grid and corresponding TreatmentZones to the Task. | ||
* | ||
* Implementation notes: | ||
* - this function doesn't remove any existing TreatmentZones from the task, it just adds new TZNs. | ||
* - TZN codes are generated automatically. | ||
* - if OutOfFieldTreatmentZone in the task is not defined, | ||
* it will be created using outOfFieldValue (which is 0 by default) | ||
* - if defaultTreatmentValue or positionLostValue are defined, corresponding TZNs will be created and used | ||
*/ | ||
addGridFromGeoJSON(geoJSON, DDI, deviceElemRef, vpnRef, defaultTreatmentValue, positionLostValue, outOfFieldValue) { | ||
var _a; | ||
const createPDV = (value) => this.isoxmlManager.createEntityFromAttributes(constants_1.TAGS.ProcessDataVariable, Object.assign(Object.assign({ ProcessDataDDI: (0, utils_1.DDIToString)(DDI), ProcessDataValue: value }, deviceElemRef && { DeviceElementIdRef: deviceElemRef }), vpnRef && { ValuePresentationIdRef: vpnRef })); | ||
this.attributes.TreatmentZone = (_a = this.attributes.TreatmentZone) !== null && _a !== void 0 ? _a : []; | ||
if (this.attributes.OutOfFieldTreatmentZoneCode === undefined || outOfFieldValue !== undefined) { | ||
this.attributes.OutOfFieldTreatmentZoneCode = this.findFreeTZNCode(); | ||
this.attributes.TreatmentZone.push(this.isoxmlManager.createEntityFromAttributes(constants_1.TAGS.TreatmentZone, { | ||
TreatmentZoneCode: this.attributes.OutOfFieldTreatmentZoneCode, | ||
ProcessDataVariable: [createPDV(outOfFieldValue !== null && outOfFieldValue !== void 0 ? outOfFieldValue : 0)] | ||
})); | ||
} | ||
const gridTZNCode = this.findFreeTZNCode(); | ||
this.attributes.TreatmentZone.push(this.isoxmlManager.createEntityFromAttributes(constants_1.TAGS.TreatmentZone, { | ||
TreatmentZoneCode: gridTZNCode, | ||
ProcessDataVariable: [createPDV(0)] | ||
})); | ||
this.attributes.Grid = [ | ||
Grid_1.ExtendedGrid.fromGeoJSON(geoJSON, this.isoxmlManager, 1) | ||
Grid_1.ExtendedGrid.fromGeoJSON(geoJSON, this.isoxmlManager, gridTZNCode) | ||
]; | ||
if (defaultTreatmentValue !== undefined) { | ||
this.attributes.DefaultTreatmentZoneCode = this.findFreeTZNCode(); | ||
this.attributes.TreatmentZone.push(this.isoxmlManager.createEntityFromAttributes(constants_1.TAGS.TreatmentZone, { | ||
TreatmentZoneCode: this.attributes.DefaultTreatmentZoneCode, | ||
ProcessDataVariable: [createPDV(defaultTreatmentValue)] | ||
})); | ||
} | ||
if (positionLostValue !== undefined) { | ||
this.attributes.PositionLostTreatmentZoneCode = this.findFreeTZNCode(); | ||
this.attributes.TreatmentZone.push(this.isoxmlManager.createEntityFromAttributes(constants_1.TAGS.TreatmentZone, { | ||
TreatmentZoneCode: this.attributes.PositionLostTreatmentZoneCode, | ||
ProcessDataVariable: [createPDV(positionLostValue)] | ||
})); | ||
} | ||
} | ||
@@ -35,0 +70,0 @@ getGridAsGeoJSON() { |
{ | ||
"name": "isoxml", | ||
"version": "1.9.8", | ||
"version": "1.10.0", | ||
"description": "JavaScript library to parse and generate ISOXML (ISO11783-10) files", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
950294
31763