nettopologysuite - NetTopologySuite.IO.SqlServerBytes 2.1.0

A SQL Server IO module for NTS which works directly with the serialization format

PM> Install-Package NetTopologySuite.IO.SqlServerBytes -Version 2.1.0 -Source https://www.myget.org/F/nettopologysuite/api/v3/index.json

Copy to clipboard

> nuget.exe install NetTopologySuite.IO.SqlServerBytes -Version 2.1.0 -Source https://www.myget.org/F/nettopologysuite/api/v3/index.json

Copy to clipboard

> dotnet add package NetTopologySuite.IO.SqlServerBytes --version 2.1.0 --source https://www.myget.org/F/nettopologysuite/api/v3/index.json

Copy to clipboard
<PackageReference Include="NetTopologySuite.IO.SqlServerBytes" Version="2.1.0" />
Copy to clipboard
source https://www.myget.org/F/nettopologysuite/api/v3/index.json

nuget NetTopologySuite.IO.SqlServerBytes  ~> 2.1.0
Copy to clipboard

> choco install NetTopologySuite.IO.SqlServerBytes --version 2.1.0 --source https://www.myget.org/F/nettopologysuite/api/v2

Copy to clipboard
Import-Module PowerShellGet
Register-PSRepository -Name "nettopologysuite" -SourceLocation "https://www.myget.org/F/nettopologysuite/api/v2"
Install-Module -Name "NetTopologySuite.IO.SqlServerBytes" -RequiredVersion "2.1.0" -Repository "nettopologysuite" 
Copy to clipboard

Browse the sources in this package using Visual Studio or WinDbg by configuring the following symbol server URL: https://www.myget.org/F/nettopologysuite/api/v2/symbolpackage/


NetTopologySuite.IO.SqlServerBytes

A SQL Server IO module for NTS which works directly with the serialization format

License Actions NuGet MyGet (pre-release)
License .NET NuGet MyGet

Usage

Reading

Read geography and geometry columns like this.

var geometryReader = new SqlServerBytesReader { IsGeography = true };
var bytes = dataReader.GetSqlBytes(columnOrdinal).Value;
var geometry = geometryReader.Read(bytes);

Writing

Write parameters like this.

var geometry = new Point(-122.129797, 47.640049) { SRID = 4326 };
var geometryWriter = new SqlServerBytesWriter { IsGeography = true };
var bytes = geometryWriter.Write(geometry);
var parameter = command.Parameters
    .AddWithValue(parameterName, new SqlBytes(bytes));

// TODO: Set these if you're using Microsoft.Data.SqlClient
//parameter.SqlDbType = SqlDbType.Udt;
//parameter.UdtTypeName = "geography";

Known limitations

Validity

SqlServer and NetTopologySuite have a slightly different notion of a geometry's validity. SqlServer stores this information along with the geometry data and the SqlServerBytesWriter uses NetTopologySuite's Geometry.IsValid value. You might get SqlServer geometries that return STIsValid() = true but STIsValidReason() = false.

Fullglobe

SqlServer geography types include FULLGLOBE, basically a polygon where the globe is the outer ring (shell) and the interior rings (holes) define areas that are excluded. To achive this, SqlServer is rigid about ring orientations for geographies. Kind | requested Orientation --- | --- outer rings | counter clockwise inner rings | clockwise

This is currently not representable using NetTopologySuite geometries and the SqlServerBytesWriter throws an ArgumentException if writing a geometry is requested that has an exterior ring oriented clockwise.

Measures

SqlServer geography types use the metric system for measures like length, distance and area. For NetTopologySuite geometries everything is planar and thus all return values are in the unit of the input coordinates. In case the coordinates are geographic these values are mostly useless.
Furthermore you can easily create buffers of geometries that exceed the extent of a hemisphere. SqlServer rejects these.

  • .NETStandard 2.0
    • NetTopologySuite (>= 2.0.0 && < 3.0.0-A)
  • .NETStandard 2.0: 2.0.0.0

Owners

NetTopologySuite-Team AirBreather

Authors

NetTopologySuite - Team

Project URL

https://github.com/NetTopologySuite/NetTopologySuite.IO.SqlServerBytes

License

BSD-3-Clause

Tags

NTS MSSQL SQLServer SQL Server SQL

Info

6 total downloads
0 downloads for version 2.1.0
Download (16.16 KB)
Download symbols (10.61 KB)
Found on the current feed only

Package history

Version Size Last updated Downloads Mirrored?
2.1.0 16.16 KB Wed, 16 Feb 2022 11:05:06 GMT 0
2.1.0-pre.190550628+ci.github.1933189367 16.49 KB Fri, 04 Mar 2022 10:38:51 GMT 0
2.1.0-pre.190390652+ci.github.1852338265 16.25 KB Wed, 16 Feb 2022 10:54:21 GMT 1
2.1.0-pre.190310994+ci.github.1813456784 15.79 KB Tue, 08 Feb 2022 16:34:23 GMT 0
2.1.0-pre.187290736+ci.github.run3 15.77 KB Mon, 12 Apr 2021 12:17:17 GMT 0
2.0.0-pre.187290699+ci.travis.33 14.29 KB Mon, 12 Apr 2021 11:39:06 GMT 0
2.0.0-pre.187290692+ci.travis.32 14.28 KB Mon, 12 Apr 2021 11:32:11 GMT 1
2.0.0-pre.181481122+ci.travis.31 14.26 KB Mon, 09 Sep 2019 18:42:14 GMT 1
2.0.0-pre.181440831+ci.travis.28 14.26 KB Thu, 05 Sep 2019 13:50:45 GMT 1
2.0.0-pre.181440807+ci.travis.27 14.31 KB Thu, 05 Sep 2019 13:27:30 GMT 1
2.0.0-pre.181420651+ci.travis.24 14.16 KB Tue, 03 Sep 2019 10:51:29 GMT 1