コード例 #1
0
ファイル: AddressParser.cs プロジェクト: koder05/fogel-ba
        internal static IEnumerable<FindEndPoint> CloseBldLevelFound(IEnumerable<FindEndPoint> parents, Location loc, string zip)
        {
            var ret = new List<FindEndPoint>();
            var blds = new List<ObjGeo>();
            parents = parents.ToList();
            if (parents.Count() > 0)
                blds = DbHelper.CreateCommand("select * from tblKLADR where GeoType=@lvl5 and ParentCode=@code")
                    .AddParameter("@lvl5", GeoLevelType.Building)
                    .ExpandParameterToList("@code", parents.Select(p => p.FoundGeo.Code)).Select<ObjGeo>().ToList();

            if (!string.IsNullOrEmpty(zip))
            {
                foreach (var bldGeo in blds.Where(bld => bld.Index == zip))
                {
                    var bldRating = loc.BuildingValidate(bldGeo);
                    var point = parents.First(p => p.FoundGeo.Code == bldGeo.ParentCode);
                    var newPoint = new FindEndPoint() { FoundGeo = bldGeo, ParentEndPoint = point, ResolveRating = point.ResolveRating | bldRating };
                    ret.Add(newPoint);
                }
            }
            else
            {
                foreach (var bldGeo in blds.Where(bld => loc.BuildingValidate(bld) == ResolveRating.Clear))
                {
                    var point = parents.First(p => p.FoundGeo.Code == bldGeo.ParentCode);
                    var newPoint = new FindEndPoint() { FoundGeo = bldGeo, ParentEndPoint = point, ResolveRating = point.ResolveRating };
                    ret.Add(newPoint);
                }
            }

            return ret;
        }
コード例 #2
0
ファイル: AddressParser.cs プロジェクト: koder05/fogel-ba
        internal static Addr MapToAddr(FindEndPoint point)
        {
            if (point == null || point.FoundGeo == null)
                return null;

            Addr ret = new Addr();
            ret.TrueCode = point.FoundGeo.Code;
            ret.HouseFlat = (point.Site ?? new Location()).Presentation;
            return ret;
        }
コード例 #3
0
ファイル: AddressParser.cs プロジェクト: koder05/fogel-ba
        internal static IEnumerable<FindEndPoint> CloseLevelFound(IEnumerable<FindEndPoint> parents, IEnumerable<ObjGeo> foundList, IEnumerable<string> foundAcronym, AddressTemplate tmpl, string restTail)
        {
            var ret = new List<FindEndPoint>();
            if (foundList != null)
                foreach (var geo in foundList)
                {
                    ResolveRating rating = foundAcronym != null && foundAcronym.Any(s => s.Equals(geo.AcronymName, StringComparison.InvariantCultureIgnoreCase)) ? ResolveRating.Clear : ResolveRating.AcronymNotFound;

                    if (parents == null)
                    {
                        var point = new FindEndPoint() { FoundGeo = geo, ResolveRating = rating, RestTail = restTail };
                        ret.Add(point);
                    }
                    else
                    {
                        foreach (var point in parents)
                        {
                            rating |= EnsureParentChildConsistency(point.FoundGeo, geo);
                            if (rating < ResolveRating.Excess)
                            {
                                ObjGeo actualGeo = null;
                                //51 Признак актуальности - в актуальное , т.е. в 0
                                if (geo.Actual == 51)
                                {
                                    actualGeo = DbHelper.Select<ObjGeo>("select top 1 * from tblKLADR where OriginalCode in (select NewCode from tbl_KLADR_AltNames where OldCode=@code and Lvl=@lvl)"
                                        , DbHelper.CreateParameter("@code", geo.OriginalCode.Substring(0, geo.OriginalCode.Length - 2) + "00")
                                        , DbHelper.CreateParameter("@lvl", (int)geo.Level + 1)).FirstOrDefault();
                                }

                                var newPoint = new FindEndPoint() { FoundGeo = actualGeo ?? geo, ParentEndPoint = point, ResolveRating = rating | point.ResolveRating, RestTail = restTail };
                                ret.Add(newPoint);
                            }
                        }
                    }
                }

            ret.ForEach(point => point.Template = tmpl);
            return ret;
        }
コード例 #4
0
ファイル: FindEndPoint.cs プロジェクト: koder05/fogel-ba
 public void AddChild(FindEndPoint child)
 {
     if (!this._childs.Contains(child))
         this._childs.Add(child);
 }