Giter VIP home page Giter VIP logo

nettopologysuite.io.sqlserverbytes's Introduction

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.

nettopologysuite.io.sqlserverbytes's People

Contributors

airbreather avatar bricelam avatar fobermaier avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.