71 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			71 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			C#
		
	
	
	
| 
								 | 
							
								using LY.App.Common;
							 | 
						|||
| 
								 | 
							
								using NetTopologySuite.Algorithm;
							 | 
						|||
| 
								 | 
							
								using NetTopologySuite.Geometries;
							 | 
						|||
| 
								 | 
							
								using Newtonsoft.Json;
							 | 
						|||
| 
								 | 
							
								using Pipelines.Sockets.Unofficial.Arenas;
							 | 
						|||
| 
								 | 
							
								using SqlSugar;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								namespace LY.App.Model
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								    /// <summary>
							 | 
						|||
| 
								 | 
							
								    /// 多边形实体
							 | 
						|||
| 
								 | 
							
								    /// </summary>
							 | 
						|||
| 
								 | 
							
								    public class MultPolygonEntity : BaseEntity
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 空间面数据
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        [SugarColumn(QuerySql = "st_astext(region)", ColumnDataType = "multipolygon", ColumnName = "region",
							 | 
						|||
| 
								 | 
							
								            UpdateSql = "ST_GeomFromText(@region)",
							 | 
						|||
| 
								 | 
							
								            InsertSql = "ST_GeomFromText(@region)", IsNullable = true, ColumnDescription = "空间面数据")]
							 | 
						|||
| 
								 | 
							
								        [JsonIgnore]
							 | 
						|||
| 
								 | 
							
								        public string? Region { get; set; } //MultiPolygon  Geometry
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        [SugarColumn(IsIgnore = true)]
							 | 
						|||
| 
								 | 
							
								        public string RegionJson { get; set; }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 空间位置点Json数据
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        public void SetRegionJson()
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            RegionJson = "";
							 | 
						|||
| 
								 | 
							
								            if (!string.IsNullOrWhiteSpace(Region))
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                var geo = GeoJsonHelper.FromWKT(Region);
							 | 
						|||
| 
								 | 
							
								                if (geo != null)
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    RegionJson = GeoJsonHelper.GetGeoJson(geo);
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 设置空间位置点
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="region"></param>
							 | 
						|||
| 
								 | 
							
								        public void SetRegion(MultiPolygon region)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            if (region != null)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                Region = region.AsText();
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 设置空间位置点
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="region"></param>
							 | 
						|||
| 
								 | 
							
								        public void SetRegionJson(string region)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            RegionJson = "";
							 | 
						|||
| 
								 | 
							
								            if (!string.IsNullOrWhiteSpace(region))
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                var geo = GeoJsonHelper.FromWKT(region);
							 | 
						|||
| 
								 | 
							
								                if (geo != null)
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    RegionJson = GeoJsonHelper.GetGeoJson(geo);
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								}
							 |