Пример #1
0
        /// <summary>
        /// Sends the options to the python script for creating tracks based on purposeful motion calculations.
        /// </summary>
        /// <param name="sSuffix"></param>
        private void CreatePurposefulMotionTracks(string sSuffix)
        {
            XmlDocument oDoc      = new XmlDocument();
            XmlElement  oRootNode = oDoc.CreateElement("Settings");

            //*************************************************************/
            //Input/Output tables
            XmlElement oNode = oDoc.CreateElement("InputFC");

            oNode.InnerText = m_sWorkspace + "\\" + m_sLayername;
            oRootNode.AppendChild(oNode);

            oNode           = oDoc.CreateElement("OutputLine");
            oNode.InnerText = m_sWorkspace + "\\" + m_sLayername + "_" + sSuffix;
            oRootNode.AppendChild(oNode);

            oNode           = oDoc.CreateElement("InputVoyageTable");
            oNode.InnerText = m_sWorkspace + "\\" + m_sLayername.Replace("Broadcast", "Voyage");
            oRootNode.AppendChild(oNode);

            oNode           = oDoc.CreateElement("InitSOG");
            oNode.InnerText = m_dInitSOG.ToString();
            oRootNode.AppendChild(oNode);

            oNode           = oDoc.CreateElement("EndSOG");
            oNode.InnerText = m_dEndSOG.ToString();
            oRootNode.AppendChild(oNode);

            oNode           = oDoc.CreateElement("EndTime");
            oNode.InnerText = m_iEndTime.ToString();
            oRootNode.AppendChild(oNode);

            oNode           = oDoc.CreateElement("EndGap");
            oNode.InnerText = m_iEndGap.ToString();
            oRootNode.AppendChild(oNode);

            oNode           = oDoc.CreateElement("MinPositions");
            oNode.InnerText = m_iMinPositions.ToString();
            oRootNode.AppendChild(oNode);

            oDoc.AppendChild(oRootNode);

            clsPython pPython = new clsPython();

            pPython.RunPythonScript("PurposefulMotion.py", oDoc, "MotionSettings.xml");
        }
