48 static int GEO_aggregate_lw(
49 int const lwmask_count[],
118 if(lwmask_count[
EPHEMERAL] > lwmask_sum / 2)
128 if(shallow > *
water/2)
130 if(inland > *
water/2)
135 if(inland > *
water/2)
140 if(shallow > *
water/2)
153 double ecr_sc_sample_position[][3],
154 double terrain_sample_position[][
MAX_PADDED][3],
158 double terrain_frame_position[][
MAX_FRAMES][3],
241 char filefunc[] = __FILE__
", GEO_aggregate";
242 char msgbuf[PGS_SMF_MAX_MSGBUF_SIZE];
244 if(!sample_flags || !ecr_sample_position || !ecr_sc_sample_position ||
245 !terrain_sample_position || !ecr_frame_position ||
246 !terrain_frame_position || !frame_flags || !ecr_sc_frame_position ||
250 sprintf(msgbuf,
"sample_flags:%p ecr_sample_position:%p\n"
251 "ecr_sc_sample_position:%p terrain_sample_position:%p\n"
252 "sample_quality:%p ecr_frame_position:%p\n"
253 "terrain_frame_position:%p frame_flags:%p\n"
254 "ecr_sc_frame_position:%p hires_offsets:%p frame_quality:%p",
255 (
void*)sample_flags, (
void*)ecr_sample_position,
256 (
void*)ecr_sc_sample_position, (
void*)terrain_sample_position,
257 (
void*)sample_quality, (
void*)ecr_frame_position,
258 (
void*)terrain_frame_position, (
void*)frame_flags,
259 (
void*)ecr_sc_frame_position, (
void*)hires_offsets,
260 (
void*)frame_quality);
266 for(frame = 0; frame < EV_frames; frame++)
270 memcpy(ecr_sc_frame_position[frame],
271 ecr_sc_sample_position[N_samp * (frame + 1) - 1],
272 sizeof *ecr_sc_frame_position);
276 frame_quality[efat][frame] = sample_quality[frame*N_samp][efat];
278 for(off=1; off < 2*N_samp-1; off++)
279 frame_quality[efat][frame] |=
280 sample_quality[frame*N_samp+off][efat];
286 PGSt_double posecr[3];
289 for(ind = 0; ind < 3; ind++)
290 ecr_frame_position[det][frame][ind] = 0.0;
291 frame_flags[det][frame] = 0;
295 frame_flags[det][frame] = sample_flags[det][frame];
296 memcpy( ecr_frame_position[det][frame],
297 ecr_sample_position[det][frame],
298 sizeof ecr_frame_position[det][frame]);
299 memcpy( terrain_frame_position[det][frame],
300 terrain_sample_position[det][frame],
301 sizeof terrain_frame_position[det][frame]);
305 for(idet = N_samp*det; idet < N_samp*(det+1); idet++)
307 for(off = 0; off < 2*N_samp-1; off++)
314 static const double weight[4][7]= {
316 {1.0/8.0, 2.0/8.0, 1.0/8.0},
317 {1.0/27.0, 2.0/27.0, 3.0/27.0, 2.0/27.0, 1.0/27.0},
318 {1.0/64.0, 2.0/64.0, 3.0/64.0, 4.0/64.0, 3.0/64.0,
323 frame_flags[det][frame] |=
324 sample_flags[idet][frame*N_samp+off];
327 if(sample_landsea[idet][frame*N_samp+off] <
NUM_LWMASK)
328 lwmask_count[sample_landsea[idet][frame*N_samp+off]]
329 += (
int)(N_samp*N_samp*N_samp*weight[N_samp-1][off]);
332 for(ind = 0; ind < 3; ind++)
333 ecr_frame_position[det][frame][ind] +=
334 weight[N_samp-1][off] *
335 ecr_sample_position[idet][frame*N_samp+off][ind];
339 height += weight[N_samp-1][off]*
340 terrain_sample_position[idet][frame*N_samp+off][
HT_IDX];
345 frame_landsea[det][frame] = GEO_aggregate_lw(lwmask_count,
346 frame_waterpresent[det]+frame);
350 for(ind = 0; ind < 3; ind++)
355 for(ind = 0; ind < 3; ind++)
356 posecr[ind] = ecr_frame_position[det][frame][ind];
359 &altitude) != PGS_S_SUCCESS)
373 terrain_frame_position[det][frame][
HT_IDX] = height;
377 posecr) != PGS_S_SUCCESS)
383 for(ind = 0; ind < 3; ind++)
384 ecr_frame_position[det][frame][ind] = posecr[ind];
387 terrain_frame_position[det][frame][
HT_IDX]
397 for(frame = 0; frame < EV_frames; frame++)
403 if(frame_landsea[det][frame] ==
DRYLAND)
405 int min_det = det - 1;
406 int max_det = det + 2;
407 int min_frame = frame - 1;
408 int max_frame = frame + 2;
417 else if(max_frame > EV_frames)
418 max_frame = EV_frames;
420 for(d=min_det; d<max_det; d++)
424 for(
f=min_frame;
f<max_frame;
f++)
426 if(frame_waterpresent[d][
f])
428 frame_landsea[det][frame] =
COAST;
441 for(frame=0; frame<EV_frames; frame++)
445 if(frame_quality[efat][frame] & (uint32)PGSd_NO_DATA)
446 frame_quality[efat][frame] = (uint32)PGSd_NO_DATA;
456 if(N_samp > 1 &&
GEO_hires(N_samp, N_samp * EV_frames + N_samp - 1,
457 hires_scale, terrain_sample_position, ecr_sample_position,
458 ecr_frame_position, sample_flags, frame_flags, hires_offsets)
461 sprintf(msgbuf,
"GEO_hires(%d, %d, %f)", (
int)N_samp,
462 (
int)(N_samp * EV_frames + N_samp - 1), hires_scale);
468 return PGS_S_SUCCESS;