To get the effective area, we have to check what area a point results in when all smaller areas are eliminated.
235{
236 LWDEBUG(2,
"Entered tune_areas");
237 const double *P1;
238 const double *P2;
239 const double *P3;
240 double area;
241 int go_on=1;
242 double check_order_min_area = 0;
243
245 int i;
246 int current, before_current, after_current;
247
249
251
252
253
254 for (i=0;i<npoints;i++)
255 {
258 }
260
261
263
264
265 for (i=0;i<npoints;i++)
266 {
269 }
270
271
272
273 i=0;
274 while (go_on)
275 {
276
278
279
280 if (i<npoints-avoid_collaps)
282 else
284
286 lwerror(
"Oh no, this is a bug. For some reason the minHeap returned our points in the wrong order. Please file a ticket in PostGIS ticket system, or send a mail at the mailing list.Returned area = %lf, and last area = %lf",ea->
res_arealist[current],check_order_min_area);
287
289
290
291
292
295
298
299
300 if(before_current>0)
301 {
302
304 if(is3d)
306 else
308
311 }
312 if(after_current<npoints-1)
313 {
314 P1=P2;
315 P2=P3;
316
318
319
320 if(is3d)
322 else
324
325
328 }
329
330
333
334
336 go_on=0;
337
338 i++;
339 };
341 return;
342}
static double triarea2d(const double *P1, const double *P2, const double *P3)
Calculate the area of a triangle in 2d.
static void minheap_update(MINHEAP *tree, areanode *arealist, int idx)
The member of the minheap at index idx is changed.
static void destroy_minheap(MINHEAP tree)
static double triarea3d(const double *P1, const double *P2, const double *P3)
Calculate the area of a triangle in 3d space.
static areanode * minheap_pop(MINHEAP *tree, areanode *arealist)
Get a reference to the point with the smallest effective area from the root of the min heap.
static int cmpfunc(const void *a, const void *b)
We create the minheap by ordering the minheap array by the areas in the areanode structs that the min...
static MINHEAP initiate_minheap(int npoints)
#define FLAGS_GET_Z(flags)
#define LWDEBUG(level, msg)
#define LWDEBUGF(level, msg,...)
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
static uint8_t * getPoint_internal(const POINTARRAY *pa, uint32_t n)
areanode * initial_arealist
This structure holds a minheap tree that is used to keep track of what points that has the smallest e...
This structure is placed in an array with one member per point.