Azavea.Open.DAO.PostgreSQL.EWKTWriter.Write C# (CSharp) Method

Write() public method

Converts a geometry into EWKT.
public Write ( IGeometry geometry ) : string
geometry IGeometry The geometry to write.
return string
        public string Write(IGeometry geometry)
        {
            if (geometry == null)
            {
                throw new ArgumentNullException("geometry", "Cannot convert null geometry to EWKT.");
            }

            // If there was no SRID on the geometry, then don't use a SRID (rather than use a SRID of 0)
            if (geometry.SRID == 0)
            {
                return _basicWriter.Write(geometry);
            }

            // Otherwise tack on the SRID.
            try
            {
                return String.Format("SRID={0};{1}", geometry.SRID, _basicWriter.Write(geometry));
            }
            catch (Exception e)
            {
                throw new LoggingException("Unable to write geometry to ewkt: " + geometry, e);
            }
        }