forked from chadly/Geocoding.net
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBatchGeocodeRequest.cs
More file actions
50 lines (44 loc) · 1.24 KB
/
BatchGeocodeRequest.cs
File metadata and controls
50 lines (44 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
namespace Geocoding.MapQuest
{
public class BatchGeocodeRequest : BaseRequest
{
public BatchGeocodeRequest(string key, ICollection<string> addresses)
: base(key)
{
if (addresses.IsNullOrEmpty())
throw new ArgumentException("addresses can not be null or empty");
Locations = (from l in addresses select new LocationRequest(l)).ToArray();
}
[JsonIgnore]
readonly List<LocationRequest> _locations = new List<LocationRequest>();
/// <summary>
/// Required collection of concatenated address string
/// Note input will be hashed for uniqueness.
/// Order is not guaranteed.
/// </summary>
[JsonProperty("locations")]
public ICollection<LocationRequest> Locations
{
get { return _locations; }
set
{
if (value.IsNullOrEmpty())
throw new ArgumentNullException("Locations can not be null or empty!");
_locations.Clear();
(from v in value
where v != null
select v).ForEach(v => _locations.Add(v));
if (_locations.Count == 0)
throw new InvalidOperationException("At least one valid Location is required");
}
}
public override string RequestAction
{
get { return "batch"; }
}
}
}