2 * The author of this software is Shane O'Sullivan.  
\r 
   3 * Permission to use, copy, modify, and distribute this software for any
\r 
   4 * purpose without fee is hereby granted, provided that this entire notice
\r 
   5 * is included in all copies of any software which is or includes a copy
\r 
   6 * or modification of this software and in all copies of the supporting
\r 
   7 * documentation for such software.
\r 
   8 * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
\r 
   9 * WARRANTY.  IN PARTICULAR, NEITHER THE AUTHORS NOR AT&T MAKE ANY
\r 
  10 * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
\r 
  11 * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
\r 
  19 #include "VoronoiDiagramGenerator.h"
\r 
  23 int main(int argc, char **argv) 
\r 
  25         double xmin, xmax, ymin, ymax;
\r 
  26         scanf("%lf %lf %lf %lf", &xmin, &xmax, &ymin, &ymax) ;
\r 
  28         SourcePoint * sites;
\r 
  32         sites = (SourcePoint *) malloc(4000 * sizeof(SourcePoint));
\r 
  33         while (scanf("%d %lf %lf %lf", &sites[nsites].id, &sites[nsites].weight, &sites[nsites].x, &sites[nsites].y) != EOF)
\r 
  36                 if (nsites % 4000 == 0) {
\r 
  37                         sites = (SourcePoint *)realloc(sites,(nsites+4000)*sizeof(SourcePoint));
\r 
  41         VoronoiDiagramGenerator * pvdg;
\r 
  42         pvdg = new VoronoiDiagramGenerator();
\r 
  43         pvdg->generateVoronoi(sites, nsites, xmin, xmax, ymin, ymax, 0);
\r 
  45 //      printf("sites %ld\n-------------------------------\n", nsites);
\r 
  46         PolygonPoint* pSitePoints;
\r 
  47         int numpoints, i, j;
\r 
  48         for(i = 0; i < nsites; i++)
\r 
  50                 pvdg->getSitePoints(i, &numpoints, &pSitePoints);
\r 
  53                         printf("-- no points for %d\n", i);
\r 
  59                         printf("update temp_child_4076440_0 set resultgeom = st_setsrid('POLYGON((");
\r 
  60                         for(j = 0; j < numpoints; j++)
\r 
  62                                 printf("%.15lf %.15lf,", pSitePoints[j].coord.x, pSitePoints[j].coord.y, (pSitePoints[j].angle/M_PI)*180);
\r 
  64                         printf("%.15lf %.15lf", pSitePoints[0].coord.x, pSitePoints[0].coord.y, (pSitePoints[j].angle/M_PI)*180);
\r 
  65                         printf("))'::geometry,4326) where id = %d;\n", sites[i].id);
\r 
  71 //      printf("sites %ld\n-------------------------------\n", nsites);
\r 
  72         pvdg->resetIterator();
\r 
  73         while(pvdg->getNext(x1,y1,x2,y2))
\r 
  75                 printf("(%f %f,%f %f)\n",x1,y1,x2, y2);
\r