struct PolygonData *make_fov(double tval,struct RadarNetwork *network, int id) { double rho,lat,lon; int i,rn,bm; float pnt[2]; int yr,mo,dy,hr,mt; double sc; int frang=180; int rsep=45; struct PolygonData *ptr=NULL; struct RadarSite *site=NULL; TimeEpochToYMDHMS(tval,&yr,&mo,&dy,&hr,&mt,&sc); ptr=PolygonMake(sizeof(float)*2,NULL); for (i=0;i<network->rnum;i++) { if (network->radar[i].status !=1) continue; if (network->radar[i].id==id) continue; site=RadarYMDHMSGetSite(&(network->radar[i]),yr,mo,dy,hr,mt,(int) sc); if (site==NULL) continue; PolygonAddPolygon(ptr,1); for (rn=0;rn<=site->maxrange;rn++) { RPosGeo(0,0,rn,site,frang,rsep, site->recrise,0,&rho,&lat,&lon); pnt[0]=lat; pnt[1]=lon; PolygonAdd(ptr,pnt); } for (bm=1;bm<=site->maxbeam;bm++) { RPosGeo(0,bm,site->maxrange,site,frang,rsep, site->recrise,0,&rho,&lat,&lon); pnt[0]=lat; pnt[1]=lon; PolygonAdd(ptr,pnt); } for (rn=site->maxrange-1;rn>=0;rn--) { RPosGeo(0,site->maxbeam,rn,site,frang,rsep, site->recrise,0,&rho,&lat,&lon); pnt[0]=lat; pnt[1]=lon; PolygonAdd(ptr,pnt); } for (bm=site->maxbeam-1;bm>0;bm--) { RPosGeo(0,bm,0,site,frang,rsep, site->recrise,0,&rho,&lat,&lon); pnt[0]=lat; pnt[1]=lon; PolygonAdd(ptr,pnt); } } return ptr; }
struct PolygonData *make_grid(float lonspc,float latspc) { struct PolygonData *ptr=NULL; float lat,lon,l; float pnt[2]; ptr=PolygonMake(2*sizeof(float),NULL); if (ptr==NULL) return NULL; for (lat=-90+latspc;lat<90-latspc;lat+=latspc) { for (lon=0;lon<360;lon+=lonspc) { PolygonAddPolygon(ptr,1); pnt[0]=lat; pnt[1]=lon; PolygonAdd(ptr,pnt); for (l=1;l<=latspc;l+=1) { pnt[0]=lat+l; PolygonAdd(ptr,pnt); } pnt[0]=lat+latspc; for (l=0;l<=lonspc;l+=1) { pnt[1]=lon+l; PolygonAdd(ptr,pnt); } pnt[1]=lon+lonspc; for (l=1;l<=latspc;l+=1) { pnt[0]=lat+latspc-l; PolygonAdd(ptr,pnt); } pnt[0]=lat; for (l=1;l<lonspc;l+=1) { pnt[1]=lon+lonspc-l; PolygonAdd(ptr,pnt); } } } return ptr; }
struct PolygonData *MapSquareClip() { int n=4; int i; float p[]={0,0, 1,0, 1,1, 0,1}; struct PolygonData *clip; clip=PolygonMake(2*sizeof(float),PolygonXYbbox); if (clip==NULL) return NULL; PolygonAddPolygon(clip,1); for (i=0;i<n;i++) PolygonAdd(clip,&p[2*i]); return clip; }
struct PolygonData *MapCircleClip(float step) { float p[2],r; struct PolygonData *clip; clip=PolygonMake(2*sizeof(float),PolygonXYbbox); if (clip==NULL) return NULL; PolygonAddPolygon(clip,1); if (step<1) step=1; if (step>45) step=45; for (r=0;r<360;r+=step) { p[0]=0.5+0.5*cosd(r); p[1]=0.5+0.5*sind(r); PolygonAdd(clip,p); } return clip; }
int main(int argc,char *argv[]) { struct Rplot *rplot=NULL; float wdt=400,hgt=400; unsigned int bgcol=0xffffffff; unsigned int fgcol=0xff000000; int i,j,k; int type; float pnt[2]; float *ptr; poly=PolygonMake(sizeof(float)*2,PolygonXYbbox); PolygonAddPolygon(poly,1); pnt[0]=0.1; pnt[1]=0.1; PolygonAdd(poly,pnt,0); pnt[0]=0.9; pnt[1]=0.1; PolygonAdd(poly,pnt,0); pnt[0]=0.9; pnt[1]=0.9; PolygonAdd(poly,pnt,0); pnt[0]=0.1; pnt[1]=0.9; PolygonAdd(poly,pnt,0); PolygonAddPolygon(poly,2); pnt[0]=0.2; pnt[1]=0.2; PolygonAdd(poly,pnt,0); pnt[0]=0.8; pnt[1]=0.2; PolygonAdd(poly,pnt,0); pnt[0]=0.5; pnt[1]=0.4; PolygonAdd(poly,pnt,0); pnt[0]=0.5; pnt[1]=0.6; PolygonAdd(poly,pnt,1); pnt[0]=0.8; pnt[1]=0.8; PolygonAdd(poly,pnt,0); pnt[0]=0.2; pnt[1]=0.8; PolygonAdd(poly,pnt,0); rplot=RplotMake(); RplotSetText(rplot,stream,stdout); RplotMakePlot(rplot,"MapPlotPolygon",wdt,hgt,24); RplotRectangle(rplot,NULL,0,0,wdt,hgt, 1,bgcol,0x0f,0,NULL); for (i=0;i<poly->polnum;i++) { type=PolygonReadType(poly,i); if (type==1) fgcol=RplotColor(255,0,0,255); if (type==2) fgcol=RplotColor(0,255,0,255); k=0; for (j=0;j<poly->num[i];j++) { if (PolygonReadOp(poly,i,j) !=0) { if (k !=0) RplotPolygon(rplot,NULL,0,0,k,fx,fy,t, 0,fgcol,0x0f,2,NULL); k=0; } ptr=(float *) PolygonRead(poly,i,j); fx[k]=ptr[0]*wdt; fy[k]=ptr[1]*hgt; t[k]=0; k++; } if (k !=0) RplotPolygon(rplot,NULL,0,0,k,fx,fy,t, 0,fgcol,0x0f,2,NULL); } RplotEndPlot(rplot); return 0; }
int main(int argc,char *argv[]) { struct Rplot *rplot=NULL; float wdt=400,hgt=400; unsigned int bgcol=0xffffffff; unsigned int fgcol=0xff000000; int i,j; float x; float pnt[2]; float *ptr; poly=PolygonMake(sizeof(float)*2,PolygonXYbbox); for (x=0.4;x>0.1;x-=0.1) { PolygonAddPolygon(poly,1); pnt[0]=0.5-x; pnt[1]=0.5-x; PolygonAdd(poly,pnt,0); pnt[0]=0.5-x; pnt[1]=0.5+x; PolygonAdd(poly,pnt,0); pnt[0]=0.5+x; pnt[1]=0.5+x; PolygonAdd(poly,pnt,0); pnt[0]=0.5+x; pnt[1]=0.5-x; PolygonAdd(poly,pnt,0); } copy=PolygonCopy(poly); PolygonFree(poly); rplot=RplotMake(); RplotSetText(rplot,stream,stdout); RplotMakeDocument(rplot,"PolygonCopy","1",wdt,hgt,24); RplotMakePlot(rplot,"PolygonCopy",wdt,hgt,24); RplotRectangle(rplot,NULL,0,0,wdt,hgt, 1,bgcol,0x0f,0,NULL); for (i=0;i<copy->polnum;i++) { fgcol=RplotColor(239-i*16,239-i*16,239-i*16,255); for (j=0;j<copy->num[i];j++) { ptr=(float *) PolygonRead(copy,i,j); fx[j]=ptr[0]*wdt; fy[j]=ptr[1]*hgt; t[j]=0; } RplotPolygon(rplot,NULL,0,0,copy->num[i],fx,fy,t, 1,fgcol,0x0f,0,NULL); } RplotEndPlot(rplot); RplotEndDocument(rplot); return 0; }
struct PolygonData *SZATerminator(int yr,int mo,int dy,int hr,int mt,int sc, int flg,int mode,float step, float zenith) { double cval[1]={102}; struct PolygonData **ctr; struct PolygonData *trm=NULL; if (zenith !=0) cval[0]=zenith; if (flg==0) { struct PolygonData *ptr=NULL; float pp[2],lon; float *p,*o; int n; int asc=0; int dsc=0; int num; ctr=SZAContour(yr,mo,dy,hr,mt,sc,0,mode,step,1,cval); ptr=ctr[0]; num=ptr->num[0]; trm=PolygonMake(sizeof(float)*2,NULL); PolygonAddPolygon(trm,1); p=PolygonRead(ptr,0,0); PolygonAdd(trm,p); PolygonAddPolygon(trm,2); for (n=1;n<num;n++) { o=PolygonRead(ptr,0,n-1); p=PolygonRead(ptr,0,n); PolygonAdd(trm,p); if ((o[0]<0) && (p[0]>0)) asc=n; if ((o[0]>0) && (p[0]<0)) dsc=n; } trm=PolygonMake(sizeof(float)*2,NULL); n=asc; PolygonAddPolygon(trm,2); p=PolygonRead(ptr,0,n); lon=SZARound(p[1]); if (lon>=180) lon-=360; while (n !=dsc) { p=PolygonRead(ptr,0,n); PolygonAdd(trm,p); n++; if (n>=num) n=0; } pp[0]=0; pp[1]=p[1]; PolygonAdd(trm,pp); pp[1]=SZARound(p[1]); do { PolygonAdd(trm,pp); pp[1]--; if (pp[1]<-180) pp[1]+=360; } while (pp[1] != lon); p=PolygonRead(ptr,0,n); lon=SZARound(p[1]); if (lon>=180) lon-=180; PolygonAddPolygon(trm,2); while (n !=asc) { p=PolygonRead(ptr,0,n); PolygonAdd(trm,p); n++; if (n>=num) n=0; } pp[0]=0; pp[1]=p[1]; PolygonAdd(trm,pp); pp[1]=SZARound(p[1]); do { PolygonAdd(trm,pp); pp[1]++; if (pp[1]>=180) pp[1]-=360; } while (pp[1] != lon); ContourFree(1,ctr); } else { int num,n=0; float *p; struct PolygonData *ptr=NULL; ctr=SZAContour(yr,mo,dy,hr,mt,sc,flg,mode,step,1,cval); ptr=ctr[0]; num=ptr->num[0]; trm=PolygonMake(sizeof(float)*2,NULL); PolygonAddPolygon(trm,1); for (n=0;n<num;n++) { p=PolygonRead(ptr,0,n); PolygonAdd(trm,p); } PolygonAddPolygon(trm,2); for (n=0;n<num;n++) { p=PolygonRead(ptr,0,n); PolygonAdd(trm,p); } ContourFree(1,ctr); } return trm; }
int main(int argc,char *argv[]) { struct Rplot *rplot=NULL; float wdt=400,hgt=400; unsigned int bgcol=0xffffffff; unsigned int fgcol=0xff000000; int i,j; int type; float pnt[2]; float *ptr; float arg[1]; poly=PolygonMake(sizeof(float)*2,PolygonXYbbox); PolygonAddPolygon(poly,1); pnt[0]=0.1; pnt[1]=0.1; PolygonAdd(poly,pnt,0); pnt[0]=0.9; pnt[1]=0.1; PolygonAdd(poly,pnt,0); pnt[0]=0.9; pnt[1]=0.9; PolygonAdd(poly,pnt,0); pnt[0]=0.1; pnt[1]=0.9; PolygonAdd(poly,pnt,0); PolygonAddPolygon(poly,2); pnt[0]=0.2; pnt[1]=0.5; PolygonAdd(poly,pnt,0); pnt[0]=0.5; pnt[1]=0.2; PolygonAdd(poly,pnt,0); pnt[0]=0.8; pnt[1]=0.5; PolygonAdd(poly,pnt,0); pnt[0]=0.5; pnt[1]=0.8; PolygonAdd(poly,pnt,0); arg[0]=30.0; npoly=PolygonTransform(poly,sizeof(float)*2,PolygonXYbbox,rotate,arg); rplot=RplotMake(); RplotSetText(rplot,stream,stdout); RplotMakeDocument(rplot,"PolygonTransform","1",wdt,hgt,24); RplotMakePlot(rplot,"PolygonTransform",wdt,hgt,24); RplotRectangle(rplot,NULL,0,0,wdt,hgt, 1,bgcol,0x0f,0,NULL); for (i=0;i<npoly->polnum;i++) { type=PolygonReadType(npoly,i); if (type==1) fgcol=RplotColor(255,0,0,255); if (type==2) fgcol=RplotColor(0,255,0,255); for (j=0;j<npoly->num[i];j++) { ptr=(float *) PolygonRead(npoly,i,j); fx[j]=ptr[0]*wdt; fy[j]=ptr[1]*hgt; t[j]=0; } RplotPolygon(rplot,NULL,0,0,npoly->num[i],fx,fy,t, 1,fgcol,0x0f,0,NULL); } RplotEndPlot(rplot); RplotEndDocument(rplot); return 0; }