title: Convert Latitude Longitude to SQL-Server Geography
body: <p>I have coordinates as two double values, latitude and longitude. I need to somehow convert them to the SQL-Server Geography datatype.</p>
  
  <p>I have a working example for this in C#, but I don't know how to do it in Delphi.
  The aim is to retrieve the same data as I get when accessing the <code>SqlGeographyBinary</code> in my example, to save it in an text file.</p>
  
  <pre><code>public Double Latitude { get; set; }
  
  public Double Longitude { get; set; }
  
  private String sqlGeographyBinary = null;
  public String SqlGeographyBinary
  {
      get
      {
          if (String.IsNullOrWhiteSpace(sqlGeographyBinary))
          {
              using (var stream = new MemoryStream())
              {
                  using (var writer = new BinaryWriter(stream))
                  {
                      var sqlPoint = SqlGeography.Point(Latitude, Longitude, SRID);
                      sqlPoint.Write(writer);
                      stream.Position = 0;
                      var buffer = new Byte[stream.Length];
                      stream.Read(buffer, 0, (int)stream.Length);
                      sqlGeographyBinary = BitConverter.ToString(buffer).Replace("-", "");
                      writer.Close();
                  }
             }
          }        
          return sqlGeographyBinary;
      }
  }
  </code></pre>