Convert a Vector (point) into a Point Sql Geometry object - CSharp System

CSharp examples for System:Math Vector

Description

Convert a Vector (point) into a Point Sql Geometry object

Demo Code


using System.Windows;
using Microsoft.SqlServer.Types;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;/*from  w w  w . j av  a2  s. c  o  m*/

public class Main{
        /// <summary>
        /// Convert a Vector (point) into a Point SqlGeometry object
        /// </summary>
        /// <param name="points"></param>
        /// <returns></returns>
        /// <remarks>by Alex Dec.2012</remarks>
        public static SqlGeography Point2SqlGeography(Double X, Double Y, int SRID)
        {
            System.Data.SqlTypes.SqlChars chars = new System.Data.SqlTypes.SqlChars(String.Format("POINT({0} {1})", X, Y));
            return SqlGeography.STGeomFromText(chars, SRID);
            
        }
}

Related Tutorials