namespace Microsoft.eShopOnContainers.Services.Locations.API.Model { using MongoDB.Bson; using MongoDB.Bson.Serialization.Attributes; using MongoDB.Driver.GeoJsonObjectModel; using System.Collections.Generic; public class Locations { [BsonId] [BsonRepresentation(BsonType.ObjectId)] public string Id { get; set; } public int LocationId { get; set; } public string Code { get; set; } [BsonRepresentation(BsonType.ObjectId)] public string Parent_Id { get; set; } public string Description { get; set; } public double Latitude { get; set; } public double Longitude { get; set; } public GeoJsonPoint Location { get; private set; } public GeoJsonPolygon Polygon { get; private set; } public void SetLocation(double lon, double lat) => SetPosition(lon, lat); public void SetArea(List coordinatesList) => SetPolygon(coordinatesList); private void SetPosition(double lon, double lat) { Latitude = lat; Longitude = lon; Location = new GeoJsonPoint( new GeoJson2DGeographicCoordinates(lon, lat)); } private void SetPolygon(List coordinatesList) { Polygon = new GeoJsonPolygon(new GeoJsonPolygonCoordinates( new GeoJsonLinearRingCoordinates(coordinatesList))); } } }