Example #1
0
        private static void AdjustSpan(PhotoMetadata meta, TripDuration duration)
        {
            for (uint i = 0; i < duration.Spans.Length; i++)
            {
                if (meta.TakenDate > duration.Spans[i].EndTime)
                {
                    duration.Spans[i].EndTime = meta.TakenDate;
                }

                if (meta.TakenDate < duration.Spans[i].StartTime)
                {
                    duration.Spans[i].StartTime = meta.TakenDate;
                }

                if (duration.Parents != null)
                {
                    for (uint j = 0; j < duration.Parents.Length; j++)
                    {
                        if (meta.TakenDate > duration.Parents[j].Spans[0].EndTime)
                        {
                            duration.Parents[j].Spans[0].EndTime = meta.TakenDate;
                        }

                        if (meta.TakenDate < duration.Parents[j].Spans[0].StartTime)
                        {
                            duration.Parents[j].Spans[0].StartTime = meta.TakenDate;
                        }
                    }
                }
            }
        }
Example #2
0
        private static TripDuration InitTripDuration(PhotoMetadata meta)
        {
            TripDuration duration = new TripDuration();

            duration.Location = meta.Address;
            duration.Spans    = new TripSpan[1];
            TripSpan span = new TripSpan();

            span.StartTime = meta.TakenDate;
            span.EndTime   = meta.TakenDate;

            duration.Spans[0] = span;

            var addressComponents = meta.Address.address_components;

            if (addressComponents != null && addressComponents.Length > 1)
            {
                duration.Parents = new TripDuration[addressComponents.Length - 1];

                for (uint i = 1; i < addressComponents.Length; i++)
                {
                    var placeId = string.Format("{0}_{1}", meta.Address.place_id, addressComponents[i].types[0]);
                    if (!cache.ContainsKey(placeId))
                    {
                        var address = new GoogleAddressInfo();
                        address.place_id           = placeId;
                        address.address_components = new GoogleAddressType[addressComponents.Length - i];
                        Array.Copy(addressComponents, 1, address.address_components, 0, address.address_components.Length);

                        var higherDuration = new TripDuration();
                        higherDuration.Location = address;
                        higherDuration.Spans    = new TripSpan[1];
                        higherDuration.Spans[0] = span;

                        cache.Add(placeId, higherDuration);
                    }

                    duration.Parents[i - 1] = cache[placeId];
                }
            }

            return(duration);
        }