Пример #1
0
geo_pointset_type *  geo_pointset_alloc( bool internal_z) {
  geo_pointset_type * pointset = util_malloc( sizeof * pointset );
  pointset->xcoord = NULL;
  pointset->ycoord = NULL;
  pointset->zcoord = NULL;
  pointset->internal_z = internal_z;
  pointset->size = 0;
  geo_pointset_resize( pointset , INIT_SIZE );
  return pointset;
}
Пример #2
0
void geo_pointset_add_xy( geo_pointset_type * pointset , double x , double y) {
  if (!pointset->internal_z) {
    if (pointset->size == pointset->alloc_size) 
      geo_pointset_resize( pointset , 1 + pointset->alloc_size * 2);
    
    pointset->xcoord[ pointset->size ] = x;
    pointset->ycoord[ pointset->size ] = y;

    pointset->size++;
  } else
    util_abort("%s: can not use function %s for pointsets with internal z.\n",__func__ , __func__);
}
Пример #3
0
void geo_pointset_memcpy( const geo_pointset_type * src, geo_pointset_type * target , bool copy_zdata) {
  if (src->internal_z != target->internal_z)
    util_abort("%s: when copying geo_poitset they must have equal value for internal_z\n", __func__);

  geo_pointset_resize( target , src->size );
  target->size = src->size;
  memcpy( target->xcoord , src->xcoord , src->size * sizeof * src->xcoord);
  memcpy( target->ycoord , src->ycoord , src->size * sizeof * src->ycoord);
  if (copy_zdata) {
    if (src->internal_z)
      memcpy( target->zcoord , src->zcoord , src->size * sizeof * src->zcoord);
    else
      util_abort("%s: can not pass copy_zdata = true for pointset with shared z\n",__func__);
  } else if (target->internal_z) {
    int i;
    for (i=0; i < target->size; i++)
      target->zcoord[i] = 0;
  }
}