2013-04-17 1 views
2

Je construis une application qui analyse une variété de formats de fichiers cartographiques externes (fichiers de formes, MapPoint, KML, etc.) et stocke les formes dans une base de données centralisée qui seront utilisés pour une centrale cartographie/base de rapports. J'ai une routine qui a maintenant une ligne représentée par un tableau abstrait de points, et je tente de le transformer en un objet sqlGeography qui sera stocké dans ma base de données (SQL2012 Express pour le moment).Création d'un LINESTRING de SqlGeography en utilisant .NET

Voici un exemple de ma déclaration de LINESTRING (stocké dans une chaîne 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) 

Je puis effectuer cette opération sur cette chaîne (VB.NET)

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

J'ai ajouté Références appropriées à Microsoft.SqlServer.Types à partir du Feature Pack SQL Server 2012, mais lorsque mon débogueur atteint la ligne SqlGeography, j'obtiens ceci:

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 

Je ne trouve pas SqlServerSpatial110.dll n'importe où sur mon ordinateur. J'ai SQL Express 2012 installé, et peut trouver SqlerverSpatial.dll dans SYSTEM32 et SYSWOW64, mais VS ne me laissera pas enregistrer l'un de ces fichiers.

J'ai remarqué que si j'utiliser deux parenthèses dans mon LINESTRING comme cela, je reçois une autre erreur:

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 

(Avant de compter les caractères, la position 27 est l'espace entre le premier combo latitude/longitude

Je m'attends à ce que mon premier format de chaîne soit le format correct, mais à ce stade, je ne suis pas sûr, et je ne sais pas quoi faire avec le problème SqlServerSpatial110.dll.

Quelqu'un est-il allé sur cette route? Est-ce que je manque quelque chose?

+0

J'ai aussi essayé, pour vous assurer que ma ligne ne soit pas trop complexe, en utilisant une chaîne comme ceci: LINESTRING (0 0,1 1) Et j'obtenir les mêmes résultats. –

+0

Salut, je vous preffer lire MSDN: http://msdn.microsoft.com/en-us/library/ee642119(v=sql.105).aspx – Ali

Répondre

0

La deuxième erreur que je sais:

LINESTRING ((41,942587758675

Deux parenthèse ouverte La seule fois où je suis arrivé cette erreur (le « un certain nombre devrait » chose) était quand je au hasard de la copie. Si vous avez une erreur sur les bibliothèques, la DLL SQL Server Spatial est un code non géré, vous pouvez trouver plus d'informations ici, mais assurez-vous d'avoir la bonne version (32/64) sur votre serveur. projet et sélectionnez l'option "copier vers sortie directe = toujours"

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