41 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
{
2019-07-29 14:05:17 +02:00
using global::Locations.API.Model.Core;
2017-06-08 17:33:55 +02:00
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
2017-06-08 17:33:55 +02:00
using MongoDB.Driver.GeoJsonObjectModel;
using System.Collections.Generic;
2017-05-30 15:01:58 +02:00
public class Locations
{
2017-06-13 18:00:49 +02:00
[BsonId]
2017-06-09 12:16:57 +02:00
[BsonRepresentation(BsonType.ObjectId)]
public string Id { get; set; }
2017-06-13 18:00:49 +02:00
public int LocationId { 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; }
2019-07-29 14:05:17 +02:00
//public GeoJsonPoint<GeoJson2DGeographicCoordinates> Location { get; private set; }
public LocationPoint Location { get; private set; }
public LocationPolygon Polygon { 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;
2019-07-29 14:05:17 +02:00
Location = new LocationPoint(lon, lat);
2017-05-30 15:01:58 +02:00
}
2017-06-09 12:16:57 +02:00
private void SetPolygon(List<GeoJson2DGeographicCoordinates> coordinatesList)
{
2019-07-29 14:05:17 +02:00
Polygon = new LocationPolygon(coordinatesList);
2017-06-09 12:16:57 +02:00
}
2017-05-30 15:01:58 +02:00
}
}