Ejemplo n.º 1
0
        /// <summary>
        /// This function compares dates only by chronological year.
        /// Month and day are not taken into account, the year is compared with the calendar.
        /// </summary>
        /// <param name="tag"></param>
        /// <param name="matchParams"></param>
        /// <returns></returns>
        public override float IsMatch(GEDCOMTag tag, MatchParams matchParams)
        {
            if (tag == null)
            {
                return(0.0f);
            }
            GEDCOMDateValue date = (GEDCOMDateValue)tag;

            if (IsEmpty() || date.IsEmpty())
            {
                return(0.0f);
            }

            int absVal1 = this.GetChronologicalYear();
            int absVal2 = date.GetChronologicalYear();

            float match   = 0.0f;
            float matches = 0.0f;

            if (absVal1 != 0 && absVal2 != 0)
            {
                matches += 1.0f;
                if (Math.Abs(absVal1 - absVal2) <= matchParams.YearsInaccuracy)
                {
                    match += 100.0f;
                }
            }

            return(match / matches);
        }
Ejemplo n.º 2
0
        public void testAhnenblattDate()
        {
            string gedcom = "0 HEAD\n1 SOUR AHN\n0 @I1@ INDI\n1 BIRT\n2 DATE (20/12-1980)";

            // TODO this bit needs to go into utility class
            GEDCOMTree     tee = new GEDCOMTree();
            GEDCOMProvider gp  = new GEDCOMProvider(tee);

            try {
                gp.LoadFromString(gedcom);
            } catch (Exception) {
            }
            Assert.AreEqual(1, tee.RecordsCount);
            GEDCOMRecord rec = tee[0];

            Assert.IsTrue(rec is GEDCOMIndividualRecord);
            GEDCOMIndividualRecord rec2 = (GEDCOMIndividualRecord)rec;
            // end for utility class

            GEDCOMList <GEDCOMCustomEvent> events = rec2.Events;

            Assert.AreEqual(1, events.Count);
            GEDCOMCustomEvent birt = events.Extract(0);
            GEDCOMDateValue   dv   = birt.Date;

            Assert.AreEqual("20 DEC 1980", dv.StringValue);
        }
Ejemplo n.º 3
0
        public override float IsMatch(GEDCOMTag tag, MatchParams matchParams)
        {
            if (tag == null)
            {
                return(0.0f);
            }
            GEDCOMCustomEvent ev = (GEDCOMCustomEvent)tag;

            // match date
            float dateMatch = 0.0f;
            float locMatch  = 0.0f;
            int   matches   = 0;

            GEDCOMDateValue dtVal  = this.Date;
            GEDCOMDateValue dtVal2 = ev.Date;

            matches += 1;
            if (dtVal != null && dtVal2 != null)
            {
                dateMatch = dtVal.IsMatch(dtVal2, matchParams);
            }

            // match location - late code-on by option implementation
            if (matchParams.CheckEventPlaces)
            {
                matches += 1;

                if (this.Place == null && ev.Place == null)
                {
                    locMatch = 100.0f;
                }
                else if (this.Place != null && ev.Place != null && this.Place.StringValue == ev.Place.StringValue)
                {
                    locMatch = 100.0f;
                }
            }

            float match = (dateMatch + locMatch) / matches;

            return(match);
        }