Files

496 lines
37 KiB
Plaintext

file << "#! /usr/bin/env python" << std::endl;
file << "" << std::endl;
file << "import xml.dom.minidom" << std::endl;
file << "from xml.dom.minidom import Node" << std::endl;
file << "import pandas as pd" << std::endl;
file << "import glob" << std::endl;
file << "import math" << std::endl;
file << "import re # regular expressions" << std::endl;
file << "import LocalCoords # conversion module" << std::endl;
file << "from ProcessZones import ProcessAbstractGeometry, ProcessLocation3DElement" << std::endl;
file << "" << std::endl;
file << "" << std::endl;
file << "def ProcessAngledAreaSearchTask(angledAreaSearchTaskElement):" << std::endl;
file << " taskID = 0" << std::endl;
file << " elements = angledAreaSearchTaskElement.getElementsByTagName('TaskID')" << std::endl;
file << " if elements and elements[0].firstChild and elements[0].firstChild.nodeType == Node.TEXT_NODE:" << std::endl;
file << " taskID = int(elements[0].firstChild.data)" << std::endl;
file << " label = 'AAS' + str(taskID)" << std::endl;
file << " elements = angledAreaSearchTaskElement.getElementsByTagName('Label')" << std::endl;
file << " if elements and elements[0].firstChild and elements[0].firstChild.nodeType == Node.TEXT_NODE:" << std::endl;
file << " label = str(elements[0].firstChild.data)" << std::endl;
file << " print('taskID[{0}], label[{1}]'.format(taskID,label))" << std::endl;
file << " searchAreaStartPoint = []" << std::endl;
file << " searchAreaPoints = []" << std::endl;
file << " startPointElements = angledAreaSearchTaskElement.getElementsByTagName('StartPoint')" << std::endl;
file << " if startPointElements:" << std::endl;
file << " location3DElements = startPointElements[0].getElementsByTagName('Location3D')" << std::endl;
file << " if location3DElements:" << std::endl;
file << " loc3D = ProcessLocation3DElement(location3DElements[0])" << std::endl;
file << " if loc3D:" << std::endl;
file << " searchAreaStartPoint = loc3D" << std::endl;
file << " searchAreaId = 0" << std::endl;
file << " elements = angledAreaSearchTaskElement.getElementsByTagName('SearchAreaID')" << std::endl;
file << " if elements and elements[0].firstChild and elements[0].firstChild.nodeType == Node.TEXT_NODE:" << std::endl;
file << " searchAreaId = int(elements[0].firstChild.data)" << std::endl;
file << " # find the area of interest" << std::endl;
file << " isFoundFile = False" << std::endl;
file << " for areaOfInterestFile in glob.glob('AreaOfInterest_Id*'):" << std::endl;
file << " #\tAreaOfInterest_Id_100.xml" << std::endl;
file << " fileId = int(re.search(r'\\d+',areaOfInterestFile).group())" << std::endl;
file << " if fileId == searchAreaId:" << std::endl;
file << " isFoundFile = True" << std::endl;
file << " docFileId = xml.dom.minidom.parse(areaOfInterestFile)" << std::endl;
file << " if docFileId.hasChildNodes():" << std::endl;
file << " fileNode = docFileId.firstChild" << std::endl;
file << " areaElements = fileNode.getElementsByTagName('Area')" << std::endl;
file << " # print('areaNode[' + str(areaNode[0].nodeName) + ']')" << std::endl;
file << " if areaElements:" << std::endl;
file << " points = ProcessAbstractGeometry(areaElements[0])" << std::endl;
file << " for point in points:" << std::endl;
file << " searchAreaPoints.append(point)" << std::endl;
file << " else:" << std::endl;
file << " print('ERROR:: Unknown search area type encountered!!!')" << std::endl;
file << " if not isFoundFile:" << std::endl;
file << " print('ERROR:: AngledAreaSearchTask could not find AreaOfInterest File for Id[' + str(searchAreaId) + ']!!!')" << std::endl;
file << "" << std::endl;
file << " else:" << std::endl;
file << " print('ERROR:: AngledAreaSearchTask could not parse SearchAreaID!!!')" << std::endl;
file << " # Close the boundary" << std::endl;
file << " if searchAreaPoints:" << std::endl;
file << " searchAreaPoints.append(searchAreaPoints[0])" << std::endl;
file << " # Add start point if there is one" << std::endl;
file << " if searchAreaStartPoint:" << std::endl;
file << " searchAreaPoints.insert(0,searchAreaStartPoint)" << std::endl;
file << " searchAreaLocationPd = pd.DataFrame(data = searchAreaPoints,columns=['latitude','longitude','altitude'])" << std::endl;
file << " return [taskID,label,searchAreaLocationPd]" << std::endl;
file << "" << std::endl;
file << "" << std::endl;
file << "def ProcessWatchTask(watchTaskNode):" << std::endl;
file << " taskID = 0" << std::endl;
file << " elements = watchTaskNode.getElementsByTagName('TaskID')" << std::endl;
file << " if elements and elements[0].firstChild and elements[0].firstChild.nodeType == Node.TEXT_NODE:" << std::endl;
file << " taskID = int(elements[0].firstChild.data)" << std::endl;
file << " label = 'W' + str(taskID)" << std::endl;
file << " elements = watchTaskNode.getElementsByTagName('Label')" << std::endl;
file << " if elements and elements[0].firstChild and elements[0].firstChild.nodeType == Node.TEXT_NODE:" << std::endl;
file << " label = str(elements[0].firstChild.data)" << std::endl;
file << " print('taskID[{0}], label[{1}]'.format(taskID,label))" << std::endl;
file << "" << std::endl;
file << " watchedEntityLocation = []" << std::endl;
file << " watchedEntityID = 0" << std::endl;
file << " elements = watchTaskNode.getElementsByTagName('WatchedEntityID')" << std::endl;
file << " if elements and elements[0].firstChild and elements[0].firstChild.nodeType == Node.TEXT_NODE:" << std::endl;
file << " watchedEntityID = int(elements[0].firstChild.data)" << std::endl;
file << " if watchedEntityID > 0:" << std::endl;
file << " # find the point of interest" << std::endl;
file << " isFoundFile = False" << std::endl;
file << " for entityStateFile in glob.glob('WatchedEntity_Id*'):" << std::endl;
file << " #\tWatchedEntity_Id_1002.xml" << std::endl;
file << " fileId = int(re.search(r'\\d+',entityStateFile).group())" << std::endl;
file << " if fileId == watchedEntityID:" << std::endl;
file << " isFoundFile = True" << std::endl;
file << " docFileId = xml.dom.minidom.parse(entityStateFile)" << std::endl;
file << " if docFileId.hasChildNodes():" << std::endl;
file << " fileNode = docFileId.firstChild" << std::endl;
file << " locationElements = fileNode.getElementsByTagName('Location')" << std::endl;
file << " if locationElements:" << std::endl;
file << " location3DElements = locationElements[0].getElementsByTagName('Location3D')" << std::endl;
file << " if location3DElements:" << std::endl;
file << " loc3D = ProcessLocation3DElement(location3DElements[0])" << std::endl;
file << " watchedEntityLocation.append(loc3D)" << std::endl;
file << " else:" << std::endl;
file << " print('ERROR:: processing [' + entityStateFile +'] !!!')" << std::endl;
file << " else:" << std::endl;
file << " print('ERROR:: processing [' + entityStateFile +'] !!!')" << std::endl;
file << " else:" << std::endl;
file << " print('ERROR:: processing [' + entityStateFile +'] !!!')" << std::endl;
file << " break" << std::endl;
file << " watchedEntityLocationPd = pd.DataFrame(data = watchedEntityLocation,columns=['latitude','longitude','altitude'])" << std::endl;
file << " return [taskID,label,watchedEntityLocationPd]" << std::endl;
file << "" << std::endl;
file << "" << std::endl;
file << "def ProcessImpactPointSearchTask(impactPointSearchTaskNode):" << std::endl;
file << " taskID = 0" << std::endl;
file << " elements = impactPointSearchTaskNode.getElementsByTagName('TaskID')" << std::endl;
file << " if elements and elements[0].firstChild and elements[0].firstChild.nodeType == Node.TEXT_NODE:" << std::endl;
file << " taskID = int(elements[0].firstChild.data)" << std::endl;
file << " label = 'IPS' + str(taskID)" << std::endl;
file << " elements = impactPointSearchTaskNode.getElementsByTagName('Label')" << std::endl;
file << " if elements and elements[0].firstChild and elements[0].firstChild.nodeType == Node.TEXT_NODE:" << std::endl;
file << " label = str(elements[0].firstChild.data)" << std::endl;
file << " print('taskID[{0}], label[{1}]'.format(taskID,label))" << std::endl;
file << "" << std::endl;
file << " searchLocation = []" << std::endl;
file << " searchLocationID = 0" << std::endl;
file << " elements = impactPointSearchTaskNode.getElementsByTagName('SearchLocationID')" << std::endl;
file << " if elements and elements[0].firstChild and elements[0].firstChild.nodeType == Node.TEXT_NODE:" << std::endl;
file << " searchLocationID = int(elements[0].firstChild.data)" << std::endl;
file << " if searchLocationID > 0:" << std::endl;
file << " # find the point of interest" << std::endl;
file << " isFoundFile = False" << std::endl;
file << " for pointOfInterestFile in glob.glob('PointOfInterest_Id*'):" << std::endl;
file << " #\tPointOfInterest_Id_102.xml" << std::endl;
file << " fileId = int(re.search(r'\\d+',pointOfInterestFile).group())" << std::endl;
file << " if fileId == searchLocationID:" << std::endl;
file << " isFoundFile = True" << std::endl;
file << " docFileId = xml.dom.minidom.parse(pointOfInterestFile)" << std::endl;
file << " if docFileId.hasChildNodes():" << std::endl;
file << " fileNode = docFileId.firstChild" << std::endl;
file << " locationNode = fileNode.getElementsByTagName('Location')" << std::endl;
file << " if len(locationNode):" << std::endl;
file << " pointsNode = locationNode[0].getElementsByTagName('Location3D')" << std::endl;
file << " if len(pointsNode):" << std::endl;
file << " loc3D = ProcessLocation3DElement(pointsNode[0])" << std::endl;
file << " searchLocation.append(loc3D)" << std::endl;
file << " else:" << std::endl;
file << " print('ERROR:: processing [' + pointOfInterestFile +'] !!!')" << std::endl;
file << " else:" << std::endl;
file << " print('ERROR:: processing [' + pointOfInterestFile +'] !!!')" << std::endl;
file << " else:" << std::endl;
file << " print('ERROR:: processing [' + pointOfInterestFile +'] !!!')" << std::endl;
file << " break" << std::endl;
file << " else:" << std::endl;
file << " searchLocationNode = impactPointSearchTaskNode.getElementsByTagName('SearchLocation')" << std::endl;
file << " if len(searchLocationNode):" << std::endl;
file << " pointsNode = searchLocationNode[0].getElementsByTagName('Location3D')" << std::endl;
file << " if len(pointsNode):" << std::endl;
file << " loc3D = ProcessLocation3DElement(pointsNode[0])" << std::endl;
file << " searchLocation.append(loc3D)" << std::endl;
file << "" << std::endl;
file << " searchLocationPd = pd.DataFrame(data = searchLocation,columns=['latitude','longitude','altitude'])" << std::endl;
file << " # print('RESULT:: ProcessImpactPointSearchTask->searchLocationPd [' + str(searchLocationPd) +'] !!!')" << std::endl;
file << " return [taskID,label,searchLocationPd]" << std::endl;
file << "" << std::endl;
file << "" << std::endl;
file << "def ProcessImpactLineSearchTask(impactLineSearchTaskNode):" << std::endl;
file << " taskID = 0" << std::endl;
file << " elements = impactLineSearchTaskNode.getElementsByTagName('TaskID')" << std::endl;
file << " if elements and elements[0].firstChild and elements[0].firstChild.nodeType == Node.TEXT_NODE:" << std::endl;
file << " taskID = int(elements[0].firstChild.data)" << std::endl;
file << " label = 'ILS' + str(taskID)" << std::endl;
file << " elements = impactLineSearchTaskNode.getElementsByTagName('Label')" << std::endl;
file << " if elements and elements[0].firstChild and elements[0].firstChild.nodeType == Node.TEXT_NODE:" << std::endl;
file << " label = str(elements[0].firstChild.data)" << std::endl;
file << " print('taskID[{0}], label[{1}]'.format(taskID,label))" << std::endl;
file << "" << std::endl;
file << " pointList = []" << std::endl;
file << " lineId = 0" << std::endl;
file << " lineIdNode = impactLineSearchTaskNode.getElementsByTagName('LineID')" << std::endl;
file << " if lineIdNode and lineIdNode[0].firstChild and lineIdNode[0].firstChild.nodeType == Node.TEXT_NODE:" << std::endl;
file << " lineId = int(lineIdNode[0].firstChild.data)" << std::endl;
file << " # find the line of interest" << std::endl;
file << " isFoundFile = False" << std::endl;
file << " for lineOfInterestFile in glob.glob('LineOfInterest_Id*'):" << std::endl;
file << " #\tLineOfInterest_Id_101.xml" << std::endl;
file << " fileId = int(re.search(r'\\d+',lineOfInterestFile).group())" << std::endl;
file << " if fileId == lineId:" << std::endl;
file << " isFoundFile = True" << std::endl;
file << " docFileId = xml.dom.minidom.parse(lineOfInterestFile)" << std::endl;
file << " if docFileId.hasChildNodes():" << std::endl;
file << " fileNode = docFileId.firstChild" << std::endl;
file << " pointListNode = fileNode.getElementsByTagName('Line')" << std::endl;
file << " # print('pointListNode[' + str(pointListNode[0].nodeName) + ']')" << std::endl;
file << " if len(pointListNode):" << std::endl;
file << " pointsNode = pointListNode[0].getElementsByTagName('Location3D')" << std::endl;
file << " for point in pointsNode:" << std::endl;
file << " latitude = 0.0" << std::endl;
file << " longitude = 0.0" << std::endl;
file << " altitude = 0.0" << std::endl;
file << " if point:" << std::endl;
file << " elements = point.getElementsByTagName('Latitude')" << std::endl;
file << " if(elements and elements[0].firstChild" << std::endl;
file << " and elements[0].firstChild.nodeType == Node.TEXT_NODE):" << std::endl;
file << " latitude = float(elements[0].firstChild.data)" << std::endl;
file << " elements = point.getElementsByTagName('Longitude')" << std::endl;
file << " if(elements and elements[0].firstChild" << std::endl;
file << " and elements[0].firstChild.nodeType == Node.TEXT_NODE):" << std::endl;
file << " longitude = float(elements[0].firstChild.data)" << std::endl;
file << " elements = point.getElementsByTagName('Altitude')" << std::endl;
file << " if(elements and elements[0].firstChild" << std::endl;
file << " and elements[0].firstChild.nodeType == Node.TEXT_NODE):" << std::endl;
file << " altitude = float(elements[0].firstChild.data)" << std::endl;
file << " pointList.append([latitude,longitude,altitude])" << std::endl;
file << " if not isFoundFile:" << std::endl;
file << " print('ERROR:: ImpactLineSearchTask could not find LineOfInterest File for Id[' + str(lineId) + '!!!')" << std::endl;
file << "" << std::endl;
file << " else:" << std::endl;
file << " print('ERROR:: ImpactLineSearchTask could not parse LineID!!!')" << std::endl;
file << "" << std::endl;
file << " pointListPd = pd.DataFrame(data = pointList,columns=['latitude','longitude','altitude'])" << std::endl;
file << " return [taskID,label,pointListPd]" << std::endl;
file << "" << std::endl;
file << "" << std::endl;
file << "def ProcessPatternSearchTask(patternSearchTaskNode):" << std::endl;
file << " taskID = 0" << std::endl;
file << " elements = patternSearchTaskNode.getElementsByTagName('TaskID')" << std::endl;
file << " if elements and elements[0].firstChild and elements[0].firstChild.nodeType == Node.TEXT_NODE:" << std::endl;
file << " taskID = int(elements[0].firstChild.data)" << std::endl;
file << " label = 'PaS' + str(taskID)" << std::endl;
file << " elements = patternSearchTaskNode.getElementsByTagName('Label')" << std::endl;
file << " if elements and elements[0].firstChild and elements[0].firstChild.nodeType == Node.TEXT_NODE:" << std::endl;
file << " label = str(elements[0].firstChild.data)" << std::endl;
file << " print('taskID[{0}], label[{1}]'.format(taskID,label))" << std::endl;
file << "" << std::endl;
file << " isGoodSearchLocation = False" << std::endl;
file << " latitude = 0.0" << std::endl;
file << " longitude = 0.0" << std::endl;
file << " altitude = 0.0" << std::endl;
file << " searchLocation = []" << std::endl;
file << " searchLocationID = 0" << std::endl;
file << " elements = patternSearchTaskNode.getElementsByTagName('SearchLocationID')" << std::endl;
file << " if elements and elements[0].firstChild and elements[0].firstChild.nodeType == Node.TEXT_NODE:" << std::endl;
file << " searchLocationID = int(elements[0].firstChild.data)" << std::endl;
file << " if searchLocationID > 0:" << std::endl;
file << " # find the point of interest" << std::endl;
file << " for pointOfInterestFile in glob.glob('PointOfInterest_Id*'):" << std::endl;
file << " #\tPointOfInterest_Id_102.xml" << std::endl;
file << " fileId = int(re.search(r'\\d+',pointOfInterestFile).group())" << std::endl;
file << " if fileId == searchLocationID:" << std::endl;
file << " isFoundFile = True" << std::endl;
file << " docFileId = xml.dom.minidom.parse(pointOfInterestFile)" << std::endl;
file << " if docFileId.hasChildNodes():" << std::endl;
file << " fileNode = docFileId.firstChild" << std::endl;
file << " locationNode = fileNode.getElementsByTagName('Location')" << std::endl;
file << " if len(locationNode):" << std::endl;
file << " pointsNode = locationNode[0].getElementsByTagName('Location3D')" << std::endl;
file << " if len(pointsNode):" << std::endl;
file << " elements = pointsNode[0].getElementsByTagName('Latitude')" << std::endl;
file << " if(elements and elements[0].firstChild" << std::endl;
file << " and elements[0].firstChild.nodeType == Node.TEXT_NODE):" << std::endl;
file << " latitude = float(elements[0].firstChild.data)" << std::endl;
file << " elements = pointsNode[0].getElementsByTagName('Longitude')" << std::endl;
file << " if (elements and elements[0].firstChild" << std::endl;
file << " and elements[0].firstChild.nodeType == Node.TEXT_NODE):" << std::endl;
file << " longitude = float(elements[0].firstChild.data)" << std::endl;
file << " elements = pointsNode[0].getElementsByTagName('Altitude')" << std::endl;
file << " if (elements and elements[0].firstChild" << std::endl;
file << " and elements[0].firstChild.nodeType == Node.TEXT_NODE):" << std::endl;
file << " altitude = float(elements[0].firstChild.data)" << std::endl;
file << " isGoodSearchLocation = True" << std::endl;
file << " else:" << std::endl;
file << " print('ERROR:: processing [' + pointOfInterestFile +'] !!!')" << std::endl;
file << " else:" << std::endl;
file << " print('ERROR:: processing [' + pointOfInterestFile +'] !!!')" << std::endl;
file << " else:" << std::endl;
file << " print('ERROR:: processing [' + pointOfInterestFile +'] !!!')" << std::endl;
file << " break" << std::endl;
file << " else:" << std::endl;
file << " searchLocationNode = patternSearchTaskNode.getElementsByTagName('SearchLocation')" << std::endl;
file << " if len(searchLocationNode):" << std::endl;
file << " pointsNode = searchLocationNode[0].getElementsByTagName('Location3D')" << std::endl;
file << " if len(pointsNode):" << std::endl;
file << " elements = pointsNode[0].getElementsByTagName('Latitude')" << std::endl;
file << " if elements and elements[0].firstChild and elements[0].firstChild.nodeType == Node.TEXT_NODE:" << std::endl;
file << " latitude = float(elements[0].firstChild.data)" << std::endl;
file << " elements = pointsNode[0].getElementsByTagName('Longitude')" << std::endl;
file << " if elements and elements[0].firstChild and elements[0].firstChild.nodeType == Node.TEXT_NODE:" << std::endl;
file << " longitude = float(elements[0].firstChild.data)" << std::endl;
file << " elements = pointsNode[0].getElementsByTagName('Altitude')" << std::endl;
file << " if elements and elements[0].firstChild and elements[0].firstChild.nodeType == Node.TEXT_NODE:" << std::endl;
file << " altitude = float(elements[0].firstChild.data)" << std::endl;
file << " isGoodSearchLocation = True" << std::endl;
file << "" << std::endl;
file << " # ADD the boundary circle" << std::endl;
file << " if isGoodSearchLocation:" << std::endl;
file << " radius = 0" << std::endl;
file << " elements = patternSearchTaskNode.getElementsByTagName('Extent')" << std::endl;
file << " if elements and elements[0].firstChild and elements[0].firstChild.nodeType == Node.TEXT_NODE:" << std::endl;
file << " radius = float(elements[0].firstChild.data)" << std::endl;
file << " centerNorthEast_m = LocalCoords.LatLong_degToNorthEast_m(latitude,longitude)" << std::endl;
file << " heading = 0;" << std::endl;
file << " headingStep = math.pi/18;\t# 10 deg steps" << std::endl;
file << " while heading < 2.0*math.pi:" << std::endl;
file << " north_m = radius*math.sin(heading) + centerNorthEast_m[0]" << std::endl;
file << " east_m = radius*math.cos(heading) + centerNorthEast_m[1]" << std::endl;
file << " searchPointLatLong = LocalCoords.NorthEast_mToLatLong_deg(north_m,east_m)" << std::endl;
file << " searchLocation.append([searchPointLatLong[0],searchPointLatLong[1],altitude])" << std::endl;
file << " heading = heading + headingStep" << std::endl;
file << " # Close the boundary" << std::endl;
file << " if searchLocation:" << std::endl;
file << " searchLocation.append(searchLocation[0])" << std::endl;
file << " searchLocationPd = pd.DataFrame(data = searchLocation,columns=['latitude','longitude','altitude'])" << std::endl;
file << " # print('RESULT:: ProcessPatternSearchTask->searchLocationPd [' + str(searchLocationPd) +'] !!!')" << std::endl;
file << " return [taskID,label,searchLocationPd]" << std::endl;
file << "" << std::endl;
file << "" << std::endl;
file << "def ProcessPointSearchTask(pointSearchTaskNode):" << std::endl;
file << " # PointSearchTask" << std::endl;
file << " # Members inherited from Task: TaskID, Label, EligibleEntities, RevisitRate, Parameters, Priority, Required," << std::endl;
file << " # Members inherited from SearchTask: DesiredWavelengthBands, DwellTime, GroundSampleDistance," << std::endl;
file << " # SearchLocation - Point to search" << std::endl;
file << " # StandoffDistance - Minimum distance that an aircraft must maintain from the point of interest." << std::endl;
file << " # ViewAngleList - A list of acceptable look-angles for this task. Each wedge is defined relative to true North. To be a valid look angle, a sensor must be looking from a direction within the bounds of the wedge." << std::endl;
file << " taskID = 0" << std::endl;
file << " elements = pointSearchTaskNode.getElementsByTagName('TaskID')" << std::endl;
file << " if elements and elements[0].firstChild and elements[0].firstChild.nodeType == Node.TEXT_NODE:" << std::endl;
file << " taskID = int(elements[0].firstChild.data)" << std::endl;
file << " label = 'PS' + str(taskID)" << std::endl;
file << " elements = pointSearchTaskNode.getElementsByTagName('Label')" << std::endl;
file << " if elements and elements[0].firstChild and elements[0].firstChild.nodeType == Node.TEXT_NODE:" << std::endl;
file << " label = str(elements[0].firstChild.data)" << std::endl;
file << " print('taskID[{0}], label[{1}]'.format(taskID,label))" << std::endl;
file << "" << std::endl;
file << " searchLocation = []" << std::endl;
file << " searchLocationNode = pointSearchTaskNode.getElementsByTagName('SearchLocation')" << std::endl;
file << " if len(searchLocationNode):" << std::endl;
file << " pointsNode = searchLocationNode[0].getElementsByTagName('Location3D')" << std::endl;
file << " if len(pointsNode):" << std::endl;
file << " latitude = 0.0" << std::endl;
file << " longitude = 0.0" << std::endl;
file << " altitude = 0.0" << std::endl;
file << " elements = pointsNode[0].getElementsByTagName('Latitude')" << std::endl;
file << " if elements and elements[0].firstChild and elements[0].firstChild.nodeType == Node.TEXT_NODE:" << std::endl;
file << " latitude = float(elements[0].firstChild.data)" << std::endl;
file << " elements = pointsNode[0].getElementsByTagName('Longitude')" << std::endl;
file << " if elements and elements[0].firstChild and elements[0].firstChild.nodeType == Node.TEXT_NODE:" << std::endl;
file << " longitude = float(elements[0].firstChild.data)" << std::endl;
file << " elements = pointsNode[0].getElementsByTagName('Altitude')" << std::endl;
file << " if elements and elements[0].firstChild and elements[0].firstChild.nodeType == Node.TEXT_NODE:" << std::endl;
file << " altitude = float(elements[0].firstChild.data)" << std::endl;
file << " searchLocation.append([latitude,longitude,altitude])" << std::endl;
file << " searchLocationPd = pd.DataFrame(data = searchLocation,columns=['latitude','longitude','altitude'])" << std::endl;
file << " return [taskID,label,searchLocationPd]" << std::endl;
file << "" << std::endl;
file << "" << std::endl;
file << "def ProcessLineSearchTask(lineSearchTaskNode):" << std::endl;
file << " # LineSearchTask" << std::endl;
file << " # Members inherited from Task: TaskID, Label, EligibleEntities, RevisitRate, Parameters, Priority, Required," << std::endl;
file << " # Members inherited from SearchTask: DesiredWavelengthBands, DwellTime, GroundSampleDistance," << std::endl;
file << " # PointList - Line to search" << std::endl;
file << " # ViewAngleList - Defines a list of acceptable look-angles for this task. See the documentation above for details." << std::endl;
file << " # UseInertialViewAngles - If true, the ViewAngleList specifies inertial (North-East) angles. See documentation above." << std::endl;
file << " taskID = 0" << std::endl;
file << " elements = lineSearchTaskNode.getElementsByTagName('TaskID')" << std::endl;
file << " if elements and elements[0].firstChild and elements[0].firstChild.nodeType == Node.TEXT_NODE:" << std::endl;
file << " taskID = int(elements[0].firstChild.data)" << std::endl;
file << " label = 'LS' + str(taskID)" << std::endl;
file << " elements = lineSearchTaskNode.getElementsByTagName('Label')" << std::endl;
file << " if elements and elements[0].firstChild and elements[0].firstChild.nodeType == Node.TEXT_NODE:" << std::endl;
file << " label = str(elements[0].firstChild.data)" << std::endl;
file << " print('taskID[{0}], label[{1}]'.format(taskID,label))" << std::endl;
file << "" << std::endl;
file << " pointList = []" << std::endl;
file << " pointListNode = lineSearchTaskNode.getElementsByTagName('PointList')" << std::endl;
file << " # print('pointListNode[' + str(pointListNode[0].nodeName) + ']')" << std::endl;
file << " if len(pointListNode):" << std::endl;
file << " pointsNode = pointListNode[0].getElementsByTagName('Location3D')" << std::endl;
file << " for point in pointsNode:" << std::endl;
file << " latitude = 0.0" << std::endl;
file << " longitude = 0.0" << std::endl;
file << " altitude = 0.0" << std::endl;
file << " if point:" << std::endl;
file << " elements = point.getElementsByTagName('Latitude')" << std::endl;
file << " if elements and elements[0].firstChild and elements[0].firstChild.nodeType == Node.TEXT_NODE:" << std::endl;
file << " latitude = float(elements[0].firstChild.data)" << std::endl;
file << " elements = point.getElementsByTagName('Longitude')" << std::endl;
file << " if elements and elements[0].firstChild and elements[0].firstChild.nodeType == Node.TEXT_NODE:" << std::endl;
file << " longitude = float(elements[0].firstChild.data)" << std::endl;
file << " elements = point.getElementsByTagName('Altitude')" << std::endl;
file << " if elements and elements[0].firstChild and elements[0].firstChild.nodeType == Node.TEXT_NODE:" << std::endl;
file << " altitude = float(elements[0].firstChild.data)" << std::endl;
file << " pointList.append([latitude,longitude,altitude])" << std::endl;
file << " pointListPd = pd.DataFrame(data = pointList,columns=['latitude','longitude','altitude'])" << std::endl;
file << " return [taskID,label,pointListPd]" << std::endl;
file << "" << std::endl;
file << "" << std::endl;
file << "def ProcessAreaSearchTask(areaSearchTaskNode):" << std::endl;
file << " # Area search task" << std::endl;
file << " # Members inherited from Task: TaskID, Label, EligibleEntities, RevisitRate, Parameters, Priority, Required," << std::endl;
file << " # Members inherited from SearchTask: DesiredWavelengthBands, DwellTime, GroundSampleDistance," << std::endl;
file << " # SearchArea - Area to search" << std::endl;
file << " # ViewAngleList - A list of acceptable look-angles for this task." << std::endl;
file << " #\t\t\t\t\tEach wedge is defined relative to true North." << std::endl;
file << " #\t\t\t\t\tTo be a valid look angle, a sensor must be looking from a direction within the bounds of the wedge." << std::endl;
file << "" << std::endl;
file << " taskID = 0" << std::endl;
file << " elements = areaSearchTaskNode.getElementsByTagName('TaskID')" << std::endl;
file << " if elements and elements[0].firstChild and elements[0].firstChild.nodeType == Node.TEXT_NODE:" << std::endl;
file << " taskID = int(elements[0].firstChild.data)" << std::endl;
file << " label = 'AS' + str(taskID)" << std::endl;
file << " elements = areaSearchTaskNode.getElementsByTagName('Label')" << std::endl;
file << " if elements and elements[0].firstChild and elements[0].firstChild.nodeType == Node.TEXT_NODE:" << std::endl;
file << " label = str(elements[0].firstChild.data)" << std::endl;
file << " print('taskID[{0}], label[{1}]'.format(taskID,label))" << std::endl;
file << "" << std::endl;
file << " searchAreaPoints = []" << std::endl;
file << " areaNode = areaSearchTaskNode.getElementsByTagName('SearchArea')" << std::endl;
file << " # print('areaNode[' + str(areaNode[0].nodeName) + ']')" << std::endl;
file << " if len(areaNode):" << std::endl;
file << " searchAreaPoints = ProcessAbstractGeometry(areaNode[0])" << std::endl;
file << " # Close the boundary" << std::endl;
file << " if searchAreaPoints:" << std::endl;
file << " searchAreaPoints.append(searchAreaPoints[0])" << std::endl;
file << " searchBoundaryPd = pd.DataFrame(data = searchAreaPoints,columns=['latitude','longitude','altitude'])" << std::endl;
file << " return [taskID,label,searchBoundaryPd]" << std::endl;
file << "" << std::endl;
file << "" << std::endl;
file << "def ProcessTaskFile(filename):" << std::endl;
file << "" << std::endl;
file << " searchTask = []" << std::endl;
file << " doc2 = xml.dom.minidom.parse(filename)" << std::endl;
file << " if doc2.hasChildNodes():" << std::endl;
file << " isGoodMessage = True" << std::endl;
file << " taskTypeNode = doc2.firstChild" << std::endl;
file << " taskType = str(taskTypeNode.nodeName)" << std::endl;
file << "" << std::endl;
file << " if taskType == 'PointSearchTask':" << std::endl;
file << " print('processing PointSearchTask ...')" << std::endl;
file << " taskData = ProcessPointSearchTask(taskTypeNode)" << std::endl;
file << " if len(taskData):" << std::endl;
file << " searchTask.append(taskData)" << std::endl;
file << " elif taskType == 'LineSearchTask':" << std::endl;
file << " print('processing LineSearchTask ...')" << std::endl;
file << " taskData = ProcessLineSearchTask(taskTypeNode)" << std::endl;
file << " if len(taskData):" << std::endl;
file << " searchTask.append(taskData)" << std::endl;
file << " elif taskType == 'AreaSearchTask':" << std::endl;
file << " print('processing AreaSearchTask ...')" << std::endl;
file << " taskData = ProcessAreaSearchTask(taskTypeNode)" << std::endl;
file << " if len(taskData):" << std::endl;
file << " searchTask.append(taskData)" << std::endl;
file << " elif taskType == 'AngledAreaSearchTask':" << std::endl;
file << " print('processing AngledAreaSearchTask ...')" << std::endl;
file << " taskData = ProcessAngledAreaSearchTask(taskTypeNode)" << std::endl;
file << " if len(taskData):" << std::endl;
file << " searchTask.append(taskData)" << std::endl;
file << " elif taskType == 'ImpactPointSearchTask':" << std::endl;
file << " print('processing ImpactPointSearchTask ...')" << std::endl;
file << " taskData = ProcessImpactPointSearchTask(taskTypeNode)" << std::endl;
file << " if len(taskData):" << std::endl;
file << " searchTask.append(taskData)" << std::endl;
file << " elif taskType == 'ImpactLineSearchTask':" << std::endl;
file << " print('processing ImpactLineSearchTask ...')" << std::endl;
file << " taskData = ProcessImpactLineSearchTask(taskTypeNode)" << std::endl;
file << " if len(taskData):" << std::endl;
file << " searchTask.append(taskData)" << std::endl;
file << " elif taskType == 'PatternSearchTask':" << std::endl;
file << " print('processing PatternSearchTask ...')" << std::endl;
file << " taskData = ProcessPatternSearchTask(taskTypeNode)" << std::endl;
file << " if len(taskData):" << std::endl;
file << " searchTask.append(taskData)" << std::endl;
file << " elif taskType == 'WatchTask':" << std::endl;
file << " print('processing WatchTask ...')" << std::endl;
file << " taskData = ProcessWatchTask(taskTypeNode)" << std::endl;
file << " if len(taskData):" << std::endl;
file << " searchTask.append(taskData)" << std::endl;
file << " else:" << std::endl;
file << " print('ERROR:: Unknown task type[' + taskType +'] encountered!!!')" << std::endl;
file << " return searchTask" << std::endl;
file << "" << std::endl;
file << "" << std::endl;
file << "def main():" << std::endl;
file << " taskArray = []" << std::endl;
file << " for taskFile in glob.glob('Task_Id*'):" << std::endl;
file << " print('')\t# add a line return" << std::endl;
file << " print('***loading [{0}] ***'.format(taskFile))" << std::endl;
file << " taskArray.extend(ProcessTaskFile(taskFile))" << std::endl;
file << " taskArrayPd = pd.DataFrame(data = taskArray,columns=['taskID','label','searchBoundaryPd'])" << std::endl;
file << " print('')\t# add a line return" << std::endl;
file << " print('*** saving [Tasks.pkl] ***')" << std::endl;
file << " print('')\t# add a line return" << std::endl;
file << " taskArrayPd.to_pickle('Tasks.pkl')" << std::endl;
file << "" << std::endl;
file << "if __name__ == '__main__':" << std::endl;
file << " main()" << std::endl;