/// <summary>
        /// 특보 해당구역 코드 리스트를 행정구역 지역명 문자열(콤마로 구분된 연속된 문자열)로 변환.
        /// </summary>
        /// <returns></returns>
        public string GetTargetRegionNames()
        {
            string[] targetRegionCodes = GetTargetRegionCodes();
            if (targetRegionCodes == null)
            {
                return(string.Empty);
            }

            List <string> regionNames = new List <string>();

            foreach (string regionCode in targetRegionCodes)
            {
                RegionProfile profile = BasisData.FindRegion(regionCode);
                if (profile == null)
                {
                    continue;
                }
                if (regionNames.Contains(profile.Name))
                {
                    continue;
                }
                regionNames.Add(profile.Name);
            }

            return(string.Join(",", regionNames));
        }
Exemplo n.º 2
0
        /// <summary>
        /// CAP 메시지로부터 발령 대상 지역 정보를 추출.
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        public List <RegionDefinition> ExtractTargetRegionsFromCAP(CAP msg)
        {
            System.Diagnostics.Debug.Assert(msg != null);

            if (msg.Scope == CAPLib.ScopeType.Private)
            {
                return(null);
            }
            if (msg.Info == null || msg.Info.Count < 1)
            {
                return(null);
            }

            List <RegionDefinition> targets = new List <RegionDefinition>();

            InfoType info = msg.Info[0];

            if (info == null)
            {
                return(null);
            }
            if (info.Area == null || info.Area.Count < 1)
            {
                return(null);
            }

            foreach (AreaType area in info.Area)
            {
                int      areaIndex        = -1;
                string[] stringSeperators = new string[] { " " };

                foreach (NameValueType geoCode in area.GeoCode)
                {
                    areaIndex++;

                    if (geoCode.Name != "KRDSTGeocode")
                    {
                        continue;
                    }
                    string        code    = geoCode.Value;
                    RegionProfile profile = BasisData.FindRegion(code);
                    if (profile == null)
                    {
                        string areaDesc = area.AreaDesc;
                        if (areaDesc == null)
                        {
                            continue;
                        }
                        string[] areaNames = areaDesc.Split(stringSeperators, StringSplitOptions.RemoveEmptyEntries);
                        if (areaNames != null && areaNames.Count() <= areaIndex)
                        {
                            continue;
                        }

                        RegionDefinition region = new RegionDefinition(code, areaNames[areaIndex]);
                        targets.Add(region);
                    }
                    else
                    {
                        RegionDefinition region = new RegionDefinition(profile.Code, profile.Name);
                        targets.Add(region);
                    }
                }
            }

            return(targets);
        }