【问题标题】:Convert Sql Server Spatial data to GeoJSON & plot on map将 Sql Server 空间数据转换为 GeoJSON 并在地图上绘制
【发布时间】:2014-04-14 14:58:41
【问题描述】:

我有一个包含地理空间数据的 sql server 表。行的一个例子是(带有列名):

type: streetline
code: 231001
geog: 0xE6100000011 ........
Centroid 0xE61000000C.......
geom: 0xE6100000011 ........

我正在使用 C# 和 MVC3 在传单地图上绘制上述形状。我正在将上述 sql 数据提取到数据表中。在“geom”列上使用 sql 函数“ToString()”,我得到以下信息:

"LINESTRING (-1.131510412 52.65531, -1.13286 52.65559)",
"POLYGON ((-1.1116360 52.6409953, -1.1116683 52.6413, -1.11146723 52.641317, -1.11133263 52.6413572, -1.1113059))",

问题是如何将上述内容转换为 GeoJSON 以便能够在传单地图上进行绘图。这是我想要的预期输出(GeoJSON)的示例:

var geojsonFeature = {
    "type": "Feature",
    "properties": {
        "name": "Coors Field",
        "amenity": "Baseball Stadium",
        "popupContent": "This is where the Rockies play!"
    },
    "geometry": {
        "type": "Point",
        "coordinates": [-104.99404, 39.75621]
    }
};

【问题讨论】:

    标签: c# jquery sql asp.net-mvc-3 geojson


    【解决方案1】:

    也许您可以使用 SQL 函数将空间转换为 GeoJSON: https://blogs.msdn.microsoft.com/sqlserverstorageengine/2016/01/13/returning-spatial-data-in-geojson-format-part-2/

    如果您有支持 JSON 的 Sql2016 或 Azure SQL 数据库,您可以将完整的结果集导出为 GeoJSON。

    【讨论】:

      猜你喜欢
      • 2016-01-27
      • 2017-10-06
      • 2021-12-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-18
      • 1970-01-01
      • 2017-11-13
      相关资源
      最近更新 更多