예제 #1
0
 private void WriteToFile(BinaryWriter bw, RspObject myObject)
 {
     bw.Write(myObject.Name);
     bw.Write(myObject.type);
     bw.Write(myObject.Lon1);
     bw.Write(myObject.Lat1);
     bw.Write(myObject.Lon2);
     bw.Write(myObject.Lat2);
     bw.Write(myObject.StartTime);
     bw.Write(myObject.EndTime);
     bw.Write(myObject.tankage);
     bw.Write(myObject.Delay);
     bw.Write(myObject.Perc_effective);
     bw.Write(myObject.speed);
     bw.Write(myObject.status);
     bw.Write(myObject.endurance);
     bw.Write(myObject.on);
     bw.Write(myObject.area);
     bw.Write(myObject.currthrs);
     bw.Write(myObject.wavethrs);
     bw.Write(myObject.StartTimeOld);
     bw.Write(myObject.EndTimeOld);
     bw.Write(myObject.opspeed);
     bw.Write(myObject.turntime);
     bw.Write(myObject.swathwidth);
     bw.Write(myObject.minmass);
     bw.Write(myObject.searchtype);
     bw.Write(myObject.ntrips);
     bw.Write(myObject.i1);
     bw.Write(myObject.i2);
     bw.Write(myObject.i3);
 }
예제 #2
0
    private string AddBoomToScenario(string sLocation, string sScenario, string sResponseObject)
    {
        XmlDocument oDoc = new XmlDocument();

        oDoc.LoadXml(sResponseObject);

        string sWebPath      = Path.GetDirectoryName(Server.MapPath("ModelRunMapPath.txt"));
        string sResponseFile = sWebPath + "\\ModelData\\" + sLocation + "\\Response\\" + sScenario + ".NO2";

        if (File.Exists(sResponseFile))
        {
            File.Delete(sResponseFile);
        }

        XmlElement oRootNode  = (XmlElement)oDoc.SelectSingleNode("booms");
        XmlElement oPolylines = (XmlElement)oRootNode.SelectSingleNode("./polylines");

        using (BinaryWriter bw = new BinaryWriter(File.Open(sResponseFile, FileMode.Create)))
        {
            XmlNodeList oList = oPolylines.SelectNodes("./polyline");
            foreach (XmlElement oPolyline in oList)
            {
                RspObject  myObject = new RspObject();
                XmlElement oNode    = (XmlElement)oPolyline.SelectSingleNode("./name");
                myObject.Name      = oNode.InnerText.PadRight(20);
                myObject.i1        = short.Parse(oPolyline.GetAttribute("id"));
                oNode              = (XmlElement)oPolyline.SelectSingleNode("./start_utc");
                myObject.StartTime = GetTimeFromString(oNode.InnerText);
                oNode              = (XmlElement)oPolyline.SelectSingleNode("./end_utc");
                myObject.EndTime   = GetTimeFromString(oNode.InnerText);
                oNode              = (XmlElement)oPolyline.SelectSingleNode("./currentthreshold");
                myObject.currthrs  = (short)double.Parse(oNode.InnerText);
                oNode              = (XmlElement)oPolyline.SelectSingleNode("./wavethreshold");
                myObject.wavethrs  = (short)double.Parse(oNode.InnerText);
                XmlNodeList oLineList = oPolyline.SelectNodes("./linepoint");
                for (int i = 1; i < oLineList.Count; i++)
                {
                    XmlElement oLineNode  = (XmlElement)oPolyline.SelectSingleNode("./linepoint[@id='" + i.ToString() + "']");
                    XmlElement oPointNode = (XmlElement)oLineNode.SelectSingleNode("./x");
                    myObject.Lon1 = float.Parse(oPointNode.InnerText);
                    oPointNode    = (XmlElement)oLineNode.SelectSingleNode("./y");
                    myObject.Lat1 = float.Parse(oPointNode.InnerText);
                    oLineNode     = (XmlElement)oPolyline.SelectSingleNode("./linepoint[@id='" + (i + 1).ToString() + "']");
                    oPointNode    = (XmlElement)oLineNode.SelectSingleNode("./x");
                    myObject.Lon2 = float.Parse(oPointNode.InnerText);
                    oPointNode    = (XmlElement)oLineNode.SelectSingleNode("./y");
                    myObject.Lat2 = float.Parse(oPointNode.InnerText);
                    WriteToFile(bw, myObject);
                }
            }
        }
        return(sWebPath + "\\ModelData\\" + sLocation + "\\Outdata\\" + sScenario + ".INP");
    }