首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用.NET创建sqlGeography线路

使用.NET创建sqlGeography线路
EN

Stack Overflow用户
提问于 2013-04-17 20:14:07
回答 1查看 1.6K关注 0票数 2

我正在构建一个可以解析各种外部地图文件格式(即ShapeFiles、MapPoint、KML等)的应用程序。并将形状存储在将用于中央映射/报告基础的中央数据库中。我有一个例程,现在有一条线由一个抽象的点数组表示,我正在尝试将其转换为一个sqlGeography对象,该对象将存储在我的数据库(目前是SQL2012 Express )中。

下面是我的LINESTRING语句的一个示例(存储在字符串strGeo中):

代码语言:javascript
复制
    LINESTRING(41.942587758675 -85.636084221926,41.9425261573997 -85.6360833224383,41.9423450573927 -85.6360807217602,41.9423035553449 -85.6360801225198,41.9421639573891 -85.6360781210972,41.9421098574371 -85.6360773225739,41.9420307561342 -85.6360762213003)

然后,我对该字符串(VB.NET)执行此操作

代码语言:javascript
复制
    Dim strSql As New SqlChars(New SqlString(strGeo))
    Dim geo As SqlGeography = SqlGeography.STLineFromText(strSql, 4326)

我已经从SQL Server2012功能包中添加了对Microsoft.SqlServer.Types的适当引用,但是当我的调试器命中SqlGeography行时,我会得到如下结果:

代码语言:javascript
复制
    System.DllNotFoundException: Unable to load DLL 'SqlServerSpatial110.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
    at Microsoft.SqlServer.Types.GLNativeMethods.GeodeticIsValid(GeoMarshalData g, Double eccentricity, Boolean forceKatmai, Boolean& result, Boolean& isSmallerThanAHemisphere)
    at Microsoft.SqlServer.Types.GLNativeMethods.GeodeticIsValid(GeoData& g, Double eccentricity, Boolean forceKatmai)
    at Microsoft.SqlServer.Types.SqlGeography.IsValidExpensive(Boolean forceKatmai)
    at Microsoft.SqlServer.Types.SqlGeography..ctor(GeoData g, Int32 srid)
    at Microsoft.SqlServer.Types.SqlGeography.GeographyFromText(OpenGisType type, SqlChars taggedText, Int32 srid)
    at Microsoft.SqlServer.Types.SqlGeography.STLineFromText(SqlChars lineStringTaggedText, Int32 srid)
    at ShpFileProcessor.Module1.ProcessFile(FileInfo fil) in C:\Users\Chet Cromer\documents\visual studio 2010\Projects\NorthernLights\ShpFileProcessor\ShpFileProcessor\Module1.vb:line 180

我在计算机上的任何地方都找不到SqlServerSpatial110.dll。我安装了SQL Express2012,可以在SYSTEM32和SYSWOW64中找到SqlerverSpatial.dll,但VS不允许我注册这两个文件中的任何一个。

我注意到,如果我像这样在LINESTRING中使用两个括号,我会得到一个不同的错误:

代码语言:javascript
复制
    LINESTRING((41.942587758675 -85.636084221926,41.9425261573997 -85.6360833224383,41.9423450573927 -85.6360807217602,41.9423035553449 -85.6360801225198,41.9421639573891 -85.6360781210972,41.9421098574371 -85.6360773225739,41.9420307561342 -85.6360762213003))

    System.FormatException: 24141: A number is expected at position 27 of the input. The input has (41.942587758675.
    at Microsoft.SqlServer.Types.WellKnownTextReader.RecognizeDouble()
    at Microsoft.SqlServer.Types.WellKnownTextReader.ParseLineStringText()
    at Microsoft.SqlServer.Types.WellKnownTextReader.ParseTaggedText(OpenGisType type)
    at Microsoft.SqlServer.Types.WellKnownTextReader.Read(OpenGisType type, Int32 srid)
    at Microsoft.SqlServer.Types.SqlGeography.ParseText(OpenGisType type, SqlChars taggedText, Int32 srid)
    at Microsoft.SqlServer.Types.SqlGeography.GeographyFromText(OpenGisType type, SqlChars taggedText, Int32 srid)
    at Microsoft.SqlServer.Types.SqlGeography.STLineFromText(SqlChars lineStringTaggedText, Int32 srid)
    at ShpFileProcessor.Module1.ProcessFile(FileInfo fil) in C:\Users\Chet Cromer\documents\visual studio 2010\Projects\NorthernLights\ShpFileProcessor\ShpFileProcessor\Module1.vb:line 180

(在计算字符之前,位置27是第一个经度/经度组合之间的空格)

我希望我的第一个字符串格式是正确的格式,但在这一点上,我不确定,并且我不确定如何处理SqlServerSpatial110.dll问题。

有人沿着这条路走过吗?我是不是遗漏了什么?

EN

回答 1

Stack Overflow用户

发布于 2013-09-22 13:03:21

我知道的第二个错误是:

线条((41.942587758675

两个左括号。我唯一一次得到这个错误(“数字是预期的”)是当我从复制/粘贴中随机地有两个左括号时。

关于您在库上遇到的错误,SQL Server Spatial DLL是非托管代码。你可以在这里找到更多信息,但请确保你的项目有正确的版本(32/64),并选择"copy to output direct = always“选项。

http://alastaira.wordpress.com/2011/08/19/spatial-applications-in-windows-azure-redux-including-denali/

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16059694

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档