我有关于空间数据和空间数据处理的问题。有谁在.NET中有过空间数据或空间数据处理的经验,请您为我指出关于空间数据包的正确方向。
在我的搜索中,我找到了这个链接,但是它已经有10年的历史了,现在它已经过时了,不幸的是它不能满足我的需求。
其中一个要求是,我可以创建空间实体(多边形,线,点)提供的坐标WGS格式(43.524477,26.571517...etc.)另一种是能够创建一些拓扑处理,如交叉和裁剪多边形和线。
目前,我使用的技术是NHibernate作为ORM,Maria作为数据库提供程序。
我的Microsoft.AspNet.Mvc解决方案的当前版本为5.2.3,我们计划在不久的将来在.NET Core3.0中进行转换。
提前谢谢你。任何链接、建议和例子都将受到高度赞赏。
发布于 2020-05-20 14:38:46
有一个名为Microsoft.SqlServer.Types的Nuget包,允许您在代码中使用空间类型。
https://www.nuget.org/packages/Microsoft.SqlServer.Types/
尽管使用的是"SqlServer“名称,但这些类型实际上是完全独立的,可以从其他来源装载WKT,或者简单的lat/lng,如果您有这种名称的话。
我在我的github中找到了这个代码示例,我记得您必须发布本机程序集,所以我不确定这是否会跨平台工作。
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using Microsoft.SqlServer.Types;
namespace GeoCalc
{
class Program
{
static void Main(string[] args)
{
SqlServerTypes.Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory);
const int srid = 4326;
var population = new List<PopulationDatum>();
using (var s = typeof(Program).Assembly.GetManifestResourceStream("GeoCalc.Data.popcounts.txt"))
using (var r = new StreamReader(s))
{
while (!r.EndOfStream)
{
var line = r.ReadLine();
if (line == null) continue;
population.Add(new PopulationDatum(line, srid));
}
}
var high = SqlGeography.Point(54.942380, -1.671109, srid);
var low = SqlGeography.Point(51.929182, -1.071103, srid);
const int radiusInMetres = 10000;
var highScore = population
.Where(p => p.Point.STDistance(high).Value <= radiusInMetres)
.GroupBy(_ => 0)
.Select(g => new PopulationScore(g.Sum(_ => _.Males), g.Sum(_ => _.Females), g.Sum(_ => _.Households)))
.First();
var lowScore = population
.Where(p => p.Point.STDistance(low).Value <= radiusInMetres)
.GroupBy(_ => 0)
.Select(g => new PopulationScore(g.Sum(_ => _.Males), g.Sum(_ => _.Females), g.Sum(_ => _.Households)))
.First();
}
}
}https://softwarerecs.stackexchange.com/questions/74589
复制相似问题