Home| general |src.lib|map| MapPlotPolygon Index

MapPlotPolygon

Syntax
void MapPlotPolygon(struct Rplot *rplot,struct RplotMatrix *matrix, float x,float y,float w,float h,int fill, unsigned int color,unsigned char mask, float width,struct RplotDash *dash, struct PolygonData *poly,int type);
Header
general/rmap.h
Library
map
Description

The MapPlotPolygon function plots sets of polygons.

The argument rplot is a pointer to the Rplot control structure that handles the plotting. The argument matrix is an optional transformation matrix that can be applied to the polygons. If this is set to a NULL pointer then no transformation is applied. The position at which the polygons are plotted and the size of the plot are given by the arguments x, y, w and h. The coordinates of the polygons data are assumed to be normalized between zero and (1). The x-coordinate is multiplied by w and the y-coordinate by h and then offset given by x and y are applied.

If the argument fill is set to a non-zero value then the polygons will be plotted as solid shapes, not outlines.

The color used to plot the polygon is given by the color which is a 32-bit number that represents the alpha,red,green and blue components of the color as 8-bit number. The alpha channel occupies the most significant bits and the blue channel occupies the least significant bits. The argument mask defines which color channels are active. Setting this argument to 0x0f will output the color to all four channels. The most significant bit controls the alpha channel and the least significant bit controls the blue channel.

The width of the line used to plot the polygons is controlled using the argument width, a value of zero will plot a hairline. The dot-dash pattern used to plot the polygon is given by dash. If this is set to a NULL pointer, a solid line is plotted.

The argument poly points to the polygon data to plot. Only polygons whose type code matches the argument type are plotted.

Returns
None
Errors
None
Example



Source Code: MapPlotPolygon.c

/* MapPlotPolygon.c
   ===============
   Author: R.J.Barnes
 Copyright (c) 2012 The Johns Hopkins University/Applied Physics Laboratory

This file is part of the Radar Software Toolkit (RST).

RST is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.

Modifications:




#include <stdio.h>
#include <stdlib.h>
#include "rtypes.h"
#include "rxml.h"
#include "option.h"
#include "rfbuffer.h"
#include "rplot.h"
#include "polygon.h"
#include "rmap.h"

struct PolygonData *map;
struct PolygonData *nmap;
struct PolygonData *pmap;

struct PolygonData *clip;

int stream(char *buf,int sze,void *data) {
  FILE *fp;
  fp=(FILE *) data;
  fwrite(buf,sze,1,stdout);
  return 0;
} 

int main(int argc,char *argv[]) {

  struct Rplot *rplot=NULL;

  float wdt=400,hgt=400;

  unsigned int bgcol=0xffffffff;
  unsigned int lndcol=0xffa0ffa0;
  unsigned int seacol=0xffa0a0ff;
 
  MapTransform  tfunc;
  float marg[3];
  
  char *envstr;
  FILE *mapfp;

  envstr=getenv("MAPDATA");

  mapfp=fopen(envstr,"r");
  map=MapFread(mapfp);
  fclose(mapfp);   

  marg[0]=90.0;
  marg[1]=0.0;
  marg[2]=1.0;

  tfunc=MapStereographic;

  clip=MapCircleClip(10); 

  nmap=PolygonTransform(map,2*sizeof(float),PolygonXYbbox,
                        tfunc,marg);

  pmap=PolygonClip(clip,nmap); 
 
  rplot=RplotMake();
  RplotSetText(rplot,stream,stdout);  
  RplotMakeDocument(rplot,"MapPlotPolygon","1",wdt,hgt,24);
  RplotMakePlot(rplot,"MapPlotPolygon",wdt,hgt,24);

  RplotRectangle(rplot,NULL,0,0,wdt,hgt,
                  1,bgcol,0x0f,0,NULL);
  RplotEllipse(rplot,NULL,wdt/2,hgt/2,wdt/2,hgt/2,
                  1,seacol,0x0f,0,NULL);

  MapPlotPolygon(rplot,NULL,0,0,wdt,hgt,1,lndcol,0x0f,0,NULL,
                   pmap,1);

  MapPlotPolygon(rplot,NULL,0,0,wdt,hgt,1,lndcol,0x0f,0,NULL,
                   pmap,3);
  
  MapPlotPolygon(rplot,NULL,0,0,wdt,hgt,1,seacol,0x0f,0,NULL,
                   pmap,0);



  RplotEndPlot(rplot);
  RplotEndDocument(rplot);
  return 0;
}