├── .eslintignore ├── .eslintrc ├── .github └── workflows │ └── on-pr.yaml ├── .gitignore ├── LICENSE ├── README.md ├── data ├── 2021-04-09T15_33_26_taskdata.zip ├── duplicate-xmlid.zip ├── task_full.zip ├── task_with_grid.zip ├── task_with_warnings.zip ├── test.geojson └── test1.zip ├── examples ├── create.ts ├── create_partfield.ts └── parse.ts ├── generation ├── index.ts ├── templates │ ├── Entity.hbs │ ├── constants.hbs │ └── index.hbs └── xsd │ ├── ISO11783_Common_V4-3.xsd │ ├── ISO11783_ExternalFile_V3-0.xsd │ ├── ISO11783_ExternalFile_V4-3.xsd │ ├── ISO11783_LinkListFile_V4-3.xsd │ ├── ISO11783_TaskFile_V3-3.xsd │ ├── ISO11783_TaskFile_V4-3.xsd │ └── ISO11783_TimeLog_V4-3.xsd ├── jest.config.js ├── package-lock.json ├── package.json ├── src ├── DDEntities.ts ├── ISOXMLManager.spec.ts ├── ISOXMLManager.ts ├── baseEntities │ ├── AllocationStamp.ts │ ├── AttachedFile.ts │ ├── BaseStation.ts │ ├── CodedComment.ts │ ├── CodedCommentGroup.ts │ ├── CodedCommentListValue.ts │ ├── ColourLegend.ts │ ├── ColourRange.ts │ ├── CommentAllocation.ts │ ├── Connection.ts │ ├── ControlAssignment.ts │ ├── CropType.ts │ ├── CropVariety.ts │ ├── CulturalPractice.ts │ ├── Customer.ts │ ├── DataLogTrigger.ts │ ├── DataLogValue.ts │ ├── Device.ts │ ├── DeviceAllocation.ts │ ├── DeviceElement.ts │ ├── DeviceObjectReference.ts │ ├── DeviceProcessData.ts │ ├── DeviceProperty.ts │ ├── DeviceValuePresentation.ts │ ├── ExternalFileContents.ts │ ├── ExternalFileReference.ts │ ├── Farm.ts │ ├── Grid.ts │ ├── GuidanceAllocation.ts │ ├── GuidanceGroup.ts │ ├── GuidancePattern.ts │ ├── GuidanceShift.ts │ ├── ISO11783LinkListFile.ts │ ├── ISO11783TaskDataFile.ts │ ├── LineString.ts │ ├── Link.ts │ ├── LinkGroup.ts │ ├── OperTechPractice.ts │ ├── OperationTechnique.ts │ ├── OperationTechniqueReference.ts │ ├── Partfield.ts │ ├── Point.ts │ ├── Polygon.ts │ ├── Position.ts │ ├── ProcessDataVariable.ts │ ├── Product.ts │ ├── ProductAllocation.ts │ ├── ProductGroup.ts │ ├── ProductRelation.ts │ ├── Task.ts │ ├── TaskControllerCapabilities.ts │ ├── Time.ts │ ├── TimeLog.ts │ ├── TimelogDataLogValue.ts │ ├── TimelogPosition.ts │ ├── TimelogTime.ts │ ├── TreatmentZone.ts │ ├── ValuePresentation.ts │ ├── Worker.ts │ ├── WorkerAllocation.ts │ ├── constants.ts │ └── index.ts ├── classRegistry.ts ├── entities │ ├── AttachedFile.ts │ ├── DeviceElement.ts │ ├── Grid │ │ ├── CellCenterBasedGridGenerator.ts │ │ ├── DefaultGridParamsGenerator.ts │ │ ├── Grid.spec.ts │ │ ├── Grid.ts │ │ ├── IntersectionBasedGridGenerator.ts │ │ └── index.ts │ ├── ISO11783LinkListFile.ts │ ├── ISO11783TaskDataFile.ts │ ├── LineString.spec.ts │ ├── LineString.ts │ ├── Partfield.spec.ts │ ├── Partfield.ts │ ├── Polygon.spec.ts │ ├── Polygon.ts │ ├── Task.spec.ts │ ├── Task.ts │ ├── TimeLog │ │ ├── BufferReader.ts │ │ ├── TimeLog.spec.ts │ │ └── index.ts │ ├── TreatmentZone.spec.ts │ ├── TreatmentZone.ts │ ├── index.ts │ └── testdata │ │ └── geometry.ts ├── index.ts ├── types.ts ├── utils.spec.ts ├── utils.ts └── xmlManager.ts ├── tsconfig-es.json └── tsconfig.json /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | dist_es 4 | src/baseEntities -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "parser": "@typescript-eslint/parser", 4 | "plugins": [ 5 | "@typescript-eslint" 6 | ], 7 | "extends": [ 8 | "eslint:recommended", 9 | "plugin:@typescript-eslint/eslint-recommended", 10 | "plugin:@typescript-eslint/recommended" 11 | ], 12 | "rules": { 13 | "@typescript-eslint/no-explicit-any": "off", 14 | "semi": "off", 15 | "@typescript-eslint/semi": ["error", "never"], 16 | "max-len": ["error", { "code": 120 }], 17 | "no-trailing-spaces": "error" 18 | }, 19 | "env": { 20 | "node": true 21 | } 22 | } -------------------------------------------------------------------------------- /.github/workflows/on-pr.yaml: -------------------------------------------------------------------------------- 1 | name: checks for pull request into main branch 2 | 3 | on: 4 | pull_request: 5 | branches: ["master"] 6 | workflow_dispatch: {} 7 | 8 | jobs: 9 | test: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Checkout code 13 | uses: actions/checkout@v3 14 | 15 | - name: Use Node.js 16 | uses: actions/setup-node@v3 17 | with: 18 | node-version: 18.14 19 | 20 | - run: npm ci 21 | 22 | - run: npm test 23 | 24 | 25 | lint: 26 | runs-on: ubuntu-latest 27 | steps: 28 | - name: Checkout code 29 | uses: actions/checkout@v3 30 | 31 | - name: Use Node.js 32 | uses: actions/setup-node@v3 33 | with: 34 | node-version: 18.14 35 | 36 | - run: npm ci 37 | 38 | - run: npm run lint 39 | 40 | 41 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /dist 3 | /dist_es 4 | /coverage 5 | /.vscode -------------------------------------------------------------------------------- /data/2021-04-09T15_33_26_taskdata.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dev4Agriculture/isoxml-js/8fc71d47a764267b826874a4ed5dd8bbf06ce66b/data/2021-04-09T15_33_26_taskdata.zip -------------------------------------------------------------------------------- /data/duplicate-xmlid.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dev4Agriculture/isoxml-js/8fc71d47a764267b826874a4ed5dd8bbf06ce66b/data/duplicate-xmlid.zip -------------------------------------------------------------------------------- /data/task_full.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dev4Agriculture/isoxml-js/8fc71d47a764267b826874a4ed5dd8bbf06ce66b/data/task_full.zip -------------------------------------------------------------------------------- /data/task_with_grid.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dev4Agriculture/isoxml-js/8fc71d47a764267b826874a4ed5dd8bbf06ce66b/data/task_with_grid.zip -------------------------------------------------------------------------------- /data/task_with_warnings.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dev4Agriculture/isoxml-js/8fc71d47a764267b826874a4ed5dd8bbf06ce66b/data/task_with_warnings.zip -------------------------------------------------------------------------------- /data/test.geojson: -------------------------------------------------------------------------------- 1 | { 2 | "type":"FeatureCollection", 3 | "crs":{ 4 | "type":"name", 5 | "properties":{ 6 | "name":"urn:ogc:def:crs:OGC:1.3:CRS84" 7 | } 8 | }, 9 | "features":[ 10 | { 11 | "type":"Feature", 12 | "properties":{ 13 | "id":1, 14 | "DOSE":12.0 15 | }, 16 | "geometry":{ 17 | "type":"Polygon", 18 | "coordinates":[ 19 | [ 20 | [ 21 | 39.138728173503324, 22 | 55.834384762042617 23 | ], 24 | [ 25 | 39.143843758661312, 26 | 55.834356033574707 27 | ], 28 | [ 29 | 39.147168889013997, 30 | 55.832977042157168 31 | ], 32 | [ 33 | 39.147168889013997, 34 | 55.8303625700322 35 | ], 36 | [ 37 | 39.139086264464389, 38 | 55.825477920470483 39 | ], 40 | [ 41 | 39.138728173503324, 42 | 55.834384762042617 43 | ] 44 | ] 45 | ] 46 | } 47 | }, 48 | { 49 | "type":"Feature", 50 | "properties":{ 51 | "id":2, 52 | "DOSE":15.7 53 | }, 54 | "geometry":{ 55 | "type":"Polygon", 56 | "coordinates":[ 57 | [ 58 | [ 59 | 39.147168889013997, 60 | 55.830391301450206 61 | ], 62 | [ 63 | 39.147526979975055, 64 | 55.825018157163711 65 | ], 66 | [ 67 | 39.139086264464389, 68 | 55.824817009008321 69 | ], 70 | [ 71 | 39.139086264464389, 72 | 55.825477920470483 73 | ], 74 | [ 75 | 39.147168889013997, 76 | 55.830391301450206 77 | ] 78 | ] 79 | ] 80 | } 81 | } 82 | ] 83 | } 84 | -------------------------------------------------------------------------------- /data/test1.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dev4Agriculture/isoxml-js/8fc71d47a764267b826874a4ed5dd8bbf06ce66b/data/test1.zip -------------------------------------------------------------------------------- /examples/create.ts: -------------------------------------------------------------------------------- 1 | /* This example suppose that the isoxml is built locally (run "npm run build" first) */ 2 | 3 | import { readFileSync, writeFileSync } from 'fs' 4 | import { join } from 'path' 5 | import { ISOXMLManager, TAGS, TaskTaskStatusEnum, ExtendedTask } from '../dist' 6 | 7 | const isoxmlManager = new ISOXMLManager() 8 | 9 | // create an instance of Task entity 10 | const task = isoxmlManager.createEntityFromAttributes(TAGS.Task, { 11 | TaskStatus: TaskTaskStatusEnum.Planned 12 | }) as ExtendedTask 13 | 14 | const geoJSONdata = JSON.parse(readFileSync(join(__dirname, '../data/test.geojson'), 'utf-8')) 15 | 16 | // add Grid to the task from GeoJSON. "1" is DDI 17 | task.addGridFromGeoJSON(geoJSONdata, 1) 18 | 19 | // assign a local ID to the task ("TSK1" in our case) 20 | isoxmlManager.registerEntity(task) 21 | 22 | // add the task to the root element 23 | isoxmlManager.rootElement.attributes.Task = [task] 24 | 25 | // save ISOXML as a zip file 26 | isoxmlManager.saveISOXML().then((data: Uint8Array) => { 27 | writeFileSync('./isoxml.zip', data) 28 | }) -------------------------------------------------------------------------------- /examples/create_partfield.ts: -------------------------------------------------------------------------------- 1 | /* This example suppose that the isoxml is built locally (run "npm run build" first) */ 2 | 3 | import { writeFileSync } from 'fs' 4 | import { 5 | ISOXMLManager, 6 | TAGS, 7 | TaskTaskStatusEnum, 8 | ExtendedTask, 9 | ExtendedPolygon, 10 | Partfield, 11 | PolygonPolygonTypeEnum 12 | } from '../dist' 13 | 14 | const isoxmlManager = new ISOXMLManager() 15 | 16 | const geoJSON = { 17 | type: "Polygon" as const, 18 | coordinates: [ 19 | // outer ring 20 | [ 21 | [52.1,7.1], 22 | [52.1,7.2], 23 | [52.2,7.2], 24 | [52.2,7.1], 25 | [52.1,7.1] 26 | ], 27 | // inner ring (hole) 28 | [ 29 | [52.13,7.12], 30 | [52.13,7.18], 31 | [52.18,7.18], 32 | [52.18,7.12], 33 | [52.13,7.12] 34 | ] 35 | ] 36 | } 37 | 38 | // create ISOXML polygons from GeoJSON 39 | const polygons = ExtendedPolygon.fromGeoJSON( 40 | geoJSON, 41 | PolygonPolygonTypeEnum.PartfieldBoundary, 42 | isoxmlManager 43 | ) 44 | 45 | // create a Partfield 46 | const partfield = isoxmlManager.createEntityFromAttributes(TAGS.Partfield, { 47 | PartfieldDesignator : "Test", 48 | PolygonnonTreatmentZoneonly: polygons 49 | }) as Partfield 50 | 51 | // assign a local ID to the partfield ("PFD1" in our case) 52 | const partFieldRef = isoxmlManager.registerEntity(partfield) 53 | 54 | // add the partfield to the root element 55 | isoxmlManager.rootElement.attributes.Partfield = [partfield] 56 | 57 | // create an instance of Task entity 58 | const task = isoxmlManager.createEntityFromAttributes(TAGS.Task, { 59 | TaskStatus: TaskTaskStatusEnum.Planned, 60 | PartfieldIdRef: partFieldRef 61 | }) as ExtendedTask 62 | 63 | // assign a local ID to the task ("TSK1" in our case) 64 | isoxmlManager.registerEntity(task) 65 | // add the task to the root element 66 | isoxmlManager.rootElement.attributes.Task = [task] 67 | 68 | // save ISOXML as a zip file 69 | isoxmlManager.saveISOXML().then((data: Uint8Array) => { 70 | writeFileSync('./isoxml_with_partfield.zip', data) 71 | }) -------------------------------------------------------------------------------- /examples/parse.ts: -------------------------------------------------------------------------------- 1 | /* This example suppose that the isoxml is built locally (run "npm run build" first) */ 2 | 3 | import { readFileSync } from 'fs' 4 | import { join } from 'path' 5 | import { ISOXMLManager, Partfield } from '../dist' 6 | 7 | // read a zipped ISOXML 8 | const isoxmlData = readFileSync(join(__dirname, '../data/task_with_warnings.zip')) 9 | 10 | // create new ISOXMLManager instance with default parameters 11 | const isoxmlManager = new ISOXMLManager() 12 | 13 | // parse the file 14 | isoxmlManager.parseISOXMLFile(new Uint8Array(isoxmlData.buffer), 'application/zip').then(() => { 15 | 16 | // getWarnings() method returns all the warnings from the last parsing 17 | console.log(isoxmlManager.getWarnings()) 18 | 19 | // all global attributes of the parsed file 20 | console.log(isoxmlManager.options) 21 | 22 | // get all the Partfileds 23 | const partfields: Partfield[] = isoxmlManager.rootElement.attributes.Partfield || [] 24 | 25 | // print designators of all the Partfields 26 | partfields.forEach(partfield => { 27 | console.log(`${partfield.attributes.PartfieldDesignator}`) 28 | }) 29 | }) -------------------------------------------------------------------------------- /generation/templates/Entity.hbs: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | {{#children}} 8 | {{#ifnoteq className ../name }} 9 | import { {{className}} } from './{{className}}' 10 | {{/ifnoteq}} 11 | {{/children}} 12 | 13 | import { Entity, EntityConstructor, AttributesDescription{{#if includeReference}}, ISOXMLReference{{/if}} } from '../types' 14 | 15 | {{#attributes}} 16 | {{#if typeEnum}} 17 | export enum {{../prefix}}{{../name}}{{name}}Enum { 18 | {{#typeEnum}} 19 | {{name}} = '{{value}}', 20 | {{/typeEnum}} 21 | } 22 | {{/if}} 23 | {{/attributes}} 24 | 25 | export type {{prefix}}{{name}}Attributes = { 26 | {{#attributes}} 27 | {{#unless isPrimaryId}} 28 | {{name}}{{#if isOptional}}?{{/if}}: {{#if typeEnum}}{{../prefix}}{{../name}}{{name}}Enum{{else}}{{type}}{{/if}} 29 | {{/unless}} 30 | {{/attributes}} 31 | {{#children}} 32 | {{name}}?: {{className}}[] 33 | {{/children}} 34 | ProprietaryAttributes?: {[name: string]: string} 35 | ProprietaryTags?: {[tag: string]: XMLElement[]} 36 | } 37 | 38 | const ATTRIBUTES: AttributesDescription = { 39 | {{#attributes}} 40 | {{xmlName}}: { 41 | name: '{{name}}', 42 | type: '{{xsdType}}', 43 | isPrimaryId: {{toString isPrimaryId}}, 44 | isOptional: {{toString isOptional}}, 45 | isOnlyV4: {{toString isOnlyV4}}, 46 | {{#if (isdefined numericalRestrictions.minValue)}} 47 | minValue: {{numericalRestrictions.minValue}}, 48 | {{/if}} 49 | {{#if (isdefined numericalRestrictions.maxValue)}} 50 | maxValue: {{numericalRestrictions.maxValue}}, 51 | {{/if}} 52 | {{#if (isdefined numericalRestrictions.fractionDigits)}} 53 | fractionDigits: {{numericalRestrictions.fractionDigits}}, 54 | {{/if}} 55 | {{#if (isdefined numericalRestrictions.allowEmptyString)}} 56 | allowEmptyString: {{numericalRestrictions.allowEmptyString}}, 57 | {{/if}} 58 | }, 59 | {{/attributes}} 60 | } 61 | const CHILD_TAGS = { 62 | {{#children}} 63 | {{tag}}: { name: '{{name}}', isOnlyV4: {{toString isOnlyV4}} }, 64 | {{/children}} 65 | } 66 | 67 | export class {{prefix}}{{name}} implements Entity { 68 | public tag = TAGS.{{name}} 69 | 70 | constructor(public attributes: {{prefix}}{{name}}Attributes, public isoxmlManager: ISOXMLManager) { 71 | } 72 | 73 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = {{prefix}}{{name}}): Promise { 74 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 75 | } 76 | 77 | toXML(): XMLElement { 78 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 79 | } 80 | } 81 | 82 | registerEntityClass('{{realm}}', TAGS.{{name}}, {{prefix}}{{name}}) -------------------------------------------------------------------------------- /generation/templates/constants.hbs: -------------------------------------------------------------------------------- 1 | export enum TAGS { 2 | {{#tags}} 3 | {{name}} = '{{tag}}', 4 | {{/tags}} 5 | } -------------------------------------------------------------------------------- /generation/templates/index.hbs: -------------------------------------------------------------------------------- 1 | {{#tags}} 2 | export * from './{{prefix}}{{name}}' 3 | {{/tags}} -------------------------------------------------------------------------------- /generation/xsd/ISO11783_ExternalFile_V4-3.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | ExternalFileContents 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | BaseStation 17 | 18 | 19 | 20 | 21 | 22 | 23 | CodedComment 24 | 25 | 26 | 27 | 28 | 29 | 30 | CodedCommentGroup 31 | 32 | 33 | 34 | 35 | 36 | 37 | ColourLegend 38 | 39 | 40 | 41 | 42 | 43 | 44 | CropType 45 | 46 | 47 | 48 | 49 | 50 | 51 | CulturalPractice 52 | 53 | 54 | 55 | 56 | 57 | 58 | Customer 59 | 60 | 61 | 62 | 63 | 64 | 65 | Device 66 | 67 | 68 | 69 | 70 | 71 | 72 | Farm 73 | 74 | 75 | 76 | 77 | 78 | 79 | OperationTechnique 80 | 81 | 82 | 83 | 84 | 85 | 86 | Partfield 87 | 88 | 89 | 90 | 91 | 92 | 93 | Product 94 | 95 | 96 | 97 | 98 | 99 | 100 | ProductGroup 101 | 102 | 103 | 104 | 105 | 106 | 107 | Task 108 | 109 | 110 | 111 | 112 | 113 | 114 | ValuePresentation 115 | 116 | 117 | 118 | 119 | 120 | 121 | Worker 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | transform: {'^.+\\.ts?$': 'ts-jest'}, 3 | testEnvironment: 'node', 4 | testTimeout: 20000, 5 | testRegex: '.*\\.spec\\.ts$', 6 | moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'] 7 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "isoxml", 3 | "version": "1.11.1", 4 | "description": "JavaScript library to parse and generate ISOXML (ISO11783-10) files", 5 | "keywords": [ 6 | "isoxml", 7 | "iso-11783", 8 | "agriculture" 9 | ], 10 | "homepage": "https://github.com/dev4Agriculture/isoxml-js", 11 | "bugs": "https://github.com/dev4Agriculture/isoxml-js/issues", 12 | "license": "Apache-2.0", 13 | "author": { 14 | "name": "Alexander Parshin", 15 | "email": "parshin.alexander@gmail.com", 16 | "url": "https://github.com/aparshin" 17 | }, 18 | "files": [ 19 | "dist", 20 | "dist_es" 21 | ], 22 | "main": "dist/index.js", 23 | "module": "dist_es/index.js", 24 | "scripts": { 25 | "gen": "ts-node generation/index.ts", 26 | "test": "jest", 27 | "coverage": "jest --coverage", 28 | "build": "tsc -p tsconfig.json && tsc -p tsconfig-es.json", 29 | "lint": "eslint . --ext .js,.jsx,.ts,.tsx", 30 | "prepare": "npm run build", 31 | "prepublishOnly": "npm t && npm run lint" 32 | }, 33 | "dependencies": { 34 | "@turf/turf": "^6.4.0", 35 | "fast-xml-parser": "^4.3.1", 36 | "jszip": "^3.10.1", 37 | "polygon-clipping": "^0.15.3", 38 | "rbush": "^3.0.1" 39 | }, 40 | "devDependencies": { 41 | "@types/jest": "^29.5.5", 42 | "@types/node": "^20.6.5", 43 | "@types/rbush": "^3.0.0", 44 | "@typescript-eslint/eslint-plugin": "^6.7.2", 45 | "@typescript-eslint/parser": "^6.7.2", 46 | "eslint": "^8.50.0", 47 | "handlebars": "^4.7.8", 48 | "jest": "^29.7.0", 49 | "ts-jest": "^29.1.1", 50 | "ts-node": "^10.9.1", 51 | "typescript": "^5.2.2" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/baseEntities/AllocationStamp.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | import { Position } from './Position' 8 | 9 | import { Entity, EntityConstructor, AttributesDescription } from '../types' 10 | 11 | export enum AllocationStampTypeEnum { 12 | Planned = '1', 13 | EffectiveRealized = '4', 14 | } 15 | 16 | export type AllocationStampAttributes = { 17 | Start: string 18 | Stop?: string 19 | Duration?: number 20 | Type: AllocationStampTypeEnum 21 | Position?: Position[] 22 | ProprietaryAttributes?: {[name: string]: string} 23 | ProprietaryTags?: {[tag: string]: XMLElement[]} 24 | } 25 | 26 | const ATTRIBUTES: AttributesDescription = { 27 | A: { 28 | name: 'Start', 29 | type: 'xs:dateTime', 30 | isPrimaryId: false, 31 | isOptional: false, 32 | isOnlyV4: false, 33 | }, 34 | B: { 35 | name: 'Stop', 36 | type: 'xs:dateTime', 37 | isPrimaryId: false, 38 | isOptional: true, 39 | isOnlyV4: false, 40 | }, 41 | C: { 42 | name: 'Duration', 43 | type: 'xs:unsignedLong', 44 | isPrimaryId: false, 45 | isOptional: true, 46 | isOnlyV4: false, 47 | minValue: 0, 48 | maxValue: 4294967294, 49 | }, 50 | D: { 51 | name: 'Type', 52 | type: 'xs:NMTOKEN', 53 | isPrimaryId: false, 54 | isOptional: false, 55 | isOnlyV4: false, 56 | }, 57 | } 58 | const CHILD_TAGS = { 59 | PTN: { name: 'Position', isOnlyV4: false }, 60 | } 61 | 62 | export class AllocationStamp implements Entity { 63 | public tag = TAGS.AllocationStamp 64 | 65 | constructor(public attributes: AllocationStampAttributes, public isoxmlManager: ISOXMLManager) { 66 | } 67 | 68 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = AllocationStamp): Promise { 69 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 70 | } 71 | 72 | toXML(): XMLElement { 73 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 74 | } 75 | } 76 | 77 | registerEntityClass('main', TAGS.AllocationStamp, AllocationStamp) -------------------------------------------------------------------------------- /src/baseEntities/AttachedFile.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | 8 | import { Entity, EntityConstructor, AttributesDescription } from '../types' 9 | 10 | export enum AttachedFilePreserveEnum { 11 | TaskControllerDoesNotNeedToPreserveAttachedFile = '1', 12 | PreserveOnTaskControllerAndSendBackToFMIS = '2', 13 | } 14 | 15 | export type AttachedFileAttributes = { 16 | FilenameWithExtension: string 17 | Preserve: AttachedFilePreserveEnum 18 | ManufacturerGLN: string 19 | FileType: number 20 | FileVersion?: string 21 | FileLength?: number 22 | ProprietaryAttributes?: {[name: string]: string} 23 | ProprietaryTags?: {[tag: string]: XMLElement[]} 24 | } 25 | 26 | const ATTRIBUTES: AttributesDescription = { 27 | A: { 28 | name: 'FilenameWithExtension', 29 | type: 'xs:ID', 30 | isPrimaryId: false, 31 | isOptional: false, 32 | isOnlyV4: undefined, 33 | }, 34 | B: { 35 | name: 'Preserve', 36 | type: 'xs:NMTOKEN', 37 | isPrimaryId: false, 38 | isOptional: false, 39 | isOnlyV4: undefined, 40 | }, 41 | C: { 42 | name: 'ManufacturerGLN', 43 | type: 'xs:anyURI', 44 | isPrimaryId: false, 45 | isOptional: false, 46 | isOnlyV4: undefined, 47 | }, 48 | D: { 49 | name: 'FileType', 50 | type: 'xs:unsignedByte', 51 | isPrimaryId: false, 52 | isOptional: false, 53 | isOnlyV4: undefined, 54 | minValue: 1, 55 | maxValue: 254, 56 | }, 57 | E: { 58 | name: 'FileVersion', 59 | type: 'xs:string', 60 | isPrimaryId: false, 61 | isOptional: true, 62 | isOnlyV4: undefined, 63 | }, 64 | F: { 65 | name: 'FileLength', 66 | type: 'xs:unsignedLong', 67 | isPrimaryId: false, 68 | isOptional: true, 69 | isOnlyV4: undefined, 70 | minValue: 0, 71 | maxValue: 4294967294, 72 | }, 73 | } 74 | const CHILD_TAGS = { 75 | } 76 | 77 | export class AttachedFile implements Entity { 78 | public tag = TAGS.AttachedFile 79 | 80 | constructor(public attributes: AttachedFileAttributes, public isoxmlManager: ISOXMLManager) { 81 | } 82 | 83 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = AttachedFile): Promise { 84 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 85 | } 86 | 87 | toXML(): XMLElement { 88 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 89 | } 90 | } 91 | 92 | registerEntityClass('main', TAGS.AttachedFile, AttachedFile) -------------------------------------------------------------------------------- /src/baseEntities/BaseStation.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | 8 | import { Entity, EntityConstructor, AttributesDescription } from '../types' 9 | 10 | 11 | export type BaseStationAttributes = { 12 | BaseStationDesignator: string 13 | BaseStationNorth: number 14 | BaseStationEast: number 15 | BaseStationUp: number 16 | ProprietaryAttributes?: {[name: string]: string} 17 | ProprietaryTags?: {[tag: string]: XMLElement[]} 18 | } 19 | 20 | const ATTRIBUTES: AttributesDescription = { 21 | A: { 22 | name: 'BaseStationId', 23 | type: 'xs:ID', 24 | isPrimaryId: true, 25 | isOptional: false, 26 | isOnlyV4: undefined, 27 | }, 28 | B: { 29 | name: 'BaseStationDesignator', 30 | type: 'xs:string', 31 | isPrimaryId: false, 32 | isOptional: false, 33 | isOnlyV4: undefined, 34 | }, 35 | C: { 36 | name: 'BaseStationNorth', 37 | type: 'xs:decimal', 38 | isPrimaryId: false, 39 | isOptional: false, 40 | isOnlyV4: undefined, 41 | minValue: -90, 42 | maxValue: 90, 43 | fractionDigits: 9, 44 | }, 45 | D: { 46 | name: 'BaseStationEast', 47 | type: 'xs:decimal', 48 | isPrimaryId: false, 49 | isOptional: false, 50 | isOnlyV4: undefined, 51 | minValue: -180, 52 | maxValue: 180, 53 | fractionDigits: 9, 54 | }, 55 | E: { 56 | name: 'BaseStationUp', 57 | type: 'xs:long', 58 | isPrimaryId: false, 59 | isOptional: false, 60 | isOnlyV4: undefined, 61 | minValue: -2147483647, 62 | maxValue: 2147483647, 63 | }, 64 | } 65 | const CHILD_TAGS = { 66 | } 67 | 68 | export class BaseStation implements Entity { 69 | public tag = TAGS.BaseStation 70 | 71 | constructor(public attributes: BaseStationAttributes, public isoxmlManager: ISOXMLManager) { 72 | } 73 | 74 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = BaseStation): Promise { 75 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 76 | } 77 | 78 | toXML(): XMLElement { 79 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 80 | } 81 | } 82 | 83 | registerEntityClass('main', TAGS.BaseStation, BaseStation) -------------------------------------------------------------------------------- /src/baseEntities/CodedComment.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | import { CodedCommentListValue } from './CodedCommentListValue' 8 | 9 | import { Entity, EntityConstructor, AttributesDescription, ISOXMLReference } from '../types' 10 | 11 | export enum CodedCommentCodedCommentScopeEnum { 12 | Point = '1', 13 | Global = '2', 14 | Continuous = '3', 15 | } 16 | 17 | export type CodedCommentAttributes = { 18 | CodedCommentDesignator: string 19 | CodedCommentScope: CodedCommentCodedCommentScopeEnum 20 | CodedCommentGroupIdRef?: ISOXMLReference 21 | CodedCommentListValue?: CodedCommentListValue[] 22 | ProprietaryAttributes?: {[name: string]: string} 23 | ProprietaryTags?: {[tag: string]: XMLElement[]} 24 | } 25 | 26 | const ATTRIBUTES: AttributesDescription = { 27 | A: { 28 | name: 'CodedCommentId', 29 | type: 'xs:ID', 30 | isPrimaryId: true, 31 | isOptional: false, 32 | isOnlyV4: false, 33 | }, 34 | B: { 35 | name: 'CodedCommentDesignator', 36 | type: 'xs:string', 37 | isPrimaryId: false, 38 | isOptional: false, 39 | isOnlyV4: false, 40 | }, 41 | C: { 42 | name: 'CodedCommentScope', 43 | type: 'xs:NMTOKEN', 44 | isPrimaryId: false, 45 | isOptional: false, 46 | isOnlyV4: false, 47 | }, 48 | D: { 49 | name: 'CodedCommentGroupIdRef', 50 | type: 'xs:IDREF', 51 | isPrimaryId: false, 52 | isOptional: true, 53 | isOnlyV4: false, 54 | }, 55 | } 56 | const CHILD_TAGS = { 57 | CCL: { name: 'CodedCommentListValue', isOnlyV4: false }, 58 | } 59 | 60 | export class CodedComment implements Entity { 61 | public tag = TAGS.CodedComment 62 | 63 | constructor(public attributes: CodedCommentAttributes, public isoxmlManager: ISOXMLManager) { 64 | } 65 | 66 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = CodedComment): Promise { 67 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 68 | } 69 | 70 | toXML(): XMLElement { 71 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 72 | } 73 | } 74 | 75 | registerEntityClass('main', TAGS.CodedComment, CodedComment) -------------------------------------------------------------------------------- /src/baseEntities/CodedCommentGroup.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | 8 | import { Entity, EntityConstructor, AttributesDescription } from '../types' 9 | 10 | 11 | export type CodedCommentGroupAttributes = { 12 | CodedCommentGroupDesignator: string 13 | ProprietaryAttributes?: {[name: string]: string} 14 | ProprietaryTags?: {[tag: string]: XMLElement[]} 15 | } 16 | 17 | const ATTRIBUTES: AttributesDescription = { 18 | A: { 19 | name: 'CodedCommentGroupId', 20 | type: 'xs:ID', 21 | isPrimaryId: true, 22 | isOptional: false, 23 | isOnlyV4: false, 24 | }, 25 | B: { 26 | name: 'CodedCommentGroupDesignator', 27 | type: 'xs:string', 28 | isPrimaryId: false, 29 | isOptional: false, 30 | isOnlyV4: false, 31 | }, 32 | } 33 | const CHILD_TAGS = { 34 | } 35 | 36 | export class CodedCommentGroup implements Entity { 37 | public tag = TAGS.CodedCommentGroup 38 | 39 | constructor(public attributes: CodedCommentGroupAttributes, public isoxmlManager: ISOXMLManager) { 40 | } 41 | 42 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = CodedCommentGroup): Promise { 43 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 44 | } 45 | 46 | toXML(): XMLElement { 47 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 48 | } 49 | } 50 | 51 | registerEntityClass('main', TAGS.CodedCommentGroup, CodedCommentGroup) -------------------------------------------------------------------------------- /src/baseEntities/CodedCommentListValue.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | 8 | import { Entity, EntityConstructor, AttributesDescription } from '../types' 9 | 10 | 11 | export type CodedCommentListValueAttributes = { 12 | CodedCommentListValueDesignator: string 13 | ProprietaryAttributes?: {[name: string]: string} 14 | ProprietaryTags?: {[tag: string]: XMLElement[]} 15 | } 16 | 17 | const ATTRIBUTES: AttributesDescription = { 18 | A: { 19 | name: 'CodedCommentListValueId', 20 | type: 'xs:ID', 21 | isPrimaryId: true, 22 | isOptional: false, 23 | isOnlyV4: false, 24 | }, 25 | B: { 26 | name: 'CodedCommentListValueDesignator', 27 | type: 'xs:string', 28 | isPrimaryId: false, 29 | isOptional: false, 30 | isOnlyV4: false, 31 | }, 32 | } 33 | const CHILD_TAGS = { 34 | } 35 | 36 | export class CodedCommentListValue implements Entity { 37 | public tag = TAGS.CodedCommentListValue 38 | 39 | constructor(public attributes: CodedCommentListValueAttributes, public isoxmlManager: ISOXMLManager) { 40 | } 41 | 42 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = CodedCommentListValue): Promise { 43 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 44 | } 45 | 46 | toXML(): XMLElement { 47 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 48 | } 49 | } 50 | 51 | registerEntityClass('main', TAGS.CodedCommentListValue, CodedCommentListValue) -------------------------------------------------------------------------------- /src/baseEntities/ColourLegend.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | import { ColourRange } from './ColourRange' 8 | 9 | import { Entity, EntityConstructor, AttributesDescription } from '../types' 10 | 11 | 12 | export type ColourLegendAttributes = { 13 | DefaultColor?: number 14 | ColourRange?: ColourRange[] 15 | ProprietaryAttributes?: {[name: string]: string} 16 | ProprietaryTags?: {[tag: string]: XMLElement[]} 17 | } 18 | 19 | const ATTRIBUTES: AttributesDescription = { 20 | A: { 21 | name: 'ColourLegendId', 22 | type: 'xs:ID', 23 | isPrimaryId: true, 24 | isOptional: false, 25 | isOnlyV4: false, 26 | }, 27 | B: { 28 | name: 'DefaultColor', 29 | type: 'xs:unsignedByte', 30 | isPrimaryId: false, 31 | isOptional: true, 32 | isOnlyV4: false, 33 | minValue: 0, 34 | maxValue: 254, 35 | }, 36 | } 37 | const CHILD_TAGS = { 38 | CRG: { name: 'ColourRange', isOnlyV4: false }, 39 | } 40 | 41 | export class ColourLegend implements Entity { 42 | public tag = TAGS.ColourLegend 43 | 44 | constructor(public attributes: ColourLegendAttributes, public isoxmlManager: ISOXMLManager) { 45 | } 46 | 47 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = ColourLegend): Promise { 48 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 49 | } 50 | 51 | toXML(): XMLElement { 52 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 53 | } 54 | } 55 | 56 | registerEntityClass('main', TAGS.ColourLegend, ColourLegend) -------------------------------------------------------------------------------- /src/baseEntities/ColourRange.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | 8 | import { Entity, EntityConstructor, AttributesDescription } from '../types' 9 | 10 | 11 | export type ColourRangeAttributes = { 12 | MinimumValue: number 13 | MaximumValue: number 14 | Colour: number 15 | ProprietaryAttributes?: {[name: string]: string} 16 | ProprietaryTags?: {[tag: string]: XMLElement[]} 17 | } 18 | 19 | const ATTRIBUTES: AttributesDescription = { 20 | A: { 21 | name: 'MinimumValue', 22 | type: 'xs:long', 23 | isPrimaryId: false, 24 | isOptional: false, 25 | isOnlyV4: false, 26 | minValue: -2147483647, 27 | maxValue: 2147483647, 28 | }, 29 | B: { 30 | name: 'MaximumValue', 31 | type: 'xs:long', 32 | isPrimaryId: false, 33 | isOptional: false, 34 | isOnlyV4: false, 35 | minValue: -2147483647, 36 | maxValue: 2147483647, 37 | }, 38 | C: { 39 | name: 'Colour', 40 | type: 'xs:unsignedByte', 41 | isPrimaryId: false, 42 | isOptional: false, 43 | isOnlyV4: false, 44 | minValue: 0, 45 | maxValue: 254, 46 | }, 47 | } 48 | const CHILD_TAGS = { 49 | } 50 | 51 | export class ColourRange implements Entity { 52 | public tag = TAGS.ColourRange 53 | 54 | constructor(public attributes: ColourRangeAttributes, public isoxmlManager: ISOXMLManager) { 55 | } 56 | 57 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = ColourRange): Promise { 58 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 59 | } 60 | 61 | toXML(): XMLElement { 62 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 63 | } 64 | } 65 | 66 | registerEntityClass('main', TAGS.ColourRange, ColourRange) -------------------------------------------------------------------------------- /src/baseEntities/CommentAllocation.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | import { AllocationStamp } from './AllocationStamp' 8 | 9 | import { Entity, EntityConstructor, AttributesDescription, ISOXMLReference } from '../types' 10 | 11 | 12 | export type CommentAllocationAttributes = { 13 | CodedCommentIdRef?: ISOXMLReference 14 | CodedCommentListValueIdRef?: ISOXMLReference 15 | FreeCommentText?: string 16 | AllocationStamp?: AllocationStamp[] 17 | ProprietaryAttributes?: {[name: string]: string} 18 | ProprietaryTags?: {[tag: string]: XMLElement[]} 19 | } 20 | 21 | const ATTRIBUTES: AttributesDescription = { 22 | A: { 23 | name: 'CodedCommentIdRef', 24 | type: 'xs:IDREF', 25 | isPrimaryId: false, 26 | isOptional: true, 27 | isOnlyV4: false, 28 | }, 29 | B: { 30 | name: 'CodedCommentListValueIdRef', 31 | type: 'xs:IDREF', 32 | isPrimaryId: false, 33 | isOptional: true, 34 | isOnlyV4: false, 35 | }, 36 | C: { 37 | name: 'FreeCommentText', 38 | type: 'xs:string', 39 | isPrimaryId: false, 40 | isOptional: true, 41 | isOnlyV4: false, 42 | }, 43 | } 44 | const CHILD_TAGS = { 45 | ASP: { name: 'AllocationStamp', isOnlyV4: false }, 46 | } 47 | 48 | export class CommentAllocation implements Entity { 49 | public tag = TAGS.CommentAllocation 50 | 51 | constructor(public attributes: CommentAllocationAttributes, public isoxmlManager: ISOXMLManager) { 52 | } 53 | 54 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = CommentAllocation): Promise { 55 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 56 | } 57 | 58 | toXML(): XMLElement { 59 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 60 | } 61 | } 62 | 63 | registerEntityClass('main', TAGS.CommentAllocation, CommentAllocation) -------------------------------------------------------------------------------- /src/baseEntities/Connection.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | 8 | import { Entity, EntityConstructor, AttributesDescription, ISOXMLReference } from '../types' 9 | 10 | 11 | export type ConnectionAttributes = { 12 | DeviceIdRef_0: ISOXMLReference 13 | DeviceElementIdRef_0: ISOXMLReference 14 | DeviceIdRef_1: ISOXMLReference 15 | DeviceElementIdRef_1: ISOXMLReference 16 | ProprietaryAttributes?: {[name: string]: string} 17 | ProprietaryTags?: {[tag: string]: XMLElement[]} 18 | } 19 | 20 | const ATTRIBUTES: AttributesDescription = { 21 | A: { 22 | name: 'DeviceIdRef_0', 23 | type: 'xs:IDREF', 24 | isPrimaryId: false, 25 | isOptional: false, 26 | isOnlyV4: false, 27 | }, 28 | B: { 29 | name: 'DeviceElementIdRef_0', 30 | type: 'xs:IDREF', 31 | isPrimaryId: false, 32 | isOptional: false, 33 | isOnlyV4: false, 34 | }, 35 | C: { 36 | name: 'DeviceIdRef_1', 37 | type: 'xs:IDREF', 38 | isPrimaryId: false, 39 | isOptional: false, 40 | isOnlyV4: false, 41 | }, 42 | D: { 43 | name: 'DeviceElementIdRef_1', 44 | type: 'xs:IDREF', 45 | isPrimaryId: false, 46 | isOptional: false, 47 | isOnlyV4: false, 48 | }, 49 | } 50 | const CHILD_TAGS = { 51 | } 52 | 53 | export class Connection implements Entity { 54 | public tag = TAGS.Connection 55 | 56 | constructor(public attributes: ConnectionAttributes, public isoxmlManager: ISOXMLManager) { 57 | } 58 | 59 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = Connection): Promise { 60 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 61 | } 62 | 63 | toXML(): XMLElement { 64 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 65 | } 66 | } 67 | 68 | registerEntityClass('main', TAGS.Connection, Connection) -------------------------------------------------------------------------------- /src/baseEntities/ControlAssignment.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | import { AllocationStamp } from './AllocationStamp' 8 | 9 | import { Entity, EntityConstructor, AttributesDescription } from '../types' 10 | 11 | 12 | export type ControlAssignmentAttributes = { 13 | SourceClientNAME: string 14 | UserClientNAME: string 15 | SourceDeviceStructureLabel: string 16 | UserDeviceStructureLabel: string 17 | SourceDeviceElementNumber: number 18 | UserDeviceElementNumber: number 19 | ProcessDataDDI: string 20 | AllocationStamp?: AllocationStamp[] 21 | ProprietaryAttributes?: {[name: string]: string} 22 | ProprietaryTags?: {[tag: string]: XMLElement[]} 23 | } 24 | 25 | const ATTRIBUTES: AttributesDescription = { 26 | A: { 27 | name: 'SourceClientNAME', 28 | type: 'xs:hexBinary', 29 | isPrimaryId: false, 30 | isOptional: false, 31 | isOnlyV4: undefined, 32 | }, 33 | B: { 34 | name: 'UserClientNAME', 35 | type: 'xs:hexBinary', 36 | isPrimaryId: false, 37 | isOptional: false, 38 | isOnlyV4: undefined, 39 | }, 40 | C: { 41 | name: 'SourceDeviceStructureLabel', 42 | type: 'xs:hexBinary', 43 | isPrimaryId: false, 44 | isOptional: false, 45 | isOnlyV4: undefined, 46 | }, 47 | D: { 48 | name: 'UserDeviceStructureLabel', 49 | type: 'xs:hexBinary', 50 | isPrimaryId: false, 51 | isOptional: false, 52 | isOnlyV4: undefined, 53 | }, 54 | E: { 55 | name: 'SourceDeviceElementNumber', 56 | type: 'xs:unsignedShort', 57 | isPrimaryId: false, 58 | isOptional: false, 59 | isOnlyV4: undefined, 60 | minValue: 0, 61 | maxValue: 4095, 62 | }, 63 | F: { 64 | name: 'UserDeviceElementNumber', 65 | type: 'xs:unsignedShort', 66 | isPrimaryId: false, 67 | isOptional: false, 68 | isOnlyV4: undefined, 69 | minValue: 0, 70 | maxValue: 4095, 71 | }, 72 | G: { 73 | name: 'ProcessDataDDI', 74 | type: 'xs:hexBinary', 75 | isPrimaryId: false, 76 | isOptional: false, 77 | isOnlyV4: undefined, 78 | }, 79 | } 80 | const CHILD_TAGS = { 81 | ASP: { name: 'AllocationStamp', isOnlyV4: undefined }, 82 | } 83 | 84 | export class ControlAssignment implements Entity { 85 | public tag = TAGS.ControlAssignment 86 | 87 | constructor(public attributes: ControlAssignmentAttributes, public isoxmlManager: ISOXMLManager) { 88 | } 89 | 90 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = ControlAssignment): Promise { 91 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 92 | } 93 | 94 | toXML(): XMLElement { 95 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 96 | } 97 | } 98 | 99 | registerEntityClass('main', TAGS.ControlAssignment, ControlAssignment) -------------------------------------------------------------------------------- /src/baseEntities/CropType.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | import { CropVariety } from './CropVariety' 8 | 9 | import { Entity, EntityConstructor, AttributesDescription, ISOXMLReference } from '../types' 10 | 11 | 12 | export type CropTypeAttributes = { 13 | CropTypeDesignator: string 14 | ProductGroupIdRef?: ISOXMLReference 15 | CropVariety?: CropVariety[] 16 | ProprietaryAttributes?: {[name: string]: string} 17 | ProprietaryTags?: {[tag: string]: XMLElement[]} 18 | } 19 | 20 | const ATTRIBUTES: AttributesDescription = { 21 | A: { 22 | name: 'CropTypeId', 23 | type: 'xs:ID', 24 | isPrimaryId: true, 25 | isOptional: false, 26 | isOnlyV4: false, 27 | }, 28 | B: { 29 | name: 'CropTypeDesignator', 30 | type: 'xs:string', 31 | isPrimaryId: false, 32 | isOptional: false, 33 | isOnlyV4: false, 34 | }, 35 | C: { 36 | name: 'ProductGroupIdRef', 37 | type: 'xs:IDREF', 38 | isPrimaryId: false, 39 | isOptional: true, 40 | isOnlyV4: true, 41 | }, 42 | } 43 | const CHILD_TAGS = { 44 | CVT: { name: 'CropVariety', isOnlyV4: false }, 45 | } 46 | 47 | export class CropType implements Entity { 48 | public tag = TAGS.CropType 49 | 50 | constructor(public attributes: CropTypeAttributes, public isoxmlManager: ISOXMLManager) { 51 | } 52 | 53 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = CropType): Promise { 54 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 55 | } 56 | 57 | toXML(): XMLElement { 58 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 59 | } 60 | } 61 | 62 | registerEntityClass('main', TAGS.CropType, CropType) -------------------------------------------------------------------------------- /src/baseEntities/CropVariety.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | 8 | import { Entity, EntityConstructor, AttributesDescription, ISOXMLReference } from '../types' 9 | 10 | 11 | export type CropVarietyAttributes = { 12 | CropVarietyDesignator: string 13 | ProductIdRef?: ISOXMLReference 14 | ProprietaryAttributes?: {[name: string]: string} 15 | ProprietaryTags?: {[tag: string]: XMLElement[]} 16 | } 17 | 18 | const ATTRIBUTES: AttributesDescription = { 19 | A: { 20 | name: 'CropVarietyId', 21 | type: 'xs:ID', 22 | isPrimaryId: true, 23 | isOptional: false, 24 | isOnlyV4: false, 25 | }, 26 | B: { 27 | name: 'CropVarietyDesignator', 28 | type: 'xs:string', 29 | isPrimaryId: false, 30 | isOptional: false, 31 | isOnlyV4: false, 32 | }, 33 | C: { 34 | name: 'ProductIdRef', 35 | type: 'xs:IDREF', 36 | isPrimaryId: false, 37 | isOptional: true, 38 | isOnlyV4: true, 39 | }, 40 | } 41 | const CHILD_TAGS = { 42 | } 43 | 44 | export class CropVariety implements Entity { 45 | public tag = TAGS.CropVariety 46 | 47 | constructor(public attributes: CropVarietyAttributes, public isoxmlManager: ISOXMLManager) { 48 | } 49 | 50 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = CropVariety): Promise { 51 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 52 | } 53 | 54 | toXML(): XMLElement { 55 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 56 | } 57 | } 58 | 59 | registerEntityClass('main', TAGS.CropVariety, CropVariety) -------------------------------------------------------------------------------- /src/baseEntities/CulturalPractice.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | import { OperationTechniqueReference } from './OperationTechniqueReference' 8 | 9 | import { Entity, EntityConstructor, AttributesDescription } from '../types' 10 | 11 | 12 | export type CulturalPracticeAttributes = { 13 | CulturalPracticeDesignator: string 14 | OperationTechniqueReference?: OperationTechniqueReference[] 15 | ProprietaryAttributes?: {[name: string]: string} 16 | ProprietaryTags?: {[tag: string]: XMLElement[]} 17 | } 18 | 19 | const ATTRIBUTES: AttributesDescription = { 20 | A: { 21 | name: 'CulturalPracticeId', 22 | type: 'xs:ID', 23 | isPrimaryId: true, 24 | isOptional: false, 25 | isOnlyV4: false, 26 | }, 27 | B: { 28 | name: 'CulturalPracticeDesignator', 29 | type: 'xs:string', 30 | isPrimaryId: false, 31 | isOptional: false, 32 | isOnlyV4: false, 33 | }, 34 | } 35 | const CHILD_TAGS = { 36 | OTR: { name: 'OperationTechniqueReference', isOnlyV4: false }, 37 | } 38 | 39 | export class CulturalPractice implements Entity { 40 | public tag = TAGS.CulturalPractice 41 | 42 | constructor(public attributes: CulturalPracticeAttributes, public isoxmlManager: ISOXMLManager) { 43 | } 44 | 45 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = CulturalPractice): Promise { 46 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 47 | } 48 | 49 | toXML(): XMLElement { 50 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 51 | } 52 | } 53 | 54 | registerEntityClass('main', TAGS.CulturalPractice, CulturalPractice) -------------------------------------------------------------------------------- /src/baseEntities/Customer.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | 8 | import { Entity, EntityConstructor, AttributesDescription } from '../types' 9 | 10 | 11 | export type CustomerAttributes = { 12 | CustomerLastName: string 13 | CustomerFirstName?: string 14 | CustomerStreet?: string 15 | CustomerPOBox?: string 16 | CustomerPostalCode?: string 17 | CustomerCity?: string 18 | CustomerState?: string 19 | CustomerCountry?: string 20 | CustomerPhone?: string 21 | CustomerMobile?: string 22 | CustomerFax?: string 23 | CustomerEMail?: string 24 | ProprietaryAttributes?: {[name: string]: string} 25 | ProprietaryTags?: {[tag: string]: XMLElement[]} 26 | } 27 | 28 | const ATTRIBUTES: AttributesDescription = { 29 | A: { 30 | name: 'CustomerId', 31 | type: 'xs:ID', 32 | isPrimaryId: true, 33 | isOptional: false, 34 | isOnlyV4: false, 35 | }, 36 | B: { 37 | name: 'CustomerLastName', 38 | type: 'xs:string', 39 | isPrimaryId: false, 40 | isOptional: false, 41 | isOnlyV4: false, 42 | }, 43 | C: { 44 | name: 'CustomerFirstName', 45 | type: 'xs:string', 46 | isPrimaryId: false, 47 | isOptional: true, 48 | isOnlyV4: false, 49 | }, 50 | D: { 51 | name: 'CustomerStreet', 52 | type: 'xs:string', 53 | isPrimaryId: false, 54 | isOptional: true, 55 | isOnlyV4: false, 56 | }, 57 | E: { 58 | name: 'CustomerPOBox', 59 | type: 'xs:string', 60 | isPrimaryId: false, 61 | isOptional: true, 62 | isOnlyV4: false, 63 | }, 64 | F: { 65 | name: 'CustomerPostalCode', 66 | type: 'xs:string', 67 | isPrimaryId: false, 68 | isOptional: true, 69 | isOnlyV4: false, 70 | }, 71 | G: { 72 | name: 'CustomerCity', 73 | type: 'xs:string', 74 | isPrimaryId: false, 75 | isOptional: true, 76 | isOnlyV4: false, 77 | }, 78 | H: { 79 | name: 'CustomerState', 80 | type: 'xs:string', 81 | isPrimaryId: false, 82 | isOptional: true, 83 | isOnlyV4: false, 84 | }, 85 | I: { 86 | name: 'CustomerCountry', 87 | type: 'xs:string', 88 | isPrimaryId: false, 89 | isOptional: true, 90 | isOnlyV4: false, 91 | }, 92 | J: { 93 | name: 'CustomerPhone', 94 | type: 'xs:string', 95 | isPrimaryId: false, 96 | isOptional: true, 97 | isOnlyV4: false, 98 | }, 99 | K: { 100 | name: 'CustomerMobile', 101 | type: 'xs:string', 102 | isPrimaryId: false, 103 | isOptional: true, 104 | isOnlyV4: false, 105 | }, 106 | L: { 107 | name: 'CustomerFax', 108 | type: 'xs:string', 109 | isPrimaryId: false, 110 | isOptional: true, 111 | isOnlyV4: false, 112 | }, 113 | M: { 114 | name: 'CustomerEMail', 115 | type: 'xs:string', 116 | isPrimaryId: false, 117 | isOptional: true, 118 | isOnlyV4: false, 119 | }, 120 | } 121 | const CHILD_TAGS = { 122 | } 123 | 124 | export class Customer implements Entity { 125 | public tag = TAGS.Customer 126 | 127 | constructor(public attributes: CustomerAttributes, public isoxmlManager: ISOXMLManager) { 128 | } 129 | 130 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = Customer): Promise { 131 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 132 | } 133 | 134 | toXML(): XMLElement { 135 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 136 | } 137 | } 138 | 139 | registerEntityClass('main', TAGS.Customer, Customer) -------------------------------------------------------------------------------- /src/baseEntities/DataLogTrigger.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | 8 | import { Entity, EntityConstructor, AttributesDescription, ISOXMLReference } from '../types' 9 | 10 | 11 | export type DataLogTriggerAttributes = { 12 | DataLogDDI: string 13 | DataLogMethod: number 14 | DataLogDistanceInterval?: number 15 | DataLogTimeInterval?: number 16 | DataLogThresholdMinimum?: number 17 | DataLogThresholdMaximum?: number 18 | DataLogThresholdChange?: number 19 | DeviceElementIdRef?: ISOXMLReference 20 | ValuePresentationIdRef?: ISOXMLReference 21 | DataLogPGN?: number 22 | DataLogPGNStartBit?: number 23 | DataLogPGNStopBit?: number 24 | ProprietaryAttributes?: {[name: string]: string} 25 | ProprietaryTags?: {[tag: string]: XMLElement[]} 26 | } 27 | 28 | const ATTRIBUTES: AttributesDescription = { 29 | A: { 30 | name: 'DataLogDDI', 31 | type: 'xs:hexBinary', 32 | isPrimaryId: false, 33 | isOptional: false, 34 | isOnlyV4: false, 35 | }, 36 | B: { 37 | name: 'DataLogMethod', 38 | type: 'xs:unsignedByte', 39 | isPrimaryId: false, 40 | isOptional: false, 41 | isOnlyV4: false, 42 | minValue: 1, 43 | maxValue: 31, 44 | }, 45 | C: { 46 | name: 'DataLogDistanceInterval', 47 | type: 'xs:long', 48 | isPrimaryId: false, 49 | isOptional: true, 50 | isOnlyV4: false, 51 | minValue: 0, 52 | maxValue: 1000000, 53 | }, 54 | D: { 55 | name: 'DataLogTimeInterval', 56 | type: 'xs:long', 57 | isPrimaryId: false, 58 | isOptional: true, 59 | isOnlyV4: false, 60 | minValue: 0, 61 | maxValue: 60000, 62 | }, 63 | E: { 64 | name: 'DataLogThresholdMinimum', 65 | type: 'xs:long', 66 | isPrimaryId: false, 67 | isOptional: true, 68 | isOnlyV4: false, 69 | minValue: -2147483647, 70 | maxValue: 2147483647, 71 | }, 72 | F: { 73 | name: 'DataLogThresholdMaximum', 74 | type: 'xs:long', 75 | isPrimaryId: false, 76 | isOptional: true, 77 | isOnlyV4: false, 78 | minValue: -2147483647, 79 | maxValue: 2147483647, 80 | }, 81 | G: { 82 | name: 'DataLogThresholdChange', 83 | type: 'xs:long', 84 | isPrimaryId: false, 85 | isOptional: true, 86 | isOnlyV4: false, 87 | minValue: -2147483647, 88 | maxValue: 2147483647, 89 | }, 90 | H: { 91 | name: 'DeviceElementIdRef', 92 | type: 'xs:IDREF', 93 | isPrimaryId: false, 94 | isOptional: true, 95 | isOnlyV4: false, 96 | }, 97 | I: { 98 | name: 'ValuePresentationIdRef', 99 | type: 'xs:IDREF', 100 | isPrimaryId: false, 101 | isOptional: true, 102 | isOnlyV4: false, 103 | }, 104 | J: { 105 | name: 'DataLogPGN', 106 | type: 'xs:unsignedLong', 107 | isPrimaryId: false, 108 | isOptional: true, 109 | isOnlyV4: false, 110 | minValue: 0, 111 | maxValue: 262143, 112 | }, 113 | K: { 114 | name: 'DataLogPGNStartBit', 115 | type: 'xs:unsignedByte', 116 | isPrimaryId: false, 117 | isOptional: true, 118 | isOnlyV4: false, 119 | minValue: 0, 120 | maxValue: 63, 121 | }, 122 | L: { 123 | name: 'DataLogPGNStopBit', 124 | type: 'xs:unsignedByte', 125 | isPrimaryId: false, 126 | isOptional: true, 127 | isOnlyV4: false, 128 | minValue: 0, 129 | maxValue: 63, 130 | }, 131 | } 132 | const CHILD_TAGS = { 133 | } 134 | 135 | export class DataLogTrigger implements Entity { 136 | public tag = TAGS.DataLogTrigger 137 | 138 | constructor(public attributes: DataLogTriggerAttributes, public isoxmlManager: ISOXMLManager) { 139 | } 140 | 141 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = DataLogTrigger): Promise { 142 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 143 | } 144 | 145 | toXML(): XMLElement { 146 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 147 | } 148 | } 149 | 150 | registerEntityClass('main', TAGS.DataLogTrigger, DataLogTrigger) -------------------------------------------------------------------------------- /src/baseEntities/DataLogValue.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | 8 | import { Entity, EntityConstructor, AttributesDescription, ISOXMLReference } from '../types' 9 | 10 | 11 | export type DataLogValueAttributes = { 12 | ProcessDataDDI: string 13 | ProcessDataValue: number 14 | DeviceElementIdRef: ISOXMLReference 15 | DataLogPGN?: number 16 | DataLogPGNStartBit?: number 17 | DataLogPGNStopBit?: number 18 | ProprietaryAttributes?: {[name: string]: string} 19 | ProprietaryTags?: {[tag: string]: XMLElement[]} 20 | } 21 | 22 | const ATTRIBUTES: AttributesDescription = { 23 | A: { 24 | name: 'ProcessDataDDI', 25 | type: 'xs:hexBinary', 26 | isPrimaryId: false, 27 | isOptional: false, 28 | isOnlyV4: false, 29 | }, 30 | B: { 31 | name: 'ProcessDataValue', 32 | type: 'xs:long', 33 | isPrimaryId: false, 34 | isOptional: false, 35 | isOnlyV4: false, 36 | minValue: -2147483648, 37 | maxValue: 2147483647, 38 | }, 39 | C: { 40 | name: 'DeviceElementIdRef', 41 | type: 'xs:IDREF', 42 | isPrimaryId: false, 43 | isOptional: false, 44 | isOnlyV4: false, 45 | }, 46 | D: { 47 | name: 'DataLogPGN', 48 | type: 'xs:unsignedLong', 49 | isPrimaryId: false, 50 | isOptional: true, 51 | isOnlyV4: false, 52 | minValue: 0, 53 | maxValue: 262143, 54 | }, 55 | E: { 56 | name: 'DataLogPGNStartBit', 57 | type: 'xs:unsignedByte', 58 | isPrimaryId: false, 59 | isOptional: true, 60 | isOnlyV4: false, 61 | minValue: 0, 62 | maxValue: 63, 63 | }, 64 | F: { 65 | name: 'DataLogPGNStopBit', 66 | type: 'xs:unsignedByte', 67 | isPrimaryId: false, 68 | isOptional: true, 69 | isOnlyV4: false, 70 | minValue: 0, 71 | maxValue: 63, 72 | }, 73 | } 74 | const CHILD_TAGS = { 75 | } 76 | 77 | export class DataLogValue implements Entity { 78 | public tag = TAGS.DataLogValue 79 | 80 | constructor(public attributes: DataLogValueAttributes, public isoxmlManager: ISOXMLManager) { 81 | } 82 | 83 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = DataLogValue): Promise { 84 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 85 | } 86 | 87 | toXML(): XMLElement { 88 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 89 | } 90 | } 91 | 92 | registerEntityClass('main', TAGS.DataLogValue, DataLogValue) -------------------------------------------------------------------------------- /src/baseEntities/Device.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | import { DeviceElement } from './DeviceElement' 8 | import { DeviceProperty } from './DeviceProperty' 9 | import { DeviceProcessData } from './DeviceProcessData' 10 | import { DeviceValuePresentation } from './DeviceValuePresentation' 11 | 12 | import { Entity, EntityConstructor, AttributesDescription } from '../types' 13 | 14 | 15 | export type DeviceAttributes = { 16 | DeviceDesignator?: string 17 | DeviceSoftwareVersion?: string 18 | ClientNAME: string 19 | DeviceSerialNumber?: string 20 | DeviceStructureLabel: string 21 | DeviceLocalizationLabel: string 22 | DeviceElement?: DeviceElement[] 23 | DeviceProperty?: DeviceProperty[] 24 | DeviceProcessData?: DeviceProcessData[] 25 | DeviceValuePresentation?: DeviceValuePresentation[] 26 | ProprietaryAttributes?: {[name: string]: string} 27 | ProprietaryTags?: {[tag: string]: XMLElement[]} 28 | } 29 | 30 | const ATTRIBUTES: AttributesDescription = { 31 | A: { 32 | name: 'DeviceId', 33 | type: 'xs:ID', 34 | isPrimaryId: true, 35 | isOptional: false, 36 | isOnlyV4: false, 37 | }, 38 | B: { 39 | name: 'DeviceDesignator', 40 | type: 'xs:string', 41 | isPrimaryId: false, 42 | isOptional: true, 43 | isOnlyV4: false, 44 | }, 45 | C: { 46 | name: 'DeviceSoftwareVersion', 47 | type: 'xs:string', 48 | isPrimaryId: false, 49 | isOptional: true, 50 | isOnlyV4: false, 51 | }, 52 | D: { 53 | name: 'ClientNAME', 54 | type: 'xs:hexBinary', 55 | isPrimaryId: false, 56 | isOptional: false, 57 | isOnlyV4: false, 58 | }, 59 | E: { 60 | name: 'DeviceSerialNumber', 61 | type: 'xs:string', 62 | isPrimaryId: false, 63 | isOptional: true, 64 | isOnlyV4: false, 65 | }, 66 | F: { 67 | name: 'DeviceStructureLabel', 68 | type: 'xs:hexBinary', 69 | isPrimaryId: false, 70 | isOptional: false, 71 | isOnlyV4: false, 72 | }, 73 | G: { 74 | name: 'DeviceLocalizationLabel', 75 | type: 'xs:hexBinary', 76 | isPrimaryId: false, 77 | isOptional: false, 78 | isOnlyV4: false, 79 | }, 80 | } 81 | const CHILD_TAGS = { 82 | DET: { name: 'DeviceElement', isOnlyV4: false }, 83 | DPT: { name: 'DeviceProperty', isOnlyV4: false }, 84 | DPD: { name: 'DeviceProcessData', isOnlyV4: false }, 85 | DVP: { name: 'DeviceValuePresentation', isOnlyV4: false }, 86 | } 87 | 88 | export class Device implements Entity { 89 | public tag = TAGS.Device 90 | 91 | constructor(public attributes: DeviceAttributes, public isoxmlManager: ISOXMLManager) { 92 | } 93 | 94 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = Device): Promise { 95 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 96 | } 97 | 98 | toXML(): XMLElement { 99 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 100 | } 101 | } 102 | 103 | registerEntityClass('main', TAGS.Device, Device) -------------------------------------------------------------------------------- /src/baseEntities/DeviceAllocation.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | import { AllocationStamp } from './AllocationStamp' 8 | 9 | import { Entity, EntityConstructor, AttributesDescription, ISOXMLReference } from '../types' 10 | 11 | 12 | export type DeviceAllocationAttributes = { 13 | ClientNAMEValue: string 14 | ClientNAMEMask?: string 15 | DeviceIdRef?: ISOXMLReference 16 | AllocationStamp?: AllocationStamp[] 17 | ProprietaryAttributes?: {[name: string]: string} 18 | ProprietaryTags?: {[tag: string]: XMLElement[]} 19 | } 20 | 21 | const ATTRIBUTES: AttributesDescription = { 22 | A: { 23 | name: 'ClientNAMEValue', 24 | type: 'xs:hexBinary', 25 | isPrimaryId: false, 26 | isOptional: false, 27 | isOnlyV4: false, 28 | }, 29 | B: { 30 | name: 'ClientNAMEMask', 31 | type: 'xs:hexBinary', 32 | isPrimaryId: false, 33 | isOptional: true, 34 | isOnlyV4: false, 35 | }, 36 | C: { 37 | name: 'DeviceIdRef', 38 | type: 'xs:IDREF', 39 | isPrimaryId: false, 40 | isOptional: true, 41 | isOnlyV4: false, 42 | }, 43 | } 44 | const CHILD_TAGS = { 45 | ASP: { name: 'AllocationStamp', isOnlyV4: false }, 46 | } 47 | 48 | export class DeviceAllocation implements Entity { 49 | public tag = TAGS.DeviceAllocation 50 | 51 | constructor(public attributes: DeviceAllocationAttributes, public isoxmlManager: ISOXMLManager) { 52 | } 53 | 54 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = DeviceAllocation): Promise { 55 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 56 | } 57 | 58 | toXML(): XMLElement { 59 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 60 | } 61 | } 62 | 63 | registerEntityClass('main', TAGS.DeviceAllocation, DeviceAllocation) -------------------------------------------------------------------------------- /src/baseEntities/DeviceElement.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | import { DeviceObjectReference } from './DeviceObjectReference' 8 | 9 | import { Entity, EntityConstructor, AttributesDescription } from '../types' 10 | 11 | export enum DeviceElementDeviceElementTypeEnum { 12 | Device = '1', 13 | Function = '2', 14 | Bin = '3', 15 | Section = '4', 16 | Unit = '5', 17 | Connector = '6', 18 | Navigation = '7', 19 | } 20 | 21 | export type DeviceElementAttributes = { 22 | DeviceElementObjectId: number 23 | DeviceElementType: DeviceElementDeviceElementTypeEnum 24 | DeviceElementDesignator?: string 25 | DeviceElementNumber: number 26 | ParentObjectId: number 27 | DeviceObjectReference?: DeviceObjectReference[] 28 | ProprietaryAttributes?: {[name: string]: string} 29 | ProprietaryTags?: {[tag: string]: XMLElement[]} 30 | } 31 | 32 | const ATTRIBUTES: AttributesDescription = { 33 | A: { 34 | name: 'DeviceElementId', 35 | type: 'xs:ID', 36 | isPrimaryId: true, 37 | isOptional: false, 38 | isOnlyV4: false, 39 | }, 40 | B: { 41 | name: 'DeviceElementObjectId', 42 | type: 'xs:unsignedShort', 43 | isPrimaryId: false, 44 | isOptional: false, 45 | isOnlyV4: false, 46 | minValue: 1, 47 | maxValue: 65534, 48 | }, 49 | C: { 50 | name: 'DeviceElementType', 51 | type: 'xs:NMTOKEN', 52 | isPrimaryId: false, 53 | isOptional: false, 54 | isOnlyV4: false, 55 | }, 56 | D: { 57 | name: 'DeviceElementDesignator', 58 | type: 'xs:string', 59 | isPrimaryId: false, 60 | isOptional: true, 61 | isOnlyV4: false, 62 | }, 63 | E: { 64 | name: 'DeviceElementNumber', 65 | type: 'xs:unsignedShort', 66 | isPrimaryId: false, 67 | isOptional: false, 68 | isOnlyV4: false, 69 | minValue: 0, 70 | maxValue: 4095, 71 | }, 72 | F: { 73 | name: 'ParentObjectId', 74 | type: 'xs:unsignedShort', 75 | isPrimaryId: false, 76 | isOptional: false, 77 | isOnlyV4: false, 78 | minValue: 0, 79 | maxValue: 65534, 80 | }, 81 | } 82 | const CHILD_TAGS = { 83 | DOR: { name: 'DeviceObjectReference', isOnlyV4: false }, 84 | } 85 | 86 | export class DeviceElement implements Entity { 87 | public tag = TAGS.DeviceElement 88 | 89 | constructor(public attributes: DeviceElementAttributes, public isoxmlManager: ISOXMLManager) { 90 | } 91 | 92 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = DeviceElement): Promise { 93 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 94 | } 95 | 96 | toXML(): XMLElement { 97 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 98 | } 99 | } 100 | 101 | registerEntityClass('main', TAGS.DeviceElement, DeviceElement) -------------------------------------------------------------------------------- /src/baseEntities/DeviceObjectReference.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | 8 | import { Entity, EntityConstructor, AttributesDescription } from '../types' 9 | 10 | 11 | export type DeviceObjectReferenceAttributes = { 12 | DeviceObjectId: number 13 | ProprietaryAttributes?: {[name: string]: string} 14 | ProprietaryTags?: {[tag: string]: XMLElement[]} 15 | } 16 | 17 | const ATTRIBUTES: AttributesDescription = { 18 | A: { 19 | name: 'DeviceObjectId', 20 | type: 'xs:unsignedShort', 21 | isPrimaryId: false, 22 | isOptional: false, 23 | isOnlyV4: false, 24 | minValue: 1, 25 | maxValue: 65534, 26 | }, 27 | } 28 | const CHILD_TAGS = { 29 | } 30 | 31 | export class DeviceObjectReference implements Entity { 32 | public tag = TAGS.DeviceObjectReference 33 | 34 | constructor(public attributes: DeviceObjectReferenceAttributes, public isoxmlManager: ISOXMLManager) { 35 | } 36 | 37 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = DeviceObjectReference): Promise { 38 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 39 | } 40 | 41 | toXML(): XMLElement { 42 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 43 | } 44 | } 45 | 46 | registerEntityClass('main', TAGS.DeviceObjectReference, DeviceObjectReference) -------------------------------------------------------------------------------- /src/baseEntities/DeviceProcessData.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | 8 | import { Entity, EntityConstructor, AttributesDescription } from '../types' 9 | 10 | 11 | export type DeviceProcessDataAttributes = { 12 | DeviceProcessDataObjectId: number 13 | DeviceProcessDataDDI: string 14 | DeviceProcessDataProperty: number 15 | DeviceProcessDataTriggerMethods: number 16 | DeviceProcessDataDesignator?: string 17 | DeviceValuePresentationObjectId?: number 18 | ProprietaryAttributes?: {[name: string]: string} 19 | ProprietaryTags?: {[tag: string]: XMLElement[]} 20 | } 21 | 22 | const ATTRIBUTES: AttributesDescription = { 23 | A: { 24 | name: 'DeviceProcessDataObjectId', 25 | type: 'xs:unsignedShort', 26 | isPrimaryId: false, 27 | isOptional: false, 28 | isOnlyV4: false, 29 | minValue: 1, 30 | maxValue: 65534, 31 | }, 32 | B: { 33 | name: 'DeviceProcessDataDDI', 34 | type: 'xs:hexBinary', 35 | isPrimaryId: false, 36 | isOptional: false, 37 | isOnlyV4: false, 38 | }, 39 | C: { 40 | name: 'DeviceProcessDataProperty', 41 | type: 'xs:unsignedByte', 42 | isPrimaryId: false, 43 | isOptional: false, 44 | isOnlyV4: false, 45 | minValue: 0, 46 | maxValue: 7, 47 | }, 48 | D: { 49 | name: 'DeviceProcessDataTriggerMethods', 50 | type: 'xs:unsignedByte', 51 | isPrimaryId: false, 52 | isOptional: false, 53 | isOnlyV4: false, 54 | minValue: 0, 55 | maxValue: 31, 56 | }, 57 | E: { 58 | name: 'DeviceProcessDataDesignator', 59 | type: 'xs:string', 60 | isPrimaryId: false, 61 | isOptional: true, 62 | isOnlyV4: false, 63 | }, 64 | F: { 65 | name: 'DeviceValuePresentationObjectId', 66 | type: 'xs:unsignedShort', 67 | isPrimaryId: false, 68 | isOptional: true, 69 | isOnlyV4: false, 70 | minValue: 1, 71 | maxValue: 65534, 72 | }, 73 | } 74 | const CHILD_TAGS = { 75 | } 76 | 77 | export class DeviceProcessData implements Entity { 78 | public tag = TAGS.DeviceProcessData 79 | 80 | constructor(public attributes: DeviceProcessDataAttributes, public isoxmlManager: ISOXMLManager) { 81 | } 82 | 83 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = DeviceProcessData): Promise { 84 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 85 | } 86 | 87 | toXML(): XMLElement { 88 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 89 | } 90 | } 91 | 92 | registerEntityClass('main', TAGS.DeviceProcessData, DeviceProcessData) -------------------------------------------------------------------------------- /src/baseEntities/DeviceProperty.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | 8 | import { Entity, EntityConstructor, AttributesDescription } from '../types' 9 | 10 | 11 | export type DevicePropertyAttributes = { 12 | DevicePropertyObjectId: number 13 | DevicePropertyDDI: string 14 | DevicePropertyValue: number 15 | DevicePropertyDesignator?: string 16 | DeviceValuePresentationObjectId?: number 17 | ProprietaryAttributes?: {[name: string]: string} 18 | ProprietaryTags?: {[tag: string]: XMLElement[]} 19 | } 20 | 21 | const ATTRIBUTES: AttributesDescription = { 22 | A: { 23 | name: 'DevicePropertyObjectId', 24 | type: 'xs:unsignedShort', 25 | isPrimaryId: false, 26 | isOptional: false, 27 | isOnlyV4: false, 28 | minValue: 1, 29 | maxValue: 65534, 30 | }, 31 | B: { 32 | name: 'DevicePropertyDDI', 33 | type: 'xs:hexBinary', 34 | isPrimaryId: false, 35 | isOptional: false, 36 | isOnlyV4: false, 37 | }, 38 | C: { 39 | name: 'DevicePropertyValue', 40 | type: 'xs:long', 41 | isPrimaryId: false, 42 | isOptional: false, 43 | isOnlyV4: false, 44 | minValue: -2147483648, 45 | maxValue: 2147483647, 46 | }, 47 | D: { 48 | name: 'DevicePropertyDesignator', 49 | type: 'xs:string', 50 | isPrimaryId: false, 51 | isOptional: true, 52 | isOnlyV4: false, 53 | }, 54 | E: { 55 | name: 'DeviceValuePresentationObjectId', 56 | type: 'xs:unsignedShort', 57 | isPrimaryId: false, 58 | isOptional: true, 59 | isOnlyV4: false, 60 | minValue: 1, 61 | maxValue: 65534, 62 | }, 63 | } 64 | const CHILD_TAGS = { 65 | } 66 | 67 | export class DeviceProperty implements Entity { 68 | public tag = TAGS.DeviceProperty 69 | 70 | constructor(public attributes: DevicePropertyAttributes, public isoxmlManager: ISOXMLManager) { 71 | } 72 | 73 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = DeviceProperty): Promise { 74 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 75 | } 76 | 77 | toXML(): XMLElement { 78 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 79 | } 80 | } 81 | 82 | registerEntityClass('main', TAGS.DeviceProperty, DeviceProperty) -------------------------------------------------------------------------------- /src/baseEntities/DeviceValuePresentation.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | 8 | import { Entity, EntityConstructor, AttributesDescription } from '../types' 9 | 10 | 11 | export type DeviceValuePresentationAttributes = { 12 | DeviceValuePresentationObjectId: number 13 | Offset: number 14 | Scale: number 15 | NumberOfDecimals: number 16 | UnitDesignator?: string 17 | ProprietaryAttributes?: {[name: string]: string} 18 | ProprietaryTags?: {[tag: string]: XMLElement[]} 19 | } 20 | 21 | const ATTRIBUTES: AttributesDescription = { 22 | A: { 23 | name: 'DeviceValuePresentationObjectId', 24 | type: 'xs:unsignedShort', 25 | isPrimaryId: false, 26 | isOptional: false, 27 | isOnlyV4: false, 28 | minValue: 1, 29 | maxValue: 65534, 30 | }, 31 | B: { 32 | name: 'Offset', 33 | type: 'xs:long', 34 | isPrimaryId: false, 35 | isOptional: false, 36 | isOnlyV4: false, 37 | minValue: -2147483648, 38 | maxValue: 2147483647, 39 | }, 40 | C: { 41 | name: 'Scale', 42 | type: 'xs:decimal', 43 | isPrimaryId: false, 44 | isOptional: false, 45 | isOnlyV4: false, 46 | minValue: 1e-9, 47 | maxValue: 100000000, 48 | }, 49 | D: { 50 | name: 'NumberOfDecimals', 51 | type: 'xs:unsignedByte', 52 | isPrimaryId: false, 53 | isOptional: false, 54 | isOnlyV4: false, 55 | minValue: 0, 56 | maxValue: 7, 57 | }, 58 | E: { 59 | name: 'UnitDesignator', 60 | type: 'xs:string', 61 | isPrimaryId: false, 62 | isOptional: true, 63 | isOnlyV4: false, 64 | }, 65 | } 66 | const CHILD_TAGS = { 67 | } 68 | 69 | export class DeviceValuePresentation implements Entity { 70 | public tag = TAGS.DeviceValuePresentation 71 | 72 | constructor(public attributes: DeviceValuePresentationAttributes, public isoxmlManager: ISOXMLManager) { 73 | } 74 | 75 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = DeviceValuePresentation): Promise { 76 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 77 | } 78 | 79 | toXML(): XMLElement { 80 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 81 | } 82 | } 83 | 84 | registerEntityClass('main', TAGS.DeviceValuePresentation, DeviceValuePresentation) -------------------------------------------------------------------------------- /src/baseEntities/ExternalFileContents.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | import { BaseStation } from './BaseStation' 8 | import { CodedComment } from './CodedComment' 9 | import { CodedCommentGroup } from './CodedCommentGroup' 10 | import { ColourLegend } from './ColourLegend' 11 | import { CropType } from './CropType' 12 | import { CulturalPractice } from './CulturalPractice' 13 | import { Customer } from './Customer' 14 | import { Device } from './Device' 15 | import { Farm } from './Farm' 16 | import { OperationTechnique } from './OperationTechnique' 17 | import { Partfield } from './Partfield' 18 | import { Product } from './Product' 19 | import { ProductGroup } from './ProductGroup' 20 | import { Task } from './Task' 21 | import { ValuePresentation } from './ValuePresentation' 22 | import { Worker } from './Worker' 23 | 24 | import { Entity, EntityConstructor, AttributesDescription } from '../types' 25 | 26 | 27 | export type ExternalFileContentsAttributes = { 28 | BaseStation?: BaseStation[] 29 | CodedComment?: CodedComment[] 30 | CodedCommentGroup?: CodedCommentGroup[] 31 | ColourLegend?: ColourLegend[] 32 | CropType?: CropType[] 33 | CulturalPractice?: CulturalPractice[] 34 | Customer?: Customer[] 35 | Device?: Device[] 36 | Farm?: Farm[] 37 | OperationTechnique?: OperationTechnique[] 38 | Partfield?: Partfield[] 39 | Product?: Product[] 40 | ProductGroup?: ProductGroup[] 41 | Task?: Task[] 42 | ValuePresentation?: ValuePresentation[] 43 | Worker?: Worker[] 44 | ProprietaryAttributes?: {[name: string]: string} 45 | ProprietaryTags?: {[tag: string]: XMLElement[]} 46 | } 47 | 48 | const ATTRIBUTES: AttributesDescription = { 49 | } 50 | const CHILD_TAGS = { 51 | BSN: { name: 'BaseStation', isOnlyV4: undefined }, 52 | CCT: { name: 'CodedComment', isOnlyV4: undefined }, 53 | CCG: { name: 'CodedCommentGroup', isOnlyV4: undefined }, 54 | CLD: { name: 'ColourLegend', isOnlyV4: undefined }, 55 | CTP: { name: 'CropType', isOnlyV4: undefined }, 56 | CPC: { name: 'CulturalPractice', isOnlyV4: undefined }, 57 | CTR: { name: 'Customer', isOnlyV4: undefined }, 58 | DVC: { name: 'Device', isOnlyV4: undefined }, 59 | FRM: { name: 'Farm', isOnlyV4: undefined }, 60 | OTQ: { name: 'OperationTechnique', isOnlyV4: undefined }, 61 | PFD: { name: 'Partfield', isOnlyV4: undefined }, 62 | PDT: { name: 'Product', isOnlyV4: undefined }, 63 | PGP: { name: 'ProductGroup', isOnlyV4: undefined }, 64 | TSK: { name: 'Task', isOnlyV4: undefined }, 65 | VPN: { name: 'ValuePresentation', isOnlyV4: undefined }, 66 | WKR: { name: 'Worker', isOnlyV4: undefined }, 67 | } 68 | 69 | export class ExternalFileContents implements Entity { 70 | public tag = TAGS.ExternalFileContents 71 | 72 | constructor(public attributes: ExternalFileContentsAttributes, public isoxmlManager: ISOXMLManager) { 73 | } 74 | 75 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = ExternalFileContents): Promise { 76 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 77 | } 78 | 79 | toXML(): XMLElement { 80 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 81 | } 82 | } 83 | 84 | registerEntityClass('main', TAGS.ExternalFileContents, ExternalFileContents) -------------------------------------------------------------------------------- /src/baseEntities/ExternalFileReference.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | 8 | import { Entity, EntityConstructor, AttributesDescription } from '../types' 9 | 10 | export enum ExternalFileReferenceFiletypeEnum { 11 | XML = '1', 12 | } 13 | 14 | export type ExternalFileReferenceAttributes = { 15 | Filename: string 16 | Filetype: ExternalFileReferenceFiletypeEnum 17 | ProprietaryAttributes?: {[name: string]: string} 18 | ProprietaryTags?: {[tag: string]: XMLElement[]} 19 | } 20 | 21 | const ATTRIBUTES: AttributesDescription = { 22 | A: { 23 | name: 'Filename', 24 | type: 'xs:ID', 25 | isPrimaryId: false, 26 | isOptional: false, 27 | isOnlyV4: false, 28 | }, 29 | B: { 30 | name: 'Filetype', 31 | type: 'xs:NMTOKEN', 32 | isPrimaryId: false, 33 | isOptional: false, 34 | isOnlyV4: false, 35 | }, 36 | } 37 | const CHILD_TAGS = { 38 | } 39 | 40 | export class ExternalFileReference implements Entity { 41 | public tag = TAGS.ExternalFileReference 42 | 43 | constructor(public attributes: ExternalFileReferenceAttributes, public isoxmlManager: ISOXMLManager) { 44 | } 45 | 46 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = ExternalFileReference): Promise { 47 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 48 | } 49 | 50 | toXML(): XMLElement { 51 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 52 | } 53 | } 54 | 55 | registerEntityClass('main', TAGS.ExternalFileReference, ExternalFileReference) -------------------------------------------------------------------------------- /src/baseEntities/Farm.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | 8 | import { Entity, EntityConstructor, AttributesDescription, ISOXMLReference } from '../types' 9 | 10 | 11 | export type FarmAttributes = { 12 | FarmDesignator: string 13 | FarmStreet?: string 14 | FarmPOBox?: string 15 | FarmPostalCode?: string 16 | FarmCity?: string 17 | FarmState?: string 18 | FarmCountry?: string 19 | CustomerIdRef?: ISOXMLReference 20 | ProprietaryAttributes?: {[name: string]: string} 21 | ProprietaryTags?: {[tag: string]: XMLElement[]} 22 | } 23 | 24 | const ATTRIBUTES: AttributesDescription = { 25 | A: { 26 | name: 'FarmId', 27 | type: 'xs:ID', 28 | isPrimaryId: true, 29 | isOptional: false, 30 | isOnlyV4: false, 31 | }, 32 | B: { 33 | name: 'FarmDesignator', 34 | type: 'xs:string', 35 | isPrimaryId: false, 36 | isOptional: false, 37 | isOnlyV4: false, 38 | }, 39 | C: { 40 | name: 'FarmStreet', 41 | type: 'xs:string', 42 | isPrimaryId: false, 43 | isOptional: true, 44 | isOnlyV4: false, 45 | }, 46 | D: { 47 | name: 'FarmPOBox', 48 | type: 'xs:string', 49 | isPrimaryId: false, 50 | isOptional: true, 51 | isOnlyV4: false, 52 | }, 53 | E: { 54 | name: 'FarmPostalCode', 55 | type: 'xs:string', 56 | isPrimaryId: false, 57 | isOptional: true, 58 | isOnlyV4: false, 59 | }, 60 | F: { 61 | name: 'FarmCity', 62 | type: 'xs:string', 63 | isPrimaryId: false, 64 | isOptional: true, 65 | isOnlyV4: false, 66 | }, 67 | G: { 68 | name: 'FarmState', 69 | type: 'xs:string', 70 | isPrimaryId: false, 71 | isOptional: true, 72 | isOnlyV4: false, 73 | }, 74 | H: { 75 | name: 'FarmCountry', 76 | type: 'xs:string', 77 | isPrimaryId: false, 78 | isOptional: true, 79 | isOnlyV4: false, 80 | }, 81 | I: { 82 | name: 'CustomerIdRef', 83 | type: 'xs:IDREF', 84 | isPrimaryId: false, 85 | isOptional: true, 86 | isOnlyV4: false, 87 | }, 88 | } 89 | const CHILD_TAGS = { 90 | } 91 | 92 | export class Farm implements Entity { 93 | public tag = TAGS.Farm 94 | 95 | constructor(public attributes: FarmAttributes, public isoxmlManager: ISOXMLManager) { 96 | } 97 | 98 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = Farm): Promise { 99 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 100 | } 101 | 102 | toXML(): XMLElement { 103 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 104 | } 105 | } 106 | 107 | registerEntityClass('main', TAGS.Farm, Farm) -------------------------------------------------------------------------------- /src/baseEntities/Grid.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | 8 | import { Entity, EntityConstructor, AttributesDescription } from '../types' 9 | 10 | export enum GridGridTypeEnum { 11 | GridType1 = '1', 12 | GridType2 = '2', 13 | } 14 | 15 | export type GridAttributes = { 16 | GridMinimumNorthPosition: number 17 | GridMinimumEastPosition: number 18 | GridCellNorthSize: number 19 | GridCellEastSize: number 20 | GridMaximumColumn: number 21 | GridMaximumRow: number 22 | Filename: string 23 | Filelength?: number 24 | GridType: GridGridTypeEnum 25 | TreatmentZoneCode?: number 26 | ProprietaryAttributes?: {[name: string]: string} 27 | ProprietaryTags?: {[tag: string]: XMLElement[]} 28 | } 29 | 30 | const ATTRIBUTES: AttributesDescription = { 31 | A: { 32 | name: 'GridMinimumNorthPosition', 33 | type: 'xs:decimal', 34 | isPrimaryId: false, 35 | isOptional: false, 36 | isOnlyV4: false, 37 | minValue: -90, 38 | maxValue: 90, 39 | fractionDigits: 9, 40 | }, 41 | B: { 42 | name: 'GridMinimumEastPosition', 43 | type: 'xs:decimal', 44 | isPrimaryId: false, 45 | isOptional: false, 46 | isOnlyV4: false, 47 | minValue: -180, 48 | maxValue: 180, 49 | fractionDigits: 9, 50 | }, 51 | C: { 52 | name: 'GridCellNorthSize', 53 | type: 'xs:double', 54 | isPrimaryId: false, 55 | isOptional: false, 56 | isOnlyV4: false, 57 | minValue: 0, 58 | maxValue: 1, 59 | }, 60 | D: { 61 | name: 'GridCellEastSize', 62 | type: 'xs:double', 63 | isPrimaryId: false, 64 | isOptional: false, 65 | isOnlyV4: false, 66 | minValue: 0, 67 | maxValue: 1, 68 | }, 69 | E: { 70 | name: 'GridMaximumColumn', 71 | type: 'xs:unsignedLong', 72 | isPrimaryId: false, 73 | isOptional: false, 74 | isOnlyV4: false, 75 | minValue: 0, 76 | maxValue: 4294967295, 77 | }, 78 | F: { 79 | name: 'GridMaximumRow', 80 | type: 'xs:unsignedLong', 81 | isPrimaryId: false, 82 | isOptional: false, 83 | isOnlyV4: false, 84 | minValue: 0, 85 | maxValue: 4294967295, 86 | }, 87 | G: { 88 | name: 'Filename', 89 | type: 'xs:ID', 90 | isPrimaryId: false, 91 | isOptional: false, 92 | isOnlyV4: false, 93 | }, 94 | H: { 95 | name: 'Filelength', 96 | type: 'xs:unsignedLong', 97 | isPrimaryId: false, 98 | isOptional: true, 99 | isOnlyV4: false, 100 | minValue: 0, 101 | maxValue: 4294967294, 102 | }, 103 | I: { 104 | name: 'GridType', 105 | type: 'xs:NMTOKEN', 106 | isPrimaryId: false, 107 | isOptional: false, 108 | isOnlyV4: false, 109 | }, 110 | J: { 111 | name: 'TreatmentZoneCode', 112 | type: 'xs:unsignedByte', 113 | isPrimaryId: false, 114 | isOptional: true, 115 | isOnlyV4: false, 116 | minValue: 0, 117 | maxValue: 254, 118 | }, 119 | } 120 | const CHILD_TAGS = { 121 | } 122 | 123 | export class Grid implements Entity { 124 | public tag = TAGS.Grid 125 | 126 | constructor(public attributes: GridAttributes, public isoxmlManager: ISOXMLManager) { 127 | } 128 | 129 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = Grid): Promise { 130 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 131 | } 132 | 133 | toXML(): XMLElement { 134 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 135 | } 136 | } 137 | 138 | registerEntityClass('main', TAGS.Grid, Grid) -------------------------------------------------------------------------------- /src/baseEntities/GuidanceAllocation.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | import { AllocationStamp } from './AllocationStamp' 8 | import { GuidanceShift } from './GuidanceShift' 9 | 10 | import { Entity, EntityConstructor, AttributesDescription, ISOXMLReference } from '../types' 11 | 12 | 13 | export type GuidanceAllocationAttributes = { 14 | GuidanceGroupIdRef: ISOXMLReference 15 | AllocationStamp?: AllocationStamp[] 16 | GuidanceShift?: GuidanceShift[] 17 | ProprietaryAttributes?: {[name: string]: string} 18 | ProprietaryTags?: {[tag: string]: XMLElement[]} 19 | } 20 | 21 | const ATTRIBUTES: AttributesDescription = { 22 | A: { 23 | name: 'GuidanceGroupIdRef', 24 | type: 'xs:IDREF', 25 | isPrimaryId: false, 26 | isOptional: false, 27 | isOnlyV4: undefined, 28 | }, 29 | } 30 | const CHILD_TAGS = { 31 | ASP: { name: 'AllocationStamp', isOnlyV4: undefined }, 32 | GST: { name: 'GuidanceShift', isOnlyV4: undefined }, 33 | } 34 | 35 | export class GuidanceAllocation implements Entity { 36 | public tag = TAGS.GuidanceAllocation 37 | 38 | constructor(public attributes: GuidanceAllocationAttributes, public isoxmlManager: ISOXMLManager) { 39 | } 40 | 41 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = GuidanceAllocation): Promise { 42 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 43 | } 44 | 45 | toXML(): XMLElement { 46 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 47 | } 48 | } 49 | 50 | registerEntityClass('main', TAGS.GuidanceAllocation, GuidanceAllocation) -------------------------------------------------------------------------------- /src/baseEntities/GuidanceGroup.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | import { GuidancePattern } from './GuidancePattern' 8 | import { Polygon } from './Polygon' 9 | 10 | import { Entity, EntityConstructor, AttributesDescription } from '../types' 11 | 12 | 13 | export type GuidanceGroupAttributes = { 14 | GuidanceGroupDesignator?: string 15 | GuidancePattern?: GuidancePattern[] 16 | BoundaryPolygon?: Polygon[] 17 | ProprietaryAttributes?: {[name: string]: string} 18 | ProprietaryTags?: {[tag: string]: XMLElement[]} 19 | } 20 | 21 | const ATTRIBUTES: AttributesDescription = { 22 | A: { 23 | name: 'GuidanceGroupId', 24 | type: 'xs:ID', 25 | isPrimaryId: true, 26 | isOptional: false, 27 | isOnlyV4: undefined, 28 | }, 29 | B: { 30 | name: 'GuidanceGroupDesignator', 31 | type: 'xs:string', 32 | isPrimaryId: false, 33 | isOptional: true, 34 | isOnlyV4: undefined, 35 | }, 36 | } 37 | const CHILD_TAGS = { 38 | GPN: { name: 'GuidancePattern', isOnlyV4: undefined }, 39 | PLN: { name: 'BoundaryPolygon', isOnlyV4: undefined }, 40 | } 41 | 42 | export class GuidanceGroup implements Entity { 43 | public tag = TAGS.GuidanceGroup 44 | 45 | constructor(public attributes: GuidanceGroupAttributes, public isoxmlManager: ISOXMLManager) { 46 | } 47 | 48 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = GuidanceGroup): Promise { 49 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 50 | } 51 | 52 | toXML(): XMLElement { 53 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 54 | } 55 | } 56 | 57 | registerEntityClass('main', TAGS.GuidanceGroup, GuidanceGroup) -------------------------------------------------------------------------------- /src/baseEntities/GuidanceShift.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | import { AllocationStamp } from './AllocationStamp' 8 | 9 | import { Entity, EntityConstructor, AttributesDescription, ISOXMLReference } from '../types' 10 | 11 | 12 | export type GuidanceShiftAttributes = { 13 | GuidanceGroupIdRef?: ISOXMLReference 14 | GuidancePatternIdRef?: ISOXMLReference 15 | GuidanceEastShift?: number 16 | GuidanceNorthShift?: number 17 | PropagationOffset?: number 18 | AllocationStamp?: AllocationStamp[] 19 | ProprietaryAttributes?: {[name: string]: string} 20 | ProprietaryTags?: {[tag: string]: XMLElement[]} 21 | } 22 | 23 | const ATTRIBUTES: AttributesDescription = { 24 | A: { 25 | name: 'GuidanceGroupIdRef', 26 | type: 'xs:IDREF', 27 | isPrimaryId: false, 28 | isOptional: true, 29 | isOnlyV4: undefined, 30 | }, 31 | B: { 32 | name: 'GuidancePatternIdRef', 33 | type: 'xs:IDREF', 34 | isPrimaryId: false, 35 | isOptional: true, 36 | isOnlyV4: undefined, 37 | }, 38 | C: { 39 | name: 'GuidanceEastShift', 40 | type: 'xs:long', 41 | isPrimaryId: false, 42 | isOptional: true, 43 | isOnlyV4: undefined, 44 | minValue: -2147483648, 45 | maxValue: 2147483647, 46 | }, 47 | D: { 48 | name: 'GuidanceNorthShift', 49 | type: 'xs:long', 50 | isPrimaryId: false, 51 | isOptional: true, 52 | isOnlyV4: undefined, 53 | minValue: -2147483648, 54 | maxValue: 2147483647, 55 | }, 56 | E: { 57 | name: 'PropagationOffset', 58 | type: 'xs:long', 59 | isPrimaryId: false, 60 | isOptional: true, 61 | isOnlyV4: undefined, 62 | minValue: -2147483648, 63 | maxValue: 2147483647, 64 | }, 65 | } 66 | const CHILD_TAGS = { 67 | ASP: { name: 'AllocationStamp', isOnlyV4: undefined }, 68 | } 69 | 70 | export class GuidanceShift implements Entity { 71 | public tag = TAGS.GuidanceShift 72 | 73 | constructor(public attributes: GuidanceShiftAttributes, public isoxmlManager: ISOXMLManager) { 74 | } 75 | 76 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = GuidanceShift): Promise { 77 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 78 | } 79 | 80 | toXML(): XMLElement { 81 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 82 | } 83 | } 84 | 85 | registerEntityClass('main', TAGS.GuidanceShift, GuidanceShift) -------------------------------------------------------------------------------- /src/baseEntities/ISO11783LinkListFile.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | import { LinkGroup } from './LinkGroup' 8 | 9 | import { Entity, EntityConstructor, AttributesDescription } from '../types' 10 | 11 | export enum ISO11783LinkListFileVersionMajorEnum { 12 | TheVersionOfTheSecondEditionPublishedAsAFinalDraftInternationalStandard = '4', 13 | } 14 | export enum ISO11783LinkListFileVersionMinorEnum { 15 | Value0 = '0', 16 | Value1 = '1', 17 | Value2 = '2', 18 | Value3 = '3', 19 | } 20 | export enum ISO11783LinkListFileDataTransferOriginEnum { 21 | FMIS = '1', 22 | MICS = '2', 23 | } 24 | 25 | export type ISO11783LinkListFileAttributes = { 26 | VersionMajor: ISO11783LinkListFileVersionMajorEnum 27 | VersionMinor: ISO11783LinkListFileVersionMinorEnum 28 | ManagementSoftwareManufacturer: string 29 | ManagementSoftwareVersion: string 30 | TaskControllerManufacturer?: string 31 | TaskControllerVersion?: string 32 | FileVersion?: string 33 | DataTransferOrigin: ISO11783LinkListFileDataTransferOriginEnum 34 | LinkGroup?: LinkGroup[] 35 | ProprietaryAttributes?: {[name: string]: string} 36 | ProprietaryTags?: {[tag: string]: XMLElement[]} 37 | } 38 | 39 | const ATTRIBUTES: AttributesDescription = { 40 | VersionMajor: { 41 | name: 'VersionMajor', 42 | type: 'xs:NMTOKEN', 43 | isPrimaryId: false, 44 | isOptional: false, 45 | isOnlyV4: undefined, 46 | }, 47 | VersionMinor: { 48 | name: 'VersionMinor', 49 | type: 'xs:NMTOKEN', 50 | isPrimaryId: false, 51 | isOptional: false, 52 | isOnlyV4: undefined, 53 | }, 54 | ManagementSoftwareManufacturer: { 55 | name: 'ManagementSoftwareManufacturer', 56 | type: 'xs:string', 57 | isPrimaryId: false, 58 | isOptional: false, 59 | isOnlyV4: undefined, 60 | }, 61 | ManagementSoftwareVersion: { 62 | name: 'ManagementSoftwareVersion', 63 | type: 'xs:string', 64 | isPrimaryId: false, 65 | isOptional: false, 66 | isOnlyV4: undefined, 67 | }, 68 | TaskControllerManufacturer: { 69 | name: 'TaskControllerManufacturer', 70 | type: 'xs:string', 71 | isPrimaryId: false, 72 | isOptional: true, 73 | isOnlyV4: undefined, 74 | }, 75 | TaskControllerVersion: { 76 | name: 'TaskControllerVersion', 77 | type: 'xs:string', 78 | isPrimaryId: false, 79 | isOptional: true, 80 | isOnlyV4: undefined, 81 | }, 82 | FileVersion: { 83 | name: 'FileVersion', 84 | type: 'xs:string', 85 | isPrimaryId: false, 86 | isOptional: true, 87 | isOnlyV4: undefined, 88 | }, 89 | DataTransferOrigin: { 90 | name: 'DataTransferOrigin', 91 | type: 'xs:NMTOKEN', 92 | isPrimaryId: false, 93 | isOptional: false, 94 | isOnlyV4: undefined, 95 | }, 96 | } 97 | const CHILD_TAGS = { 98 | LGP: { name: 'LinkGroup', isOnlyV4: undefined }, 99 | } 100 | 101 | export class ISO11783LinkListFile implements Entity { 102 | public tag = TAGS.ISO11783LinkListFile 103 | 104 | constructor(public attributes: ISO11783LinkListFileAttributes, public isoxmlManager: ISOXMLManager) { 105 | } 106 | 107 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = ISO11783LinkListFile): Promise { 108 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 109 | } 110 | 111 | toXML(): XMLElement { 112 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 113 | } 114 | } 115 | 116 | registerEntityClass('main', TAGS.ISO11783LinkListFile, ISO11783LinkListFile) -------------------------------------------------------------------------------- /src/baseEntities/LineString.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | import { Point } from './Point' 8 | 9 | import { Entity, EntityConstructor, AttributesDescription } from '../types' 10 | 11 | export enum LineStringLineStringTypeEnum { 12 | PolygonExterior = '1', 13 | PolygonInterior = '2', 14 | TramLine = '3', 15 | SamplingRoute = '4', 16 | GuidancePattern = '5', 17 | Drainage = '6', 18 | Fence = '7', 19 | Flag = '8', 20 | Obstacle = '9', 21 | } 22 | 23 | export type LineStringAttributes = { 24 | LineStringType: LineStringLineStringTypeEnum 25 | LineStringDesignator?: string 26 | LineStringWidth?: number 27 | LineStringLength?: number 28 | LineStringColour?: number 29 | Point?: Point[] 30 | ProprietaryAttributes?: {[name: string]: string} 31 | ProprietaryTags?: {[tag: string]: XMLElement[]} 32 | } 33 | 34 | const ATTRIBUTES: AttributesDescription = { 35 | A: { 36 | name: 'LineStringType', 37 | type: 'xs:NMTOKEN', 38 | isPrimaryId: false, 39 | isOptional: false, 40 | isOnlyV4: false, 41 | }, 42 | B: { 43 | name: 'LineStringDesignator', 44 | type: 'xs:string', 45 | isPrimaryId: false, 46 | isOptional: true, 47 | isOnlyV4: false, 48 | }, 49 | C: { 50 | name: 'LineStringWidth', 51 | type: 'xs:unsignedLong', 52 | isPrimaryId: false, 53 | isOptional: true, 54 | isOnlyV4: false, 55 | minValue: 0, 56 | maxValue: 4294967294, 57 | }, 58 | D: { 59 | name: 'LineStringLength', 60 | type: 'xs:unsignedLong', 61 | isPrimaryId: false, 62 | isOptional: true, 63 | isOnlyV4: false, 64 | minValue: 0, 65 | maxValue: 4294967294, 66 | }, 67 | E: { 68 | name: 'LineStringColour', 69 | type: 'xs:unsignedByte', 70 | isPrimaryId: false, 71 | isOptional: true, 72 | isOnlyV4: false, 73 | minValue: 0, 74 | maxValue: 254, 75 | }, 76 | F: { 77 | name: 'LineStringId', 78 | type: 'xs:ID', 79 | isPrimaryId: true, 80 | isOptional: true, 81 | isOnlyV4: true, 82 | }, 83 | } 84 | const CHILD_TAGS = { 85 | PNT: { name: 'Point', isOnlyV4: false }, 86 | } 87 | 88 | export class LineString implements Entity { 89 | public tag = TAGS.LineString 90 | 91 | constructor(public attributes: LineStringAttributes, public isoxmlManager: ISOXMLManager) { 92 | } 93 | 94 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = LineString): Promise { 95 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 96 | } 97 | 98 | toXML(): XMLElement { 99 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 100 | } 101 | } 102 | 103 | registerEntityClass('main', TAGS.LineString, LineString) -------------------------------------------------------------------------------- /src/baseEntities/Link.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | 8 | import { Entity, EntityConstructor, AttributesDescription, ISOXMLReference } from '../types' 9 | 10 | 11 | export type LinkAttributes = { 12 | ObjectIdRef: ISOXMLReference 13 | LinkValue: string 14 | LinkDesignator?: string 15 | ProprietaryAttributes?: {[name: string]: string} 16 | ProprietaryTags?: {[tag: string]: XMLElement[]} 17 | } 18 | 19 | const ATTRIBUTES: AttributesDescription = { 20 | A: { 21 | name: 'ObjectIdRef', 22 | type: 'xs:IDREF', 23 | isPrimaryId: false, 24 | isOptional: false, 25 | isOnlyV4: undefined, 26 | }, 27 | B: { 28 | name: 'LinkValue', 29 | type: 'xs:token', 30 | isPrimaryId: false, 31 | isOptional: false, 32 | isOnlyV4: undefined, 33 | }, 34 | C: { 35 | name: 'LinkDesignator', 36 | type: 'xs:string', 37 | isPrimaryId: false, 38 | isOptional: true, 39 | isOnlyV4: undefined, 40 | }, 41 | } 42 | const CHILD_TAGS = { 43 | } 44 | 45 | export class Link implements Entity { 46 | public tag = TAGS.Link 47 | 48 | constructor(public attributes: LinkAttributes, public isoxmlManager: ISOXMLManager) { 49 | } 50 | 51 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = Link): Promise { 52 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 53 | } 54 | 55 | toXML(): XMLElement { 56 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 57 | } 58 | } 59 | 60 | registerEntityClass('main', TAGS.Link, Link) -------------------------------------------------------------------------------- /src/baseEntities/LinkGroup.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | import { Link } from './Link' 8 | 9 | import { Entity, EntityConstructor, AttributesDescription } from '../types' 10 | 11 | export enum LinkGroupLinkGroupTypeEnum { 12 | UUIDs = '1', 13 | ManufacturerProprietary = '2', 14 | UniqueResolvableURIs = '3', 15 | InformationalResolvableURIs = '4', 16 | } 17 | 18 | export type LinkGroupAttributes = { 19 | LinkGroupType: LinkGroupLinkGroupTypeEnum 20 | ManufacturerGLN?: string 21 | LinkGroupNamespace?: string 22 | LinkGroupDesignator?: string 23 | Link?: Link[] 24 | ProprietaryAttributes?: {[name: string]: string} 25 | ProprietaryTags?: {[tag: string]: XMLElement[]} 26 | } 27 | 28 | const ATTRIBUTES: AttributesDescription = { 29 | A: { 30 | name: 'LinkGroupId', 31 | type: 'xs:ID', 32 | isPrimaryId: true, 33 | isOptional: false, 34 | isOnlyV4: undefined, 35 | }, 36 | B: { 37 | name: 'LinkGroupType', 38 | type: 'xs:NMTOKEN', 39 | isPrimaryId: false, 40 | isOptional: false, 41 | isOnlyV4: undefined, 42 | }, 43 | C: { 44 | name: 'ManufacturerGLN', 45 | type: 'xs:anyURI', 46 | isPrimaryId: false, 47 | isOptional: true, 48 | isOnlyV4: undefined, 49 | }, 50 | D: { 51 | name: 'LinkGroupNamespace', 52 | type: 'xs:token', 53 | isPrimaryId: false, 54 | isOptional: true, 55 | isOnlyV4: undefined, 56 | }, 57 | E: { 58 | name: 'LinkGroupDesignator', 59 | type: 'xs:string', 60 | isPrimaryId: false, 61 | isOptional: true, 62 | isOnlyV4: undefined, 63 | }, 64 | } 65 | const CHILD_TAGS = { 66 | LNK: { name: 'Link', isOnlyV4: undefined }, 67 | } 68 | 69 | export class LinkGroup implements Entity { 70 | public tag = TAGS.LinkGroup 71 | 72 | constructor(public attributes: LinkGroupAttributes, public isoxmlManager: ISOXMLManager) { 73 | } 74 | 75 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = LinkGroup): Promise { 76 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 77 | } 78 | 79 | toXML(): XMLElement { 80 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 81 | } 82 | } 83 | 84 | registerEntityClass('main', TAGS.LinkGroup, LinkGroup) -------------------------------------------------------------------------------- /src/baseEntities/OperTechPractice.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | 8 | import { Entity, EntityConstructor, AttributesDescription, ISOXMLReference } from '../types' 9 | 10 | 11 | export type OperTechPracticeAttributes = { 12 | CulturalPracticeIdRef: ISOXMLReference 13 | OperationTechniqueIdRef?: ISOXMLReference 14 | ProprietaryAttributes?: {[name: string]: string} 15 | ProprietaryTags?: {[tag: string]: XMLElement[]} 16 | } 17 | 18 | const ATTRIBUTES: AttributesDescription = { 19 | A: { 20 | name: 'CulturalPracticeIdRef', 21 | type: 'xs:IDREF', 22 | isPrimaryId: false, 23 | isOptional: false, 24 | isOnlyV4: false, 25 | }, 26 | B: { 27 | name: 'OperationTechniqueIdRef', 28 | type: 'xs:IDREF', 29 | isPrimaryId: false, 30 | isOptional: true, 31 | isOnlyV4: false, 32 | }, 33 | } 34 | const CHILD_TAGS = { 35 | } 36 | 37 | export class OperTechPractice implements Entity { 38 | public tag = TAGS.OperTechPractice 39 | 40 | constructor(public attributes: OperTechPracticeAttributes, public isoxmlManager: ISOXMLManager) { 41 | } 42 | 43 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = OperTechPractice): Promise { 44 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 45 | } 46 | 47 | toXML(): XMLElement { 48 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 49 | } 50 | } 51 | 52 | registerEntityClass('main', TAGS.OperTechPractice, OperTechPractice) -------------------------------------------------------------------------------- /src/baseEntities/OperationTechnique.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | 8 | import { Entity, EntityConstructor, AttributesDescription } from '../types' 9 | 10 | 11 | export type OperationTechniqueAttributes = { 12 | OperationTechniqueDesignator: string 13 | ProprietaryAttributes?: {[name: string]: string} 14 | ProprietaryTags?: {[tag: string]: XMLElement[]} 15 | } 16 | 17 | const ATTRIBUTES: AttributesDescription = { 18 | A: { 19 | name: 'OperationTechniqueId', 20 | type: 'xs:ID', 21 | isPrimaryId: true, 22 | isOptional: false, 23 | isOnlyV4: false, 24 | }, 25 | B: { 26 | name: 'OperationTechniqueDesignator', 27 | type: 'xs:string', 28 | isPrimaryId: false, 29 | isOptional: false, 30 | isOnlyV4: false, 31 | }, 32 | } 33 | const CHILD_TAGS = { 34 | } 35 | 36 | export class OperationTechnique implements Entity { 37 | public tag = TAGS.OperationTechnique 38 | 39 | constructor(public attributes: OperationTechniqueAttributes, public isoxmlManager: ISOXMLManager) { 40 | } 41 | 42 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = OperationTechnique): Promise { 43 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 44 | } 45 | 46 | toXML(): XMLElement { 47 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 48 | } 49 | } 50 | 51 | registerEntityClass('main', TAGS.OperationTechnique, OperationTechnique) -------------------------------------------------------------------------------- /src/baseEntities/OperationTechniqueReference.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | 8 | import { Entity, EntityConstructor, AttributesDescription, ISOXMLReference } from '../types' 9 | 10 | 11 | export type OperationTechniqueReferenceAttributes = { 12 | OperationTechniqueIdRef: ISOXMLReference 13 | ProprietaryAttributes?: {[name: string]: string} 14 | ProprietaryTags?: {[tag: string]: XMLElement[]} 15 | } 16 | 17 | const ATTRIBUTES: AttributesDescription = { 18 | A: { 19 | name: 'OperationTechniqueIdRef', 20 | type: 'xs:IDREF', 21 | isPrimaryId: false, 22 | isOptional: false, 23 | isOnlyV4: false, 24 | }, 25 | } 26 | const CHILD_TAGS = { 27 | } 28 | 29 | export class OperationTechniqueReference implements Entity { 30 | public tag = TAGS.OperationTechniqueReference 31 | 32 | constructor(public attributes: OperationTechniqueReferenceAttributes, public isoxmlManager: ISOXMLManager) { 33 | } 34 | 35 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = OperationTechniqueReference): Promise { 36 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 37 | } 38 | 39 | toXML(): XMLElement { 40 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 41 | } 42 | } 43 | 44 | registerEntityClass('main', TAGS.OperationTechniqueReference, OperationTechniqueReference) -------------------------------------------------------------------------------- /src/baseEntities/Partfield.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | import { Polygon } from './Polygon' 8 | import { LineString } from './LineString' 9 | import { Point } from './Point' 10 | import { GuidanceGroup } from './GuidanceGroup' 11 | 12 | import { Entity, EntityConstructor, AttributesDescription, ISOXMLReference } from '../types' 13 | 14 | 15 | export type PartfieldAttributes = { 16 | PartfieldCode?: string 17 | PartfieldDesignator: string 18 | PartfieldArea: number 19 | CustomerIdRef?: ISOXMLReference 20 | FarmIdRef?: ISOXMLReference 21 | CropTypeIdRef?: ISOXMLReference 22 | CropVarietyIdRef?: ISOXMLReference 23 | FieldIdRef?: ISOXMLReference 24 | PolygonnonTreatmentZoneonly?: Polygon[] 25 | LineString?: LineString[] 26 | Point?: Point[] 27 | GuidanceGroup?: GuidanceGroup[] 28 | ProprietaryAttributes?: {[name: string]: string} 29 | ProprietaryTags?: {[tag: string]: XMLElement[]} 30 | } 31 | 32 | const ATTRIBUTES: AttributesDescription = { 33 | A: { 34 | name: 'PartfieldId', 35 | type: 'xs:ID', 36 | isPrimaryId: true, 37 | isOptional: false, 38 | isOnlyV4: false, 39 | }, 40 | B: { 41 | name: 'PartfieldCode', 42 | type: 'xs:string', 43 | isPrimaryId: false, 44 | isOptional: true, 45 | isOnlyV4: false, 46 | }, 47 | C: { 48 | name: 'PartfieldDesignator', 49 | type: 'xs:string', 50 | isPrimaryId: false, 51 | isOptional: false, 52 | isOnlyV4: false, 53 | }, 54 | D: { 55 | name: 'PartfieldArea', 56 | type: 'xs:unsignedLong', 57 | isPrimaryId: false, 58 | isOptional: false, 59 | isOnlyV4: false, 60 | minValue: 0, 61 | maxValue: 4294967294, 62 | }, 63 | E: { 64 | name: 'CustomerIdRef', 65 | type: 'xs:IDREF', 66 | isPrimaryId: false, 67 | isOptional: true, 68 | isOnlyV4: false, 69 | }, 70 | F: { 71 | name: 'FarmIdRef', 72 | type: 'xs:IDREF', 73 | isPrimaryId: false, 74 | isOptional: true, 75 | isOnlyV4: false, 76 | }, 77 | G: { 78 | name: 'CropTypeIdRef', 79 | type: 'xs:IDREF', 80 | isPrimaryId: false, 81 | isOptional: true, 82 | isOnlyV4: false, 83 | }, 84 | H: { 85 | name: 'CropVarietyIdRef', 86 | type: 'xs:IDREF', 87 | isPrimaryId: false, 88 | isOptional: true, 89 | isOnlyV4: false, 90 | }, 91 | I: { 92 | name: 'FieldIdRef', 93 | type: 'xs:IDREF', 94 | isPrimaryId: false, 95 | isOptional: true, 96 | isOnlyV4: false, 97 | }, 98 | } 99 | const CHILD_TAGS = { 100 | PLN: { name: 'PolygonnonTreatmentZoneonly', isOnlyV4: false }, 101 | LSG: { name: 'LineString', isOnlyV4: false }, 102 | PNT: { name: 'Point', isOnlyV4: false }, 103 | GGP: { name: 'GuidanceGroup', isOnlyV4: true }, 104 | } 105 | 106 | export class Partfield implements Entity { 107 | public tag = TAGS.Partfield 108 | 109 | constructor(public attributes: PartfieldAttributes, public isoxmlManager: ISOXMLManager) { 110 | } 111 | 112 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = Partfield): Promise { 113 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 114 | } 115 | 116 | toXML(): XMLElement { 117 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 118 | } 119 | } 120 | 121 | registerEntityClass('main', TAGS.Partfield, Partfield) -------------------------------------------------------------------------------- /src/baseEntities/Polygon.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | import { LineString } from './LineString' 8 | 9 | import { Entity, EntityConstructor, AttributesDescription } from '../types' 10 | 11 | export enum PolygonPolygonTypeEnum { 12 | PartfieldBoundary = '1', 13 | TreatmentZone = '2', 14 | WaterSurface = '3', 15 | Building = '4', 16 | Road = '5', 17 | Obstacle = '6', 18 | Flag = '7', 19 | Other = '8', 20 | Mainfield = '9', 21 | Headland = '10', 22 | BufferZone = '11', 23 | Windbreak = '12', 24 | } 25 | 26 | export type PolygonAttributes = { 27 | PolygonType: PolygonPolygonTypeEnum 28 | PolygonDesignator?: string 29 | PolygonArea?: number 30 | PolygonColour?: number 31 | LineString?: LineString[] 32 | ProprietaryAttributes?: {[name: string]: string} 33 | ProprietaryTags?: {[tag: string]: XMLElement[]} 34 | } 35 | 36 | const ATTRIBUTES: AttributesDescription = { 37 | A: { 38 | name: 'PolygonType', 39 | type: 'xs:NMTOKEN', 40 | isPrimaryId: false, 41 | isOptional: false, 42 | isOnlyV4: false, 43 | }, 44 | B: { 45 | name: 'PolygonDesignator', 46 | type: 'xs:string', 47 | isPrimaryId: false, 48 | isOptional: true, 49 | isOnlyV4: false, 50 | }, 51 | C: { 52 | name: 'PolygonArea', 53 | type: 'xs:unsignedLong', 54 | isPrimaryId: false, 55 | isOptional: true, 56 | isOnlyV4: false, 57 | minValue: 0, 58 | maxValue: 4294967294, 59 | }, 60 | D: { 61 | name: 'PolygonColour', 62 | type: 'xs:unsignedByte', 63 | isPrimaryId: false, 64 | isOptional: true, 65 | isOnlyV4: false, 66 | minValue: 0, 67 | maxValue: 254, 68 | }, 69 | E: { 70 | name: 'PolygonId', 71 | type: 'xs:ID', 72 | isPrimaryId: true, 73 | isOptional: true, 74 | isOnlyV4: true, 75 | }, 76 | } 77 | const CHILD_TAGS = { 78 | LSG: { name: 'LineString', isOnlyV4: false }, 79 | } 80 | 81 | export class Polygon implements Entity { 82 | public tag = TAGS.Polygon 83 | 84 | constructor(public attributes: PolygonAttributes, public isoxmlManager: ISOXMLManager) { 85 | } 86 | 87 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = Polygon): Promise { 88 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 89 | } 90 | 91 | toXML(): XMLElement { 92 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 93 | } 94 | } 95 | 96 | registerEntityClass('main', TAGS.Polygon, Polygon) -------------------------------------------------------------------------------- /src/baseEntities/Position.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | 8 | import { Entity, EntityConstructor, AttributesDescription } from '../types' 9 | 10 | export enum PositionPositionStatusEnum { 11 | NoGPSFix = '0', 12 | GNSSFix = '1', 13 | DGNSSFix = '2', 14 | PreciseGNSS = '3', 15 | RTKFixedInteger = '4', 16 | RTKFloat = '5', 17 | EstDRMode = '6', 18 | ManualInput = '7', 19 | SimulateMode = '8', 20 | Reserved9 = '9', 21 | Reserved10 = '10', 22 | Reserved11 = '11', 23 | Reserved12 = '12', 24 | Reserved13 = '13', 25 | Error = '14', 26 | PositionStatusValueIsNotAvailable = '15', 27 | } 28 | 29 | export type PositionAttributes = { 30 | PositionNorth: number 31 | PositionEast: number 32 | PositionUp?: number 33 | PositionStatus: PositionPositionStatusEnum 34 | PDOP?: number 35 | HDOP?: number 36 | NumberOfSatellites?: number 37 | GpsUtcTime?: number 38 | GpsUtcDate?: number 39 | ProprietaryAttributes?: {[name: string]: string} 40 | ProprietaryTags?: {[tag: string]: XMLElement[]} 41 | } 42 | 43 | const ATTRIBUTES: AttributesDescription = { 44 | A: { 45 | name: 'PositionNorth', 46 | type: 'xs:decimal', 47 | isPrimaryId: false, 48 | isOptional: false, 49 | isOnlyV4: false, 50 | minValue: -90, 51 | maxValue: 90, 52 | fractionDigits: 9, 53 | }, 54 | B: { 55 | name: 'PositionEast', 56 | type: 'xs:decimal', 57 | isPrimaryId: false, 58 | isOptional: false, 59 | isOnlyV4: false, 60 | minValue: -180, 61 | maxValue: 180, 62 | fractionDigits: 9, 63 | }, 64 | C: { 65 | name: 'PositionUp', 66 | type: 'xs:long', 67 | isPrimaryId: false, 68 | isOptional: true, 69 | isOnlyV4: false, 70 | minValue: -2147483648, 71 | maxValue: 2147483647, 72 | }, 73 | D: { 74 | name: 'PositionStatus', 75 | type: 'xs:NMTOKEN', 76 | isPrimaryId: false, 77 | isOptional: false, 78 | isOnlyV4: false, 79 | }, 80 | E: { 81 | name: 'PDOP', 82 | type: 'xs:decimal', 83 | isPrimaryId: false, 84 | isOptional: true, 85 | isOnlyV4: false, 86 | minValue: 0, 87 | maxValue: 99.9, 88 | }, 89 | F: { 90 | name: 'HDOP', 91 | type: 'xs:decimal', 92 | isPrimaryId: false, 93 | isOptional: true, 94 | isOnlyV4: false, 95 | minValue: 0, 96 | maxValue: 99.9, 97 | }, 98 | G: { 99 | name: 'NumberOfSatellites', 100 | type: 'xs:unsignedByte', 101 | isPrimaryId: false, 102 | isOptional: true, 103 | isOnlyV4: false, 104 | minValue: 0, 105 | maxValue: 254, 106 | }, 107 | H: { 108 | name: 'GpsUtcTime', 109 | type: 'xs:unsignedLong', 110 | isPrimaryId: false, 111 | isOptional: true, 112 | isOnlyV4: false, 113 | minValue: 0, 114 | maxValue: 4294967294, 115 | }, 116 | I: { 117 | name: 'GpsUtcDate', 118 | type: 'xs:unsignedShort', 119 | isPrimaryId: false, 120 | isOptional: true, 121 | isOnlyV4: false, 122 | minValue: 0, 123 | maxValue: 65534, 124 | }, 125 | } 126 | const CHILD_TAGS = { 127 | } 128 | 129 | export class Position implements Entity { 130 | public tag = TAGS.Position 131 | 132 | constructor(public attributes: PositionAttributes, public isoxmlManager: ISOXMLManager) { 133 | } 134 | 135 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = Position): Promise { 136 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 137 | } 138 | 139 | toXML(): XMLElement { 140 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 141 | } 142 | } 143 | 144 | registerEntityClass('main', TAGS.Position, Position) -------------------------------------------------------------------------------- /src/baseEntities/ProcessDataVariable.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | 8 | import { Entity, EntityConstructor, AttributesDescription, ISOXMLReference } from '../types' 9 | 10 | 11 | export type ProcessDataVariableAttributes = { 12 | ProcessDataDDI: string 13 | ProcessDataValue: number 14 | ProductIdRef?: ISOXMLReference 15 | DeviceElementIdRef?: ISOXMLReference 16 | ValuePresentationIdRef?: ISOXMLReference 17 | ActualCulturalPracticeValue?: number 18 | ElementTypeInstanceValue?: number 19 | ProcessDataVariable?: ProcessDataVariable[] 20 | ProprietaryAttributes?: {[name: string]: string} 21 | ProprietaryTags?: {[tag: string]: XMLElement[]} 22 | } 23 | 24 | const ATTRIBUTES: AttributesDescription = { 25 | A: { 26 | name: 'ProcessDataDDI', 27 | type: 'xs:hexBinary', 28 | isPrimaryId: false, 29 | isOptional: false, 30 | isOnlyV4: false, 31 | }, 32 | B: { 33 | name: 'ProcessDataValue', 34 | type: 'xs:long', 35 | isPrimaryId: false, 36 | isOptional: false, 37 | isOnlyV4: false, 38 | minValue: -2147483648, 39 | maxValue: 2147483647, 40 | }, 41 | C: { 42 | name: 'ProductIdRef', 43 | type: 'xs:IDREF', 44 | isPrimaryId: false, 45 | isOptional: true, 46 | isOnlyV4: false, 47 | }, 48 | D: { 49 | name: 'DeviceElementIdRef', 50 | type: 'xs:IDREF', 51 | isPrimaryId: false, 52 | isOptional: true, 53 | isOnlyV4: false, 54 | }, 55 | E: { 56 | name: 'ValuePresentationIdRef', 57 | type: 'xs:IDREF', 58 | isPrimaryId: false, 59 | isOptional: true, 60 | isOnlyV4: false, 61 | }, 62 | F: { 63 | name: 'ActualCulturalPracticeValue', 64 | type: 'xs:long', 65 | isPrimaryId: false, 66 | isOptional: true, 67 | isOnlyV4: true, 68 | minValue: -2147483648, 69 | maxValue: 2147483647, 70 | }, 71 | G: { 72 | name: 'ElementTypeInstanceValue', 73 | type: 'xs:long', 74 | isPrimaryId: false, 75 | isOptional: true, 76 | isOnlyV4: true, 77 | minValue: -2147483648, 78 | maxValue: 2147483647, 79 | }, 80 | } 81 | const CHILD_TAGS = { 82 | PDV: { name: 'ProcessDataVariable', isOnlyV4: false }, 83 | } 84 | 85 | export class ProcessDataVariable implements Entity { 86 | public tag = TAGS.ProcessDataVariable 87 | 88 | constructor(public attributes: ProcessDataVariableAttributes, public isoxmlManager: ISOXMLManager) { 89 | } 90 | 91 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = ProcessDataVariable): Promise { 92 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 93 | } 94 | 95 | toXML(): XMLElement { 96 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 97 | } 98 | } 99 | 100 | registerEntityClass('main', TAGS.ProcessDataVariable, ProcessDataVariable) -------------------------------------------------------------------------------- /src/baseEntities/Product.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | import { ProductRelation } from './ProductRelation' 8 | 9 | import { Entity, EntityConstructor, AttributesDescription, ISOXMLReference } from '../types' 10 | 11 | export enum ProductProductTypeEnum { 12 | SingleDefault = '1', 13 | Mixture = '2', 14 | TemporaryMixture = '3', 15 | } 16 | 17 | export type ProductAttributes = { 18 | ProductDesignator: string 19 | ProductGroupIdRef?: ISOXMLReference 20 | ValuePresentationIdRef?: ISOXMLReference 21 | QuantityDDI?: string 22 | ProductType?: ProductProductTypeEnum 23 | MixtureRecipeQuantity?: number 24 | DensityMassPerVolume?: number 25 | DensityMassPerCount?: number 26 | DensityVolumePerCount?: number 27 | ProductRelation?: ProductRelation[] 28 | ProprietaryAttributes?: {[name: string]: string} 29 | ProprietaryTags?: {[tag: string]: XMLElement[]} 30 | } 31 | 32 | const ATTRIBUTES: AttributesDescription = { 33 | A: { 34 | name: 'ProductId', 35 | type: 'xs:ID', 36 | isPrimaryId: true, 37 | isOptional: false, 38 | isOnlyV4: false, 39 | }, 40 | B: { 41 | name: 'ProductDesignator', 42 | type: 'xs:string', 43 | isPrimaryId: false, 44 | isOptional: false, 45 | isOnlyV4: false, 46 | }, 47 | C: { 48 | name: 'ProductGroupIdRef', 49 | type: 'xs:IDREF', 50 | isPrimaryId: false, 51 | isOptional: true, 52 | isOnlyV4: false, 53 | }, 54 | D: { 55 | name: 'ValuePresentationIdRef', 56 | type: 'xs:IDREF', 57 | isPrimaryId: false, 58 | isOptional: true, 59 | isOnlyV4: false, 60 | }, 61 | E: { 62 | name: 'QuantityDDI', 63 | type: 'xs:hexBinary', 64 | isPrimaryId: false, 65 | isOptional: true, 66 | isOnlyV4: false, 67 | }, 68 | F: { 69 | name: 'ProductType', 70 | type: 'xs:NMTOKEN', 71 | isPrimaryId: false, 72 | isOptional: true, 73 | isOnlyV4: true, 74 | }, 75 | G: { 76 | name: 'MixtureRecipeQuantity', 77 | type: 'xs:long', 78 | isPrimaryId: false, 79 | isOptional: true, 80 | isOnlyV4: true, 81 | minValue: 0, 82 | maxValue: 2147483647, 83 | }, 84 | H: { 85 | name: 'DensityMassPerVolume', 86 | type: 'xs:long', 87 | isPrimaryId: false, 88 | isOptional: true, 89 | isOnlyV4: true, 90 | minValue: 0, 91 | maxValue: 2147483647, 92 | }, 93 | I: { 94 | name: 'DensityMassPerCount', 95 | type: 'xs:long', 96 | isPrimaryId: false, 97 | isOptional: true, 98 | isOnlyV4: true, 99 | minValue: 0, 100 | maxValue: 2147483647, 101 | }, 102 | J: { 103 | name: 'DensityVolumePerCount', 104 | type: 'xs:long', 105 | isPrimaryId: false, 106 | isOptional: true, 107 | isOnlyV4: true, 108 | minValue: 0, 109 | maxValue: 2147483647, 110 | }, 111 | } 112 | const CHILD_TAGS = { 113 | PRN: { name: 'ProductRelation', isOnlyV4: true }, 114 | } 115 | 116 | export class Product implements Entity { 117 | public tag = TAGS.Product 118 | 119 | constructor(public attributes: ProductAttributes, public isoxmlManager: ISOXMLManager) { 120 | } 121 | 122 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = Product): Promise { 123 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 124 | } 125 | 126 | toXML(): XMLElement { 127 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 128 | } 129 | } 130 | 131 | registerEntityClass('main', TAGS.Product, Product) -------------------------------------------------------------------------------- /src/baseEntities/ProductAllocation.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | import { AllocationStamp } from './AllocationStamp' 8 | 9 | import { Entity, EntityConstructor, AttributesDescription, ISOXMLReference } from '../types' 10 | 11 | export enum ProductAllocationTransferModeEnum { 12 | Filling = '1', 13 | Emptying = '2', 14 | Remainder = '3', 15 | } 16 | 17 | export type ProductAllocationAttributes = { 18 | ProductIdRef: ISOXMLReference 19 | QuantityDDI?: string 20 | QuantityValue?: number 21 | TransferMode?: ProductAllocationTransferModeEnum 22 | DeviceElementIdRef?: ISOXMLReference 23 | ValuePresentationIdRef?: ISOXMLReference 24 | ProductSubTypeIdRef?: ISOXMLReference 25 | AllocationStamp?: AllocationStamp[] 26 | ProprietaryAttributes?: {[name: string]: string} 27 | ProprietaryTags?: {[tag: string]: XMLElement[]} 28 | } 29 | 30 | const ATTRIBUTES: AttributesDescription = { 31 | A: { 32 | name: 'ProductIdRef', 33 | type: 'xs:IDREF', 34 | isPrimaryId: false, 35 | isOptional: false, 36 | isOnlyV4: false, 37 | }, 38 | B: { 39 | name: 'QuantityDDI', 40 | type: 'xs:hexBinary', 41 | isPrimaryId: false, 42 | isOptional: true, 43 | isOnlyV4: false, 44 | }, 45 | C: { 46 | name: 'QuantityValue', 47 | type: 'xs:long', 48 | isPrimaryId: false, 49 | isOptional: true, 50 | isOnlyV4: false, 51 | minValue: 0, 52 | maxValue: 2147483647, 53 | }, 54 | D: { 55 | name: 'TransferMode', 56 | type: 'xs:NMTOKEN', 57 | isPrimaryId: false, 58 | isOptional: true, 59 | isOnlyV4: false, 60 | }, 61 | E: { 62 | name: 'DeviceElementIdRef', 63 | type: 'xs:IDREF', 64 | isPrimaryId: false, 65 | isOptional: true, 66 | isOnlyV4: false, 67 | }, 68 | F: { 69 | name: 'ValuePresentationIdRef', 70 | type: 'xs:IDREF', 71 | isPrimaryId: false, 72 | isOptional: true, 73 | isOnlyV4: false, 74 | }, 75 | G: { 76 | name: 'ProductSubTypeIdRef', 77 | type: 'xs:IDREF', 78 | isPrimaryId: false, 79 | isOptional: true, 80 | isOnlyV4: true, 81 | }, 82 | } 83 | const CHILD_TAGS = { 84 | ASP: { name: 'AllocationStamp', isOnlyV4: false }, 85 | } 86 | 87 | export class ProductAllocation implements Entity { 88 | public tag = TAGS.ProductAllocation 89 | 90 | constructor(public attributes: ProductAllocationAttributes, public isoxmlManager: ISOXMLManager) { 91 | } 92 | 93 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = ProductAllocation): Promise { 94 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 95 | } 96 | 97 | toXML(): XMLElement { 98 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 99 | } 100 | } 101 | 102 | registerEntityClass('main', TAGS.ProductAllocation, ProductAllocation) -------------------------------------------------------------------------------- /src/baseEntities/ProductGroup.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | 8 | import { Entity, EntityConstructor, AttributesDescription } from '../types' 9 | 10 | export enum ProductGroupProductGroupTypeEnum { 11 | ProductGroupDefault = '1', 12 | CropType = '2', 13 | } 14 | 15 | export type ProductGroupAttributes = { 16 | ProductGroupDesignator: string 17 | ProductGroupType?: ProductGroupProductGroupTypeEnum 18 | ProprietaryAttributes?: {[name: string]: string} 19 | ProprietaryTags?: {[tag: string]: XMLElement[]} 20 | } 21 | 22 | const ATTRIBUTES: AttributesDescription = { 23 | A: { 24 | name: 'ProductGroupId', 25 | type: 'xs:ID', 26 | isPrimaryId: true, 27 | isOptional: false, 28 | isOnlyV4: false, 29 | }, 30 | B: { 31 | name: 'ProductGroupDesignator', 32 | type: 'xs:string', 33 | isPrimaryId: false, 34 | isOptional: false, 35 | isOnlyV4: false, 36 | }, 37 | C: { 38 | name: 'ProductGroupType', 39 | type: 'xs:NMTOKEN', 40 | isPrimaryId: false, 41 | isOptional: true, 42 | isOnlyV4: true, 43 | }, 44 | } 45 | const CHILD_TAGS = { 46 | } 47 | 48 | export class ProductGroup implements Entity { 49 | public tag = TAGS.ProductGroup 50 | 51 | constructor(public attributes: ProductGroupAttributes, public isoxmlManager: ISOXMLManager) { 52 | } 53 | 54 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = ProductGroup): Promise { 55 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 56 | } 57 | 58 | toXML(): XMLElement { 59 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 60 | } 61 | } 62 | 63 | registerEntityClass('main', TAGS.ProductGroup, ProductGroup) -------------------------------------------------------------------------------- /src/baseEntities/ProductRelation.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | 8 | import { Entity, EntityConstructor, AttributesDescription, ISOXMLReference } from '../types' 9 | 10 | 11 | export type ProductRelationAttributes = { 12 | ProductIdRef: ISOXMLReference 13 | QuantityValue: number 14 | ProprietaryAttributes?: {[name: string]: string} 15 | ProprietaryTags?: {[tag: string]: XMLElement[]} 16 | } 17 | 18 | const ATTRIBUTES: AttributesDescription = { 19 | A: { 20 | name: 'ProductIdRef', 21 | type: 'xs:IDREF', 22 | isPrimaryId: false, 23 | isOptional: false, 24 | isOnlyV4: undefined, 25 | }, 26 | B: { 27 | name: 'QuantityValue', 28 | type: 'xs:long', 29 | isPrimaryId: false, 30 | isOptional: false, 31 | isOnlyV4: undefined, 32 | minValue: 0, 33 | maxValue: 2147483647, 34 | }, 35 | } 36 | const CHILD_TAGS = { 37 | } 38 | 39 | export class ProductRelation implements Entity { 40 | public tag = TAGS.ProductRelation 41 | 42 | constructor(public attributes: ProductRelationAttributes, public isoxmlManager: ISOXMLManager) { 43 | } 44 | 45 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = ProductRelation): Promise { 46 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 47 | } 48 | 49 | toXML(): XMLElement { 50 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 51 | } 52 | } 53 | 54 | registerEntityClass('main', TAGS.ProductRelation, ProductRelation) -------------------------------------------------------------------------------- /src/baseEntities/TaskControllerCapabilities.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | 8 | import { Entity, EntityConstructor, AttributesDescription } from '../types' 9 | 10 | export enum TaskControllerCapabilitiesVersionNumberEnum { 11 | TheVersionOfTheDIS1FirstDraftInternationalStandard = '0', 12 | TheVersionOfTheFDIS1FinalDraftInternationalStandardFirstEdition = '1', 13 | TheVersionOfTheFDIS2AndTheFirstEditionPublishedAsAnInternationalStandard = '2', 14 | TheVersionOfTheSecondEditionPublishedAsADraftInternationalStandardE2DIS = '3', 15 | TheVersionOfTheSecondEditionPublishedAsAFinalDraftInternationalStandardE2FDIS = '4', 16 | } 17 | 18 | export type TaskControllerCapabilitiesAttributes = { 19 | TaskControllerControlFunctionNAME: string 20 | TaskControllerDesignator: string 21 | VersionNumber: TaskControllerCapabilitiesVersionNumberEnum 22 | ProvidedCapabilities: number 23 | NumberOfBoomsSectionControl: number 24 | NumberOfSectionsSectionControl: number 25 | NumberOfControlChannels: number 26 | ProprietaryAttributes?: {[name: string]: string} 27 | ProprietaryTags?: {[tag: string]: XMLElement[]} 28 | } 29 | 30 | const ATTRIBUTES: AttributesDescription = { 31 | A: { 32 | name: 'TaskControllerControlFunctionNAME', 33 | type: 'xs:hexBinary', 34 | isPrimaryId: false, 35 | isOptional: false, 36 | isOnlyV4: undefined, 37 | }, 38 | B: { 39 | name: 'TaskControllerDesignator', 40 | type: 'xs:string', 41 | isPrimaryId: false, 42 | isOptional: false, 43 | isOnlyV4: undefined, 44 | }, 45 | C: { 46 | name: 'VersionNumber', 47 | type: 'xs:NMTOKEN', 48 | isPrimaryId: false, 49 | isOptional: false, 50 | isOnlyV4: undefined, 51 | }, 52 | D: { 53 | name: 'ProvidedCapabilities', 54 | type: 'xs:unsignedByte', 55 | isPrimaryId: false, 56 | isOptional: false, 57 | isOnlyV4: undefined, 58 | minValue: 0, 59 | maxValue: 63, 60 | }, 61 | E: { 62 | name: 'NumberOfBoomsSectionControl', 63 | type: 'xs:unsignedByte', 64 | isPrimaryId: false, 65 | isOptional: false, 66 | isOnlyV4: undefined, 67 | minValue: 0, 68 | maxValue: 254, 69 | }, 70 | F: { 71 | name: 'NumberOfSectionsSectionControl', 72 | type: 'xs:unsignedByte', 73 | isPrimaryId: false, 74 | isOptional: false, 75 | isOnlyV4: undefined, 76 | minValue: 0, 77 | maxValue: 254, 78 | }, 79 | G: { 80 | name: 'NumberOfControlChannels', 81 | type: 'xs:unsignedByte', 82 | isPrimaryId: false, 83 | isOptional: false, 84 | isOnlyV4: undefined, 85 | minValue: 0, 86 | maxValue: 254, 87 | }, 88 | } 89 | const CHILD_TAGS = { 90 | } 91 | 92 | export class TaskControllerCapabilities implements Entity { 93 | public tag = TAGS.TaskControllerCapabilities 94 | 95 | constructor(public attributes: TaskControllerCapabilitiesAttributes, public isoxmlManager: ISOXMLManager) { 96 | } 97 | 98 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = TaskControllerCapabilities): Promise { 99 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 100 | } 101 | 102 | toXML(): XMLElement { 103 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 104 | } 105 | } 106 | 107 | registerEntityClass('main', TAGS.TaskControllerCapabilities, TaskControllerCapabilities) -------------------------------------------------------------------------------- /src/baseEntities/Time.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | import { Position } from './Position' 8 | import { DataLogValue } from './DataLogValue' 9 | 10 | import { Entity, EntityConstructor, AttributesDescription } from '../types' 11 | 12 | export enum TimeTypeEnum { 13 | Planned = '1', 14 | Preliminary = '2', 15 | Effective = '4', 16 | Ineffective = '5', 17 | Repair = '6', 18 | Clearing = '7', 19 | PoweredDown = '8', 20 | } 21 | 22 | export type TimeAttributes = { 23 | Start: string 24 | Stop?: string 25 | Duration?: number 26 | Type: TimeTypeEnum 27 | Position?: Position[] 28 | DataLogValue?: DataLogValue[] 29 | ProprietaryAttributes?: {[name: string]: string} 30 | ProprietaryTags?: {[tag: string]: XMLElement[]} 31 | } 32 | 33 | const ATTRIBUTES: AttributesDescription = { 34 | A: { 35 | name: 'Start', 36 | type: 'xs:dateTime', 37 | isPrimaryId: false, 38 | isOptional: false, 39 | isOnlyV4: false, 40 | }, 41 | B: { 42 | name: 'Stop', 43 | type: 'xs:dateTime', 44 | isPrimaryId: false, 45 | isOptional: true, 46 | isOnlyV4: false, 47 | }, 48 | C: { 49 | name: 'Duration', 50 | type: 'xs:unsignedLong', 51 | isPrimaryId: false, 52 | isOptional: true, 53 | isOnlyV4: false, 54 | minValue: 0, 55 | maxValue: 4294967294, 56 | }, 57 | D: { 58 | name: 'Type', 59 | type: 'xs:NMTOKEN', 60 | isPrimaryId: false, 61 | isOptional: false, 62 | isOnlyV4: false, 63 | }, 64 | } 65 | const CHILD_TAGS = { 66 | PTN: { name: 'Position', isOnlyV4: false }, 67 | DLV: { name: 'DataLogValue', isOnlyV4: false }, 68 | } 69 | 70 | export class Time implements Entity { 71 | public tag = TAGS.Time 72 | 73 | constructor(public attributes: TimeAttributes, public isoxmlManager: ISOXMLManager) { 74 | } 75 | 76 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = Time): Promise { 77 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 78 | } 79 | 80 | toXML(): XMLElement { 81 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 82 | } 83 | } 84 | 85 | registerEntityClass('main', TAGS.Time, Time) -------------------------------------------------------------------------------- /src/baseEntities/TimeLog.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | 8 | import { Entity, EntityConstructor, AttributesDescription } from '../types' 9 | 10 | export enum TimeLogTimeLogTypeEnum { 11 | BinaryTimelogFileType1 = '1', 12 | } 13 | 14 | export type TimeLogAttributes = { 15 | Filename: string 16 | Filelength?: number 17 | TimeLogType: TimeLogTimeLogTypeEnum 18 | ProprietaryAttributes?: {[name: string]: string} 19 | ProprietaryTags?: {[tag: string]: XMLElement[]} 20 | } 21 | 22 | const ATTRIBUTES: AttributesDescription = { 23 | A: { 24 | name: 'Filename', 25 | type: 'xs:ID', 26 | isPrimaryId: false, 27 | isOptional: false, 28 | isOnlyV4: false, 29 | }, 30 | B: { 31 | name: 'Filelength', 32 | type: 'xs:unsignedLong', 33 | isPrimaryId: false, 34 | isOptional: true, 35 | isOnlyV4: false, 36 | minValue: 0, 37 | maxValue: 4294967294, 38 | }, 39 | C: { 40 | name: 'TimeLogType', 41 | type: 'xs:NMTOKEN', 42 | isPrimaryId: false, 43 | isOptional: false, 44 | isOnlyV4: false, 45 | }, 46 | } 47 | const CHILD_TAGS = { 48 | } 49 | 50 | export class TimeLog implements Entity { 51 | public tag = TAGS.TimeLog 52 | 53 | constructor(public attributes: TimeLogAttributes, public isoxmlManager: ISOXMLManager) { 54 | } 55 | 56 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = TimeLog): Promise { 57 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 58 | } 59 | 60 | toXML(): XMLElement { 61 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 62 | } 63 | } 64 | 65 | registerEntityClass('main', TAGS.TimeLog, TimeLog) -------------------------------------------------------------------------------- /src/baseEntities/TimelogDataLogValue.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | 8 | import { Entity, EntityConstructor, AttributesDescription, ISOXMLReference } from '../types' 9 | 10 | 11 | export type TimelogDataLogValueAttributes = { 12 | ProcessDataDDI: string 13 | ProcessDataValue: string 14 | DeviceElementIdRef: ISOXMLReference 15 | DataLogPGN?: number 16 | DataLogPGNStartBit?: number 17 | DataLogPGNStopBit?: number 18 | ProprietaryAttributes?: {[name: string]: string} 19 | ProprietaryTags?: {[tag: string]: XMLElement[]} 20 | } 21 | 22 | const ATTRIBUTES: AttributesDescription = { 23 | A: { 24 | name: 'ProcessDataDDI', 25 | type: 'xs:hexBinary', 26 | isPrimaryId: false, 27 | isOptional: false, 28 | isOnlyV4: false, 29 | }, 30 | B: { 31 | name: 'ProcessDataValue', 32 | type: 'emptyString', 33 | isPrimaryId: false, 34 | isOptional: false, 35 | isOnlyV4: false, 36 | }, 37 | C: { 38 | name: 'DeviceElementIdRef', 39 | type: 'xs:IDREF', 40 | isPrimaryId: false, 41 | isOptional: false, 42 | isOnlyV4: false, 43 | }, 44 | D: { 45 | name: 'DataLogPGN', 46 | type: 'xs:unsignedLong', 47 | isPrimaryId: false, 48 | isOptional: true, 49 | isOnlyV4: false, 50 | minValue: 0, 51 | maxValue: 262143, 52 | }, 53 | E: { 54 | name: 'DataLogPGNStartBit', 55 | type: 'xs:unsignedByte', 56 | isPrimaryId: false, 57 | isOptional: true, 58 | isOnlyV4: false, 59 | minValue: 0, 60 | maxValue: 63, 61 | }, 62 | F: { 63 | name: 'DataLogPGNStopBit', 64 | type: 'xs:unsignedByte', 65 | isPrimaryId: false, 66 | isOptional: true, 67 | isOnlyV4: false, 68 | minValue: 0, 69 | maxValue: 63, 70 | }, 71 | } 72 | const CHILD_TAGS = { 73 | } 74 | 75 | export class TimelogDataLogValue implements Entity { 76 | public tag = TAGS.DataLogValue 77 | 78 | constructor(public attributes: TimelogDataLogValueAttributes, public isoxmlManager: ISOXMLManager) { 79 | } 80 | 81 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = TimelogDataLogValue): Promise { 82 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 83 | } 84 | 85 | toXML(): XMLElement { 86 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 87 | } 88 | } 89 | 90 | registerEntityClass('timelog', TAGS.DataLogValue, TimelogDataLogValue) -------------------------------------------------------------------------------- /src/baseEntities/TimelogPosition.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | 8 | import { Entity, EntityConstructor, AttributesDescription } from '../types' 9 | 10 | export enum TimelogPositionPositionStatusEnum { 11 | NoGPSFix = '0', 12 | GNSSFix = '1', 13 | DGNSSFix = '2', 14 | PreciseGNSS = '3', 15 | RTKFixedInteger = '4', 16 | RTKFloat = '5', 17 | EstDRMode = '6', 18 | ManualInput = '7', 19 | SimulateMode = '8', 20 | Reserved9 = '9', 21 | Reserved10 = '10', 22 | Reserved11 = '11', 23 | Reserved12 = '12', 24 | Reserved13 = '13', 25 | Error = '14', 26 | PositionStatusValueIsNotAvailable = '15', 27 | } 28 | 29 | export type TimelogPositionAttributes = { 30 | PositionNorth: number 31 | PositionEast: number 32 | PositionUp?: number 33 | PositionStatus: TimelogPositionPositionStatusEnum 34 | PDOP?: number 35 | HDOP?: number 36 | NumberOfSatellites?: number 37 | GpsUtcTime?: number 38 | GpsUtcDate?: number 39 | ProprietaryAttributes?: {[name: string]: string} 40 | ProprietaryTags?: {[tag: string]: XMLElement[]} 41 | } 42 | 43 | const ATTRIBUTES: AttributesDescription = { 44 | A: { 45 | name: 'PositionNorth', 46 | type: 'xs:decimal', 47 | isPrimaryId: false, 48 | isOptional: false, 49 | isOnlyV4: false, 50 | minValue: -90, 51 | maxValue: 90, 52 | fractionDigits: 9, 53 | allowEmptyString: true, 54 | }, 55 | B: { 56 | name: 'PositionEast', 57 | type: 'xs:decimal', 58 | isPrimaryId: false, 59 | isOptional: false, 60 | isOnlyV4: false, 61 | minValue: -180, 62 | maxValue: 180, 63 | fractionDigits: 9, 64 | allowEmptyString: true, 65 | }, 66 | C: { 67 | name: 'PositionUp', 68 | type: 'xs:long', 69 | isPrimaryId: false, 70 | isOptional: true, 71 | isOnlyV4: false, 72 | minValue: -2147483648, 73 | maxValue: 2147483647, 74 | allowEmptyString: true, 75 | }, 76 | D: { 77 | name: 'PositionStatus', 78 | type: 'xs:NMTOKEN', 79 | isPrimaryId: false, 80 | isOptional: false, 81 | isOnlyV4: false, 82 | allowEmptyString: true, 83 | }, 84 | E: { 85 | name: 'PDOP', 86 | type: 'xs:decimal', 87 | isPrimaryId: false, 88 | isOptional: true, 89 | isOnlyV4: false, 90 | minValue: 0, 91 | maxValue: 99.9, 92 | allowEmptyString: true, 93 | }, 94 | F: { 95 | name: 'HDOP', 96 | type: 'xs:decimal', 97 | isPrimaryId: false, 98 | isOptional: true, 99 | isOnlyV4: false, 100 | minValue: 0, 101 | maxValue: 99.9, 102 | allowEmptyString: true, 103 | }, 104 | G: { 105 | name: 'NumberOfSatellites', 106 | type: 'xs:unsignedByte', 107 | isPrimaryId: false, 108 | isOptional: true, 109 | isOnlyV4: false, 110 | minValue: 0, 111 | maxValue: 254, 112 | allowEmptyString: true, 113 | }, 114 | H: { 115 | name: 'GpsUtcTime', 116 | type: 'xs:unsignedLong', 117 | isPrimaryId: false, 118 | isOptional: true, 119 | isOnlyV4: false, 120 | minValue: 0, 121 | maxValue: 4294967294, 122 | allowEmptyString: true, 123 | }, 124 | I: { 125 | name: 'GpsUtcDate', 126 | type: 'xs:unsignedShort', 127 | isPrimaryId: false, 128 | isOptional: true, 129 | isOnlyV4: false, 130 | minValue: 0, 131 | maxValue: 65534, 132 | allowEmptyString: true, 133 | }, 134 | } 135 | const CHILD_TAGS = { 136 | } 137 | 138 | export class TimelogPosition implements Entity { 139 | public tag = TAGS.Position 140 | 141 | constructor(public attributes: TimelogPositionAttributes, public isoxmlManager: ISOXMLManager) { 142 | } 143 | 144 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = TimelogPosition): Promise { 145 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 146 | } 147 | 148 | toXML(): XMLElement { 149 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 150 | } 151 | } 152 | 153 | registerEntityClass('timelog', TAGS.Position, TimelogPosition) -------------------------------------------------------------------------------- /src/baseEntities/TimelogTime.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | import { TimelogPosition } from './TimelogPosition' 8 | import { TimelogDataLogValue } from './TimelogDataLogValue' 9 | 10 | import { Entity, EntityConstructor, AttributesDescription } from '../types' 11 | 12 | export enum TimelogTimeTypeEnum { 13 | Effective = '4', 14 | } 15 | 16 | export type TimelogTimeAttributes = { 17 | Start: string 18 | Type: TimelogTimeTypeEnum 19 | Position?: TimelogPosition[] 20 | DataLogValue?: TimelogDataLogValue[] 21 | ProprietaryAttributes?: {[name: string]: string} 22 | ProprietaryTags?: {[tag: string]: XMLElement[]} 23 | } 24 | 25 | const ATTRIBUTES: AttributesDescription = { 26 | A: { 27 | name: 'Start', 28 | type: 'emptyString', 29 | isPrimaryId: false, 30 | isOptional: false, 31 | isOnlyV4: false, 32 | }, 33 | D: { 34 | name: 'Type', 35 | type: 'xs:NMTOKEN', 36 | isPrimaryId: false, 37 | isOptional: false, 38 | isOnlyV4: false, 39 | }, 40 | } 41 | const CHILD_TAGS = { 42 | PTN: { name: 'Position', isOnlyV4: false }, 43 | DLV: { name: 'DataLogValue', isOnlyV4: false }, 44 | } 45 | 46 | export class TimelogTime implements Entity { 47 | public tag = TAGS.Time 48 | 49 | constructor(public attributes: TimelogTimeAttributes, public isoxmlManager: ISOXMLManager) { 50 | } 51 | 52 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = TimelogTime): Promise { 53 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 54 | } 55 | 56 | toXML(): XMLElement { 57 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 58 | } 59 | } 60 | 61 | registerEntityClass('timelog', TAGS.Time, TimelogTime) -------------------------------------------------------------------------------- /src/baseEntities/TreatmentZone.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | import { Polygon } from './Polygon' 8 | import { ProcessDataVariable } from './ProcessDataVariable' 9 | 10 | import { Entity, EntityConstructor, AttributesDescription } from '../types' 11 | 12 | 13 | export type TreatmentZoneAttributes = { 14 | TreatmentZoneCode: number 15 | TreatmentZoneDesignator?: string 16 | TreatmentZoneColour?: number 17 | PolygonTreatmentZoneonly?: Polygon[] 18 | ProcessDataVariable?: ProcessDataVariable[] 19 | ProprietaryAttributes?: {[name: string]: string} 20 | ProprietaryTags?: {[tag: string]: XMLElement[]} 21 | } 22 | 23 | const ATTRIBUTES: AttributesDescription = { 24 | A: { 25 | name: 'TreatmentZoneCode', 26 | type: 'xs:unsignedByte', 27 | isPrimaryId: false, 28 | isOptional: false, 29 | isOnlyV4: false, 30 | minValue: 0, 31 | maxValue: 254, 32 | }, 33 | B: { 34 | name: 'TreatmentZoneDesignator', 35 | type: 'xs:string', 36 | isPrimaryId: false, 37 | isOptional: true, 38 | isOnlyV4: false, 39 | }, 40 | C: { 41 | name: 'TreatmentZoneColour', 42 | type: 'xs:unsignedByte', 43 | isPrimaryId: false, 44 | isOptional: true, 45 | isOnlyV4: false, 46 | minValue: 0, 47 | maxValue: 254, 48 | }, 49 | } 50 | const CHILD_TAGS = { 51 | PLN: { name: 'PolygonTreatmentZoneonly', isOnlyV4: false }, 52 | PDV: { name: 'ProcessDataVariable', isOnlyV4: false }, 53 | } 54 | 55 | export class TreatmentZone implements Entity { 56 | public tag = TAGS.TreatmentZone 57 | 58 | constructor(public attributes: TreatmentZoneAttributes, public isoxmlManager: ISOXMLManager) { 59 | } 60 | 61 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = TreatmentZone): Promise { 62 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 63 | } 64 | 65 | toXML(): XMLElement { 66 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 67 | } 68 | } 69 | 70 | registerEntityClass('main', TAGS.TreatmentZone, TreatmentZone) -------------------------------------------------------------------------------- /src/baseEntities/ValuePresentation.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | 8 | import { Entity, EntityConstructor, AttributesDescription, ISOXMLReference } from '../types' 9 | 10 | 11 | export type ValuePresentationAttributes = { 12 | Offset: number 13 | Scale: number 14 | NumberOfDecimals: number 15 | UnitDesignator?: string 16 | ColourLegendIdRef?: ISOXMLReference 17 | ProprietaryAttributes?: {[name: string]: string} 18 | ProprietaryTags?: {[tag: string]: XMLElement[]} 19 | } 20 | 21 | const ATTRIBUTES: AttributesDescription = { 22 | A: { 23 | name: 'ValuePresentationId', 24 | type: 'xs:ID', 25 | isPrimaryId: true, 26 | isOptional: false, 27 | isOnlyV4: false, 28 | }, 29 | B: { 30 | name: 'Offset', 31 | type: 'xs:long', 32 | isPrimaryId: false, 33 | isOptional: false, 34 | isOnlyV4: false, 35 | minValue: -2147483648, 36 | maxValue: 2147483647, 37 | }, 38 | C: { 39 | name: 'Scale', 40 | type: 'xs:decimal', 41 | isPrimaryId: false, 42 | isOptional: false, 43 | isOnlyV4: false, 44 | minValue: 1e-9, 45 | maxValue: 100000000, 46 | }, 47 | D: { 48 | name: 'NumberOfDecimals', 49 | type: 'xs:unsignedByte', 50 | isPrimaryId: false, 51 | isOptional: false, 52 | isOnlyV4: false, 53 | minValue: 0, 54 | maxValue: 7, 55 | }, 56 | E: { 57 | name: 'UnitDesignator', 58 | type: 'xs:string', 59 | isPrimaryId: false, 60 | isOptional: true, 61 | isOnlyV4: false, 62 | }, 63 | F: { 64 | name: 'ColourLegendIdRef', 65 | type: 'xs:IDREF', 66 | isPrimaryId: false, 67 | isOptional: true, 68 | isOnlyV4: false, 69 | }, 70 | } 71 | const CHILD_TAGS = { 72 | } 73 | 74 | export class ValuePresentation implements Entity { 75 | public tag = TAGS.ValuePresentation 76 | 77 | constructor(public attributes: ValuePresentationAttributes, public isoxmlManager: ISOXMLManager) { 78 | } 79 | 80 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = ValuePresentation): Promise { 81 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 82 | } 83 | 84 | toXML(): XMLElement { 85 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 86 | } 87 | } 88 | 89 | registerEntityClass('main', TAGS.ValuePresentation, ValuePresentation) -------------------------------------------------------------------------------- /src/baseEntities/Worker.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | 8 | import { Entity, EntityConstructor, AttributesDescription } from '../types' 9 | 10 | 11 | export type WorkerAttributes = { 12 | WorkerLastName: string 13 | WorkerFirstName?: string 14 | WorkerStreet?: string 15 | WorkerPOBox?: string 16 | WorkerPostalCode?: string 17 | WorkerCity?: string 18 | WorkerState?: string 19 | WorkerCountry?: string 20 | WorkerPhone?: string 21 | WorkerMobile?: string 22 | WorkerLicenseNumber?: string 23 | WorkerEMail?: string 24 | ProprietaryAttributes?: {[name: string]: string} 25 | ProprietaryTags?: {[tag: string]: XMLElement[]} 26 | } 27 | 28 | const ATTRIBUTES: AttributesDescription = { 29 | A: { 30 | name: 'WorkerId', 31 | type: 'xs:ID', 32 | isPrimaryId: true, 33 | isOptional: false, 34 | isOnlyV4: false, 35 | }, 36 | B: { 37 | name: 'WorkerLastName', 38 | type: 'xs:string', 39 | isPrimaryId: false, 40 | isOptional: false, 41 | isOnlyV4: false, 42 | }, 43 | C: { 44 | name: 'WorkerFirstName', 45 | type: 'xs:string', 46 | isPrimaryId: false, 47 | isOptional: true, 48 | isOnlyV4: false, 49 | }, 50 | D: { 51 | name: 'WorkerStreet', 52 | type: 'xs:string', 53 | isPrimaryId: false, 54 | isOptional: true, 55 | isOnlyV4: false, 56 | }, 57 | E: { 58 | name: 'WorkerPOBox', 59 | type: 'xs:string', 60 | isPrimaryId: false, 61 | isOptional: true, 62 | isOnlyV4: false, 63 | }, 64 | F: { 65 | name: 'WorkerPostalCode', 66 | type: 'xs:string', 67 | isPrimaryId: false, 68 | isOptional: true, 69 | isOnlyV4: false, 70 | }, 71 | G: { 72 | name: 'WorkerCity', 73 | type: 'xs:string', 74 | isPrimaryId: false, 75 | isOptional: true, 76 | isOnlyV4: false, 77 | }, 78 | H: { 79 | name: 'WorkerState', 80 | type: 'xs:string', 81 | isPrimaryId: false, 82 | isOptional: true, 83 | isOnlyV4: false, 84 | }, 85 | I: { 86 | name: 'WorkerCountry', 87 | type: 'xs:string', 88 | isPrimaryId: false, 89 | isOptional: true, 90 | isOnlyV4: false, 91 | }, 92 | J: { 93 | name: 'WorkerPhone', 94 | type: 'xs:string', 95 | isPrimaryId: false, 96 | isOptional: true, 97 | isOnlyV4: false, 98 | }, 99 | K: { 100 | name: 'WorkerMobile', 101 | type: 'xs:string', 102 | isPrimaryId: false, 103 | isOptional: true, 104 | isOnlyV4: false, 105 | }, 106 | L: { 107 | name: 'WorkerLicenseNumber', 108 | type: 'xs:string', 109 | isPrimaryId: false, 110 | isOptional: true, 111 | isOnlyV4: false, 112 | }, 113 | M: { 114 | name: 'WorkerEMail', 115 | type: 'xs:string', 116 | isPrimaryId: false, 117 | isOptional: true, 118 | isOnlyV4: false, 119 | }, 120 | } 121 | const CHILD_TAGS = { 122 | } 123 | 124 | export class Worker implements Entity { 125 | public tag = TAGS.Worker 126 | 127 | constructor(public attributes: WorkerAttributes, public isoxmlManager: ISOXMLManager) { 128 | } 129 | 130 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = Worker): Promise { 131 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 132 | } 133 | 134 | toXML(): XMLElement { 135 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 136 | } 137 | } 138 | 139 | registerEntityClass('main', TAGS.Worker, Worker) -------------------------------------------------------------------------------- /src/baseEntities/WorkerAllocation.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './constants' 2 | import { ISOXMLManager } from '../ISOXMLManager' 3 | import { registerEntityClass } from '../classRegistry' 4 | import { fromXML, toXML } from '../utils' 5 | import { XMLElement } from '../types' 6 | 7 | import { AllocationStamp } from './AllocationStamp' 8 | 9 | import { Entity, EntityConstructor, AttributesDescription, ISOXMLReference } from '../types' 10 | 11 | 12 | export type WorkerAllocationAttributes = { 13 | WorkerIdRef: ISOXMLReference 14 | AllocationStamp?: AllocationStamp[] 15 | ProprietaryAttributes?: {[name: string]: string} 16 | ProprietaryTags?: {[tag: string]: XMLElement[]} 17 | } 18 | 19 | const ATTRIBUTES: AttributesDescription = { 20 | A: { 21 | name: 'WorkerIdRef', 22 | type: 'xs:IDREF', 23 | isPrimaryId: false, 24 | isOptional: false, 25 | isOnlyV4: false, 26 | }, 27 | } 28 | const CHILD_TAGS = { 29 | ASP: { name: 'AllocationStamp', isOnlyV4: false }, 30 | } 31 | 32 | export class WorkerAllocation implements Entity { 33 | public tag = TAGS.WorkerAllocation 34 | 35 | constructor(public attributes: WorkerAllocationAttributes, public isoxmlManager: ISOXMLManager) { 36 | } 37 | 38 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string, targetClass: EntityConstructor = WorkerAllocation): Promise { 39 | return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId) 40 | } 41 | 42 | toXML(): XMLElement { 43 | return toXML(this, ATTRIBUTES, CHILD_TAGS) 44 | } 45 | } 46 | 47 | registerEntityClass('main', TAGS.WorkerAllocation, WorkerAllocation) -------------------------------------------------------------------------------- /src/baseEntities/constants.ts: -------------------------------------------------------------------------------- 1 | export enum TAGS { 2 | AllocationStamp = 'ASP', 3 | BaseStation = 'BSN', 4 | CodedComment = 'CCT', 5 | CodedCommentGroup = 'CCG', 6 | CodedCommentListValue = 'CCL', 7 | ColourLegend = 'CLD', 8 | ColourRange = 'CRG', 9 | CommentAllocation = 'CAN', 10 | Connection = 'CNN', 11 | ControlAssignment = 'CAT', 12 | CropType = 'CTP', 13 | CropVariety = 'CVT', 14 | CulturalPractice = 'CPC', 15 | Customer = 'CTR', 16 | DataLogTrigger = 'DLT', 17 | DataLogValue = 'DLV', 18 | Device = 'DVC', 19 | DeviceAllocation = 'DAN', 20 | DeviceElement = 'DET', 21 | DeviceObjectReference = 'DOR', 22 | DeviceProcessData = 'DPD', 23 | DeviceProperty = 'DPT', 24 | DeviceValuePresentation = 'DVP', 25 | Farm = 'FRM', 26 | Grid = 'GRD', 27 | GuidanceAllocation = 'GAN', 28 | GuidanceGroup = 'GGP', 29 | GuidancePattern = 'GPN', 30 | GuidanceShift = 'GST', 31 | LineString = 'LSG', 32 | OperationTechnique = 'OTQ', 33 | OperationTechniqueReference = 'OTR', 34 | OperTechPractice = 'OTP', 35 | Partfield = 'PFD', 36 | Point = 'PNT', 37 | Polygon = 'PLN', 38 | Position = 'PTN', 39 | ProcessDataVariable = 'PDV', 40 | Product = 'PDT', 41 | ProductAllocation = 'PAN', 42 | ProductGroup = 'PGP', 43 | ProductRelation = 'PRN', 44 | Task = 'TSK', 45 | Time = 'TIM', 46 | TimeLog = 'TLG', 47 | TreatmentZone = 'TZN', 48 | ValuePresentation = 'VPN', 49 | Worker = 'WKR', 50 | WorkerAllocation = 'WAN', 51 | AttachedFile = 'AFE', 52 | ISO11783TaskDataFile = 'ISO11783_TaskData', 53 | TaskControllerCapabilities = 'TCC', 54 | ExternalFileReference = 'XFR', 55 | ISO11783LinkListFile = 'ISO11783LinkList', 56 | Link = 'LNK', 57 | LinkGroup = 'LGP', 58 | ExternalFileContents = 'XFC', 59 | } -------------------------------------------------------------------------------- /src/baseEntities/index.ts: -------------------------------------------------------------------------------- 1 | export * from './AllocationStamp' 2 | export * from './BaseStation' 3 | export * from './CodedComment' 4 | export * from './CodedCommentGroup' 5 | export * from './CodedCommentListValue' 6 | export * from './ColourLegend' 7 | export * from './ColourRange' 8 | export * from './CommentAllocation' 9 | export * from './Connection' 10 | export * from './ControlAssignment' 11 | export * from './CropType' 12 | export * from './CropVariety' 13 | export * from './CulturalPractice' 14 | export * from './Customer' 15 | export * from './DataLogTrigger' 16 | export * from './DataLogValue' 17 | export * from './Device' 18 | export * from './DeviceAllocation' 19 | export * from './DeviceElement' 20 | export * from './DeviceObjectReference' 21 | export * from './DeviceProcessData' 22 | export * from './DeviceProperty' 23 | export * from './DeviceValuePresentation' 24 | export * from './Farm' 25 | export * from './Grid' 26 | export * from './GuidanceAllocation' 27 | export * from './GuidanceGroup' 28 | export * from './GuidancePattern' 29 | export * from './GuidanceShift' 30 | export * from './LineString' 31 | export * from './OperationTechnique' 32 | export * from './OperationTechniqueReference' 33 | export * from './OperTechPractice' 34 | export * from './Partfield' 35 | export * from './Point' 36 | export * from './Polygon' 37 | export * from './Position' 38 | export * from './ProcessDataVariable' 39 | export * from './Product' 40 | export * from './ProductAllocation' 41 | export * from './ProductGroup' 42 | export * from './ProductRelation' 43 | export * from './Task' 44 | export * from './Time' 45 | export * from './TimeLog' 46 | export * from './TreatmentZone' 47 | export * from './ValuePresentation' 48 | export * from './Worker' 49 | export * from './WorkerAllocation' 50 | export * from './AttachedFile' 51 | export * from './ISO11783TaskDataFile' 52 | export * from './TaskControllerCapabilities' 53 | export * from './ExternalFileReference' 54 | export * from './ISO11783LinkListFile' 55 | export * from './Link' 56 | export * from './LinkGroup' 57 | export * from './ExternalFileContents' 58 | export * from './TimelogDataLogValue' 59 | export * from './TimelogPosition' 60 | export * from './TimelogTime' 61 | -------------------------------------------------------------------------------- /src/classRegistry.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from './baseEntities/constants' 2 | import {EntityConstructor} from './types' 3 | 4 | const availableEntityClasses: { 5 | [realm: string]: {[tagName: string]: EntityConstructor} 6 | } = {} 7 | 8 | export function registerEntityClass(realm: string, tagName: TAGS, entityClass: EntityConstructor): void { 9 | availableEntityClasses[realm] = availableEntityClasses[realm] || {} 10 | availableEntityClasses[realm][tagName] = entityClass 11 | } 12 | 13 | export function getEntityClassByTag(realm: string, tagName: TAGS): EntityConstructor { 14 | return availableEntityClasses[realm][tagName] 15 | } -------------------------------------------------------------------------------- /src/entities/AttachedFile.ts: -------------------------------------------------------------------------------- 1 | import { AttachedFile, AttachedFileAttributes, AttachedFilePreserveEnum } from "../baseEntities" 2 | import { TAGS } from "../baseEntities/constants" 3 | import { registerEntityClass } from "../classRegistry" 4 | import { js2xml, xml2js } from '../xmlManager' 5 | import { ISOXMLManager } from "../ISOXMLManager" 6 | import { Entity, XMLElement } from "../types" 7 | import { ExtendedISO11783LinkListFile } from "./ISO11783LinkListFile" 8 | 9 | export class ExtendedAttachedFile extends AttachedFile { 10 | public tag = TAGS.AttachedFile 11 | 12 | public fileData: Uint8Array 13 | 14 | constructor(attributes: AttachedFileAttributes, isoxmlManager: ISOXMLManager) { 15 | super(attributes, isoxmlManager) 16 | } 17 | 18 | static async fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string): Promise { 19 | const entity = await AttachedFile.fromXML( 20 | xml, isoxmlManager, internalId, ExtendedAttachedFile 21 | ) as ExtendedAttachedFile 22 | 23 | const filename = entity.attributes.FilenameWithExtension 24 | 25 | if (filename.toUpperCase() !== filename) { 26 | isoxmlManager.addWarning(`[${internalId}] Name of attached file must be uppercase (real name: ${filename})`) 27 | } 28 | 29 | if (entity.attributes.FileType === 1) { 30 | const linkListString = await isoxmlManager.getParsedFile(filename, false) 31 | let linkListXml 32 | try { 33 | linkListXml = xml2js(linkListString) 34 | } catch(e) { 35 | throw new Error ('Failed to parse LinkList file') 36 | } 37 | await ExtendedISO11783LinkListFile.fromXML( 38 | linkListXml[TAGS.ISO11783LinkListFile][0], 39 | isoxmlManager, 40 | 'LINKLIST' 41 | ) 42 | } else { 43 | entity.fileData = await isoxmlManager.getParsedFile(filename, true) 44 | } 45 | return entity 46 | } 47 | 48 | toXML(): XMLElement { 49 | if (this.attributes.FileType === 1) { 50 | const linkListFile = ExtendedISO11783LinkListFile.fromISOXMLManager(this.isoxmlManager) 51 | 52 | const json = { 53 | [TAGS.ISO11783LinkListFile]: linkListFile.toXML() 54 | } 55 | const xmlString = js2xml(json) 56 | this.isoxmlManager.addFileToSave(xmlString, this.attributes.FilenameWithExtension) 57 | } else { 58 | this.isoxmlManager.addFileToSave(this.fileData, this.attributes.FilenameWithExtension) 59 | } 60 | return super.toXML() 61 | } 62 | 63 | static linkListFromISOXMLManager(isoxmlManager: ISOXMLManager): ExtendedAttachedFile { 64 | return new ExtendedAttachedFile({ 65 | FilenameWithExtension: 'LINKLIST.XML', 66 | Preserve: AttachedFilePreserveEnum.PreserveOnTaskControllerAndSendBackToFMIS, 67 | FileType: 1, 68 | ManufacturerGLN: '' 69 | }, isoxmlManager) 70 | } 71 | } 72 | 73 | registerEntityClass('main', TAGS.AttachedFile, ExtendedAttachedFile) -------------------------------------------------------------------------------- /src/entities/DeviceElement.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Device, 3 | DeviceElement, 4 | DeviceElementAttributes, 5 | DeviceProcessData, 6 | DeviceValuePresentation 7 | } from "../baseEntities" 8 | import { TAGS } from "../baseEntities/constants" 9 | import { registerEntityClass } from "../classRegistry" 10 | import { ISOXMLManager } from "../ISOXMLManager" 11 | import { Entity, XMLElement } from "../types" 12 | 13 | export class ExtendedDeviceElement extends DeviceElement { 14 | public tag = TAGS.DeviceElement 15 | 16 | constructor(attributes: DeviceElementAttributes, isoxmlManager: ISOXMLManager) { 17 | super(attributes, isoxmlManager) 18 | } 19 | 20 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId: string): Promise { 21 | return DeviceElement.fromXML(xml, isoxmlManager, internalId, ExtendedDeviceElement) 22 | } 23 | 24 | getParentDevice(): Device | undefined { 25 | return this.isoxmlManager.getEntitiesOfTag(TAGS.Device).find( 26 | device => (device.attributes.DeviceElement || []).find(deviceElement => deviceElement === this) 27 | ) 28 | } 29 | 30 | getValuePresentation(ddi: string): DeviceValuePresentation { 31 | const device = this.getParentDevice() 32 | 33 | if (!device) { 34 | return null 35 | } 36 | 37 | const processData = this.getDataProcess(ddi) 38 | 39 | const dvpObjectId = processData?.attributes.DeviceValuePresentationObjectId 40 | 41 | if (!dvpObjectId) { 42 | return null 43 | } 44 | 45 | return (device.attributes.DeviceValuePresentation || []) 46 | .find(dvp => dvp.attributes.DeviceValuePresentationObjectId === dvpObjectId) 47 | } 48 | 49 | getDataProcess(ddi: string): DeviceProcessData { 50 | const device = this.getParentDevice() 51 | 52 | if (!device) { 53 | return null 54 | } 55 | 56 | return (device.attributes.DeviceProcessData || []).find( 57 | dpd => dpd.attributes.DeviceProcessDataDDI === ddi && 58 | (this.attributes.DeviceObjectReference || []) 59 | .find(ref => ref.attributes.DeviceObjectId === dpd.attributes.DeviceProcessDataObjectId) 60 | ) 61 | } 62 | } 63 | 64 | registerEntityClass('main', TAGS.DeviceElement, ExtendedDeviceElement) -------------------------------------------------------------------------------- /src/entities/Grid/DefaultGridParamsGenerator.ts: -------------------------------------------------------------------------------- 1 | import { bbox as turfBbox, degreesToRadians, lengthToDegrees } from '@turf/turf' 2 | 3 | import { GridParametersGenerator } from ".." 4 | 5 | export function createGridParamsGenerator ( 6 | targetCellWidth: number, 7 | targetCellHeight: number 8 | ): GridParametersGenerator { 9 | return (geometry: any) => { 10 | const [minX, minY, maxX, maxY] = turfBbox(geometry) 11 | 12 | const sizeY = lengthToDegrees(targetCellHeight, 'meters') 13 | 14 | // works fine for small areas 15 | const sizeX = lengthToDegrees(targetCellWidth, 'meters') / Math.cos(degreesToRadians((minY + maxY) / 2)) 16 | 17 | const numCols = Math.floor((maxX - minX) / sizeX) 18 | const numRows = Math.floor((maxY - minY) / sizeY) 19 | 20 | return { 21 | minX, 22 | minY, 23 | numCols, 24 | numRows, 25 | cellWidth: (maxX - minX) / numCols, 26 | cellHeight: (maxY - minY) / numRows 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /src/entities/Grid/Grid.spec.ts: -------------------------------------------------------------------------------- 1 | import {readFileSync} from 'fs' 2 | 3 | import { ISOXMLManager } from '../../ISOXMLManager' 4 | import { ExtendedGrid } from './Grid' 5 | import { Task } from '../../baseEntities/Task' 6 | 7 | describe('Grid Entity', () => { 8 | it('should create instance from GeoJSON', async () => { 9 | const geoJSONdata = JSON.parse(readFileSync('./data/test.geojson', 'utf-8')) 10 | const isoxmlManager = new ISOXMLManager() 11 | const grid = ExtendedGrid.fromGeoJSON(geoJSONdata, ['DOSE'], isoxmlManager) 12 | expect(grid.attributes.Filelength).toBe(22896) 13 | 14 | expect(grid.attributes.GridMinimumNorthPosition).toBe(55.82481700900832) 15 | expect(grid.attributes.GridMinimumEastPosition).toBe(39.138728173503324) 16 | expect(grid.attributes.Filename).toBe('GRD00001') 17 | 18 | const xml = grid.toXML() 19 | 20 | expect(xml).toBeTruthy() 21 | expect(Object.keys(isoxmlManager.filesToSave)).toHaveLength(1) 22 | }) 23 | 24 | it('should convert Grid to GeoJSON', async () => { 25 | const geoJSONdata = JSON.parse(readFileSync('./data/test.geojson', 'utf-8')) 26 | const isoxmlManager = new ISOXMLManager() 27 | const grid = ExtendedGrid.fromGeoJSON(geoJSONdata, ['DOSE'], isoxmlManager) 28 | 29 | const geoJSON = grid.toGeoJSON(['DOSE']) 30 | 31 | expect(geoJSON).toBeTruthy() 32 | expect(geoJSON.features[0].properties!.DOSE).toBe(16) // 15.7 should be rounded to 16 33 | 34 | }) 35 | 36 | it('should verify grid size correctly', async () => { 37 | const isoxmlData = readFileSync('./data/task_with_grid.zip') 38 | const isoxmlManager = new ISOXMLManager({version: 4}) 39 | 40 | await isoxmlManager.parseISOXMLFile(new Uint8Array(isoxmlData.buffer), 'application/zip') 41 | 42 | const grid = isoxmlManager.getEntityByXmlId('TSK1').attributes.Grid![0] as ExtendedGrid 43 | 44 | const anotherIsoxmlManager = new ISOXMLManager({version: 4}) 45 | 46 | grid.verifyGridSize(anotherIsoxmlManager, 1) 47 | expect(anotherIsoxmlManager.getWarnings()).toHaveLength(0) 48 | grid.verifyGridSize(anotherIsoxmlManager, 2) 49 | expect(anotherIsoxmlManager.getWarnings()).toHaveLength(1) 50 | }) 51 | }) 52 | -------------------------------------------------------------------------------- /src/entities/Grid/IntersectionBasedGridGenerator.ts: -------------------------------------------------------------------------------- 1 | import { area, bbox as turfBbox, FeatureCollection } from "@turf/turf" 2 | import type { Polygon } from 'polygon-clipping' 3 | import geomOps from 'polygon-clipping' 4 | import RBush from "rbush" 5 | 6 | import { GridParameters } from ".." 7 | 8 | export function intersectionBasedGridGenerator( 9 | geoJSON: FeatureCollection, 10 | propertyNames: string[], 11 | gridParams: GridParameters 12 | ): ArrayBuffer { 13 | const {minX, minY, numCols, numRows, cellWidth, cellHeight} = gridParams 14 | 15 | const filelength = numCols * numRows * 4 * propertyNames.length 16 | const buffer = new ArrayBuffer(filelength) 17 | const int32array = new Int32Array(buffer) 18 | 19 | const tree = new RBush<{feature: any}>() 20 | tree.load(geoJSON.features.map(f => { 21 | const [bboxMinX, bboxMinY, bboxMaxX, bboxMaxY] = turfBbox(f) 22 | return {minX: bboxMinX, minY: bboxMinY, maxX: bboxMaxX, maxY: bboxMaxY, feature: f} 23 | })) 24 | 25 | let index = 0 26 | for (let y = 0; y < numRows; y++) { 27 | const subTree = new RBush<{feature: any}>() 28 | 29 | // TODO: check that it gives performance boost (test case: many small polygons) 30 | subTree.load(tree.search({ 31 | minX: minX , 32 | minY: minY + y * cellHeight, 33 | maxX: minX + (numCols) * cellWidth, 34 | maxY: minY + (y + 1) * cellHeight 35 | })) 36 | for (let x = 0; x < numCols; x++) { 37 | 38 | // Simplified algorithm: just check the center of cell 39 | // const lng = minX + (x + 0.5) * cellWidth 40 | // const lat = minY + (y + 0.5) * cellHeight 41 | // const searchResults = tree.search({minX: lng, minY: lat, maxX: lng, maxY: lat}) 42 | // const feature = searchResults.find(res => booleanPointInPolygon([lng, lat], res.feature))?.feature 43 | 44 | const searchResults = subTree.search({ 45 | minX: minX + x * cellWidth, 46 | minY: minY + y * cellHeight, 47 | maxX: minX + (x + 1) * cellWidth, 48 | maxY: minY + (y + 1) * cellHeight 49 | }) 50 | 51 | 52 | let feature = null 53 | let maxArea = 0 54 | let uncoveredArea = cellWidth * cellHeight 55 | if (searchResults.length > 0) { 56 | const cell = [[ 57 | [minX + x * cellWidth, minY + y * cellHeight], 58 | [minX + x * cellWidth, minY + (y + 1) * cellHeight], 59 | [minX + (x + 1) * cellWidth, minY + (y + 1) * cellHeight], 60 | [minX + (x + 1) * cellWidth, minY + y * cellHeight], 61 | [minX + x * cellWidth, minY + y * cellHeight] 62 | ]] as Polygon 63 | 64 | searchResults.some(res => { 65 | const intersectionRes = geomOps.intersection(res.feature.geometry.coordinates, cell) 66 | if (intersectionRes.length) { 67 | if (searchResults.length === 1) { 68 | feature = res.feature 69 | return true 70 | } 71 | const intersectionArea = area({type: 'MultiPolygon', coordinates: intersectionRes}) 72 | 73 | uncoveredArea -= intersectionArea 74 | 75 | if (intersectionArea > maxArea) { 76 | feature = res.feature 77 | maxArea = intersectionArea 78 | } 79 | 80 | return maxArea > uncoveredArea 81 | } 82 | }) 83 | } 84 | 85 | for (const propertyName of propertyNames) { 86 | const value = Math.round(feature?.properties[propertyName] ?? 0) 87 | int32array[index++] = value 88 | } 89 | } 90 | } 91 | 92 | return buffer 93 | } -------------------------------------------------------------------------------- /src/entities/Grid/index.ts: -------------------------------------------------------------------------------- 1 | export * from './Grid' 2 | export * from './DefaultGridParamsGenerator' 3 | export * from './CellCenterBasedGridGenerator' 4 | export * from './IntersectionBasedGridGenerator' -------------------------------------------------------------------------------- /src/entities/ISO11783LinkListFile.ts: -------------------------------------------------------------------------------- 1 | import { 2 | ISO11783LinkListFile, 3 | ISO11783LinkListFileAttributes, 4 | ISO11783LinkListFileDataTransferOriginEnum, 5 | Link, 6 | LinkGroup, 7 | LinkGroupLinkGroupTypeEnum 8 | } from "../baseEntities" 9 | import { TAGS } from "../baseEntities/constants" 10 | import { registerEntityClass } from "../classRegistry" 11 | import { ISOXMLManager } from "../ISOXMLManager" 12 | import { Entity, XMLElement } from "../types" 13 | 14 | export class ExtendedISO11783LinkListFile extends ISO11783LinkListFile { 15 | public tag = TAGS.ISO11783LinkListFile 16 | 17 | public fileData: Uint8Array 18 | 19 | constructor(attributes: ISO11783LinkListFileAttributes, isoxmlManager: ISOXMLManager) { 20 | super(attributes, isoxmlManager) 21 | } 22 | 23 | static async fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string): Promise { 24 | const entity = await ISO11783LinkListFile.fromXML( 25 | xml, 26 | isoxmlManager, 27 | internalId, 28 | ExtendedISO11783LinkListFile 29 | ) as ISO11783LinkListFile 30 | 31 | const linkGroup = entity.attributes.LinkGroup?.find(group => 32 | group.attributes.LinkGroupType === LinkGroupLinkGroupTypeEnum.UniqueResolvableURIs && 33 | group.attributes.LinkGroupNamespace === isoxmlManager.options.fmisURI 34 | ) 35 | 36 | linkGroup?.attributes.Link?.forEach(link => { 37 | isoxmlManager.registerEntity(null, link.attributes.ObjectIdRef.xmlId, link.attributes.LinkValue) 38 | }) 39 | return entity 40 | } 41 | 42 | toXML(): XMLElement { 43 | this.attributes.LinkGroup = [] 44 | if (this.isoxmlManager.options.fmisURI) { 45 | const links = Object.values(this.isoxmlManager.xmlReferences) 46 | .filter(ref => ref.fmisId) 47 | .map(ref => new Link({ 48 | ObjectIdRef: ref, 49 | LinkValue: ref.fmisId 50 | }, this.isoxmlManager)) 51 | const linkGroup = this.isoxmlManager.createEntityFromAttributes(TAGS.LinkGroup, { 52 | LinkGroupType: LinkGroupLinkGroupTypeEnum.UniqueResolvableURIs, 53 | LinkGroupNamespace: this.isoxmlManager.options.fmisURI, 54 | Link: links 55 | }) 56 | this.isoxmlManager.registerEntity(linkGroup) 57 | this.attributes.LinkGroup = [linkGroup] 58 | } 59 | return super.toXML() 60 | } 61 | 62 | static fromISOXMLManager(isoxmlManager: ISOXMLManager): ExtendedISO11783LinkListFile { 63 | const version = isoxmlManager.options.version 64 | return new ExtendedISO11783LinkListFile({ 65 | VersionMajor: (version === 4 ? '4' : '3') as any, 66 | VersionMinor: (version === 4 ? '2' : '3') as any, 67 | ManagementSoftwareManufacturer: isoxmlManager.options.fmisTitle, 68 | ManagementSoftwareVersion: isoxmlManager.options.fmisVersion, 69 | DataTransferOrigin: ISO11783LinkListFileDataTransferOriginEnum.FMIS 70 | }, isoxmlManager) 71 | } 72 | } 73 | 74 | registerEntityClass('main', TAGS.ISO11783LinkListFile, ExtendedISO11783LinkListFile) 75 | -------------------------------------------------------------------------------- /src/entities/LineString.spec.ts: -------------------------------------------------------------------------------- 1 | import { ISOXMLManager } from "../ISOXMLManager" 2 | import { LineStringLineStringTypeEnum } from "../baseEntities" 3 | import { ExtendedLineString } from "./LineString" 4 | 5 | describe("LineString Entity", () => { 6 | it("should be constructed from GeoJSON without altitude - version 4", async () => { 7 | const isoxmlManager = new ISOXMLManager({version: 4}) 8 | const lineString = ExtendedLineString.fromGeoJSONCoordinates( 9 | [ 10 | [-44.904, 61.277], 11 | [-44.852, 61.034], 12 | ], 13 | isoxmlManager, 14 | LineStringLineStringTypeEnum.GuidancePattern 15 | ) 16 | 17 | expect(lineString.attributes.Point?.[0].attributes.PointEast).toEqual(-44.904) 18 | expect(lineString.attributes.Point?.[0].attributes.PointNorth).toEqual(61.277) 19 | expect(lineString.attributes.Point?.[0].attributes.PointUp).toBeUndefined() 20 | 21 | expect(lineString.attributes.Point?.[1].attributes.PointEast).toEqual(-44.852) 22 | expect(lineString.attributes.Point?.[1].attributes.PointNorth).toEqual(61.034) 23 | expect(lineString.attributes.Point?.[1].attributes.PointUp).toBeUndefined() 24 | }) 25 | }) 26 | 27 | describe("LineString Entity", () => { 28 | it("should be constructed from GeoJSON with altitude - version 4", async () => { 29 | const isoxmlManager = new ISOXMLManager({version: 4}) 30 | const lineString = ExtendedLineString.fromGeoJSONCoordinates( 31 | [ 32 | [-44.904, 61.277, 12.140], 33 | [-44.852, 61.034, 12.213], 34 | ], 35 | isoxmlManager, 36 | LineStringLineStringTypeEnum.GuidancePattern 37 | ) 38 | 39 | expect(lineString.attributes.Point?.[0].attributes.PointEast).toEqual(-44.904) 40 | expect(lineString.attributes.Point?.[0].attributes.PointNorth).toEqual(61.277) 41 | expect(lineString.attributes.Point?.[0].attributes.PointUp).toEqual(0.012140) 42 | 43 | expect(lineString.attributes.Point?.[1].attributes.PointEast).toEqual(-44.852) 44 | expect(lineString.attributes.Point?.[1].attributes.PointNorth).toEqual(61.034) 45 | expect(lineString.attributes.Point?.[1].attributes.PointUp).toEqual(0.012213) 46 | }) 47 | }) -------------------------------------------------------------------------------- /src/entities/LineString.ts: -------------------------------------------------------------------------------- 1 | import { 2 | LineString, 3 | LineStringAttributes, 4 | LineStringLineStringTypeEnum, 5 | Point, 6 | PointPointTypeEnum 7 | } from "../baseEntities" 8 | import { TAGS } from "../baseEntities/constants" 9 | import { registerEntityClass } from "../classRegistry" 10 | import { ISOXMLManager } from "../ISOXMLManager" 11 | import { Entity, XMLElement } from "../types" 12 | 13 | export class ExtendedLineString extends LineString { 14 | public tag = TAGS.LineString 15 | 16 | constructor(attributes: LineStringAttributes, isoxmlManager: ISOXMLManager) { 17 | super(attributes, isoxmlManager) 18 | } 19 | 20 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId: string): Promise { 21 | return LineString.fromXML(xml, isoxmlManager, internalId, ExtendedLineString) 22 | } 23 | 24 | toCoordinatesArray(): [number, number][] { 25 | return this.attributes.Point.map(point => [point.attributes.PointEast, point.attributes.PointNorth]) 26 | } 27 | 28 | static fromGeoJSONCoordinates( 29 | coordinates: number[][], 30 | isoxmlManager: ISOXMLManager, 31 | type: LineStringLineStringTypeEnum 32 | ): ExtendedLineString { 33 | return new ExtendedLineString({ 34 | LineStringType: type, 35 | Point: coordinates.map(c => new Point({ 36 | PointType: PointPointTypeEnum.Other, 37 | PointNorth: c[1], 38 | PointEast: c[0], 39 | ...c[2] != undefined && {PointUp: c[2] / 1000}, 40 | }, isoxmlManager)) 41 | }, isoxmlManager) 42 | } 43 | } 44 | 45 | registerEntityClass('main', TAGS.LineString, ExtendedLineString) -------------------------------------------------------------------------------- /src/entities/Partfield.spec.ts: -------------------------------------------------------------------------------- 1 | import { ISOXMLManager } from '../ISOXMLManager' 2 | import { MultiPolygon } from '@turf/helpers' 3 | import { MULTIPOLYGON } from './testdata/geometry' 4 | import { ExtendedPartfield } from './Partfield' 5 | import { TAGS } from '../baseEntities/constants' 6 | 7 | describe('Partfield Entity', () => { 8 | it('should add geometry from GeoJSON', () => { 9 | const isoxmlManager = new ISOXMLManager() 10 | const partfield = new ExtendedPartfield({ 11 | PartfieldDesignator: 'test field', 12 | PartfieldArea: 0 13 | }, isoxmlManager) 14 | 15 | partfield.boundaryFromGeoJSON(MULTIPOLYGON.features[0].geometry as MultiPolygon, isoxmlManager) 16 | 17 | expect(partfield.attributes.PartfieldArea).toBe(2026305612) 18 | expect(partfield.attributes.PolygonnonTreatmentZoneonly).toHaveLength(2) 19 | }) 20 | 21 | it('should normalize boundary from v4 to v3', () => { 22 | const isoxmlManager = new ISOXMLManager({version: 4}) 23 | const partfield = new ExtendedPartfield({ 24 | PartfieldDesignator: 'test', 25 | PartfieldArea: 0 26 | }, isoxmlManager) 27 | 28 | partfield.boundaryFromGeoJSON(MULTIPOLYGON.features[0].geometry as MultiPolygon, isoxmlManager) 29 | 30 | isoxmlManager.updateOptions({version: 3}) 31 | 32 | const xml = partfield.toXML() 33 | expect(xml[TAGS.Polygon]).toHaveLength(1) 34 | }) 35 | 36 | it('should normalize boundary from v3 to v4', () => { 37 | const isoxmlManager = new ISOXMLManager({version: 3}) 38 | const partfield = new ExtendedPartfield({ 39 | PartfieldDesignator: 'test', 40 | PartfieldArea: 0 41 | }, isoxmlManager) 42 | 43 | partfield.boundaryFromGeoJSON(MULTIPOLYGON.features[0].geometry as MultiPolygon, isoxmlManager) 44 | 45 | isoxmlManager.updateOptions({version: 4}) 46 | 47 | const xml = partfield.toXML() 48 | expect(xml[TAGS.Polygon]).toHaveLength(2) 49 | }) 50 | 51 | it('should return GeoJSON', () => { 52 | const isoxmlManager = new ISOXMLManager({version: 3}) 53 | const partfield = new ExtendedPartfield({ 54 | PartfieldDesignator: 'test', 55 | PartfieldArea: 0 56 | }, isoxmlManager) 57 | 58 | partfield.boundaryFromGeoJSON(MULTIPOLYGON.features[0].geometry as MultiPolygon, isoxmlManager) 59 | 60 | const geoJSON = partfield.toGeoJSON() 61 | expect(geoJSON.type).toBe('MultiPolygon') 62 | expect(geoJSON.coordinates).toHaveLength(2) 63 | expect(geoJSON.coordinates[0]).toHaveLength(2) 64 | expect(geoJSON.coordinates[1]).toHaveLength(2) 65 | }) 66 | }) -------------------------------------------------------------------------------- /src/entities/Partfield.ts: -------------------------------------------------------------------------------- 1 | import { area, MultiPolygon as TurfMultiPolygon, Polygon as TurfPolygon} from "@turf/turf" 2 | import { Partfield, PartfieldAttributes, PolygonPolygonTypeEnum } from "../baseEntities" 3 | import { TAGS } from "../baseEntities/constants" 4 | import { registerEntityClass } from "../classRegistry" 5 | import { ISOXMLManager } from "../ISOXMLManager" 6 | import { Entity, XMLElement } from "../types" 7 | import { ExtendedPolygon } from "./Polygon" 8 | 9 | export class ExtendedPartfield extends Partfield { 10 | public tag = TAGS.Partfield 11 | 12 | constructor(attributes: PartfieldAttributes, isoxmlManager: ISOXMLManager) { 13 | super(attributes, isoxmlManager) 14 | } 15 | 16 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId: string): Promise { 17 | return Partfield.fromXML(xml, isoxmlManager, internalId, ExtendedPartfield) 18 | } 19 | 20 | toXML(): XMLElement { 21 | this.attributes.PolygonnonTreatmentZoneonly = 22 | ExtendedPolygon.normalizePolygons(this.attributes.PolygonnonTreatmentZoneonly) 23 | return super.toXML() 24 | } 25 | 26 | boundaryFromGeoJSON(geoJSON: TurfMultiPolygon | TurfPolygon, isoxmlManager: ISOXMLManager): void { 27 | this.attributes.PolygonnonTreatmentZoneonly = 28 | ExtendedPolygon.fromGeoJSON(geoJSON, PolygonPolygonTypeEnum.PartfieldBoundary, isoxmlManager) 29 | this.attributes.PartfieldArea = Math.round(area(geoJSON)) 30 | } 31 | 32 | toGeoJSON(): TurfMultiPolygon { 33 | return ExtendedPolygon.toGeoJSON(this.attributes.PolygonnonTreatmentZoneonly) 34 | } 35 | } 36 | 37 | registerEntityClass('main', TAGS.Partfield, ExtendedPartfield) -------------------------------------------------------------------------------- /src/entities/Polygon.spec.ts: -------------------------------------------------------------------------------- 1 | import { ISOXMLManager } from '../ISOXMLManager' 2 | import { LineStringLineStringTypeEnum, Polygon, PolygonPolygonTypeEnum } from '../baseEntities' 3 | import { ExtendedPolygon } from './Polygon' 4 | import { MultiPolygon } from '@turf/helpers' 5 | import { MULTIPOLYGON } from './testdata/geometry' 6 | 7 | 8 | function stat(polygon: Polygon) { 9 | return { 10 | outer: polygon.attributes.LineString 11 | .filter( 12 | lineString => lineString.attributes.LineStringType === LineStringLineStringTypeEnum.PolygonExterior 13 | ).length, 14 | inner: polygon.attributes.LineString 15 | .filter( 16 | lineString => lineString.attributes.LineStringType === LineStringLineStringTypeEnum.PolygonInterior 17 | ).length 18 | } 19 | } 20 | 21 | describe('Polygon Entity', () => { 22 | it('should be constructed from GeoJSON - version 3', async () => { 23 | const isoxmlManager = new ISOXMLManager({version: 3}) 24 | const polygons = ExtendedPolygon.fromGeoJSON( 25 | MULTIPOLYGON.features[0].geometry as MultiPolygon, 26 | PolygonPolygonTypeEnum.TreatmentZone, 27 | isoxmlManager 28 | ) 29 | expect(polygons).toHaveLength(1) 30 | expect(stat(polygons[0])).toEqual({inner: 2, outer: 2}) 31 | }) 32 | 33 | it('should be constructed from GeoJSON - version 4', async () => { 34 | const isoxmlManager = new ISOXMLManager({version: 4}) 35 | const polygons = ExtendedPolygon.fromGeoJSON( 36 | MULTIPOLYGON.features[0].geometry as MultiPolygon, 37 | PolygonPolygonTypeEnum.TreatmentZone, 38 | isoxmlManager 39 | ) 40 | expect(polygons).toHaveLength(2) 41 | expect(stat(polygons[0])).toEqual({inner: 1, outer: 1}) 42 | }) 43 | 44 | it('should normalize polygons from v4 to v3', async () => { 45 | const isoxmlManager = new ISOXMLManager({version: 4}) 46 | const polygons = ExtendedPolygon.fromGeoJSON( 47 | MULTIPOLYGON.features[0].geometry as MultiPolygon, 48 | PolygonPolygonTypeEnum.TreatmentZone, 49 | isoxmlManager 50 | ) 51 | 52 | isoxmlManager.updateOptions({version: 3}) 53 | 54 | const normalizedPolygons = ExtendedPolygon.normalizePolygons(polygons) 55 | 56 | expect(normalizedPolygons).toHaveLength(1) 57 | expect(stat(normalizedPolygons[0])).toEqual({inner: 2, outer: 2}) 58 | }) 59 | 60 | it('should normalize polygons from v3 to v4', async () => { 61 | const isoxmlManager = new ISOXMLManager({version: 3}) 62 | const polygons = ExtendedPolygon.fromGeoJSON( 63 | MULTIPOLYGON.features[0].geometry as MultiPolygon, 64 | PolygonPolygonTypeEnum.TreatmentZone, 65 | isoxmlManager 66 | ) 67 | 68 | isoxmlManager.updateOptions({version: 4}) 69 | 70 | const normalizedPolygons = ExtendedPolygon.normalizePolygons(polygons) 71 | 72 | expect(normalizedPolygons).toHaveLength(2) 73 | expect(stat(normalizedPolygons[0])).toEqual({inner: 1, outer: 1}) 74 | }) 75 | 76 | it('should normalize polygons with undefined argument', async () => { 77 | const normalizedPolygons = ExtendedPolygon.normalizePolygons(undefined) 78 | 79 | expect(normalizedPolygons).toHaveLength(0) 80 | }) 81 | 82 | it('should convert to GeoJSON', async () => { 83 | 84 | // Version 3 allows us to test LineString splitting algorithm 85 | const isoxmlManager = new ISOXMLManager({version: 3}) 86 | const polygons = ExtendedPolygon.fromGeoJSON( 87 | MULTIPOLYGON.features[0].geometry as MultiPolygon, 88 | PolygonPolygonTypeEnum.TreatmentZone, 89 | isoxmlManager 90 | ) 91 | 92 | const geoJSON = ExtendedPolygon.toGeoJSON(polygons) 93 | 94 | expect(geoJSON.type).toBe('MultiPolygon') 95 | expect(geoJSON.coordinates).toHaveLength(2) 96 | expect(geoJSON.coordinates[0]).toHaveLength(2) 97 | expect(geoJSON.coordinates[1]).toHaveLength(2) 98 | expect(geoJSON.bbox).toEqual([ 99 | -44.90386962890624, 100 | 60.52959025656515, 101 | -43.38500976562497, 102 | 61.31442918692164 103 | ]) 104 | }) 105 | }) -------------------------------------------------------------------------------- /src/entities/TimeLog/BufferReader.ts: -------------------------------------------------------------------------------- 1 | // A modified version of https://github.com/villadora/node-buffer-reader 2 | 3 | const types = { 4 | 'Int8': 1, 5 | 'Uint8': 1, 6 | 'Int16': 2, 7 | 'Uint16': 2, 8 | 'Int32': 4, 9 | 'Uint32': 4, 10 | 'Float': 4, 11 | 'Double': 8, 12 | } 13 | 14 | type BufferReaderInterface = { 15 | [t in keyof typeof types as `next${t}`]: () => number 16 | } & { 17 | tell: () => number 18 | seek: (pos: number) => void 19 | move: (diff: number) => void 20 | } 21 | 22 | type BufferReaderConstructor = { new (buffer: ArrayBuffer): BufferReaderInterface } 23 | 24 | const BufferReader = function (buffer: ArrayBuffer) { 25 | buffer = buffer || new ArrayBuffer(0) 26 | this.buf = buffer 27 | this.view = new DataView(this.buf) 28 | this.offset = 0 29 | } as any as BufferReaderConstructor 30 | 31 | BufferReader.prototype.tell = function() { 32 | return this.offset 33 | } 34 | 35 | BufferReader.prototype.seek = function(pos) { 36 | this.offset = pos 37 | } 38 | 39 | BufferReader.prototype.move = function(diff) { 40 | this.offset += diff 41 | } 42 | 43 | function MAKE_NEXT_READER(valueName, size) { 44 | BufferReader.prototype['next' + valueName] = function() { 45 | const val = this.view['get' + valueName](this.offset, true) 46 | this.offset += size 47 | return val 48 | } 49 | } 50 | 51 | Object.keys(types).forEach(type => { 52 | MAKE_NEXT_READER(type, types[type]) 53 | }) 54 | 55 | export default BufferReader -------------------------------------------------------------------------------- /src/entities/TimeLog/TimeLog.spec.ts: -------------------------------------------------------------------------------- 1 | import { readFileSync } from "fs" 2 | import { ISOXMLManager, Task } from "../.." 3 | import { ExtendedTimeLog } from "." 4 | 5 | describe('TimeLog Entity', () => { 6 | it('should parse binary TimeLog files', async () => { 7 | const isoxmlData = readFileSync('./data/2021-04-09T15_33_26_taskdata.zip') 8 | const isoxmlManager = new ISOXMLManager({version: 4}) 9 | 10 | await isoxmlManager.parseISOXMLFile(new Uint8Array(isoxmlData.buffer), 'application/zip') 11 | 12 | const timeLog = isoxmlManager.getEntityByXmlId('TSK-1').attributes.TimeLog[0] as ExtendedTimeLog 13 | 14 | const parsedTimeLog = timeLog.parseBinaryFile() 15 | 16 | expect(parsedTimeLog.timeLogs).toHaveLength(207) 17 | expect(parsedTimeLog.valuesInfo).toHaveLength(4) 18 | expect(parsedTimeLog.bbox).toEqual([9.5777866, 45.5277534, 9.5779409, 45.5278066]) 19 | }) 20 | 21 | it('should convert TimeLog-record times into correct Date-objects', async () => { 22 | const isoxmlData = readFileSync('./data/2021-04-09T15_33_26_taskdata.zip') 23 | const isoxmlManager = new ISOXMLManager({version: 4}) 24 | 25 | await isoxmlManager.parseISOXMLFile(new Uint8Array(isoxmlData.buffer), 'application/zip') 26 | 27 | const timeLog = isoxmlManager.getEntityByXmlId('TSK-1').attributes.TimeLog[0] as ExtendedTimeLog 28 | 29 | const parsedTimeLog = timeLog.parseBinaryFile() 30 | 31 | expect(parsedTimeLog.timeLogs[0].time.toUTCString()).toEqual('Fri, 09 Apr 2021 14:54:04 GMT') 32 | }) 33 | 34 | it('should detect outliers', async () => { 35 | const isoxmlData = readFileSync('./data/2021-04-09T15_33_26_taskdata.zip') 36 | const isoxmlManager = new ISOXMLManager() 37 | 38 | await isoxmlManager.parseISOXMLFile(new Uint8Array(isoxmlData.buffer), 'application/zip') 39 | 40 | const timeLog = isoxmlManager.getEntityByXmlId('TSK-1').attributes.TimeLog[0] as ExtendedTimeLog 41 | 42 | const ranges = timeLog.rangesWithoutOutliers() 43 | 44 | expect(ranges[2].minValue).toBe(-2231) 45 | expect(ranges[2].maxValue).toBe(334) 46 | }) 47 | 48 | 49 | it('should fill missing values', async () => { 50 | const isoxmlData = readFileSync('./data/2021-04-09T15_33_26_taskdata.zip') 51 | const isoxmlManager = new ISOXMLManager() 52 | 53 | await isoxmlManager.parseISOXMLFile(new Uint8Array(isoxmlData.buffer), 'application/zip') 54 | 55 | const timeLog = isoxmlManager.getEntityByXmlId('TSK-1').attributes.TimeLog[0] as ExtendedTimeLog 56 | 57 | const filledValues = timeLog.getFilledTimeLogs() 58 | 59 | expect(filledValues[3].values['0090_DET-1']).toBe(67159) 60 | }) 61 | }) 62 | -------------------------------------------------------------------------------- /src/entities/TreatmentZone.spec.ts: -------------------------------------------------------------------------------- 1 | import { ISOXMLManager } from '../ISOXMLManager' 2 | import { PolygonPolygonTypeEnum } from '../baseEntities' 3 | import { ExtendedPolygon } from './Polygon' 4 | import { MultiPolygon } from '@turf/helpers' 5 | import { MULTIPOLYGON } from './testdata/geometry' 6 | import { TAGS } from '../baseEntities/constants' 7 | import { ExtendedTreatmentZone } from './TreatmentZone' 8 | 9 | describe('TreatmentZone Entity', () => { 10 | it('should normalize boundary from v4 to v3', async () => { 11 | const isoxmlManager = new ISOXMLManager({version: 4}) 12 | const polygons = ExtendedPolygon.fromGeoJSON( 13 | MULTIPOLYGON.features[0].geometry as MultiPolygon, 14 | PolygonPolygonTypeEnum.PartfieldBoundary, 15 | isoxmlManager 16 | ) 17 | const partfield = new ExtendedTreatmentZone({ 18 | TreatmentZoneCode: 1, 19 | PolygonTreatmentZoneonly: polygons 20 | }, isoxmlManager) 21 | 22 | isoxmlManager.updateOptions({version: 3}) 23 | 24 | const xml = partfield.toXML() 25 | expect(xml[TAGS.Polygon]).toHaveLength(1) 26 | }) 27 | 28 | it('should normalize boundary from v3 to v4', async () => { 29 | const isoxmlManager = new ISOXMLManager({version: 3}) 30 | const polygons = ExtendedPolygon.fromGeoJSON( 31 | MULTIPOLYGON.features[0].geometry as MultiPolygon, 32 | PolygonPolygonTypeEnum.PartfieldBoundary, 33 | isoxmlManager 34 | ) 35 | const partfield = new ExtendedTreatmentZone({ 36 | TreatmentZoneCode: 1, 37 | PolygonTreatmentZoneonly: polygons 38 | }, isoxmlManager) 39 | 40 | isoxmlManager.updateOptions({version: 4}) 41 | 42 | const xml = partfield.toXML() 43 | expect(xml[TAGS.Polygon]).toHaveLength(2) 44 | }) 45 | }) -------------------------------------------------------------------------------- /src/entities/TreatmentZone.ts: -------------------------------------------------------------------------------- 1 | import { TreatmentZone, TreatmentZoneAttributes } from "../baseEntities" 2 | import { TAGS } from "../baseEntities/constants" 3 | import { registerEntityClass } from "../classRegistry" 4 | import { ISOXMLManager } from "../ISOXMLManager" 5 | import { Entity, XMLElement } from "../types" 6 | import { ExtendedPolygon } from "./Polygon" 7 | 8 | export class ExtendedTreatmentZone extends TreatmentZone { 9 | public tag = TAGS.TreatmentZone 10 | 11 | constructor(attributes: TreatmentZoneAttributes, isoxmlManager: ISOXMLManager) { 12 | super(attributes, isoxmlManager) 13 | } 14 | 15 | static fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId: string): Promise { 16 | return TreatmentZone.fromXML(xml, isoxmlManager, internalId, ExtendedTreatmentZone) 17 | } 18 | 19 | toXML(): XMLElement { 20 | this.attributes.PolygonTreatmentZoneonly = 21 | ExtendedPolygon.normalizePolygons(this.attributes.PolygonTreatmentZoneonly) 22 | return super.toXML() 23 | } 24 | } 25 | 26 | registerEntityClass('main', TAGS.TreatmentZone, ExtendedTreatmentZone) -------------------------------------------------------------------------------- /src/entities/index.ts: -------------------------------------------------------------------------------- 1 | export * from './AttachedFile' 2 | export * from './Grid' 3 | export * from './ISO11783LinkListFile' 4 | export * from './ISO11783TaskDataFile' 5 | export * from './LineString' 6 | export * from './Partfield' 7 | export * from './Polygon' 8 | export * from './Task' 9 | export * from './TimeLog' 10 | export * from './TreatmentZone' 11 | export * from './DeviceElement' -------------------------------------------------------------------------------- /src/entities/testdata/geometry.ts: -------------------------------------------------------------------------------- 1 | export const MULTIPOLYGON = { 2 | "type": "FeatureCollection", 3 | "features": [ 4 | { 5 | "type": "Feature", 6 | "properties": {}, 7 | "geometry": { 8 | "type": "MultiPolygon", 9 | "coordinates": [ 10 | [ 11 | [ 12 | [ 13 | -44.90386962890624, 14 | 61.277493186470366 15 | ], 16 | [ 17 | -44.851684570312486, 18 | 61.03368701477991 19 | ], 20 | [ 21 | -44.442443847656236, 22 | 60.895048709158495 23 | ], 24 | [ 25 | -44.08950805664062, 26 | 61.100125153823406 27 | ], 28 | [ 29 | -44.30511474609375, 30 | 61.31442918692164 31 | ], 32 | [ 33 | -44.90386962890624, 34 | 61.277493186470366 35 | ] 36 | ], 37 | [ 38 | [ 39 | -44.64843749999999, 40 | 61.18099111150924 41 | ], 42 | [ 43 | -44.32983398437499, 44 | 61.218040603616984 45 | ], 46 | [ 47 | -44.20898437499999, 48 | 61.106761304821745 49 | ], 50 | [ 51 | -44.33532714843749, 52 | 60.99775244198903 53 | ], 54 | [ 55 | -44.566040039062486, 56 | 61.04831536461301 57 | ], 58 | [ 59 | -44.64843749999999, 60 | 61.18099111150924 61 | ] 62 | ] 63 | ], 64 | [ 65 | [ 66 | [ 67 | -44.1993713378906, 68 | 60.91641702637622 69 | ], 70 | [ 71 | -44.14718627929684, 72 | 60.669815264737665 73 | ], 74 | [ 75 | -43.73794555664059, 76 | 60.52959025656515 77 | ], 78 | [ 79 | -43.38500976562497, 80 | 60.7370145508271 81 | ], 82 | [ 83 | -43.600616455078104, 84 | 60.95377713282332 85 | ], 86 | [ 87 | -44.1993713378906, 88 | 60.91641702637622 89 | ] 90 | ], 91 | [ 92 | [ 93 | -43.94393920898435, 94 | 60.81880761759344 95 | ], 96 | [ 97 | -43.62533569335935, 98 | 60.85628211863575 99 | ], 100 | [ 101 | -43.50448608398435, 102 | 60.74372675603921 103 | ], 104 | [ 105 | -43.63082885742186, 106 | 60.633469215649846 107 | ], 108 | [ 109 | -43.86154174804685, 110 | 60.68461116124036 111 | ], 112 | [ 113 | -43.94393920898435, 114 | 60.81880761759344 115 | ] 116 | ] 117 | ] 118 | ] 119 | } 120 | } 121 | ] 122 | } -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | export * from './baseEntities' 2 | export * from './entities' 3 | export * from './ISOXMLManager' 4 | export * from './types' 5 | export * from './baseEntities/constants' 6 | 7 | export { FeatureCollection } from '@turf/helpers' -------------------------------------------------------------------------------- /src/types.ts: -------------------------------------------------------------------------------- 1 | import { TAGS } from "./baseEntities/constants" 2 | import { ISOXMLManager } from './ISOXMLManager' 3 | 4 | export interface XMLElement { 5 | _attributes?: {[attr: string]: any} 6 | _text?: string 7 | [tag: string]: any 8 | } 9 | 10 | export interface AttributeDescription { 11 | name: string 12 | type: string 13 | isPrimaryId: boolean 14 | isOptional: boolean 15 | isOnlyV4: boolean 16 | minValue?: number 17 | maxValue?: number 18 | fractionDigits?: number 19 | allowEmptyString?: boolean 20 | } 21 | export interface AttributesDescription { 22 | [xmlTag: string]: AttributeDescription 23 | } 24 | 25 | export interface ReferencesDescription { 26 | [xmlTag: string]: {name: string, isOnlyV4: boolean} 27 | } 28 | 29 | export type ISOXMLReference = { 30 | xmlId: string 31 | fmisId?: string 32 | entity?: Entity 33 | } 34 | 35 | export type EntityAttributes = {[name: string]: any} 36 | 37 | export interface Entity { 38 | isoxmlManager: ISOXMLManager 39 | attributes: EntityAttributes 40 | tag: TAGS 41 | toXML (): XMLElement 42 | } 43 | 44 | export interface EntityConstructor { 45 | fromXML(xml: XMLElement, isoxmlManager: ISOXMLManager, internalId?: string): Promise 46 | new (attributes: EntityAttributes, isoxmlManager: ISOXMLManager, xmlId?: string, fmisId?: string): Entity 47 | } 48 | 49 | interface ISOBinaryFileInformation { 50 | isBinary: true 51 | data: Uint8Array 52 | filename: string 53 | } 54 | 55 | interface ISOXMLFileInformation { 56 | isBinary: false 57 | data: string 58 | filename: string 59 | } 60 | 61 | export type ISOFileInformation = ISOBinaryFileInformation | ISOXMLFileInformation 62 | 63 | export type ValueInformation = { 64 | DDINumber: number 65 | DDIString: string 66 | DDEntityName: string 67 | unit: string 68 | scale: number 69 | offset: number 70 | numberOfDecimals: number 71 | isProprietary: boolean 72 | } -------------------------------------------------------------------------------- /src/utils.spec.ts: -------------------------------------------------------------------------------- 1 | import { DeviceProcessData, ValuePresentation } from "./baseEntities" 2 | import { TAGS } from "./baseEntities/constants" 3 | import { ISOXMLManager } from "./ISOXMLManager" 4 | import { constructValueInformation } from "./utils" 5 | 6 | describe('Utils', () => { 7 | it('constructValueInformation', async () => { 8 | 9 | const valueInfo = constructValueInformation('0001') 10 | 11 | expect(valueInfo.DDIString).toBe('0001') 12 | expect(valueInfo.DDINumber).toBe(1) 13 | expect(valueInfo.DDEntityName).toBe('Setpoint Volume Per Area Application Rate as [mm³/m²]') 14 | expect(valueInfo.unit).toBe('mm³/m²') 15 | expect(valueInfo.numberOfDecimals).toBe(2) 16 | expect(valueInfo.offset).toBe(0) 17 | expect(valueInfo.scale).toBe(0.01) 18 | expect(valueInfo.isProprietary).toBe(false) 19 | }) 20 | 21 | it('constructValueInformation with ValuePresentation', async () => { 22 | const isoxmlManager = new ISOXMLManager() 23 | 24 | const valuePresentation = isoxmlManager.createEntityFromAttributes(TAGS.ValuePresentation, { 25 | Offset: 0, 26 | Scale: 0.0001, 27 | NumberOfDecimals: 1, 28 | UnitDesignator: 'l/h' 29 | }) 30 | 31 | const valueInfo = constructValueInformation('0001', valuePresentation) 32 | 33 | expect(valueInfo.DDIString).toBe('0001') 34 | expect(valueInfo.DDINumber).toBe(1) 35 | expect(valueInfo.DDEntityName).toBe('Setpoint Volume Per Area Application Rate as [mm³/m²]') 36 | expect(valueInfo.unit).toBe('l/h') 37 | expect(valueInfo.numberOfDecimals).toBe(1) 38 | expect(valueInfo.offset).toBe(0) 39 | expect(valueInfo.scale).toBe(0.0001) 40 | expect(valueInfo.isProprietary).toBe(false) 41 | }) 42 | 43 | it('constructValueInformation with ValuePresentation without unit', async () => { 44 | const isoxmlManager = new ISOXMLManager() 45 | 46 | const valuePresentation = isoxmlManager.createEntityFromAttributes(TAGS.ValuePresentation, { 47 | Offset: 0, 48 | Scale: 0.0001, 49 | NumberOfDecimals: 1 50 | }) 51 | 52 | const valueInfo = constructValueInformation('0001', valuePresentation) 53 | 54 | expect(valueInfo.unit).toBe('') 55 | }) 56 | 57 | it('constructValueInformation with DeviceProcessData', async () => { 58 | const isoxmlManager = new ISOXMLManager() 59 | 60 | const dpd = isoxmlManager.createEntityFromAttributes(TAGS.DeviceProcessData, { 61 | DeviceProcessDataObjectId: 0, 62 | DeviceProcessDataDDI: 'FFFF', 63 | DeviceProcessDataProperty: 1, 64 | DeviceProcessDataTriggerMethods: 0, 65 | DeviceProcessDataDesignator: 'Test process' 66 | }) 67 | 68 | const valueInfo = constructValueInformation('FFFF', null, dpd) 69 | 70 | expect(valueInfo.DDIString).toBe('FFFF') 71 | expect(valueInfo.DDINumber).toBe(0xFFFF) 72 | expect(valueInfo.DDEntityName).toBe('Test process') 73 | }) 74 | 75 | it('constructValueInformation - unknown DDEntity', async () => { 76 | 77 | const valueInfo = constructValueInformation('FFFF') 78 | 79 | expect(valueInfo.DDIString).toBe('FFFF') 80 | expect(valueInfo.DDINumber).toBe(65535) 81 | expect(valueInfo.DDEntityName).toBe('') 82 | expect(valueInfo.unit).toBe('') 83 | expect(valueInfo.numberOfDecimals).toBe(-0) 84 | expect(valueInfo.offset).toBe(0) 85 | expect(valueInfo.scale).toBe(1) 86 | }) 87 | }) -------------------------------------------------------------------------------- /src/xmlManager.ts: -------------------------------------------------------------------------------- 1 | import {XMLBuilder, XmlBuilderOptionsOptional, XMLParser, X2jOptionsOptional} from 'fast-xml-parser' 2 | import { XMLElement } from './types' 3 | 4 | const XML_PARSE_OPTIONS: X2jOptionsOptional = { 5 | textNodeName: '_text', 6 | attributeNamePrefix: '', 7 | ignoreAttributes: false, 8 | attributesGroupName: '_attributes', 9 | parseTagValue: false, 10 | parseAttributeValue: false, 11 | isArray: (tagName: string, jPath: string, isLeafNode: boolean, isAttribute: boolean) => !isAttribute, 12 | attributeValueProcessor: (name: string, value: string) => 13 | value.replace(/&/g, '&') 14 | .replace(/'/g, "'") 15 | .replace(/"/g, '"') 16 | .replace(/</g, '<') 17 | .replace(/>/g, '>') 18 | } 19 | const XML_BUILD_OPTIONS: XmlBuilderOptionsOptional = { 20 | textNodeName: '_text', 21 | attributeNamePrefix: '', 22 | ignoreAttributes: false, 23 | attributesGroupName: '_attributes', 24 | format: true, 25 | attributeValueProcessor: (name: string, value: string) => 26 | value.replace(/&/g, '&') 27 | .replace(/'/g, ''') 28 | .replace(/"/g, '"') 29 | .replace(//g, '>') 31 | } 32 | 33 | export function js2xml(json: XMLElement): string { 34 | return ` 35 | ${new XMLBuilder(XML_BUILD_OPTIONS).build(json)}` 36 | } 37 | 38 | export function xml2js(xml: string): XMLElement { 39 | return new XMLParser(XML_PARSE_OPTIONS).parse(xml) 40 | } --------------------------------------------------------------------------------