-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…writing SqlGeography to WKT
- Loading branch information
Showing
9 changed files
with
174 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
using Microsoft.SqlServer.Types.Tests.Geometry; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace Microsoft.SqlServer.Types.Tests.Geography | ||
{ | ||
[TestClass] | ||
[TestCategory("SqlGeography")] | ||
[TestCategory("WKT")] | ||
public class WktTests | ||
{ | ||
|
||
[TestMethod] | ||
[WorkItem(13)] | ||
public void UserSubmittedIssue_WKT2() | ||
{ | ||
using (var conn = new System.Data.SqlClient.SqlConnection(DBTests.ConnectionString)) | ||
{ | ||
conn.Open(); | ||
var id = SqlGeography.Parse("LINESTRING (-122.36 47.656, -122.343 47.656)"); | ||
|
||
using (var cmd = conn.CreateCommand()) | ||
{ | ||
cmd.CommandText = "SELECT @p"; | ||
var p = cmd.CreateParameter(); | ||
cmd.Parameters.Add(p); | ||
|
||
p.UdtTypeName = "geography"; | ||
p.ParameterName = "@p"; | ||
p.Value = id; | ||
|
||
Assert.AreEqual(id.ToString(), cmd.ExecuteScalar().ToString()); | ||
} | ||
} | ||
} | ||
|
||
[TestMethod] | ||
[WorkItem(13)] | ||
public void UserSubmittedIssue_WKT3() | ||
{ | ||
using (var conn = new System.Data.SqlClient.SqlConnection(DBTests.ConnectionString)) | ||
{ | ||
conn.Open(); | ||
var id = SqlGeography.Parse("LINESTRING (-122.36 47.656, -122.343 47.656)"); | ||
var l = id.STPointN(1).Long; | ||
using (var cmd = conn.CreateCommand()) | ||
{ | ||
cmd.CommandText = "SELECT Cast(geography::STGeomFromText('LINESTRING(-122.360 47.656, -122.343 47.656)', 4326) as geography)"; | ||
|
||
Assert.AreEqual(id.ToString(), cmd.ExecuteScalar().ToString()); | ||
} | ||
} | ||
} | ||
|
||
[TestMethod] | ||
[WorkItem(14)] | ||
public void UserSubmittedIssue_WKT4() | ||
{ | ||
using (var conn = new System.Data.SqlClient.SqlConnection(DBTests.ConnectionString)) | ||
{ | ||
conn.Open(); | ||
using (var cmd = conn.CreateCommand()) | ||
{ | ||
cmd.CommandText = "SELECT Cast(geography::STGeomFromText('LINESTRING(-122.360 47.656, -122.343 47.656)', 4326) as geography)"; | ||
var result = cmd.ExecuteScalar(); | ||
Assert.IsInstanceOfType(result, typeof(SqlGeography)); | ||
SqlGeography g = (SqlGeography)result; | ||
Assert.AreEqual("LineString", g.STGeometryType()); | ||
Assert.AreEqual(2, g.STNumPoints()); | ||
Assert.AreEqual(47.656, g.STPointN(1).Lat.Value); | ||
Assert.AreEqual(-122.360, g.STPointN(1).Long.Value); | ||
Assert.AreEqual(47.656, g.STPointN(2).Lat.Value); | ||
Assert.AreEqual(-122.343, g.STPointN(2).Long.Value); | ||
Assert.AreEqual("LINESTRING (-122.36 47.656, -122.343 47.656)", cmd.ExecuteScalar().ToString()); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,8 +27,4 @@ | |
</Compile> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Folder Include="Geography\" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.