public override PJ Init() { es = 0.0; try { sinu = new PJ_sinu(); moll = new PJ_moll(); } catch { return(null); } sinu.es = 0; sinu.ctx = ctx; moll.ctx = ctx; sinu = sinu.Init(); moll = moll.Init(); if (sinu == null || moll == null) { return(null); } fwd = s_forward; inv = s_inverse; return(this); }
public override PJ Init() { es=0.0; try { sinu=new PJ_sinu(); moll=new PJ_moll(); } catch { return null; } sinu.es=0; sinu.ctx=ctx; moll.ctx=ctx; sinu=sinu.Init(); moll=moll.Init(); if(sinu==null||moll==null) return null; fwd=s_forward; inv=s_inverse; return this; }
internal static B_PJ ToBusiness(this PJ entity) { return(new B_PJ() { Id = entity.Id, Nom = entity.Nom, Sexe = entity.Sexe, Blesse = entity.Blesse, Esquive = entity.Esquive, CoupPuissant = entity.CoupPuissant, Id_Race = entity.Id_Race, Id_Classe = entity.Id_Classe, Id_Signe = entity.Id_Signe, ValeurD4 = entity.ValeurD4 }); }
private void ExecuteCommandPesquisarInscricao(object obj) { try { if (Atendimento.Cliente.Inscricao == string.Empty) { return; } string identificador = new mMascaras().Remove(Atendimento.Cliente.Inscricao); PF.Clear(); PJ.Clear(); switch (identificador.Length) { case 11: ClientePF(new mData().ExistPessoaFisica(identificador)); break; case 14: ClientePJ(new mData().ExistPessoaJuridica(identificador)); break; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// Exibe MessageBox /// </summary> /// <param name="message">passa messagem por parametro</param> private void AsyncMessageBox(string message, bool retornook) { BlackBox = Visibility.Collapsed; StarProgress = false; TextMsgBox = message; ShowMsgBox = Visibility.Visible; System.Media.SystemSounds.Exclamation.Play(); Task.Factory.StartNew(() => Freezetime(10)).ContinueWith(taskmsg => { if (taskmsg.IsCompleted) { ShowMsgBox = Visibility.Collapsed; if (retornook == true) { Atendimento.Clear(); PF.Clear(); PJ.Clear(); Protocolo = NProtocolo(); Atendimento.Operador = AccountOn.Identificador; AreaTransferencia.Limpar(); ns.GoBack(); } } }, System.Threading.CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext()); }
// dervative of (P.fwd) projection public static bool pj_deriv(LP lp, double h, PJ P, out DERIVS der) { der.x_l = der.y_p = der.x_p = der.y_l = 0; XY t; lp.lam += h; lp.phi += h; if (Math.Abs(lp.phi) > Proj.HALFPI) { return(true); } h += h; t = P.fwd(lp); if (t.x == Libc.HUGE_VAL) { return(true); } der.x_l = t.x; der.y_p = t.y; der.x_p = -t.x; der.y_l = -t.y; lp.phi -= h; if (Math.Abs(lp.phi) > Proj.HALFPI) { return(true); } t = P.fwd(lp); if (t.x == Libc.HUGE_VAL) { return(true); } der.x_l += t.x; der.y_p -= t.y; der.x_p += t.x; der.y_l -= t.y; lp.lam -= h; t = P.fwd(lp); if (t.x == Libc.HUGE_VAL) { return(true); } der.x_l -= t.x; der.y_p -= t.y; der.x_p += t.x; der.y_l += t.y; lp.phi += h; t = P.fwd(lp); if (t.x == Libc.HUGE_VAL) { return(true); } der.x_l -= t.x; der.y_p += t.y; der.x_p -= t.x; der.y_l += t.y; der.x_l /= (h += h); der.y_p /= h; der.x_p /= h; der.y_l /= h; return(false); }
private async void MostrarCliente(string cpf) { PF.Clear(); ListaPJ.Clear(); var pf = Task.Run(() => mdata.ExistPessoaFisica(cpf)); await pf; if (pf.IsCompleted) { PF.Add(new mCliente() { Inscricao = pf.Result.CPF, NomeRazao = pf.Result.Nome, Telefones = pf.Result.Telefones, Email = pf.Result.Email }); } List <Task <mPJ_Ext> > l_pj = new List <Task <mPJ_Ext> >(); foreach (mVinculos v in pf.Result.ColecaoVinculos) { l_pj.Add(Task.Run(() => mdata.ExistPessoaJuridica(v.CNPJ))); } foreach (Task <mPJ_Ext> pj in l_pj) { await pj; //if (pj.Result.SituacaoCadastral != "BAIXADO") if (pj.IsCompleted) { if (pf.Result.ColecaoVinculos.Count > 1) { ListaPJ.Add(new mCliente() { Inscricao = pj.Result.CNPJ, NomeRazao = pj.Result.RazaoSocial, Telefones = pj.Result.Telefones, Email = pj.Result.Email }); ViewListaPJ = Visibility.Visible; } else { PJ.Add(new mCliente() { Inscricao = pj.Result.CNPJ, NomeRazao = pj.Result.RazaoSocial, Telefones = pj.Result.Telefones, Email = pj.Result.Email }); } } } }
private void AsyncMostrarCliente(string cpf) { Task <mPF_Ext> .Factory.StartNew(() => mdata.ExistPessoaFisica(cpf)) .ContinueWith(task => { if (task.IsCompleted) { PF.Clear(); PF.Add(new mCliente() { Inscricao = task.Result.CPF, NomeRazao = task.Result.Nome, Telefones = task.Result.Telefones, Email = task.Result.Email }); ListaPJ.Clear(); foreach (mVinculos v in task.Result.ColecaoVinculos) { Task <mPJ_Ext> .Factory.StartNew(() => mdata.ExistPessoaJuridica(v.CNPJ)).ContinueWith(task_two => { if (task_two.IsCompleted) { if (task.Result.ColecaoVinculos.Count > 1) { ListaPJ.Add(new mCliente() { Inscricao = task_two.Result.CNPJ, NomeRazao = task_two.Result.RazaoSocial, Telefones = task_two.Result.Telefones, Email = task_two.Result.Email }); ViewListaPJ = Visibility.Visible; } else { PJ.Add(new mCliente() { Inscricao = task_two.Result.CNPJ, NomeRazao = task_two.Result.RazaoSocial, Telefones = task_two.Result.Telefones, Email = task_two.Result.Email }); } } }, System.Threading.CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext()); } } }, System.Threading.CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext()); }
public ActionResult Cadastro(int?id) { var model = new PJ(); if (id != null) { model = _db.PJ.Find(id); } return(View(model)); }
private void ExecuteCommandCancelCliente(object obj) { if (MessageBox.Show(string.Format("Cancelar Atendimento do Cliente {0}?", Atendimento.Cliente.NomeRazao), "Sim.Alerta!", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes) { Atendimento.Clear(); PJ.Clear(); PF.Clear(); Atendimento.Operador = AccountOn.Identificador; AreaTransferencia.Limpar(); Corpo = Visibility.Collapsed; Cabecalho = Visibility.Visible; } }
private void ExecuteCommandCancel(object obj) { Atendimento.Clear(); PJ.Clear(); PF.Clear(); Atendimento.Operador = AccountOn.Identificador; AreaTransferencia.Limpar(); Corpo = Visibility.Collapsed; Cabecalho = Visibility.Visible; if (ns.CanGoBack) { ns.GoBack(); } }
//*********************************************************************** // pj_apply_gridshift_2() // // This implmentation takes uses the gridlist from a coordinate // system definition. If the gridlist has not yet been // populated in the coordinate system definition we set it up // now. //*********************************************************************** public static int pj_apply_gridshift_2(PJ defn, bool inverse, int point_count, int point_offset, double[] x, double[] y, double[] z) { if(defn.catalog_name!=null) return pj_gc_apply_gridshift(defn, inverse, point_count, point_offset, x, y, z); if(defn.gridlist==null) { defn.gridlist=pj_gridlist_from_nadgrids(Proj.pj_get_ctx(defn), Proj.pj_param_s(defn.ctx, defn.parameters, "nadgrids"), out defn.gridlist_count); if(defn.gridlist==null||defn.gridlist_count==0) return defn.ctx.last_errno; } return pj_apply_gridshift_3(Proj.pj_get_ctx(defn), defn.gridlist, defn.gridlist_count, inverse, point_count, point_offset, x, y, z); }
// Zones: // // -180 -40 180 // +--------------+-------------------------+ Zones 1,2,9,10,11 & 12: // |1 |2 | Mollweide projection // | | | // +--------------+-------------------------+ Zones 3,4,5,6,7 & 8: // |3 |4 | Sinusoidal projection // | | | // 0 +-------+------+-+-----------+-----------+ // |5 |6 |7 |8 | // | | | | | // +-------+--------+-----------+-----------+ // |9 |10 |11 |12 | // | | | | | // +-------+--------+-----------+-----------+ // -180 -100 -20 80 180 bool SETUP(int n, PJ proj, double x_0, double y_0, double lon_0) { if (proj == null) { return(false); } pj[n - 1] = proj.Init(); if (pj[n - 1] == null) { return(false); } pj[n - 1].x0 = x_0; pj[n - 1].y0 = y_0; pj[n - 1].lam0 = lon_0; return(true); }
//*********************************************************************** // pj_apply_gridshift_2() // // This implmentation takes uses the gridlist from a coordinate // system definition. If the gridlist has not yet been // populated in the coordinate system definition we set it up // now. //*********************************************************************** public static int pj_apply_gridshift_2(PJ defn, bool inverse, int point_count, int point_offset, double[] x, double[] y, double[] z) { if (defn.catalog_name != null) { return(pj_gc_apply_gridshift(defn, inverse, point_count, point_offset, x, y, z)); } if (defn.gridlist == null) { defn.gridlist = pj_gridlist_from_nadgrids(Proj.pj_get_ctx(defn), Proj.pj_param_s(defn.ctx, defn.parameters, "nadgrids"), out defn.gridlist_count); if (defn.gridlist == null || defn.gridlist_count == 0) { return(defn.ctx.last_errno); } } return(pj_apply_gridshift_3(Proj.pj_get_ctx(defn), defn.gridlist, defn.gridlist_count, inverse, point_count, point_offset, x, y, z)); }
private void AsyncPJ(string cnpj) { Task <mPJ_Ext> .Factory.StartNew(() => mdata.ExistPessoaJuridica(cnpj)).ContinueWith(task_two => { if (task_two.IsCompleted) { PJ.Clear(); PJ.Add(new mCliente() { Inscricao = task_two.Result.CNPJ, NomeRazao = task_two.Result.RazaoSocial, Telefones = task_two.Result.Telefones, Email = task_two.Result.Email }); } }, System.Threading.CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext()); }
public ActionResult Cadastro(PJ PJ) { if (ModelState.IsValid) { if (PJ.Id > 0) { _db.Entry(PJ).State = EntityState.Modified; } else { _db.PJ.Add(PJ); } _db.SaveChanges(); return(RedirectToAction("Index")); } return(View(PJ)); }
// dervative of (P.fwd) projection public static bool pj_deriv(LP lp, double h, PJ P, out DERIVS der) { der.x_l=der.y_p=der.x_p=der.y_l=0; XY t; lp.lam+=h; lp.phi+=h; if(Math.Abs(lp.phi)>Proj.HALFPI) return true; h+=h; t=P.fwd(lp); if(t.x==Libc.HUGE_VAL) return true; der.x_l=t.x; der.y_p=t.y; der.x_p=-t.x; der.y_l=-t.y; lp.phi-=h; if(Math.Abs(lp.phi)>Proj.HALFPI) return true; t=P.fwd(lp); if(t.x==Libc.HUGE_VAL) return true; der.x_l+=t.x; der.y_p-=t.y; der.x_p+=t.x; der.y_l-=t.y; lp.lam-=h; t=P.fwd(lp); if(t.x==Libc.HUGE_VAL) return true; der.x_l-=t.x; der.y_p-=t.y; der.x_p+=t.x; der.y_l+=t.y; lp.phi+=h; t=P.fwd(lp); if(t.x==Libc.HUGE_VAL) return true; der.x_l-=t.x; der.y_p+=t.y; der.x_p-=t.x; der.y_l+=t.y; der.x_l/=(h+=h); der.y_p/=h; der.x_p/=h; der.y_l/=h; return false; }
//********************************************************************** // pj_gc_apply_gridshift() //********************************************************************** public static int pj_gc_apply_gridshift(PJ defn, bool inverse, int point_count, int point_offset, double[] x, double[] y, double[] z) { int i; if (defn.catalog == null) { defn.catalog = pj_gc_findcatalog(defn.ctx, defn.catalog_name); if (defn.catalog == null) { return(defn.ctx.last_errno); } } defn.ctx.last_errno = 0; for (i = 0; i < point_count; i++) { long io = i * point_offset; LP input; input.phi = y[io]; input.lam = x[io]; // make sure we have appropriate "after" shift file available if (defn.last_after_grid == null || input.lam < defn.last_after_region.ll_long || input.lam > defn.last_after_region.ur_long || input.phi < defn.last_after_region.ll_lat || input.phi > defn.last_after_region.ll_lat) { defn.last_after_grid = pj_gc_findgrid(defn.ctx, defn.catalog, true, input, defn.datum_date, ref defn.last_after_region, ref defn.last_after_date); } PJ_GRIDINFO gi = defn.last_after_grid; Debug.Assert(gi.child == null); // load the grid shift info if we don't have it. if (gi.ct.cvs == null && !pj_gridinfo_load(defn.ctx, gi)) { Proj.pj_ctx_set_errno(defn.ctx, -38); return(-38); } LP output_after = nad_cvt(input, inverse, gi.ct); if (output_after.lam == Libc.HUGE_VAL) { if (defn.ctx.debug_level >= PJ_LOG.DEBUG_MAJOR) { Proj.pj_log(defn.ctx, PJ_LOG.DEBUG_MAJOR, "pj_apply_gridshift(): failed to find a grid shift table for"); Proj.pj_log(defn.ctx, PJ_LOG.DEBUG_MAJOR, " location ({0:F7}dW,{1:F7}dN)", x[io] * Proj.RAD_TO_DEG, y[io] * Proj.RAD_TO_DEG); } continue; } if (defn.datum_date == 0.0) { y[io] = output_after.phi; x[io] = output_after.lam; continue; } // make sure we have appropriate "before" shift file available if (defn.last_before_grid == null || input.lam < defn.last_before_region.ll_long || input.lam > defn.last_before_region.ur_long || input.phi < defn.last_before_region.ll_lat || input.phi > defn.last_before_region.ll_lat) { defn.last_before_grid = pj_gc_findgrid(defn.ctx, defn.catalog, false, input, defn.datum_date, ref defn.last_before_region, ref defn.last_before_date); } gi = defn.last_before_grid; Debug.Assert(gi.child == null); // load the grid shift info if we don't have it. if (gi.ct.cvs == null && !pj_gridinfo_load(defn.ctx, gi)) { Proj.pj_ctx_set_errno(defn.ctx, -38); return(-38); } LP output_before = nad_cvt(input, inverse, gi.ct); if (output_before.lam == Libc.HUGE_VAL) { if (defn.ctx.debug_level >= PJ_LOG.DEBUG_MAJOR) { Proj.pj_log(defn.ctx, PJ_LOG.DEBUG_MAJOR, "pj_apply_gridshift(): failed to find a grid shift table for"); Proj.pj_log(defn.ctx, PJ_LOG.DEBUG_MAJOR, " location ({0:F7}dW,{1:F7}dN)", x[io] * Proj.RAD_TO_DEG, y[io] * Proj.RAD_TO_DEG); } continue; } double mix_ratio = (defn.datum_date - defn.last_before_date) / (defn.last_after_date - defn.last_before_date); y[io] = mix_ratio * output_after.phi + (1.0 - mix_ratio) * output_before.phi; x[io] = mix_ratio * output_after.lam + (1.0 - mix_ratio) * output_before.lam; } return(0); }
public const int IS_ANAL_XP_YP = 02; // derivatives of lat analytic #endregion Fields #region Methods public static bool pj_factors(LP lp, PJ P, double h, ref FACTORS fac) { IFactors PFac=P as IFactors; const double EPS=1.0e-12; const double DEFAULT_H=1e-5; // check for forward and latitude or longitude overange double t=Math.Abs(lp.phi)-Proj.HALFPI; if(t>EPS||Math.Abs(lp.lam)>10.0) { Proj.pj_ctx_set_errno(P.ctx, -14); return true; } // proceed Libc.errno=Proj.pj_errno=0; P.ctx.last_errno=0; if(h<EPS) h=DEFAULT_H; if(Math.Abs(lp.phi)>(Proj.HALFPI-h)) lp.phi=lp.phi<0.0?(-Proj.HALFPI+h):(Proj.HALFPI-h); // adjust to value around pi/2 where derived still exists else if(P.geoc) lp.phi=Math.Atan(P.rone_es*Math.Tan(lp.phi)); lp.lam-=P.lam0; // compute del lp.lam if(!P.over) lp.lam=Proj.adjlon(lp.lam); // adjust del longitude if(PFac!=null) PFac.spc(lp, ref fac); // get what projection analytic values if((fac.code&(IS_ANAL_XL_YL+IS_ANAL_XP_YP))!=(IS_ANAL_XL_YL+IS_ANAL_XP_YP)) { DERIVS der; if(pj_deriv(lp, h, P, out der)) return true; if((fac.code&IS_ANAL_XL_YL)==0) { fac.der.x_l=der.x_l; fac.der.y_l=der.y_l; } if((fac.code&IS_ANAL_XP_YP)==0) { fac.der.x_p=der.x_p; fac.der.y_p=der.y_p; } } double cosphi=Math.Cos(lp.phi); double r; if((fac.code&IS_ANAL_HK)==0) { fac.h=Libc.hypot(fac.der.x_p, fac.der.y_p); fac.k=Libc.hypot(fac.der.x_l, fac.der.y_l)/cosphi; if(P.es!=0) { t=Math.Sin(lp.phi); t=1.0-P.es*t*t; double n=Math.Sqrt(t); fac.h*=t*n/P.one_es; fac.k*=n; r=t*t/P.one_es; } else r=1.0; } else if(P.es!=0) { r=Math.Sin(lp.phi); r=1.0-P.es*r*r; r=r*r/P.one_es; } else r=1.0; // convergence if((fac.code&IS_ANAL_CONV)==0) { fac.conv=-Math.Atan2(fac.der.y_l, fac.der.x_l); if((fac.code&IS_ANAL_XL_YL)!=0) fac.code|=IS_ANAL_CONV; } // areal scale factor fac.s=(fac.der.y_p*fac.der.x_l-fac.der.x_p*fac.der.y_l)*r/cosphi; // meridian-parallel angle theta prime fac.thetap=Proj.aasin(P.ctx, fac.s/(fac.h*fac.k)); // Tissot ellips axis t=fac.k*fac.k+fac.h*fac.h; fac.a=Math.Sqrt(t+2.0*fac.s); t=(t=t-2.0*fac.s)<=0.0?0.0:Math.Sqrt(t); fac.b=0.5*(fac.a-t); fac.a=0.5*(fac.a+t); // omega fac.omega=2.0*Proj.aasin(P.ctx, (fac.a-fac.b)/(fac.a+fac.b)); return false; }
//********************************************************************** // pj_gc_apply_gridshift() //********************************************************************** public static int pj_gc_apply_gridshift(PJ defn, bool inverse, int point_count, int point_offset, double[] x, double[] y, double[] z) { int i; if(defn.catalog==null) { defn.catalog=pj_gc_findcatalog(defn.ctx, defn.catalog_name); if(defn.catalog==null) return defn.ctx.last_errno; } defn.ctx.last_errno=0; for(i=0; i<point_count; i++) { long io=i*point_offset; LP input; input.phi=y[io]; input.lam=x[io]; // make sure we have appropriate "after" shift file available if(defn.last_after_grid==null|| input.lam<defn.last_after_region.ll_long||input.lam>defn.last_after_region.ur_long|| input.phi<defn.last_after_region.ll_lat||input.phi>defn.last_after_region.ll_lat) { defn.last_after_grid=pj_gc_findgrid(defn.ctx, defn.catalog, true, input, defn.datum_date, ref defn.last_after_region, ref defn.last_after_date); } PJ_GRIDINFO gi=defn.last_after_grid; Debug.Assert(gi.child==null); // load the grid shift info if we don't have it. if(gi.ct.cvs==null&&!pj_gridinfo_load(defn.ctx, gi)) { Proj.pj_ctx_set_errno(defn.ctx, -38); return -38; } LP output_after=nad_cvt(input, inverse, gi.ct); if(output_after.lam==Libc.HUGE_VAL) { if(defn.ctx.debug_level>=PJ_LOG.DEBUG_MAJOR) { Proj.pj_log(defn.ctx, PJ_LOG.DEBUG_MAJOR, "pj_apply_gridshift(): failed to find a grid shift table for"); Proj.pj_log(defn.ctx, PJ_LOG.DEBUG_MAJOR, " location ({0:F7}dW,{1:F7}dN)", x[io]*Proj.RAD_TO_DEG, y[io]*Proj.RAD_TO_DEG); } continue; } if(defn.datum_date==0.0) { y[io]=output_after.phi; x[io]=output_after.lam; continue; } // make sure we have appropriate "before" shift file available if(defn.last_before_grid==null|| input.lam<defn.last_before_region.ll_long||input.lam>defn.last_before_region.ur_long|| input.phi<defn.last_before_region.ll_lat||input.phi>defn.last_before_region.ll_lat) { defn.last_before_grid=pj_gc_findgrid(defn.ctx, defn.catalog, false, input, defn.datum_date, ref defn.last_before_region, ref defn.last_before_date); } gi=defn.last_before_grid; Debug.Assert(gi.child==null); // load the grid shift info if we don't have it. if(gi.ct.cvs==null&&!pj_gridinfo_load(defn.ctx, gi)) { Proj.pj_ctx_set_errno(defn.ctx, -38); return -38; } LP output_before=nad_cvt(input, inverse, gi.ct); if(output_before.lam==Libc.HUGE_VAL) { if(defn.ctx.debug_level>=PJ_LOG.DEBUG_MAJOR) { Proj.pj_log(defn.ctx, PJ_LOG.DEBUG_MAJOR, "pj_apply_gridshift(): failed to find a grid shift table for"); Proj.pj_log(defn.ctx, PJ_LOG.DEBUG_MAJOR, " location ({0:F7}dW,{1:F7}dN)", x[io]*Proj.RAD_TO_DEG, y[io]*Proj.RAD_TO_DEG); } continue; } double mix_ratio=(defn.datum_date-defn.last_before_date)/(defn.last_after_date-defn.last_before_date); y[io]=mix_ratio*output_after.phi+(1.0-mix_ratio)*output_before.phi; x[io]=mix_ratio*output_after.lam+(1.0-mix_ratio)*output_before.lam; } return 0; }
public const int IS_ANAL_CONV = 010; // convergence analytic public static bool pj_factors(LP lp, PJ P, double h, ref FACTORS fac) { IFactors PFac = P as IFactors; const double EPS = 1.0e-12; const double DEFAULT_H = 1e-5; // check for forward and latitude or longitude overange double t = Math.Abs(lp.phi) - Proj.HALFPI; if (t > EPS || Math.Abs(lp.lam) > 10.0) { Proj.pj_ctx_set_errno(P.ctx, -14); return(true); } // proceed Libc.errno = Proj.pj_errno = 0; P.ctx.last_errno = 0; if (h < EPS) { h = DEFAULT_H; } if (Math.Abs(lp.phi) > (Proj.HALFPI - h)) { lp.phi = lp.phi < 0.0?(-Proj.HALFPI + h):(Proj.HALFPI - h); // adjust to value around pi/2 where derived still exists } else if (P.geoc) { lp.phi = Math.Atan(P.rone_es * Math.Tan(lp.phi)); } lp.lam -= P.lam0; // compute del lp.lam if (!P.over) { lp.lam = Proj.adjlon(lp.lam); // adjust del longitude } if (PFac != null) { PFac.spc(lp, ref fac); // get what projection analytic values } if ((fac.code & (IS_ANAL_XL_YL + IS_ANAL_XP_YP)) != (IS_ANAL_XL_YL + IS_ANAL_XP_YP)) { DERIVS der; if (pj_deriv(lp, h, P, out der)) { return(true); } if ((fac.code & IS_ANAL_XL_YL) == 0) { fac.der.x_l = der.x_l; fac.der.y_l = der.y_l; } if ((fac.code & IS_ANAL_XP_YP) == 0) { fac.der.x_p = der.x_p; fac.der.y_p = der.y_p; } } double cosphi = Math.Cos(lp.phi); double r; if ((fac.code & IS_ANAL_HK) == 0) { fac.h = Libc.hypot(fac.der.x_p, fac.der.y_p); fac.k = Libc.hypot(fac.der.x_l, fac.der.y_l) / cosphi; if (P.es != 0) { t = Math.Sin(lp.phi); t = 1.0 - P.es * t * t; double n = Math.Sqrt(t); fac.h *= t * n / P.one_es; fac.k *= n; r = t * t / P.one_es; } else { r = 1.0; } } else if (P.es != 0) { r = Math.Sin(lp.phi); r = 1.0 - P.es * r * r; r = r * r / P.one_es; } else { r = 1.0; } // convergence if ((fac.code & IS_ANAL_CONV) == 0) { fac.conv = -Math.Atan2(fac.der.y_l, fac.der.x_l); if ((fac.code & IS_ANAL_XL_YL) != 0) { fac.code |= IS_ANAL_CONV; } } // areal scale factor fac.s = (fac.der.y_p * fac.der.x_l - fac.der.x_p * fac.der.y_l) * r / cosphi; // meridian-parallel angle theta prime fac.thetap = Proj.aasin(P.ctx, fac.s / (fac.h * fac.k)); // Tissot ellips axis t = fac.k * fac.k + fac.h * fac.h; fac.a = Math.Sqrt(t + 2.0 * fac.s); t = (t = t - 2.0 * fac.s) <= 0.0?0.0:Math.Sqrt(t); fac.b = 0.5 * (fac.a - t); fac.a = 0.5 * (fac.a + t); // omega fac.omega = 2.0 * Proj.aasin(P.ctx, (fac.a - fac.b) / (fac.a + fac.b)); return(false); }
public override PJ Init() { // get name of projection to be translated string name = Proj.pj_param_s(ctx, parameters, "o_proj"); if (name == null || name == "") { Proj.pj_ctx_set_errno(ctx, -26); return(null); } link = Proj.GetPJ(name); if (link == null) { Proj.pj_ctx_set_errno(ctx, -5); return(null); } // copy existing header into new es = 0.0; // force to spherical link.parameters = parameters; link.ctx = ctx; link.over = over; link.geoc = geoc; link.a = a; link.es = es; link.ra = ra; link.lam0 = lam0; link.phi0 = phi0; link.x0 = x0; link.y0 = y0; link.k0 = k0; // force spherical earth link.one_es = link.rone_es = 1.0; link.es = link.e = 0.0; link = link.Init(); if (link == null) { return(null); } double phip = 0; if (Proj.pj_param_t(ctx, parameters, "o_alpha")) { double lamc = Proj.pj_param_r(ctx, parameters, "o_lon_c"); double phic = Proj.pj_param_r(ctx, parameters, "o_lat_c"); double alpha = Proj.pj_param_r(ctx, parameters, "o_alpha"); //if(Math.Abs(phic)<=TOL10||Math.Abs(Math.Abs(phic)-HALFPI)<=TOL10||Math.Abs(Math.Abs(alpha)-HALFPI)<=TOL10) if (Math.Abs(Math.Abs(phic) - Proj.HALFPI) <= TOL) { Proj.pj_ctx_set_errno(ctx, -32); return(null); } lamp = lamc + Proj.aatan2(-Math.Cos(alpha), -Math.Sin(alpha) * Math.Sin(phic)); phip = Proj.aasin(ctx, Math.Cos(phic) * Math.Sin(alpha)); } else if (Proj.pj_param_t(ctx, parameters, "o_lat_p")) { // specified new pole lamp = Proj.pj_param_r(ctx, parameters, "o_lon_p"); phip = Proj.pj_param_r(ctx, parameters, "o_lat_p"); } else { // specified new "equator" points double lam1 = Proj.pj_param_r(ctx, parameters, "o_lon_1"); double phi1 = Proj.pj_param_r(ctx, parameters, "o_lat_1"); double lam2 = Proj.pj_param_r(ctx, parameters, "o_lon_2"); double phi2 = Proj.pj_param_r(ctx, parameters, "o_lat_2"); double con = Math.Abs(phi1); if (Math.Abs(phi1 - phi2) <= TOL || con <= TOL || Math.Abs(con - Proj.HALFPI) <= TOL || Math.Abs(Math.Abs(phi2) - Proj.HALFPI) <= TOL) { Proj.pj_ctx_set_errno(ctx, -33); return(null); } lamp = Math.Atan2(Math.Cos(phi1) * Math.Sin(phi2) * Math.Cos(lam1) - Math.Sin(phi1) * Math.Cos(phi2) * Math.Cos(lam2), Math.Sin(phi1) * Math.Cos(phi2) * Math.Sin(lam2) - Math.Cos(phi1) * Math.Sin(phi2) * Math.Sin(lam1)); phip = Math.Atan(-Math.Cos(lamp - lam1) / Math.Tan(phi1)); } if (Math.Abs(phip) > TOL) { // oblique cphip = Math.Cos(phip); sphip = Math.Sin(phip); fwd = o_forward; inv = link.inv != null?o_inverse:(LP_XY_PJ)null; } else { // transverse fwd = t_forward; inv = link.inv != null?t_inverse:(LP_XY_PJ)null; } return(this); }
public override PJ Init() { // get name of projection to be translated string name=Proj.pj_param_s(ctx, parameters, "o_proj"); if(name==null||name=="") { Proj.pj_ctx_set_errno(ctx, -26); return null; } link=Proj.GetPJ(name); if(link==null) { Proj.pj_ctx_set_errno(ctx, -5); return null; } // copy existing header into new es=0.0; // force to spherical link.parameters=parameters; link.ctx=ctx; link.over=over; link.geoc=geoc; link.a=a; link.es=es; link.ra=ra; link.lam0=lam0; link.phi0=phi0; link.x0=x0; link.y0=y0; link.k0=k0; // force spherical earth link.one_es=link.rone_es=1.0; link.es=link.e=0.0; link=link.Init(); if(link==null) return null; double phip=0; if(Proj.pj_param_t(ctx, parameters, "o_alpha")) { double lamc=Proj.pj_param_r(ctx, parameters, "o_lon_c"); double phic=Proj.pj_param_r(ctx, parameters, "o_lat_c"); double alpha=Proj.pj_param_r(ctx, parameters, "o_alpha"); //if(Math.Abs(phic)<=TOL10||Math.Abs(Math.Abs(phic)-HALFPI)<=TOL10||Math.Abs(Math.Abs(alpha)-HALFPI)<=TOL10) if(Math.Abs(Math.Abs(phic)-Proj.HALFPI)<=TOL) { Proj.pj_ctx_set_errno(ctx, -32); return null; } lamp=lamc+Proj.aatan2(-Math.Cos(alpha), -Math.Sin(alpha)*Math.Sin(phic)); phip=Proj.aasin(ctx, Math.Cos(phic)*Math.Sin(alpha)); } else if(Proj.pj_param_t(ctx, parameters, "o_lat_p")) { // specified new pole lamp=Proj.pj_param_r(ctx, parameters, "o_lon_p"); phip=Proj.pj_param_r(ctx, parameters, "o_lat_p"); } else { // specified new "equator" points double lam1=Proj.pj_param_r(ctx, parameters, "o_lon_1"); double phi1=Proj.pj_param_r(ctx, parameters, "o_lat_1"); double lam2=Proj.pj_param_r(ctx, parameters, "o_lon_2"); double phi2=Proj.pj_param_r(ctx, parameters, "o_lat_2"); double con=Math.Abs(phi1); if(Math.Abs(phi1-phi2)<=TOL||con<=TOL|| Math.Abs(con-Proj.HALFPI)<=TOL||Math.Abs(Math.Abs(phi2)-Proj.HALFPI)<=TOL) { Proj.pj_ctx_set_errno(ctx, -33); return null; } lamp=Math.Atan2(Math.Cos(phi1)*Math.Sin(phi2)*Math.Cos(lam1)-Math.Sin(phi1)*Math.Cos(phi2)*Math.Cos(lam2), Math.Sin(phi1)*Math.Cos(phi2)*Math.Sin(lam2)-Math.Cos(phi1)*Math.Sin(phi2)*Math.Sin(lam1)); phip=Math.Atan(-Math.Cos(lamp-lam1)/Math.Tan(phi1)); } if(Math.Abs(phip)>TOL) { // oblique cphip=Math.Cos(phip); sphip=Math.Sin(phip); fwd=o_forward; inv=link.inv!=null?o_inverse:(Func<XY, LP>)null; } else { // transverse fwd=t_forward; inv=link.inv!=null?t_inverse:(Func<XY, LP>)null; } return this; }
private void AsyncPessoa(string cpf) { try { Task <mPF_Ext> .Factory.StartNew(() => mdata.ExistPessoaFisica(cpf)) .ContinueWith(task => { if (task.IsCompleted) { PF = new ObservableCollection <mCliente>(); PF.Add(new mCliente() { Inscricao = task.Result.CPF, NomeRazao = task.Result.Nome, Telefones = task.Result.Telefones, Email = task.Result.Email }); ListaPJ.Clear(); PJ.Clear(); if (task.Result.ColecaoVinculos.Count < 1) { SomentePF = true; TemEmpresa = Visibility.Visible; } else { SomentePF = false; TemEmpresa = Visibility.Collapsed; } foreach (mVinculos v in task.Result.ColecaoVinculos) { Task <mPJ_Ext> .Factory.StartNew(() => mdata.ExistPessoaJuridica(v.CNPJ)).ContinueWith(task_two => { if (task_two.IsCompleted) { if (task.Result.ColecaoVinculos.Count > 1) { ListaPJ.Add(new mCliente() { Inscricao = task_two.Result.CNPJ, NomeRazao = task_two.Result.RazaoSocial, Telefones = task_two.Result.Telefones, Email = task_two.Result.Email }); ViewListaPJ = Visibility.Visible; } else { PJ = new ObservableCollection <mCliente>(); PJ.Add(new mCliente() { Inscricao = task_two.Result.CNPJ, NomeRazao = task_two.Result.RazaoSocial, Telefones = task_two.Result.Telefones, Email = task_two.Result.Email }); } } }, System.Threading.CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext()); } } }, System.Threading.CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext()); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
// Zones: // // -180 -40 180 // +--------------+-------------------------+ Zones 1,2,9,10,11 & 12: // |1 |2 | Mollweide projection // | | | // +--------------+-------------------------+ Zones 3,4,5,6,7 & 8: // |3 |4 | Sinusoidal projection // | | | // 0 +-------+------+-+-----------+-----------+ // |5 |6 |7 |8 | // | | | | | // +-------+--------+-----------+-----------+ // |9 |10 |11 |12 | // | | | | | // +-------+--------+-----------+-----------+ // -180 -100 -20 80 180 bool SETUP(int n, PJ proj, double x_0, double y_0, double lon_0) { if(proj==null) return false; pj[n-1]=proj.Init(); if(pj[n-1]==null) return false; pj[n-1].x0=x_0; pj[n-1].y0=y_0; pj[n-1].lam0=lon_0; return true; }
public static int pj_apply_vgridshift(PJ defn, string listname, ref PJ_GRIDINFO[] gridlist_p, ref int gridlist_count_p, bool inverse, int point_count, int point_offset, double[] x, double[] y, double[] z) { if (gridlist_p == null) { gridlist_p = pj_gridlist_from_nadgrids(Proj.pj_get_ctx(defn), Proj.pj_param_s(defn.ctx, defn.parameters, listname), out gridlist_count_p); if (gridlist_p == null || gridlist_count_p == 0) { return(defn.ctx.last_errno); } } if (gridlist_p == null || gridlist_count_p == 0) { Proj.pj_ctx_set_errno(defn.ctx, -38); return(-38); } PJ_GRIDINFO[] tables = gridlist_p; defn.ctx.last_errno = 0; for (int i = 0; i < point_count; i++) { int io = i * point_offset; double value = Libc.HUGE_VAL; LP input; input.phi = y[io]; input.lam = x[io]; // keep trying till we find a table that works for (int itable = 0; itable < gridlist_count_p; itable++) { PJ_GRIDINFO gi = tables[itable]; CTABLE ct = gi.ct; double grid_x, grid_y; int grid_ix, grid_iy; // skip tables that don't match our point at all. if (ct.ll.phi > input.phi || ct.ll.lam > input.lam || ct.ll.phi + (ct.lim.phi - 1) * ct.del.phi < input.phi || ct.ll.lam + (ct.lim.lam - 1) * ct.del.lam < input.lam) { continue; } // If we have child nodes, check to see if any of them apply. while (gi.child != null) { PJ_GRIDINFO child = gi.child; for (; child != null; child = child.next) { CTABLE ct1 = child.ct; if (ct1.ll.phi > input.phi || ct1.ll.lam > input.lam || ct1.ll.phi + (ct1.lim.phi - 1) * ct1.del.phi < input.phi || ct1.ll.lam + (ct1.lim.lam - 1) * ct1.del.lam < input.lam) { continue; } break; } // If we didn't find a child then nothing more to do, if (child == null) { break; } // otherwise use the child, first checking it's children. gi = child; ct = child.ct; } // load the grid shift info if we don't have it. if (ct.cvs == null && !pj_gridinfo_load(Proj.pj_get_ctx(defn), gi)) { Proj.pj_ctx_set_errno(defn.ctx, -38); return(-38); } // Interpolation a location within the grid grid_x = (input.lam - ct.ll.lam) / ct.del.lam; grid_y = (input.phi - ct.ll.phi) / ct.del.phi; grid_ix = (int)Math.Floor(grid_x); grid_iy = (int)Math.Floor(grid_y); grid_x -= grid_ix; grid_y -= grid_iy; LP cvs1 = ct.cvs[(grid_ix + grid_iy * ct.lim.lam) / 2]; LP cvs2 = ct.cvs[(grid_ix + (grid_iy + 1) * ct.lim.lam) / 2]; value = cvs1.lam * (1.0 - grid_x) * (1.0 - grid_y) + cvs1.phi * grid_x * (1.0 - grid_y) + cvs2.lam * (1.0 - grid_x) * grid_y + cvs2.phi * grid_x * grid_y; if (Math.Abs(value + 88.8888) < 0.0001) { value = Libc.HUGE_VAL; // nodata? } else { if (inverse) { z[io] -= value; } else { z[io] += value; } } if (value != Libc.HUGE_VAL) { if (debug_count_apply_vgridshift++ < 20) { Proj.pj_log(defn.ctx, PJ_LOG.DEBUG_MINOR, "pj_apply_gridshift(): used {0}", ct.id); } break; } } if (value == Libc.HUGE_VAL) { Proj.pj_log(defn.ctx, PJ_LOG.DEBUG_MAJOR, "pj_apply_vgridshift(): failed to find a grid shift table for\n\t\t\tlocation ({0}dW,{1}dN)", x[io] * Proj.RAD_TO_DEG, y[io] * Proj.RAD_TO_DEG); StringBuilder gridlist = new StringBuilder(); for (int itable = 0; itable < gridlist_count_p; itable++) { PJ_GRIDINFO gi = tables[itable]; if (itable == 0) { gridlist.AppendFormat(" tried: {0}", gi.gridname); } else { gridlist.AppendFormat(",{0}", gi.gridname); } } Proj.pj_log(defn.ctx, PJ_LOG.DEBUG_MAJOR, "{0}", gridlist.ToString()); Proj.pj_ctx_set_errno(defn.ctx, (int)PJD_ERR.GRID_AREA); return((int)PJD_ERR.GRID_AREA); } } return(0); }
//*********************************************************************** //* pj_set_ctx() * //* * //* Note we do not deallocate the old context! * //*********************************************************************** public static void pj_set_ctx(PJ pj, projCtx ctx) { pj.ctx=ctx; }
//*********************************************************************** //* pj_get_ctx() * //*********************************************************************** public static projCtx pj_get_ctx(PJ pj) { return pj.ctx; }
//*********************************************************************** //* pj_set_ctx() * //* * //* Note we do not deallocate the old context! * //*********************************************************************** public static void pj_set_ctx(PJ pj, projCtx ctx) { pj.ctx = ctx; }
public static void gen_cheb(bool inverse, ProjFunc proj, string s, PJ P, int iargc, string[] iargv) { InputFunc input = Proj.dmstor; if (inverse) { input = Libc.strtod; } int errin = 0; projUV low, upp; low.u = low.v = upp.u = upp.v = 0; if (s.Length > 0) { low.u = input(s, out s); } else { errin++; } if (s.Length > 1 && s[0] == ',') { upp.u = input(s.Substring(1), out s); } else { errin++; } if (s.Length > 1 && s[0] == ',') { low.v = input(s.Substring(1), out s); } else { errin++; } if (s.Length > 1 && s[0] == ',') { upp.v = input(s.Substring(1), out s); } else { errin++; } if (errin != 0) { emess(16, "null or absent -T parameters"); } int NU = 15, NV = 15, res = -1; if (s.Length > 1 && s[0] == ',') { s = s.Substring(1); if (s[0] != ',') { res = Libc.strtol(s, out s, 10); } } if (s.Length > 1 && s[0] == ',') { s = s.Substring(1); if (s[0] != ',') { NU = Libc.strtol(s, out s, 10); } } if (s.Length > 1 && s[0] == ',') { s = s.Substring(1); if (s[0] != ',') { NV = Libc.strtol(s, out s, 10); } } bool pwr = s.Length > 0 && s.StartsWith(",P"); Console.WriteLine("#proj_{0}\n#\trun-line:", pwr?"Power":"Chebyshev"); // proj execution audit trail if (iargc > 0) { int n = 0; for (int i = 0; i < iargc; i++) { string arg = iargv[i]; if (arg[0] != '+') { if (n == 0) { Console.Write("#"); n++; } Console.Write(" " + arg); n += arg.Length + 1; if (n > 50) { Console.WriteLine(); n = 0; } } } if (n != 0) { Console.WriteLine(); } } Console.WriteLine("# projection parameters"); Console.WriteLine("#" + P.DescriptionName); Console.WriteLine("#" + P.DescriptionParameters); Console.WriteLine("#" + P.DescriptionType); Console.WriteLine("#" + P.ToProj4String()); if (low.u == upp.u || low.v >= upp.v) { emess(16, "approx. argument range error"); } if (low.u > upp.u) { low.u -= Proj.TWOPI; } if (NU < 2 || NV < 2) { emess(16, "approx. work dimensions ({0} {1}) too small", NU, NV); } projUV resid = new projUV(); Tseries F = mk_cheby(low, upp, Math.Pow(10.0, res) * 0.5, ref resid, proj, NU, NV, pwr); if (F == null) { emess(16, "generation of approx failed\nreason: {0}\n", Proj.pj_strerrno(Libc.errno)); } Console.WriteLine("{0},{1:G12},{2:G12},{3:G12},{4:G12},{5:G12}", inverse?'I':'F', P.lam0 * Proj.RAD_TO_DEG, low.u * (inverse?1.0:Proj.RAD_TO_DEG), upp.u * (inverse?1.0:Proj.RAD_TO_DEG), low.v * (inverse?1.0:Proj.RAD_TO_DEG), upp.v * (inverse?1.0:Proj.RAD_TO_DEG)); string fmt; if (pwr) { fmt = "G15"; } else if (res <= 0) { fmt = string.Format("F{0}", -res + 1); } else { fmt = "F0"; } p_series(F, Console.Out, fmt); Console.WriteLine("# |u,v| sums {0} {1}\n#end_proj_{2}", resid.u, resid.v, pwr?"Power":"Chebyshev"); }
private void AsyncMostrarDados(string _cpf) { try { Task <mAmbulante> .Factory.StartNew(() => mdatacm.GetCAmbulante(_cpf)) .ContinueWith(task => { if (task.IsCompleted) { try { if (task.Result != null) { if (task.Result.Pessoa.Inscricao == _cpf || task.Result.Cadastro == _cpf) { Ambulante = task.Result; PF.Clear(); PJ.Clear(); PF.Add(task.Result.Pessoa); PJ.Add(task.Result.Empresa); DataLicencaView = Ambulante.TemLicenca; if (PJ[0].Inscricao == string.Empty) { SomentePF = true; TemEmpresa = Visibility.Visible; } else { SomentePF = false; TemEmpresa = Visibility.Collapsed; } if (task.Result.Empresa.Inscricao == string.Empty) { PJ.Clear(); } string[] _atv = task.Result.Atividades.Split(';'); foreach (string atv in _atv) { if (atv != string.Empty) { ListaAtividades.Add(new mCNAE() { CNAE = atv.Substring(0, 10), Ocupacao = atv.Remove(0, 13) }); } } if (task.Result.TipoInstalacoes.Contains("TENDA;")) { IsTenda = true; } if (task.Result.TipoInstalacoes.Contains("VEÍCULO;")) { IsVeiculo = true; } if (task.Result.TipoInstalacoes.Contains("CARRINHO;")) { IsCarrinho = true; } if (task.Result.TipoInstalacoes.Contains("TRAILER;")) { IsTrailer = true; } if (task.Result.TipoInstalacoes.Contains("OUTROS")) { IsOutros = true; string input = task.Result.TipoInstalacoes; string[] testing = Regex.Matches(input, @"\[(.+?)\]") .Cast <Match>() .Select(s => s.Groups[1].Value).ToArray(); GetOutros = testing[0]; } string[] _twk = task.Result.PeridoTrabalho.Split('/'); foreach (string wk in _twk) { if (wk != string.Empty) { string[] iwk = wk.Split('-'); ListarTimeWork.Add(new mPeriodos() { Dias = iwk[0].TrimEnd(), Periodos = iwk[1].TrimStart() }); } } ViewInfo = Visibility.Visible; } else { AsyncPessoa(AreaTransferencia.CPF); AsyncEmpresa(AreaTransferencia.CNPJ); } } } catch (Exception ex) { MessageBox.Show(string.Format("Erro '{0}' inesperado, informe o Suporte!", ex.Message), "Sim.Alerta!"); } } }, System.Threading.CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext()); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public static void gen_cheb(bool inverse, ProjFunc proj, string s, PJ P, int iargc, string[] iargv) { InputFunc input=Proj.dmstor; if(inverse) input=Libc.strtod; int errin=0; projUV low, upp; low.u=low.v=upp.u=upp.v=0; if(s.Length>0) low.u=input(s, out s); else errin++; if(s.Length>1&&s[0]==',') upp.u=input(s.Substring(1), out s); else errin++; if(s.Length>1&&s[0]==',') low.v=input(s.Substring(1), out s); else errin++; if(s.Length>1&&s[0]==',') upp.v=input(s.Substring(1), out s); else errin++; if(errin!=0) emess(16, "null or absent -T parameters"); int NU=15, NV=15, res=-1; if(s.Length>1&&s[0]==',') { s=s.Substring(1); if(s[0]!=',') res=Libc.strtol(s, out s, 10); } if(s.Length>1&&s[0]==',') { s=s.Substring(1); if(s[0]!=',') NU=Libc.strtol(s, out s, 10); } if(s.Length>1&&s[0]==',') { s=s.Substring(1); if(s[0]!=',') NV=Libc.strtol(s, out s, 10); } bool pwr=s.Length>0&&s.StartsWith(",P"); Console.WriteLine("#proj_{0}\n#\trun-line:", pwr?"Power":"Chebyshev"); // proj execution audit trail if(iargc>0) { int n=0; for(int i=0; i<iargc; i++) { string arg=iargv[i]; if(arg[0]!='+') { if(n==0) { Console.Write("#"); n++; } Console.Write(" "+arg); n+=arg.Length+1; if(n>50) { Console.WriteLine(); n=0; } } } if(n!=0) Console.WriteLine(); } Console.WriteLine("# projection parameters"); Console.WriteLine("#"+P.DescriptionName); Console.WriteLine("#"+P.DescriptionParameters); Console.WriteLine("#"+P.DescriptionType); Console.WriteLine("#"+P.ToProj4String()); if(low.u==upp.u||low.v>=upp.v) emess(16, "approx. argument range error"); if(low.u>upp.u) low.u-=Proj.TWOPI; if(NU<2||NV<2) emess(16, "approx. work dimensions ({0} {1}) too small", NU, NV); projUV resid=new projUV(); Tseries F=mk_cheby(low, upp, Math.Pow(10.0, res)*0.5, ref resid, proj, NU, NV, pwr); if(F==null) emess(16, "generation of approx failed\nreason: {0}\n", Proj.pj_strerrno(Libc.errno)); Console.WriteLine("{0},{1:G12},{2:G12},{3:G12},{4:G12},{5:G12}", inverse?'I':'F', P.lam0*Proj.RAD_TO_DEG, low.u*(inverse?1.0:Proj.RAD_TO_DEG), upp.u*(inverse?1.0:Proj.RAD_TO_DEG), low.v*(inverse?1.0:Proj.RAD_TO_DEG), upp.v*(inverse?1.0:Proj.RAD_TO_DEG)); string fmt; if(pwr) fmt="G15"; else if(res<=0) fmt=string.Format("F{0}", -res+1); else fmt="F0"; p_series(F, Console.Out, fmt); Console.WriteLine("# |u,v| sums {0} {1}\n#end_proj_{2}", resid.u, resid.v, pwr?"Power":"Chebyshev"); }
public static int pj_apply_vgridshift(PJ defn, string listname, ref PJ_GRIDINFO[] gridlist_p, ref int gridlist_count_p, bool inverse, int point_count, int point_offset, double[] x, double[] y, double[] z) { if(gridlist_p==null) { gridlist_p=pj_gridlist_from_nadgrids(Proj.pj_get_ctx(defn), Proj.pj_param_s(defn.ctx, defn.parameters, listname), out gridlist_count_p); if(gridlist_p==null||gridlist_count_p==0) return defn.ctx.last_errno; } if(gridlist_p==null||gridlist_count_p==0) { Proj.pj_ctx_set_errno(defn.ctx, -38); return -38; } PJ_GRIDINFO[] tables=gridlist_p; defn.ctx.last_errno=0; for(int i=0; i<point_count; i++) { int io=i*point_offset; double value=Libc.HUGE_VAL; LP input; input.phi=y[io]; input.lam=x[io]; // keep trying till we find a table that works for(int itable=0; itable<gridlist_count_p; itable++) { PJ_GRIDINFO gi=tables[itable]; CTABLE ct=gi.ct; double grid_x, grid_y; int grid_ix, grid_iy; // skip tables that don't match our point at all. if(ct.ll.phi>input.phi||ct.ll.lam>input.lam||ct.ll.phi+(ct.lim.phi-1)*ct.del.phi<input.phi||ct.ll.lam+(ct.lim.lam-1)*ct.del.lam<input.lam) continue; // If we have child nodes, check to see if any of them apply. while(gi.child!=null) { PJ_GRIDINFO child=gi.child; for(; child!=null; child=child.next) { CTABLE ct1=child.ct; if(ct1.ll.phi>input.phi||ct1.ll.lam>input.lam||ct1.ll.phi+(ct1.lim.phi-1)*ct1.del.phi<input.phi||ct1.ll.lam+(ct1.lim.lam-1)*ct1.del.lam<input.lam) continue; break; } // If we didn't find a child then nothing more to do, if(child==null) break; // otherwise use the child, first checking it's children. gi=child; ct=child.ct; } // load the grid shift info if we don't have it. if(ct.cvs==null&&!pj_gridinfo_load(Proj.pj_get_ctx(defn), gi)) { Proj.pj_ctx_set_errno(defn.ctx, -38); return -38; } // Interpolation a location within the grid grid_x=(input.lam-ct.ll.lam)/ct.del.lam; grid_y=(input.phi-ct.ll.phi)/ct.del.phi; grid_ix=(int)Math.Floor(grid_x); grid_iy=(int)Math.Floor(grid_y); grid_x-=grid_ix; grid_y-=grid_iy; LP cvs1=ct.cvs[(grid_ix+grid_iy*ct.lim.lam)/2]; LP cvs2=ct.cvs[(grid_ix+(grid_iy+1)*ct.lim.lam)/2]; value=cvs1.lam*(1.0-grid_x)*(1.0-grid_y)+cvs1.phi*grid_x*(1.0-grid_y)+ cvs2.lam*(1.0-grid_x)*grid_y+cvs2.phi*grid_x*grid_y; if(Math.Abs(value+88.8888)<0.0001) value=Libc.HUGE_VAL; // nodata? else { if(inverse) z[io]-=value; else z[io]+=value; } if(value!=Libc.HUGE_VAL) { if(debug_count_apply_vgridshift++<20) Proj.pj_log(defn.ctx, PJ_LOG.DEBUG_MINOR, "pj_apply_gridshift(): used {0}", ct.id); break; } } if(value==Libc.HUGE_VAL) { Proj.pj_log(defn.ctx, PJ_LOG.DEBUG_MAJOR, "pj_apply_vgridshift(): failed to find a grid shift table for\n\t\t\tlocation ({0}dW,{1}dN)", x[io]*Proj.RAD_TO_DEG, y[io]*Proj.RAD_TO_DEG); StringBuilder gridlist=new StringBuilder(); for(int itable=0; itable<gridlist_count_p; itable++) { PJ_GRIDINFO gi=tables[itable]; if(itable==0) gridlist.AppendFormat(" tried: {0}", gi.gridname); else gridlist.AppendFormat(",{0}", gi.gridname); } Proj.pj_log(defn.ctx, PJ_LOG.DEBUG_MAJOR, "{0}", gridlist.ToString()); Proj.pj_ctx_set_errno(defn.ctx, (int)PJD_ERR.GRID_AREA); return (int)PJD_ERR.GRID_AREA; } } return 0; }
//*********************************************************************** //* pj_get_ctx() * //*********************************************************************** public static projCtx pj_get_ctx(PJ pj) { return(pj.ctx); }