Пример #2
0
        /// <summary>
        /// Sends the selected options to a Python script as XML to clean a table.
        /// </summary>
        /// <param name="sNewTableName"></param>
        /// <returns></returns>
        private ITable CleanTable(string sNewTableName)
        {
            try
            {
                string      sWorkspace  = m_sWorkspace;
                string      sInputTable = m_sLayername;
                XmlDocument oDoc        = new XmlDocument();
                XmlElement  oRootNode   = oDoc.CreateElement("Settings");

                //*************************************************************/
                //Input/Output tables
                XmlElement oNode = oDoc.CreateElement("InputTable");
                oNode.InnerText = sWorkspace + "\\" + sInputTable;
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("OutputCleanedTable");
                oNode.InnerText = sWorkspace + "\\" + sInputTable + "_" + sNewTableName;
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("OutputDeletedTable");
                oNode.InnerText = sWorkspace + "\\" + sInputTable + "_" + sNewTableName + "_Deleted";
                oRootNode.AppendChild(oNode);

                //*************************************************************/
                //Clean IMO Entries
                oNode           = oDoc.CreateElement("CleanIMO");
                oNode.InnerText = (m_bCleanIMO ? "T" : "F");
                oRootNode.AppendChild(oNode);

                //*************************************************************/
                //Clean Callsign Entries
                oNode           = oDoc.CreateElement("CleanCallsign");
                oNode.InnerText = (m_bCleanCallsign ? "T" : "F");
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("RemoveFirstCharSpecial");
                oNode.InnerText = (m_bRemoveLeadingSpecialChar ? "T" : "F");
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("RemoveSpecialAnywhere");
                oNode.InnerText = (m_bRemoveAnySpecialChar ? "T" : "F");
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("RemoveSpace");
                oNode.InnerText = (m_bRemoveSpaces ? "T" : "F");
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("RemoveBlankZero");
                oNode.InnerText = (m_bRemoveBlanks ? "T" : "F");
                oRootNode.AppendChild(oNode);

                //*************************************************************/
                //Clean Shiptype Entries
                oNode           = oDoc.CreateElement("CleanShiptype");
                oNode.InnerText = (m_bCleanShiptype ? "T" : "F");
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("NAShiptype");
                oNode.InnerText = (m_bShipRemoveNAValues ? "T" : "F");
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("FutureShiptype");
                oNode.InnerText = (m_bShipRemoveFutureValues ? "T" : "F");
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("RegionalShiptype");
                oNode.InnerText = (m_bShipRemoveRegionalValues ? "T" : "F");
                oRootNode.AppendChild(oNode);

                //*************************************************************/
                //Clean Cargo Entries
                oNode           = oDoc.CreateElement("CleanCargotype");
                oNode.InnerText = (m_bCleanCargo ? "T" : "F");
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("NACargo");
                oNode.InnerText = (m_bCargoRemoveNAValues ? "T" : "F");
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("FutureCargo");
                oNode.InnerText = (m_bCargoRemoveFutureValues ? "T" : "F");
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("RegionalCargo");
                oNode.InnerText = (m_bCargoRemoveRegionalValues ? "T" : "F");
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("NoAdditionalInfoCargo");
                oNode.InnerText = (m_bCargoNoAddInfo ? "T" : "F");
                oRootNode.AppendChild(oNode);

                //*************************************************************/
                //Clean MMSI Entries
                oNode           = oDoc.CreateElement("CleanMMSI");
                oNode.InnerText = (m_bCleanMMSI ? "T" : "F");
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("CountryCodes");
                oNode.InnerText = GetCountryCodes();
                oRootNode.AppendChild(oNode);

                //*************************************************************/
                //Clean Name Entries
                oNode           = oDoc.CreateElement("CleanNames");
                oNode.InnerText = (m_bCleanName ? "T" : "F");
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("CleanEmptyNames");
                oNode.InnerText = (m_bNameRemoveEmptyStrings ? "T" : "F");
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("CleanManySpacesNames");
                oNode.InnerText = (m_bNameRemoveMultiSpace ? "T" : "F");
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("CleanSpecialCharNames");
                oNode.InnerText = (m_bNameRemoveSpecialChar ? "T" : "F");
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("CleanUserCharNames");
                oNode.InnerText = (m_bNameRemoveUserChar ? "T" : "F");
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("UserCharNames");
                oNode.InnerText = m_sUserChar;
                oRootNode.AppendChild(oNode);

                //*************************************************************/
                //Clean Ship Dimensions Entries
                oNode           = oDoc.CreateElement("CleanDimensions");
                oNode.InnerText = (m_bCleanDimensions ? "T" : "F");
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("MinWidth");
                oNode.InnerText = m_iMinWidth.ToString();
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("MaxWidth");
                oNode.InnerText = m_iMaxWidth.ToString();
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("MinLength");
                oNode.InnerText = m_iMinLength.ToString();
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("MaxLength");
                oNode.InnerText = m_iMaxLength.ToString();
                oRootNode.AppendChild(oNode);

                //*************************************************************/
                //Clean ETA/End Time Entries
                oNode           = oDoc.CreateElement("CleanETA");
                oNode.InnerText = (m_bCleanETA ? "T" : "F");
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("EarlyThreshold");
                oNode.InnerText = m_iETAEarlyThresh.ToString();
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("LateThreshold");
                oNode.InnerText = m_iETALateThresh.ToString();
                oRootNode.AppendChild(oNode);

                //*************************************************************/
                //Clean Inconsistent Static Data
                oNode           = oDoc.CreateElement("CleanInconsistentRecords");
                oNode.InnerText = (m_bRemoveInconsistentEntries ? "T" : "F");
                oRootNode.AppendChild(oNode);

                oDoc.AppendChild(oRootNode);

                clsPython pPython = new clsPython();
                pPython.RunPythonScript("Clean_Table.py", oDoc, "TableSettings.xml");

                return(clsStatic.GetTable(sWorkspace, sInputTable + "_" + sNewTableName));
            }
            catch (Exception ex)
            {
                clsStatic.ShowErrorMessage(ex.ToString());
                return(null);
            }
        }
