コード例 #1
0
        static public bool  FindAtDistance(EGH01DB.IDBContext dbcontext, Coordinates coordinates, int buffer, out EcoObjectsList ecolist)
        {
            bool rc = false;

            ecolist = new EcoObjectsList();
            //List<EcoObject> ecolist = new List<EcoObject>();

            using (SqlCommand cmd = new SqlCommand("MAP.EcoObjectInBuffer", dbcontext.connection))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                {
                    SqlParameter parm = new SqlParameter("@point", SqlDbType.VarChar);
                    parm.Value = coordinates.GetMapPoint();;
                    cmd.Parameters.Add(parm);
                }

                {
                    SqlParameter parm = new SqlParameter("@buffer", SqlDbType.Int);
                    parm.Value = buffer;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@exitrc", SqlDbType.Int);
                    parm.Direction = ParameterDirection.ReturnValue;
                    cmd.Parameters.Add(parm);
                }
                try
                {
                    SqlDataReader reader = cmd.ExecuteReader();
                    rc = true;
                    //EcoObject(int id, Point point, EcoObjectType ecoobjecttype, CadastreType cadastretype, string name, bool iswaterobject)

                    while (reader.Read())
                    {
                        int           id              = (int)reader["Obj_Id"];
                        string        name            = (string)reader["name"];
                        string        type            = (string)reader["type"];
                        float         dist            = (float)reader["distance"];
                        float         x               = (float)reader["yPoint"];
                        float         y               = (float)reader["xPoint"];
                        Coordinates   nearbypoint     = new Coordinates(x, y);
                        Point         point           = new Point(nearbypoint);
                        EcoObjectType eco_object_type = new EcoObjectType(type);
                        CadastreType  cadastre_type   = new CadastreType("Не определено на карте");

                        EcoObject ecoobject = new EcoObject(id, point, eco_object_type, cadastre_type, name, true); // уточнить насчет iswaterobject! blinova
                        ecolist.Add(ecoobject);
                    }
                    reader.Close();
                }
                catch (Exception e)
                {
                    rc = false;
                };
                return(rc);
            }
        }
コード例 #2
0
        public static EcoObjectsList CreateEcoObjectsList(XmlNode node)
        {
            EcoObjectsList eco_objects_list = new EcoObjectsList();

            foreach (XmlElement x in node)
            {
                if (x.Name.Equals("EcoObject"))
                {
                    eco_objects_list.Add(new EcoObject(x));
                }
            }
            return(eco_objects_list);
        }
コード例 #3
0
        public static EcoObjectsList CreateEcoObjectsList(EGH01DB.IDBContext dbcontext, Point center, float distance = float.MaxValue)
        {
            EcoObjectsList   rc      = new EcoObjectsList();
            List <EcoObject> ecolist = new List <EcoObject>();

            if (Helper.GetListEcoObject(dbcontext, ref ecolist))
            {
                var selx = ecolist.Where(o => o.coordinates.Distance(center.coordinates) <= distance).AsQueryable();
                foreach (EcoObject o in selx)
                {
                    // float x = o.coordinates.Distance(center.coordinates);
                    rc.Add(o);
                }
            }
            return(rc);
        }