Beispiel #1
0
void computeSymbolStyle(symbolStyleObj *s, styleObj *src, symbolObj *symbol, double scalefactor,
    double resolutionfactor)
{
  double default_size;
  double target_size;
  double style_size;

  default_size = msSymbolGetDefaultSize(symbol);
  style_size = (src->size==-1)?default_size:src->size;

  INIT_SYMBOL_STYLE(*s);
  if(symbol->type == MS_SYMBOL_PIXMAP) {
    s->color = s->outlinecolor = NULL;
  } else if(symbol->filled || symbol->type == MS_SYMBOL_TRUETYPE) {
    if(MS_VALID_COLOR(src->color))
      s->color = &src->color;
    if(MS_VALID_COLOR(src->outlinecolor))
      s->outlinecolor = &src->outlinecolor;
  } else {
    if(MS_VALID_COLOR(src->color))
      s->outlinecolor = &(src->color);
    else if(MS_VALID_COLOR(src->outlinecolor))
      s->outlinecolor = &(src->outlinecolor);
    s->color = NULL;
  }


  if(MS_VALID_COLOR(src->backgroundcolor)) {
    s->backgroundcolor = &(src->backgroundcolor);
  }

  target_size = style_size * scalefactor;
  target_size = MS_MAX(target_size, src->minsize*resolutionfactor);
  target_size = MS_MIN(target_size, src->maxsize*resolutionfactor);
  s->scale = target_size / default_size;
  s->gap = src->gap * target_size / style_size;

  if(s->outlinecolor) {
    s->outlinewidth =  src->width * scalefactor;
    s->outlinewidth = MS_MAX(s->outlinewidth, src->minwidth*resolutionfactor);
    s->outlinewidth = MS_MIN(s->outlinewidth, src->maxwidth*resolutionfactor);
  } else {
    s->outlinewidth = 0;
  }

  s->rotation = src->angle * MS_DEG_TO_RAD;
}
Beispiel #2
0
/* ------------------------------------------------------------------------- */
void msDrawMarkerSymbolIM(mapObj *map, imageObj* img, pointObj *p, styleObj *style, double scalefactor)
{
  symbolObj *symbol;
  int ox, oy;
  double size;

  DEBUG_IF printf("msDrawMarkerSymbolIM\n<BR>");

  /* skip this, we don't do text */



  if(!p) return;


  if(style->symbol > map->symbolset.numsymbols || style->symbol < 0) return; /* no such symbol, 0 is OK */
  symbol = map->symbolset.symbol[style->symbol];
  ox = style->offsetx*scalefactor;
  oy = style->offsety*scalefactor;
  if(style->size == -1) {
    size = msSymbolGetDefaultSize( symbol );
    size = MS_NINT(size*scalefactor);
  } else
    size = MS_NINT(style->size*scalefactor);
  size = MS_MAX(size, style->minsize*img->resolutionfactor);
  size = MS_MIN(size, style->maxsize*img->resolutionfactor);

  if(size < 1) return; /* size too small */

  /* DEBUG_IF printf(".%d.%d.%d.", symbol->type, style->symbol, fc); */
  if(style->symbol == 0) { /* simply draw a single pixel of the specified color */

    if (dxf) {
      if (dxf==2)
        im_iprintf (&imgStr, "POINT\n%.0f %.0f\n%d\n",
                    p->x + ox, p->y + oy, matchdxfcolor(style->color));
      else
        im_iprintf (&imgStr,
                    "  0\nPOINT\n 10\n%f\n 20\n%f\n 30\n0.0\n"
                    " 62\n%6d\n  8\n%s\n",
                    p->x + ox, p->y + oy, matchdxfcolor(style->color), lname);
    } else {
      im_iprintf (&imgStr, "<area ");
      if (strcmp(symbolHrefFmt,"%.s")!=0) {
        im_iprintf (&imgStr, "href=\"");
        im_iprintf (&imgStr, symbolHrefFmt, lname);
        im_iprintf (&imgStr, "\" ");
      }
      if (strcmp(symbolMOverFmt,"%.s")!=0) {
        im_iprintf (&imgStr, "onMouseOver=\"");
        im_iprintf (&imgStr, symbolMOverFmt, lname);
        im_iprintf (&imgStr, "\" ");
      }
      if (strcmp(symbolMOutFmt,"%.s")!=0) {
        im_iprintf (&imgStr, "onMouseOut=\"");
        im_iprintf (&imgStr, symbolMOutFmt, lname);
        im_iprintf (&imgStr, "\" ");
      }
      im_iprintf (&imgStr, "shape=\"circle\" coords=\"%.0f,%.0f, 3\" />\n",
                  p->x + ox, p->y + oy);
    }

    /* point2 = &( p->line[j].point[i] ); */
    /* if(point1->y == point2->y) {} */
    return;
  }
  DEBUG_IF printf("A");
  switch(symbol->type) {
    case(MS_SYMBOL_TRUETYPE):
      DEBUG_IF printf("T");
      break;
    case(MS_SYMBOL_PIXMAP):
      DEBUG_IF printf("P");
      break;
    case(MS_SYMBOL_VECTOR):
      DEBUG_IF printf("V");
      {
        double d, offset_x, offset_y;

        d = size/symbol->sizey;
        offset_x = MS_NINT(p->x - d*.5*symbol->sizex + ox);
        offset_y = MS_NINT(p->y - d*.5*symbol->sizey + oy);

        /* For now I only render filled vector symbols in imagemap, and no */
        /* dxf support available yet.  */
        if(symbol->filled && !dxf /* && fc >= 0 */ ) {
          /* char *title=(p->numvalues) ? p->values[0] : ""; */
          char *title = "";
          int  j;

          im_iprintf (&imgStr, "<area ");
          if (strcmp(symbolHrefFmt,"%.s")!=0) {
            im_iprintf (&imgStr, "href=\"");
            im_iprintf (&imgStr, symbolHrefFmt, lname);
            im_iprintf (&imgStr, "\" ");
          }
          if (strcmp(symbolMOverFmt,"%.s")!=0) {
            im_iprintf (&imgStr, "onMouseOver=\"");
            im_iprintf (&imgStr, symbolMOverFmt, lname);
            im_iprintf (&imgStr, "\" ");
          }
          if (strcmp(symbolMOutFmt,"%.s")!=0) {
            im_iprintf (&imgStr, "onMouseOut=\"");
            im_iprintf (&imgStr, symbolMOutFmt, lname);
            im_iprintf (&imgStr, "\" ");
          }

          im_iprintf (&imgStr, "title=\"%s\" shape=\"poly\" coords=\"", title);

          for(j=0; j < symbol->numpoints; j++) {
            im_iprintf (&imgStr, "%s %d,%d", j == 0 ? "": ",",
                        MS_NINT(d*symbol->points[j].x + offset_x),
                        MS_NINT(d*symbol->points[j].y + offset_y) );
          }
          im_iprintf (&imgStr, "\" />\n");
        } /* end of imagemap, filled case. */
      }
      break;

    default:
      DEBUG_IF printf("DEF");
      break;
  } /* end switch statement */

  return;
}
Beispiel #3
0
/* ------------------------------------------------------------------------- */
void msDrawShadeSymbolIM(mapObj *map, imageObj* img, shapeObj *p, styleObj *style, double scalefactor)
{
  symbolObj *symbol;
  int i,j,l;
  char first = 1;
  double size;

  DEBUG_IF printf("msDrawShadeSymbolIM\n<BR>");
  if(!p) return;
  if(p->numlines <= 0) return;

  symbol = map->symbolset.symbol[style->symbol];
  if(style->size == -1) {
    size = msSymbolGetDefaultSize( symbol );
    size = MS_NINT(size*scalefactor);
  } else
    size = MS_NINT(style->size*scalefactor);
  size = MS_MAX(size, style->minsize*img->resolutionfactor);
  size = MS_MIN(size, style->maxsize*img->resolutionfactor);

  if (suppressEmpty && p->numvalues==0) return;/* suppress area with empty title */
  if(style->symbol == 0) { /* simply draw a single pixel of the specified color //     */
    for(l=0,j=0; j<p->numlines; j++) {
      if (dxf == 2) {
        im_iprintf (&imgStr, "POLY\n%d\n", matchdxfcolor(style->color));
      } else if (dxf) {
        im_iprintf (&imgStr, "  0\nPOLYLINE\n 73\n     1\n 62\n%6d\n  8\n%s\n", matchdxfcolor(style->color), lname);
      } else {
        char *title=(p->numvalues) ? p->values[0] : "";
        first = 1;
        im_iprintf (&imgStr, "<area ");
        if (strcmp(polyHrefFmt,"%.s")!=0) {
          im_iprintf (&imgStr, "href=\"");
          im_iprintf (&imgStr, polyHrefFmt, title);
          im_iprintf (&imgStr, "\" ");
        }
        if (strcmp(polyMOverFmt,"%.s")!=0) {
          im_iprintf (&imgStr, "onMouseOver=\"");
          im_iprintf (&imgStr, polyMOverFmt, title);
          im_iprintf (&imgStr, "\" ");
        }
        if (strcmp(polyMOutFmt,"%.s")!=0) {
          im_iprintf (&imgStr, "onMouseOut=\"");
          im_iprintf (&imgStr, polyMOutFmt, title);
          im_iprintf (&imgStr, "\" ");
        }
        im_iprintf (&imgStr, "title=\"%s\" shape=\"poly\" coords=\"", title);
      }

      /* point1 = &( p->line[j].point[p->line[j].numpoints-1] ); */
      for(i=0; i < p->line[j].numpoints; i++,l++) {
        if (dxf == 2) {
          im_iprintf (&imgStr, "%.0f %.0f\n", p->line[j].point[i].x, p->line[j].point[i].y);
        } else if (dxf) {
          im_iprintf (&imgStr, "  0\nVERTEX\n 10\n%f\n 20\n%f\n 30\n%f\n", p->line[j].point[i].x, p->line[j].point[i].y, 0.0);
        } else {
          im_iprintf (&imgStr, "%s %.0f,%.0f", first ? "": ",", p->line[j].point[i].x, p->line[j].point[i].y);
        }
        first = 0;

        /* point2 = &( p->line[j].point[i] ); */
        /* if(point1->y == point2->y) {} */
      }
      im_iprintf (&imgStr, dxf ? (dxf == 2 ? "": "  0\nSEQEND\n") : "\" />\n");
    }

    return;
  }
  /* DEBUG_IF printf ("d"); */
  DEBUG_IF printf("-%d-",symbol->type);
  return;
}
Beispiel #4
0
/*
** Returns the size, in pixels, of a marker symbol defined by a specific style and scalefactor. Used for annotation
** layer collision avoidance. A marker is made up of a number of styles so the calling code must either do the looping
** itself or call this function for the bottom style which should be the largest.
*/
int msGetMarkerSize(symbolSetObj *symbolset, styleObj *style, double *width, double *height, double scalefactor)
{
  rectObj rect;
  int size;
  symbolObj *symbol;
  *width = *height = 0; /* set a starting value */

  if(style->symbol > symbolset->numsymbols || style->symbol < 0) return(MS_FAILURE); /* no such symbol, 0 is OK */

  if(style->symbol == 0) { /* single point */
    *width = 1;
    *height = 1;
    return(MS_SUCCESS);
  }

  symbol = symbolset->symbol[style->symbol];
  if (symbol->type == MS_SYMBOL_PIXMAP && !symbol->pixmap_buffer) {
    if (MS_SUCCESS != msPreloadImageSymbol(MS_MAP_RENDERER(symbolset->map), symbol))
      return MS_FAILURE;
  }
  if(symbol->type == MS_SYMBOL_SVG && !symbol->renderer_cache) {
#ifdef USE_SVG_CAIRO
    if(MS_SUCCESS != msPreloadSVGSymbol(symbol))
      return MS_FAILURE;
#else
    msSetError(MS_SYMERR, "SVG symbol support is not enabled.", "msGetMarkerSize()");
    return MS_FAILURE;
#endif
  }
  if(style->size == -1) {
    size = ( msSymbolGetDefaultSize(symbol) * scalefactor );
  } else
    size = (style->size*scalefactor);
  size = MS_MAX(size, style->minsize);
  size = MS_MIN(size, style->maxsize);

  switch(symbol->type) {

    case(MS_SYMBOL_TRUETYPE):
      if(msGetTruetypeTextBBox(MS_MAP_RENDERER(symbolset->map),symbol->font,symbolset->fontset,size,symbol->character,&rect,NULL,0) != MS_SUCCESS)
        return(MS_FAILURE);

      *width = MS_MAX(*width, rect.maxx - rect.minx);
      *height = MS_MAX(*height, rect.maxy - rect.miny);

      break;

    case(MS_SYMBOL_PIXMAP):
      if(size == 1) {
        *width = MS_MAX(*width, symbol->pixmap_buffer->width);
        *height = MS_MAX(*height, symbol->pixmap_buffer->height);
      } else {
        *width = MS_MAX(*width, (((double)size/(double)symbol->pixmap_buffer->height) * symbol->pixmap_buffer->width));
        *height = MS_MAX(*height, size);
      }
      break;
    default: /* vector and ellipses, scalable */
      if(style->size > 0) {
        *width = MS_MAX(*width, ((size/symbol->sizey) * symbol->sizex));
        *height = MS_MAX(*height, size);
      } else { /* use symbol defaults */
        *width = MS_MAX(*width, symbol->sizex);
        *height = MS_MAX(*height, symbol->sizey);
      }
      break;
  }

  return(MS_SUCCESS);
}