关于Geometry转GeoJson

Posted 咖啡漩涡

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了关于Geometry转GeoJson相关的知识,希望对你有一定的参考价值。

这个问题 我似乎问了大神好几遍了 我竟然还没记住 羞愧

NuGet添加GeoJSON4EntityFramework,引用using alatas.GeoJSON4EntityFramework;

FeatureCollection features = new FeatureCollection(item.Geom);
string Geo = Regex.Replace(features.Serialize(prettyPrint: true), @"\s", "");

当然我是在EF中调取的,有些Geometry可能会不正确,需要进行修正

1                 var list = from a in context.aaa
2                            select new
3                            {
4                                ...
5                                Geom = SqlSpatialFunctions.MakeValid(a.geom),
6                                ...
7                            };

这样就好了 我真的是服了自己了....

以上是关于关于Geometry转GeoJson的主要内容,如果未能解决你的问题,请参考以下文章