Beispiel #1
0
int msCopySymbolSet(symbolSetObj *dst, symbolSetObj *src, mapObj *map)
{
  int i, return_value;

  MS_COPYSTRING(dst->filename, src->filename);

  dst->map = map;
  dst->fontset = &(map->fontset);

  /* Copy child symbols */
  for (i = 0; i < src->numsymbols; i++) {
    if (msGrowSymbolSet(dst) == NULL)
      return MS_FAILURE;
    return_value = msCopySymbol(dst->symbol[i], src->symbol[i], map);
    if (return_value != MS_SUCCESS) {
      msSetError(MS_MEMERR,"Failed to copy symbol.","msCopySymbolSet()");
      return(MS_FAILURE);
    }
    dst->numsymbols++;
  }

  /* MS_COPYSTELEM(imagecachesize); */

  /* I have a feeling that the code below is not quite right - Sean */
  /*copyProperty(&(dst->imagecache), &(src->imagecache),
               sizeof(struct imageCacheObj));
   */

  dst->imagecachesize = 0; /* since we are not copying the cache set the cache  to NUNLL and the size to 0 (bug 1521) */
  dst->imagecache = NULL;

  return(MS_SUCCESS);
}
Beispiel #2
0
/*
 ** msRotateSymbol - Clockwise rotation of a symbol definition. Contributed
 ** by MapMedia, with clean up by SDL. Currently only type VECTOR and PIXMAP
 ** symbols are handled.
 */
symbolObj *msRotateVectorSymbol(symbolObj *symbol, double angle)
{
  double angle_rad=0.0;
  double cos_a, sin_a;
  double minx=0.0, miny=0.0, maxx=0.0, maxy=0.0;
  symbolObj *newSymbol = NULL;
  double dp_x, dp_y, xcor, ycor;
  double TOL=0.00000000001;
  int i;

  /* assert(symbol->type == MS_SYMBOL_VECTOR); */

  newSymbol = (symbolObj *) malloc(sizeof(symbolObj));
  msCopySymbol(newSymbol, symbol, NULL); /* TODO: do we really want to do this for all symbol types? */

  angle_rad = (MS_DEG_TO_RAD*angle);


  sin_a = sin(angle_rad);
  cos_a = cos(angle_rad);

  dp_x = symbol->sizex * .5; /* get the shift vector at 0,0 */
  dp_y = symbol->sizey * .5;

  /* center at 0,0 and rotate; then move back */
  for( i=0; i < symbol->numpoints; i++) {
    /* don't rotate PENUP commands (TODO: should use a constant here) */
    if ((symbol->points[i].x == -99.0) || (symbol->points[i].x == -99.0) ) {
      newSymbol->points[i].x = -99.0;
      newSymbol->points[i].y = -99.0;
      continue;
    }

    newSymbol->points[i].x = dp_x + ((symbol->points[i].x-dp_x)*cos_a - (symbol->points[i].y-dp_y)*sin_a);
    newSymbol->points[i].y = dp_y + ((symbol->points[i].x-dp_x)*sin_a + (symbol->points[i].y-dp_y)*cos_a);
  }

  /* get the new bbox of the symbol, because we need it to get the new dimensions of the new symbol */
  get_bbox(newSymbol->points, newSymbol->numpoints, &minx, &miny, &maxx, &maxy);
  if ( (fabs(minx)>TOL) || (fabs(miny)>TOL) ) {
    xcor = minx*-1.0; /* symbols always start at 0,0 so get the shift vector */
    ycor = miny*-1.0;
    for( i=0; i < newSymbol->numpoints; i++) {
      if ((newSymbol->points[i].x == -99.0) || (newSymbol->points[i].x == -99.0))
        continue;
      newSymbol->points[i].x = newSymbol->points[i].x + xcor;
      newSymbol->points[i].y = newSymbol->points[i].y + ycor;
    }

    /* update the bbox to get the final dimension values for the symbol */
    get_bbox(newSymbol->points, newSymbol->numpoints, &minx, &miny, &maxx, &maxy);
  }

  newSymbol->sizex = maxx;
  newSymbol->sizey = maxy;
  return newSymbol;
}
Beispiel #3
0
symbolObj* rotateVectorSymbolPoints(symbolObj *symbol, double angle_rad)
{
    double dp_x, dp_y, xcor, ycor;
    double sin_a, cos_a;
    double minx,miny,maxx,maxy;
    symbolObj *newSymbol;
    double TOL=0.00000000001;
    int i;

    angle_rad = -angle_rad;

    newSymbol = (symbolObj *) msSmallMalloc(sizeof(symbolObj));
    msCopySymbol(newSymbol, symbol, NULL);

    sin_a = sin(angle_rad);
    cos_a = cos(angle_rad);

    dp_x = symbol->sizex * .5; /* get the shift vector at 0,0 */
    dp_y = symbol->sizey * .5;

    /* center at 0,0 and rotate; then move back */
    for( i=0; i < symbol->numpoints; i++) {
        /* don't rotate PENUP commands (TODO: should use a constant here) */
        if ((symbol->points[i].x == -99.0) && (symbol->points[i].y == -99.0) ) {
            newSymbol->points[i].x = -99.0;
            newSymbol->points[i].y = -99.0;
            continue;
        }

        newSymbol->points[i].x = dp_x + ((symbol->points[i].x-dp_x)*cos_a - (symbol->points[i].y-dp_y)*sin_a);
        newSymbol->points[i].y = dp_y + ((symbol->points[i].x-dp_x)*sin_a + (symbol->points[i].y-dp_y)*cos_a);
    }

    /* get the new bbox of the symbol, because we need it to get the new dimensions of the new symbol */
    get_bbox(newSymbol->points, newSymbol->numpoints, &minx, &miny, &maxx, &maxy);
    if ( (fabs(minx)>TOL) || (fabs(miny)>TOL) ) {
        xcor = minx*-1.0; /* symbols always start at 0,0 so get the shift vector */
        ycor = miny*-1.0;
        for( i=0; i < newSymbol->numpoints; i++) {
            if ((newSymbol->points[i].x == -99.0) && (newSymbol->points[i].y == -99.0))
                continue;
            newSymbol->points[i].x = newSymbol->points[i].x + xcor;
            newSymbol->points[i].y = newSymbol->points[i].y + ycor;
        }

        /* update the bbox to get the final dimension values for the symbol */
        get_bbox(newSymbol->points, newSymbol->numpoints, &minx, &miny, &maxx, &maxy);
    }
    newSymbol->sizex = maxx;
    newSymbol->sizey = maxy;
    return newSymbol;
}