2

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

这是我的 LINESTRING 语句的示例(存储在字符串 strGeo 中):

    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)

    Dim strSql As New SqlChars(New SqlString(strGeo))
    Dim geo As SqlGeography = SqlGeography.STLineFromText(strSql, 4326)

我已经从 SQL Server 2012 功能包中添加了对 Microsoft.SqlServer.Types 的适当引用,但是当我的调试器点击 SqlGeography 行时,我得到了这个:

    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 Express 2012,并且可以在 SYSTEM32 和 SYSWOW64 中找到 SqlerverSpatial.dll,但是 VS 不允许我注册这些文件中的任何一个。

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

    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 是第一个 lat/lon 组合之间的空格)

我希望我的第一个字符串格式是正确的格式,但此时我不确定,我不确定如何处理 SqlServerSpatial110.dll 问题。

有人走过这条路吗?我错过了什么吗?

4

1 回答 1

0

我知道的第二个错误:

线串((41.942587758675

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

关于您在库中遇到的错误,SQL Server Spatial DLL 是非托管代码。您可以在此处找到更多信息,但请确保您的项目具有正确的版本 (32/64) 并选择“直接复制到输出 = 始终”选项。

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

于 2013-09-22T05:03:20.760 回答