38 lines
1.6 KiB
C#
Raw Normal View History

2017-06-08 17:33:55 +02:00
namespace Microsoft.eShopOnContainers.Services.Locations.API.Model
2017-05-30 15:01:58 +02:00
{
2017-06-08 17:33:55 +02:00
using MongoDB.Bson;
using MongoDB.Driver.GeoJsonObjectModel;
using System.Collections.Generic;
2017-06-09 12:16:57 +02:00
using MongoDB.Bson.Serialization.Attributes;
2017-06-08 17:33:55 +02:00
2017-05-30 15:01:58 +02:00
public class Locations
{
2017-06-09 12:16:57 +02:00
[BsonRepresentation(BsonType.ObjectId)]
public string Id { get; set; }
2017-06-08 17:33:55 +02:00
public string Code { get; set; }
2017-06-09 12:16:57 +02:00
[BsonRepresentation(BsonType.ObjectId)]
public string Parent_Id { get; set; }
2017-06-08 17:33:55 +02:00
public string Description { get; set; }
public double Latitude { get; set; }
public double Longitude { get; set; }
2017-06-09 12:16:57 +02:00
public GeoJsonPoint<GeoJson2DGeographicCoordinates> Location { get; private set; }
public GeoJsonPolygon<GeoJson2DGeographicCoordinates> Polygon { get; private set; }
2017-06-08 17:33:55 +02:00
public void SetLocation(double lon, double lat) => SetPosition(lon, lat);
2017-06-09 12:16:57 +02:00
public void SetArea(List<GeoJson2DGeographicCoordinates> coordinatesList) => SetPolygon(coordinatesList);
2017-06-08 17:33:55 +02:00
private void SetPosition(double lon, double lat)
{
2017-06-08 17:33:55 +02:00
Latitude = lat;
Longitude = lon;
Location = new GeoJsonPoint<GeoJson2DGeographicCoordinates>(
new GeoJson2DGeographicCoordinates(lon, lat));
2017-05-30 15:01:58 +02:00
}
2017-06-09 12:16:57 +02:00
private void SetPolygon(List<GeoJson2DGeographicCoordinates> coordinatesList)
{
Polygon = new GeoJsonPolygon<GeoJson2DGeographicCoordinates>(new GeoJsonPolygonCoordinates<GeoJson2DGeographicCoordinates>(
new GeoJsonLinearRingCoordinates<GeoJson2DGeographicCoordinates>(coordinatesList)));
}
2017-05-30 15:01:58 +02:00
}
}