static void scale(float v[], unsigned long v_len, float min0, float max0, float ysize, float maxamp, float * smin, float * smax, unsigned long * step) { unsigned long i; float d; float a; float k; unsigned long tmp; if (min0==(-1.E+4f)) { min0 = 0.0f; d = max0; if (d<=maxamp) d = maxamp; a = X2C_DIVR(ysize,d); k = 0.0f; } else { d = max0-min0; if (d<=maxamp) d = maxamp; a = X2C_DIVR(ysize*0.9f,d); k = ysize*0.05f; } *step = sfact(d); *smin = min0-X2C_DIVR(k,a); *smax = min0+X2C_DIVR(k,a)+d; tmp = v_len-1; i = 0UL; if (i<=tmp) for (;; i++) { if (v[i]!=(-1.E+4f)) v[i] = (v[i]-min0)*a+k; if (i==tmp) break; } /* end for */ } /* end scale() */
bool CoarsenClasses::itemIsValid( const CoarsenClasses::Data& data_item, const std::shared_ptr<hier::PatchDescriptor>& descriptor) const { bool item_good = true; std::shared_ptr<hier::PatchDescriptor> pd(descriptor); if (!pd) { pd = hier::VariableDatabase::getDatabase()->getPatchDescriptor(); } const tbox::Dimension& dim = pd->getPatchDataFactory(data_item.d_dst)->getDim(); const int dst_id = data_item.d_dst; const int src_id = data_item.d_src; if (dst_id < 0) { item_good = false; TBOX_ERROR("Bad data given to CoarsenClasses...\n" << "`Destination' patch data id invalid (< 0!)" << std::endl); } if (item_good && (src_id < 0)) { item_good = false; TBOX_ERROR("Bad data given to CoarsenClasses...\n" << "`Source' patch data id invalid (< 0!)" << std::endl); } std::shared_ptr<hier::PatchDataFactory> dfact( pd->getPatchDataFactory(dst_id)); std::shared_ptr<hier::PatchDataFactory> sfact( pd->getPatchDataFactory(src_id)); if (item_good && !(sfact->validCopyTo(dfact))) { item_good = false; TBOX_ERROR("Bad data given to CoarsenClasses...\n" << "It is not a valid operation to copy from `Source' patch data \n" << pd->mapIndexToName(src_id) << " to `Destination' patch data " << pd->mapIndexToName(dst_id) << std::endl); } std::shared_ptr<hier::CoarsenOperator> coarsop(data_item.d_opcoarsen); if (item_good && coarsop) { if (coarsop->getStencilWidth(dim) > sfact->getGhostCellWidth()) { item_good = false; TBOX_ERROR("Bad data given to CoarsenClasses...\n" << "Coarsen operator " << coarsop->getOperatorName() << "\nhas larger stencil width than ghost cell width" << "of `Source' patch data" << pd->mapIndexToName(src_id) << "\noperator stencil width = " << coarsop->getStencilWidth(dim) << "\n`Source' ghost width = " << sfact->getGhostCellWidth() << std::endl); } } return item_good; }
extern void aprstat_althist(maptool_pIMAGE * img, aprsdecode_pOPHIST op, char * test, float * way, unsigned long * beacons, unsigned long * msgs, unsigned long * acks, unsigned long * rejs) { char h[256]; char s[256]; float maxalt; float minalt; float alt[5760]; float hdiv; float wdiv; unsigned long markx1; unsigned long markx; unsigned long xc; unsigned long sc; unsigned long x; unsigned long Maxx; struct aprsdecode_DAT dat; float waysum; long markalt; size_t tmp[2]; unsigned long tmp0; *way = 0.0f; *beacons = 0UL; *msgs = 0UL; *acks = 0UL; *rejs = 0UL; if (op==0 || op->frames==0) { *test = 0; return; } Maxx = dynmaxx(8UL, 400UL, 720UL); decodealt(way, beacons, wdiv, rejs, acks, msgs, &dat, alt, &waysum, op, &markalt, &markx1, &markx, 0); if (waysum<0.05f) { *test = 0; /* no altitudes or km */ return; } if (*test) return; X2C_DYNALLOCATE((char **)img,sizeof(struct maptool_PIX), (tmp[0] = Maxx+16UL,tmp[1] = 136U,tmp),2u); useri_debugmem.screens += (*img)->Len1*(*img)->Size1; if (*img==0) { osi_WrStrLn("error image alloc", 18ul); return; } maptool_clr(*img); wdiv = X2C_DIVR((float)(Maxx*8UL-1UL),waysum); decodealt(way, beacons, wdiv, rejs, acks, msgs, &dat, alt, &waysum, op, &markalt, &markx1, &markx, 1); interpol(alt); norm(&hdiv, alt, &maxalt, &minalt); /* FOR x:=0 TO HIGH(alt) DO IF alt[x]>=0.0 THEN WrFixed(alt[x], 3,11) ELSE WrStr(".") END; END; WrStrLn(""); */ /*sc:=VAL(CARDINAL, maxalt-minalt) DIV sfact(FLOAT(maxalt-minalt)); */ sc = sfact(maxalt-minalt); strncpy(s," ",256u); aprsstr_Append(s, 256ul, op->call, 9ul); aprsstr_Append(s, 256ul, " dist=", 7ul); aprsstr_FixToStr(waysum, 2UL, h, 256ul); aprsstr_Append(s, 256ul, h, 256ul); aprsstr_Append(s, 256ul, "km min=", 8ul); aprsstr_IntToStr((long)X2C_TRUNCI(minalt,X2C_min_longint,X2C_max_longint), 1UL, h, 256ul); aprsstr_Append(s, 256ul, h, 256ul); aprsstr_Append(s, 256ul, "m max=", 7ul); aprsstr_IntToStr((long)X2C_TRUNCI(maxalt,X2C_min_longint,X2C_max_longint), 1UL, h, 256ul); aprsstr_Append(s, 256ul, h, 256ul); if (markalt>X2C_min_longint) { aprsstr_Append(s, 256ul, "m curs=", 8ul); aprsstr_IntToStr(markalt, 1UL, h, 256ul); aprsstr_Append(s, 256ul, h, 256ul); } aprsstr_Append(s, 256ul, "m (NN)", 7ul); paper(img, minalt, maxalt, sc, 8UL, Maxx, 120UL, s, 256ul); tmp0 = Maxx+8UL; x = 5UL; if (x<=tmp0) for (;; x++) { setpix(*img, (long)x, 8L, 200L, 1000L, 200L); if (x==tmp0) break; } /* end for */ strncpy(h,"km",256u); if (waysum<5.0f) { waysum = waysum*1000.0f; strncpy(h,"m",256u); } sc = sfact(waysum); hdiv = X2C_DIVR((float)sc*(float)Maxx,waysum); wdiv = 0.0f; xc = 0UL; do { for (x = 5UL; x<=7UL; x++) { setpix(*img, (long)(aprsdecode_trunc(wdiv)+8UL), (long)x, 200L, 1000L, 200L); } /* end for */ if (xc>0UL && aprsdecode_trunc(wdiv)<Maxx-10UL) { num(*img, (long)((aprsdecode_trunc(wdiv)+8UL)-6UL), 8L, (long)xc, h, 256ul); h[0U] = 0; } xc += sc; wdiv = wdiv+hdiv; } while (aprsdecode_trunc(wdiv)<=Maxx); if (markx>0UL) { for (x = 8UL; x<=128UL; x++) { setpix(*img, (long)(markx+8UL), (long)x, 50L, 400L, 500L); } /* end for */ } tmp0 = Maxx*8UL-1UL; x = 0UL; if (x<=tmp0) for (;; x++) { /* draw graph */ addpix(*img, (float)x*0.125f+8.0f, alt[x]+8.0f, 62UL, 62UL, 87UL); if (x==tmp0) break; } /* end for */ } /* end althist() */