public static List <Tuple <string, List <entity_dynamic> > > GetAllTypeDynamicParcels(int cityId)
        {
            var parcels = LinqHelper.DataContext.entity_dynamic.Where(x => x.fk_cityid == cityId && x.active).ToList();

            return(PlanManager.GetParcelTypeGroups(cityId).Select(x => Tuple.Create(x.Key, parcels.Where(y => x.Value(y.code)).ToList())).ToList());
            //return LinqHelper.DataContext.entity_plan.Where(x => x.fk_cityid == cityId && x.active).ToList().GroupBy(x => string.IsNullOrEmpty(x.code) ? "未知类型" : x.code).OrderBy(x => x.Key);
        }
        public static UnitData GetUnitData(int cityId, int mapId, string unit = "")
        {
            var      map      = MapManager.GetMapData(mapId);
            var      features = unit == "" ? map.Layers["地块"].Features : map.Layers["地块"].Features.Where(x => x.Unit() == unit);
            UnitData ud       = new UnitData();

            ud.ParcelCount  = features.Count();
            ud.Area         = features.Sum(x => x.Area);
            ud.BuildingArea = features.Sum(x => x.Far() * x.Area);
            ud.FAR          = ud.BuildingArea / ud.Area;
            ud.Parks        = features.Sum(x => x.Parks());
            ud.GreenRate    = 100 * (features.Sum(x => x.Area * x.Gr() / 100) + features.Where(x => x.Type().StartsWith("G")).Sum(x => x.Area)) / ud.Area;

            List <BalanceBlock> bbs = new List <BalanceBlock>();

            foreach (var type in PlanManager.GetParcelTypeGroups(cityId))
            {
                BalanceBlock bb            = new BalanceBlock();
                var          parcelsOfType = features.Where(x => type.Value(x.Type())).ToList();
                bb.Name  = type.Key;
                bb.Count = parcelsOfType.Count;
                bb.Area  = parcelsOfType.Sum(x => x.Area * x.Far());
                if (PlanManager.GetParcelColor(cityId).ContainsKey(type.Key))
                {
                    bb.Color = PlanManager.GetParcelColor(cityId)[type.Key].Remove(1, 2);
                }
                bbs.Add(bb);
            }
            ud.UnitsBalance = bbs;
            return(ud);
        }