示例#1
0
        /// <summary>
        /// Initializes the command.
        /// </summary>
        public override void Init()
        {
            NumberFormatInfo nfi = CultureInfo.InvariantCulture.NumberFormat;

            this.RequestParameters.Add("lat", this.Latitude.ToString(nfi));
            this.RequestParameters.Add("long", this.Longitude.ToString(nfi));

            TwitterPlaceLookupOptions options = this.OptionalProperties as TwitterPlaceLookupOptions;

            if (options == null)
            {
                return;
            }

            if (!string.IsNullOrEmpty(options.Accuracy))
            {
                this.RequestParameters.Add("accuracy", options.Accuracy);
            }

            if (!string.IsNullOrEmpty(options.Granularity))
            {
                this.RequestParameters.Add("granularity", options.Granularity);
            }

            if (options.MaxResults != null)
            {
                this.RequestParameters.Add("max_results", options.MaxResults.Value.ToString(nfi));
            }
        }
示例#2
0
        public void LookupPlaces()
        {
            TwitterPlaceLookupOptions options = new TwitterPlaceLookupOptions
            {
                Granularity = "city",
                MaxResults  = 2
            };

            var places = TwitterPlace.Lookup(30.475012, -84.35509, options);

            Assert.IsNotNull(places.ResponseObject, places.ErrorMessage);
            Assert.AreNotEqual(0, places.ResponseObject.Count, places.ErrorMessage);
            Assert.IsTrue(places.ResponseObject.Count == 2, places.ErrorMessage);
        }
示例#3
0
        public static void LookupPlaces()
        {
            TwitterPlaceLookupOptions options = new TwitterPlaceLookupOptions
            {
                Granularity = "city",
                MaxResults  = 2
            };

            TwitterPlaceCollection places = TwitterPlace.Lookup(30.475012, -84.35509, options).ResponseObject;

            Assert.IsNotNull(places);
            Assert.IsNotEmpty(places);
            Assert.That(places.Count == 2);
        }
示例#4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ReverseGeocodeCommand"/> class.
 /// </summary>
 /// <param name="latitude">The latitude.</param>
 /// <param name="longitude">The longitude.</param>
 /// <param name="options">The options.</param>
 public ReverseGeocodeCommand(double latitude, double longitude, TwitterPlaceLookupOptions options)
     : base(HTTPVerb.GET, "geo/reverse_geocode.json", null, options)
 {
     this.Latitude  = latitude;
     this.Longitude = longitude;
 }