Exemplo n.º 1
0
        public static string GetWebPointInfo1(string connectionString, string strLng, double lon, double lat, string[] mInfoRegion, string[] mInfoRayon, ref string mInfoSettlement)
        {
            //var fds = new FeatureDataSet();
            DataTable tbl;
            var       lPoint         = new Point(lon, lat);
            var       projectedPoint = GeometryTransform.TransformPoint(lPoint, CoordinateSystems.WGS84,
                                                                        CoordinateSystems.SphericalMercatorCS);
            //var connectionString = ConnectionManager.DefaultInstance.ConnectionString;
            var sqlConnection = new SqlConnection(connectionString);

            string lRegion = null;
            long   id      = 0;

            lRegion = GetGeoName(connectionString, strLng, "gisWKBRegion", projectedPoint.X, projectedPoint.Y) + "  ";
            if (lRegion == null)
            {
                return("");
            }
            else
            {
                mInfoRegion[0] = lRegion;
                //// Region
                id  = GetGeoId(connectionString, "gisWKBRegion", projectedPoint.X, projectedPoint.Y);
                tbl = SqlExecHelper.SqlExecTable(sqlConnection,
                                                 string.Format("SELECT * FROM dbo.fn_GetRegionStatInfo(dbo.fnGetLanguageCode('{0}'), {1})", strLng, id));
                tbl.Columns.Add("varPopDens", Type.GetType("System.Double"));
                foreach (DataRow row in tbl.Rows)
                {
                    if (row["varPopulation"] is DBNull || row["varArea"] is DBNull)
                    {
                        continue;
                    }

                    double population = (double)row["varPopulation"];
                    double area       = (double)row["varArea"];

                    if (area != 0)
                    {
                        row["varPopDens"] = population / area;
                    }
                    else
                    {
                        row["varPopDens"] = null;
                    }

                    mInfoRegion[1] = GetStatValue(row["varArea"]);
                    mInfoRegion[2] = GetStatValue(row["varPopulation"]);
                    mInfoRegion[3] = GetStatValue(row["varPopDens"]);
                }
            }

            mInfoRayon[0] = GetGeoName(connectionString, strLng, "gisWKBRayon", projectedPoint.X, projectedPoint.Y) + "  ";
            id            = GetGeoId(connectionString, "gisWKBRayon", projectedPoint.X, projectedPoint.Y);
            tbl           = SqlExecHelper.SqlExecTable(sqlConnection, string.Format("SELECT * FROM dbo.fn_GetRayonStatInfo(dbo.fnGetLanguageCode('{0}'), {1})", strLng, id));
            tbl.Columns.Add("varPopDens", Type.GetType("System.Double"));
            foreach (DataRow row in tbl.Rows)
            {
                if (row["varPopulation"] is DBNull || row["varArea"] is DBNull)
                {
                    continue;
                }
                double population = (double)row["varPopulation"];
                double area       = (double)row["varArea"];
                //double density;
                if (area != 0)
                {
                    row["varPopDens"] = population / area;
                }
                else
                {
                    row["varPopDens"] = null;
                }

                mInfoRayon[1] = GetStatValue(row["varArea"]);
                mInfoRayon[2] = GetStatValue(row["varPopulation"]);
                mInfoRayon[3] = GetStatValue(row["varPopDens"]);
            }


            mInfoSettlement = GetGeoName(connectionString, strLng, "gisWKBSettlement", projectedPoint.X, projectedPoint.Y);


            /*
             * varArea
             * varPopulation
             * varPopDens
             */

            return("");
        }
