internal void FreeSeCoordRef(SE_COORDREF coordRef) { if (coordRef.handle != IntPtr.Zero) { Wrapper10.SE_coordref_free(coordRef); } coordRef.handle = IntPtr.Zero; }
/* * internal SdeConnection AllocConnection() * { * if (_sConnection == null) return null; * return _current = _sConnection.AllocConnection(); * } * * internal void FreeConnection() * { * if (_sConnection == null) return; * _current = null; * _sConnection.FreeConnection(); * } */ internal SE_COORDREF GetSeCoordRef(ArcSdeConnection connection, string table, string spatialColumnName, ref SE_ENVELOPE envelope) { _errMsg = ""; if (connection == null || connection.SeConnection.handle == IntPtr.Zero) { _errMsg = "GetSeCoordRef:\n No Connection allocated!"; return(new SE_COORDREF()); } SE_COORDREF coordRef = new SE_COORDREF(); SE_LAYERINFO layerInfo = new SE_LAYERINFO(); Int32 _err_no = 0; try { _err_no = Wrapper10.SE_coordref_create(ref coordRef); if (_err_no != 0) { return(new SE_COORDREF()); } _err_no = Wrapper10.SE_layerinfo_create(coordRef, ref layerInfo); if (_err_no != 0) { return(new SE_COORDREF()); } _err_no = Wrapper10.SE_layer_get_info(connection.SeConnection, table, spatialColumnName, layerInfo); if (_err_no != 0) { return(new SE_COORDREF()); } _err_no = Wrapper10.SE_layerinfo_get_coordref(layerInfo, coordRef); if (_err_no != 0) { return(new SE_COORDREF()); } _err_no = Wrapper10.SE_coordref_get_xy_envelope(coordRef, ref envelope); if (_err_no != 0) { return(new SE_COORDREF()); } return(coordRef); } catch (Exception ex) { _errMsg = "GetSeCoordRef:\n " + ex.Message + "\n" + ex.StackTrace; return(new SE_COORDREF()); } finally { if (layerInfo.handle != IntPtr.Zero) { Wrapper10.SE_layerinfo_free(layerInfo); } if (_err_no != 0) { if (coordRef.handle != IntPtr.Zero) { Wrapper10.SE_coordref_free(coordRef); } _errMsg = Wrapper10.GetErrorMsg(new SE_CONNECTION(), _err_no); } } }
internal ISpatialReference GetLayerSpatialReference(SE_CONNECTION connection, string table, string spatialColumnName) { _errMsg = ""; if (connection.handle == IntPtr.Zero) { _errMsg = "GetLayerSpatialReference:\n No Connection allocated!"; return(null); } SE_COORDREF coordRef = new SE_COORDREF(); SE_LAYERINFO layerInfo = new SE_LAYERINFO(); Int32 _err_no = 0; try { _err_no = Wrapper10.SE_coordref_create(ref coordRef); if (_err_no != 0) { return(null); } _err_no = Wrapper10.SE_layerinfo_create(coordRef, ref layerInfo); if (_err_no != 0) { return(null); } _err_no = Wrapper10.SE_layer_get_info(connection, table, spatialColumnName, layerInfo); if (_err_no != 0) { return(null); } _err_no = Wrapper10.SE_layerinfo_get_coordref(layerInfo, coordRef); if (_err_no != 0) { return(null); } System.Int32 srid = 0; _err_no = Wrapper10.SE_coordref_get_srid(coordRef, ref srid); if (_err_no != 0) { return(null); } byte[] description = new byte[1024 * 4]; _err_no = Wrapper10.SE_coordref_get_description(coordRef, description); if (_err_no != 0) { return(null); } string wkt = Functions.GetASCIIString(description); ISpatialReference sRef = gView.Framework.Geometry.SpatialReference.FromWKT(wkt); return(sRef); } catch (Exception ex) { _errMsg = "GetLayerSpatialReference:\n " + ex.Message + "\n" + ex.StackTrace; return(null); } finally { if (layerInfo.handle != IntPtr.Zero) { Wrapper10.SE_layerinfo_free(layerInfo); } if (coordRef.handle != IntPtr.Zero) { Wrapper10.SE_coordref_free(coordRef); } if (_err_no != 0) { _errMsg = Wrapper10.GetErrorMsg(new SE_CONNECTION(), _err_no); } } }