创建sqlGeography LINESTRING我建立一个分析各种外部地图文件格式(即shape文件,MapPoint的,KML等)的应用程序,并集中保存在一个数据库中的形状,将被用于中央绘图/报告基础。我有一个例程,现在有一个由抽象点数组表示的行,并且我试图将其转换为将存储在我的数据库(SQL2012 Express)中的sqlGeography对象。使用.NET
这里是我的LINESTRING语句的例子(存储在一个字符串strGeo):
Dim strSql As New SqlChars(New SqlString(strGeo))
Dim geo As SqlGeography = SqlGeography.STLineFromText(strSql, 4326)
我添加
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)适当引用来自SQL Server 2012 Feature Pack的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位是第一个经/纬度组合之间的空间)
我想到的是我的第一个字符串格式是正确的格式,但在这一点上我不知道,我不知道该怎么做与SqlServerSpatial110.dll问题。
有人在这条路上?我错过了什么吗?
我也试过,以确保我行是不是太复杂了,使用这样的字符串: LINESTRING(0 0,1 1) 我也得到了相同的结果。 –
嗨,我preffer你读取MSDN:http://msdn.microsoft.com/en-us/library/ee642119(v=sql.105).aspx – Ali