Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Oct CTP geospatial provider sample

View gist:1293201
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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
using System.Collections.Generic;
using System.Data.Services;
using System.Data.Services.Common;
using System.Linq;
using System.Spatial;
 
namespace AllTheNews
{
[DataServiceKey("BusinessId")]
public class Business
{
public int BusinessId { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public GeographicPoint Location { get; set; }
}
 
[DataServiceKey("Username")]
public class User
{
public User()
{
this.Friends = new List<User>();
}
 
public string Username { get; set; }
public IList<User> Friends { get; set; }
public GeographicPoint LastKnownLocation { get; set; }
}
 
public partial class OrderItemData
{
private static readonly IList<Business> _businesses;
private static readonly IList<User> _users;
 
static OrderItemData()
{
_businesses = new[]
{
new Business
{
BusinessId = 0,
Name = "Franks's Dogs",
Description = "Frank really knows his dogs. Dogs for all tastes!",
Location = GeographyFactory.Point(47.6035614013672, -122.329437255859)
},
new Business
{
BusinessId = 1,
Name = "Movie Palace",
Description = "Watch movies while getting a massage and eating grapes.",
Location = GeographyFactory.Point(47.7035614013672, -122.329437255859)
}
};
_users = new[]
{
new User
{
Username = "Chai",
LastKnownLocation = GeographyFactory.Point(47.7035614013672, -122.329437255859)
},
new User
{
Username = "Chang",
LastKnownLocation = GeographyFactory.Point(47.6535614013672, -122.329437255859)
},
new User
{
Username = "Anselem",
LastKnownLocation = GeographyFactory.Point(47.7535614013672, -122.329437255859)
},
new User
{
Username = "Anton",
LastKnownLocation = GeographyFactory.Point(47.6035614013672, -122.329437255859)
}
};
_users[0].Friends.Add(_users[3]);
_users[3].Friends.Add(_users[0]);
_users[1].Friends.Add(_users[0]);
_users[1].Friends.Add(_users[2]);
}
 
public IQueryable<Business> Businesses
{
get { return _businesses.AsQueryable(); }
}
 
public IQueryable<User> Users
{
get { return _users.AsQueryable(); }
}
}
 
public class LocalStuff : DataService<OrderItemData>
{
public static void InitializeService(DataServiceConfiguration config)
{
// Geospatial data requires version 3 of the OData protocol.
config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;
 
config.SetEntitySetAccessRule("Businesses", EntitySetRights.All);
config.SetEntitySetAccessRule("Users", EntitySetRights.All);
}
}
}

Couldn't run this sample. API seems to be changed after RTM v5.0.1 GeographicPoint became GeographyPoint but GeographyFactory disappeared and I'm not able to find what's the new way to create a point in the new API!! Trying to find a release note to explain this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.