Пример #3
0
        /// <summary>
        /// Sends the selected options to a Python script as XML to clean the feature class.
        /// </summary>
        /// <param name="sNewFCName"></param>
        /// <returns></returns>
        private IFeatureLayer CleanFeatureClass(string sNewFCName)
        {
            try
            {
                string      sWorkspace = m_sWorkspace;
                string      sInputFC   = m_sLayername;
                XmlDocument oDoc       = new XmlDocument();
                XmlElement  oRootNode  = oDoc.CreateElement("Settings");

                //*************************************************************/
                //Input/Output feature classes
                //Base stations table
                XmlElement oNode = oDoc.CreateElement("InputFC");
                oNode.InnerText = sWorkspace + "\\" + sInputFC;
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("VoyageTable");
                oNode.InnerText = sWorkspace + "\\" + sInputFC.Replace("Broadcast", "Voyage");
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("VesselTable");
                oNode.InnerText = sWorkspace + "\\" + sInputFC.Replace("Broadcast", "Vessel");
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("OutputCleanedFeature");
                oNode.InnerText = sWorkspace + "\\" + sInputFC + "_" + sNewFCName;
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("OutputDeletedFeature");
                oNode.InnerText = sWorkspace + "\\" + sInputFC + "_" + sNewFCName + "_Deleted";
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("BaseStationTable");
                oNode.InnerText = sWorkspace + "\\" + "BaseStations";
                oRootNode.AppendChild(oNode);

                //************************************************************
                //Clean Status
                oNode           = oDoc.CreateElement("CleanStatus");
                oNode.InnerText = (m_bCleanStatus ? "T" : "F");
                oRootNode.AppendChild(oNode);

                //************************************************************
                //Clean Minimum Number Of Reports
                oNode           = oDoc.CreateElement("CleanNumReports");
                oNode.InnerText = (m_bCleanNumReports ? "T" : "F");
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("ReportsLowerThresh");
                oNode.InnerText = m_iNumReports.ToString();
                oRootNode.AppendChild(oNode);

                //*************************************************************/
                //Clean MMSI
                oNode           = oDoc.CreateElement("CleanMMSI");
                oNode.InnerText = (m_bCleanMMSI ? "T" : "F");
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("CountryCodes");
                oNode.InnerText = GetCountryCodes();
                oRootNode.AppendChild(oNode);

                //*************************************************************/
                //Clean Speed Over Ground
                oNode           = oDoc.CreateElement("CleanSOG");
                oNode.InnerText = (m_bCleanSOG ? "T" : "F");
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("SOGLowerThresh");
                oNode.InnerText = m_iCleanSOGLower.ToString();
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("SOGUpperThresh");
                oNode.InnerText = m_iCleanSOGUpper.ToString();
                oRootNode.AppendChild(oNode);

                //*************************************************************/
                //Clean Base Station Distance From Point
                oNode           = oDoc.CreateElement("CleanBaseStationDistance");
                oNode.InnerText = (m_bCleanBaseDistance ? "T" : "F");
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("UserDistance");
                oNode.InnerText = m_iMaxDistance.ToString();
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("UserPositionX");
                oNode.InnerText = m_dMaxDistLongitude.ToString();
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("UserPositionY");
                oNode.InnerText = m_dMaxDistLatitude.ToString();
                oRootNode.AppendChild(oNode);

                //*************************************************************/
                //Remove duplicate entries
                oNode           = oDoc.CreateElement("RemoveDuplicates");
                oNode.InnerText = (m_bRemoveDuplicates ? "T" : "F");
                oRootNode.AppendChild(oNode);

                //*************************************************************/
                //Remove No Static Records
                oNode           = oDoc.CreateElement("RemoveNoStaticRecords");
                oNode.InnerText = (m_bRemoveNoStaticRecords ? "T" : "F");
                oRootNode.AppendChild(oNode);

                //*************************************************************/
                //Clean Voyage Track Cargo Types
                oNode           = oDoc.CreateElement("CleanCargotype");
                oNode.InnerText = (m_bCleanCargo ? "T" : "F");
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("NACargo");
                oNode.InnerText = (m_bCargoRemoveNAValues ? "T" : "F");
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("FutureCargo");
                oNode.InnerText = (m_bCargoRemoveFutureValues ? "T" : "F");
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("RegionalCargo");
                oNode.InnerText = (m_bCargoRemoveRegionalValues ? "T" : "F");
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("NoAdditionalInfoCargo");
                oNode.InnerText = (m_bCargoNoAddInfo ? "T" : "F");
                oRootNode.AppendChild(oNode);

                //*************************************************************/
                //Clean Voyage Track ETA/End Time Entries
                oNode           = oDoc.CreateElement("CleanETA");
                oNode.InnerText = (m_bCleanETA ? "T" : "F");
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("EarlyThreshold");
                oNode.InnerText = m_iETAEarlyThresh.ToString();
                oRootNode.AppendChild(oNode);

                oNode           = oDoc.CreateElement("LateThreshold");
                oNode.InnerText = m_iETALateThresh.ToString();
                oRootNode.AppendChild(oNode);

                oDoc.AppendChild(oRootNode);

                clsPython pPython = new clsPython();
                pPython.RunPythonScript("Clean_FeatureClass.py", oDoc, "FCSettings.xml");

                return(clsStatic.GetFeatureLayer(sWorkspace, sInputFC + "_" + sNewFCName));
            }
            catch (Exception ex)
            {
                clsStatic.ShowErrorMessage(ex.ToString());
                return(null);
            }
        }
