示例#1
0
        // YD:
        // get polygon openings from database by sql
        private static List <clsPolygonOpening> GetPolygonOpeningsBySql(string sql)
        {
            try
            {
                List <clsPolygonOpening> polygonOpenings = new List <clsPolygonOpening>();

                using (NpgsqlConnection connection = new NpgsqlConnection(strPostGISConnection))
                    using (NpgsqlDataAdapter da = new NpgsqlDataAdapter(sql, connection))
                    {
                        DataSet   dsPol = new DataSet();
                        DataTable dtPol = new DataTable();
                        dsPol.Reset();
                        da.Fill(dsPol);
                        dtPol = dsPol.Tables[0];

                        if (dtPol == null || dtPol.Rows == null || dtPol.Rows.Count == 0)
                        {
                            return(null);
                        }

                        foreach (DataRow rowPol in dtPol.Rows)
                        {
                            clsPolygonOpening polygonOpening = new clsPolygonOpening();
                            polygonOpening.PolygonGUID    = rowPol["polygon_guid"].ToString();
                            polygonOpening.PolygonEdgeNum = (int)rowPol["polygon_edge_num"];
                            polygonOpening.x           = Convert.ToDouble(rowPol["position_x"]);
                            polygonOpening.y           = Convert.ToDouble(rowPol["position_y"]);
                            polygonOpening.openingSize = Convert.ToDouble(rowPol["opening_size_meters"]);
                            polygonOpenings.Add(polygonOpening);
                        }
                    }

                return(polygonOpenings);
            }
            catch (Exception ex)
            {
            }
            return(null);
        }
示例#2
0
		// YD:
		// get polygon openings from database by sql
        private static List<clsPolygonOpening> GetPolygonOpeningsBySql(string sql)
        {
            try
            {
                List<clsPolygonOpening> polygonOpenings = new List<clsPolygonOpening>();

                using (NpgsqlConnection connection = new NpgsqlConnection(strPostGISConnection))
                using (NpgsqlDataAdapter da = new NpgsqlDataAdapter(sql, connection))
                {
                    DataSet dsPol = new DataSet();
                    DataTable dtPol = new DataTable();
                    dsPol.Reset();
                    da.Fill(dsPol);
                    dtPol = dsPol.Tables[0];

                    if (dtPol == null || dtPol.Rows == null || dtPol.Rows.Count == 0)
                    {
                        return null;
                    }

                    foreach (DataRow rowPol in dtPol.Rows)
                    {
                        clsPolygonOpening polygonOpening = new clsPolygonOpening();
                        polygonOpening.PolygonGUID = rowPol["polygon_guid"].ToString();
                        polygonOpening.PolygonEdgeNum = (int)rowPol["polygon_edge_num"];
                        polygonOpening.x = Convert.ToDouble(rowPol["position_x"]);
                        polygonOpening.y = Convert.ToDouble(rowPol["position_y"]);
                        polygonOpening.openingSize = Convert.ToDouble(rowPol["opening_size_meters"]);
                        polygonOpenings.Add(polygonOpening);
                    }
                }

                return polygonOpenings;
            }
            catch (Exception ex)
            {

            }
            return null;
        }