Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Oct CTP geospatial provider sample
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);
}
}
}
@waheedsayed

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.