コード例 #1
0
        //---------------------------------------------------------------------
        // Static members

        internal static GeoQuery FromMessage(GeoQueryMsg queryMsg)
        {
            GeoQuery query = new GeoQuery();
            string   value;

            query.Options       = GeoQueryOptions.Load(queryMsg);
            query.EntityFilters = queryMsg._GetArray("EntityFilter");
            query.GroupFilters  = queryMsg._GetArray("QueryFilter");

            value = queryMsg._Get("Region", (string)null);
            if (!string.IsNullOrWhiteSpace(value))
            {
                query.Region = GeoRegion.Parse(value);
            }

            if (!string.IsNullOrWhiteSpace(queryMsg["MinTimeUtc"]))
            {
                query.MinTimeUtc = queryMsg._Get("MinTimeUtc", DateTime.MinValue);
            }

            if (!string.IsNullOrWhiteSpace(queryMsg["MaxTimeUtc"]))
            {
                query.MaxTimeUtc = queryMsg._Get("MaxTimeUtc", DateTime.MaxValue);
            }

            return(query);
        }
コード例 #2
0
        /// <summary>
        /// Deserializes the query options from a <see cref="GeoQueryMsg" /> if any options
        /// are present.
        /// </summary>
        /// <param name="queryMsg">The source message.</param>
        /// <returns>The deserialized options or <c>null</c> if none are present.</returns>
        internal static GeoQueryOptions Load(GeoQueryMsg queryMsg)
        {
            string          queryType = queryMsg._Get("QueryType", (string)null);
            GeoQueryOptions options;

            switch (queryType)
            {
            case EntityQueryKey:

                options = new GeoEntityQueryOptions();
                break;

            case HeatmapQueryKey:

                options = new GeoHeatmapQueryOptions();
                break;

            default:

                return(null);
            }

            options.LoadFrom(queryMsg);
            return(options);
        }
コード例 #3
0
        /// <summary>
        /// Derived classes must implement this to load the option fields from the
        /// query passed.
        /// </summary>
        /// <param name="queryMsg">The source message.</param>
        /// <remarks>
        /// The derived class must store its values as <see cref="PropertyMsg" /> fields
        /// using <b>"Option."</b> as the key prefix for each value's property name.
        /// </remarks>
        protected override void LoadFrom(GeoQueryMsg queryMsg)
        {
            string value;
            double d;

            value = queryMsg._Get("Option.MapBounds", (string)null);
            if (!string.IsNullOrWhiteSpace(value))
            {
                MapBounds = (GeoRectangle)GeoRegion.Parse(value);
            }

            value = queryMsg._Get("Option.ResolutionMiles", (string)null);
            if (!string.IsNullOrWhiteSpace(value))
            {
                if (double.TryParse(value, out d))
                {
                    ResolutionMiles = d;
                }
            }
        }
コード例 #4
0
 /// <summary>
 /// Derived classes must implement this to load the option fields from the
 /// query passed.
 /// </summary>
 /// <param name="queryMsg">The source message.</param>
 /// <remarks>
 /// The derived class must store its values as <see cref="PropertyMsg" /> fields
 /// using <b>"Option."</b> as the key prefix for each value's property name.
 /// </remarks>
 protected override void LoadFrom(GeoQueryMsg queryMsg)
 {
     this.FixCount      = queryMsg._Get("Option.FixCount", this.FixCount);
     this.MinFixTimeUtc = queryMsg._Get("Option.MinFixTimeUtc", this.MinFixTimeUtc);
     this.FixFields     = (GeoFixField)queryMsg._Get("Option.FixFields", (int)this.FixFields);
 }