Exemplo n.º 1
0
        static public ISpatialReference setEsriSpatiaReferenceFromSrText(int srid, Connection conn)
        {
            ISpatialReference sr     = new UnknownCoordinateSystemClass();
            string            srText = "";
            int i = 0;

            try
            {
                //Bill: query srtext associated with srid
                AutoDataReader dr = conn.doQuery("select * from spatial_ref_sys where srid = " + srid.ToString());
                if (dr.Read())
                {
                    srText = dr["srtext"] + "";
                    ISpatialReferenceFactory2 srf = new SpatialReferenceEnvironmentClass();
                    if (srText == "")
                    {
                        sr = new UnknownCoordinateSystemClass();
                    }
                    else
                    {
                        //use srText to construct SR.
                        srf.CreateESRISpatialReference(srText, out sr, out i);
                    }
                }
                return(sr);
            }
            catch
            {
                //PostGis srid is not implemented as an Esri Factory Code
                sr = new UnknownCoordinateSystemClass();
                return(sr);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates the a spatial reference for the srid
        /// </summary>
        /// <returns>ESRI ISpatialReference </returns>
        private ISpatialReference CreateSpatialReference()
        {
            ISpatialReferenceFactory spatialReferenceFactory = new SpatialReferenceEnvironmentClass();
            string esriwkt = EsriSpatialReferenceWKT(this.Table.SpatialReferenceID);

            try
            {
                ISpatialReference spatialReference;
                int bytesRead;

                spatialReferenceFactory.CreateESRISpatialReference(esriwkt, out spatialReference, out bytesRead);

                return(spatialReference);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.StackTrace);
                throw;
            }
        }
Exemplo n.º 3
0
 public static ISpatialReference setEsriSpatiaReferenceFromSrText(int srid, Connection conn)
 {
     ISpatialReference sr = new UnknownCoordinateSystemClass();
     string srText = "";
     int i = 0;
     try
     {
         //Bill: query srtext associated with srid
         AutoDataReader dr = conn.doQuery("select * from spatial_ref_sys where srid = " + srid.ToString());
         if (dr.Read())
         {
             srText = dr["srtext"] + "";
             ISpatialReferenceFactory2 srf = new SpatialReferenceEnvironmentClass();
             if (srText == "")
             {
                 sr = new UnknownCoordinateSystemClass();
             }
             else
             {
                 //use srText to construct SR.
                 srf.CreateESRISpatialReference(srText, out sr, out i);
             }
         }
         return sr;
     }
     catch
     {
         //PostGis srid is not implemented as an Esri Factory Code
         sr = new UnknownCoordinateSystemClass();
         return sr;
     }
 }