Exemplo n.º 2
0
        private void InfoRoutine(Point worldPos)
        {
            m_CurrentLayer = m_MapContent.CurrentLayer;

            if (m_CurrentLayer == null)
            {
                return;
            }
            if (!m_CurrentLayer.Enabled)
            {
                return;
            }

            var featureDataRow = GetNearestFeature(worldPos);

            if (featureDataRow == null)
            {
                return;
            }

            var id = (long)featureDataRow.ItemArray[0];

            // Check type of selected layer

            if (m_CurrentLayer is EidssSystemDbLayer)
            {
                var strTableName = ((SqlServer2008)(((EidssSystemDbLayer)m_CurrentLayer).DataSource)).Table;
                if (strTableName == "gisWKBRegion")
                {
                    #region Regional statistic
                    var sqlConnection = new SqlConnection(ConnectionManager.DefaultInstance.ConnectionString);
                    var tbl           = SqlExecHelper.SqlExecTable(sqlConnection,
                                                                   string.Format(
                                                                       "SELECT * FROM dbo.fn_GetRegionStatInfo(dbo.fnGetLanguageCode('{0}'), {1})",
                                                                       EidssUserContext.CurrentLanguage, id));
                    tbl.Columns.Add("varPopDens", Type.GetType("System.Double"));
                    foreach (DataRow row in tbl.Rows)
                    {
                        if (row["varPopulation"] is DBNull || row["varArea"] is DBNull)
                        {
                            continue;
                        }

                        double population = (double)row["varPopulation"];
                        double area       = (double)row["varArea"];

                        //double density;
                        if (area != 0)
                        {
                            row["varPopDens"] = population / area;
                        }
                        else
                        {
                            row["varPopDens"] = null;
                        }
                    }

                    if (m_InfoForm == null)
                    {
                        m_InfoForm = new InfoForm {
                            IsAVR = false, Text = CurrentFeatureName, Feature = null, StatTable = tbl
                        }
                    }
                    ;
                    else
                    {
                        m_InfoForm.IsAVR     = m_IsAVR;
                        m_InfoForm.Text      = CurrentFeatureName;
                        m_InfoForm.Feature   = null;
                        m_InfoForm.StatTable = tbl;
                    }
                    #endregion
                }
                else if (strTableName == "gisWKBRayon")
                {
                    #region Rayon statistic
                    var sqlConnection = new SqlConnection(ConnectionManager.DefaultInstance.ConnectionString);
                    var tbl           = SqlExecHelper.SqlExecTable(sqlConnection,
                                                                   string.Format(
                                                                       "SELECT * FROM dbo.fn_GetRayonStatInfo(dbo.fnGetLanguageCode('{0}'), {1})",
                                                                       EidssUserContext.CurrentLanguage, id));

                    tbl.Columns.Add("strRayon", Type.GetType("System.String"));
                    tbl.Columns.Add("strRegion", Type.GetType("System.String"));



                    tbl.Columns.Add("varPopDens", Type.GetType("System.Double"));
                    foreach (DataRow row in tbl.Rows)
                    {
                        var name  = row["strName"].ToString();
                        var reg   = name.Substring(0, name.IndexOf(",", System.StringComparison.Ordinal));
                        var distr = name.Substring(name.IndexOf(",", System.StringComparison.Ordinal) + 2);

                        row["strRegion"] = reg;
                        row["strRayon"]  = distr;

                        if (row["varPopulation"] is DBNull || row["varArea"] is DBNull)
                        {
                            continue;
                        }

                        double population = (double)row["varPopulation"];
                        double area       = (double)row["varArea"];

                        //double density;
                        if (area != 0)
                        {
                            row["varPopDens"] = population / area;
                        }
                        else
                        {
                            row["varPopDens"] = null;
                        }
                    }

                    if (m_InfoForm == null)
                    {
                        m_InfoForm = new InfoForm {
                            IsAVR = false, Text = CurrentFeatureName, Feature = null, StatTable = tbl
                        }
                    }
                    ;
                    else
                    {
                        m_InfoForm.IsAVR     = m_IsAVR;
                        m_InfoForm.Text      = CurrentFeatureName;
                        m_InfoForm.Feature   = null;
                        m_InfoForm.StatTable = tbl;
                    }
                    #endregion
                }
                else if (strTableName == "gisWKBSettlement")
                {
                    #region Settlement statistic

                    var sqlConnection = new SqlConnection(ConnectionManager.DefaultInstance.ConnectionString);
                    var tbl           = SqlExecHelper.SqlExecTable(sqlConnection,
                                                                   string.Format(
                                                                       "SELECT * FROM dbo.fn_GetSettlementStatInfo(dbo.fnGetLanguageCode('{0}'), {1})",
                                                                       EidssUserContext.CurrentLanguage, id));

                    if (m_InfoForm == null)
                    {
                        m_InfoForm = new InfoForm {
                            IsAVR = false, Text = CurrentFeatureName, Feature = null, StatTable = tbl
                        }
                    }
                    ;
                    else
                    {
                        m_InfoForm.IsAVR     = m_IsAVR;
                        m_InfoForm.Text      = CurrentFeatureName;
                        m_InfoForm.Feature   = null;
                        m_InfoForm.StatTable = tbl;
                    }

                    #endregion
                }
                else if (strTableName == "gisWKBCountry")
                {
                    if (m_InfoForm == null)
                    {
                        m_InfoForm = new InfoForm {
                            IsAVR = m_IsAVR, Text = CurrentFeatureName, StatTable = null, Feature = featureDataRow
                        }
                    }
                    ;
                    else
                    {
                        m_InfoForm.IsAVR     = m_IsAVR;
                        m_InfoForm.Text      = CurrentFeatureName;
                        m_InfoForm.StatTable = null;
                        m_InfoForm.Feature   = featureDataRow;
                    }
                }
                //m_InfoForm.Show();
            }
            else
            {
                // for other type of layers

                //m_InfoForm = new InfoForm {IsAVR = m_IsAVR, Text = CurrentFeatureName, Feature = featureDataRow};
                if (m_InfoForm == null)
                {
                    m_InfoForm = new InfoForm {
                        IsAVR = m_IsAVR, Text = CurrentFeatureName, StatTable = null, Feature = featureDataRow
                    }
                }
                ;
                else
                {
                    m_InfoForm.IsAVR     = m_IsAVR;
                    m_InfoForm.Text      = CurrentFeatureName;
                    m_InfoForm.StatTable = null;
                    m_InfoForm.Feature   = featureDataRow;
                }

                // Dialog();
                //infoForm.ShowDialog();
            }
            m_InfoForm.Show();
        }