Пример #4
0
        /// <summary>
        /// Sends the selected options to the Filtering python script as XML.
        /// </summary>
        /// <param name="sSuffix"></param>
        /// <returns></returns>
        public IFeatureLayer FilterLayer(string sSuffix)
        {
            IFeatureLayer pResult    = null;
            string        sWorkspace = m_sWorkspace;
            string        sInputFC   = m_sLayername;

            try
            {
                if (m_bFilterDistance)
                {
                    XmlDocument oDoc      = new XmlDocument();
                    XmlElement  oRootNode = oDoc.CreateElement("Settings");

                    //*************************************************************/
                    //Input/Output feature classes
                    //Base stations table
                    XmlElement oNode = oDoc.CreateElement("InputFC");
                    oNode.InnerText = sWorkspace + "\\" + sInputFC;
                    oRootNode.AppendChild(oNode);

                    oNode           = oDoc.CreateElement("OutputCleanedFeature");
                    oNode.InnerText = sWorkspace + "\\" + sInputFC + "_" + sSuffix;
                    oRootNode.AppendChild(oNode);

                    oNode           = oDoc.CreateElement("OutputDeletedFeature");
                    oNode.InnerText = sWorkspace + "\\" + sInputFC + "_" + sSuffix + "_Deleted";
                    oRootNode.AppendChild(oNode);

                    oNode           = oDoc.CreateElement("FilterDistance");
                    oNode.InnerText = (m_bFilterDistance ? "T" : "F");
                    oRootNode.AppendChild(oNode);

                    oNode           = oDoc.CreateElement("MaximumDistance");
                    oNode.InnerText = m_dMaximumDistance.ToString();
                    oRootNode.AppendChild(oNode);

                    oDoc.AppendChild(oRootNode);

                    clsPython pPython = new clsPython();
                    pPython.RunPythonScript("filter_fortrackgen.py", oDoc, "FilterSettings.xml");
                }
                else if (m_bSmoothLines)
                {
                    IMxDocument   pMxDoc = ArcMap.Document;
                    IFeatureLayer pFL    = clsStatic.GetLayerFromMap(sWorkspace, sInputFC);
                    if (pFL != null)
                    {
                        pMxDoc.DelayUpdateContents = true;
                        pMxDoc.FocusMap.DeleteLayer((ILayer)pFL);
                    }

                    ESRI.ArcGIS.Geoprocessor.Geoprocessor gp = new ESRI.ArcGIS.Geoprocessor.Geoprocessor();
                    gp.OverwriteOutput = true;
                    gp.AddOutputsToMap = false;

                    ESRI.ArcGIS.CartographyTools.SmoothLine smoothLine = new ESRI.ArcGIS.CartographyTools.SmoothLine();
                    smoothLine.in_features       = sWorkspace + "\\" + sInputFC;
                    smoothLine.out_feature_class = sWorkspace + "\\" + sInputFC + "_" + sSuffix;
                    smoothLine.algorithm         = m_sAlgorithm;
                    if (m_sAlgorithm == "PAEK")
                    {
                        smoothLine.tolerance       = m_iTolerance;
                        smoothLine.endpoint_option = m_sEndpointOption;
                    }
                    else
                    {
                        smoothLine.tolerance = 0;
                    }

                    smoothLine.error_option = m_sErrorOption;
                    gp.Execute(smoothLine, null);
                    ProcessGPMessages(gp);

                    pMxDoc.FocusMap.AddLayer((ILayer)pFL);
                }
            }
            catch (COMException exCom)
            {
                MessageBox.Show("You need an ArcInfo license to access this operation.", clsStatic.g_cProjectName, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                clsStatic.ShowErrorMessage(ex.ToString());
            }
            finally
            {
                pResult = clsStatic.GetFeatureLayer(sWorkspace, sInputFC + "_" + sSuffix);
            }
            return(pResult);
        }