Example #1
0
/*
 * Simply draws a label based on the label point and the supplied label object.
 */
int msDrawTextIM(mapObj *map, imageObj* img, pointObj labelPnt, char *string, labelObj *label, double scalefactor)
{
  DEBUG_IF printf("msDrawText<BR>\n");
  if(!string) return(0); /* not errors, just don't want to do anything */
  if(strlen(string) == 0) return(0);
  if(!dxf) return (0);

  if (dxf == 2) {
    im_iprintf (&imgStr, "TEXT\n%d\n%s\n%.0f\n%.0f\n%.0f\n" , matchdxfcolor(label->color), string, labelPnt.x, labelPnt.y, -label->angle);
  } else if (dxf) {
    im_iprintf (&imgStr, "  0\nTEXT\n  1\n%s\n 10\n%f\n 20\n%f\n 30\n0.0\n 40\n%f\n 50\n%f\n 62\n%6d\n  8\n%s\n 73\n   2\n 72\n   1\n" , string, labelPnt.x, labelPnt.y, label->size * scalefactor *100, -label->angle, matchdxfcolor(label->color), lname);
  }
  return(0);
}
Example #2
0
void msImageStartLayerIM(mapObj *map, layerObj *layer, imageObj *image){
DEBUG_IF printf("ImageStartLayerIM\n<BR>");
	free(lname);
	if (layer->name)
		lname = msStrdup(layer->name);
	else
		lname = msStrdup("NONE");
	if (dxf == 2){
		im_iprintf(&layerStr, "LAYER\n%s\n", lname);
	} else if (dxf) {
		im_iprintf(&layerStr,
			"  0\nLAYER\n  2\n%s\n"
			" 70\n  64\n 6\nCONTINUOUS\n", lname);
	}
	lastcolor = -1;
}
Example #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;
}
Example #4
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;
}
Example #5
0
/*
 * Utility function to create a IM image. Returns
 * a pointer to an imageObj structure.
 */
imageObj *msImageCreateIM(int width, int height, outputFormatObj *format,
                          char *imagepath, char *imageurl, double resolution, double defresolution)
{
  imageObj  *image=NULL;
  if (setvbuf(stdout, NULL, _IONBF , 0)) {
    printf("Whoops...");
  };
  DEBUG_IF printf("msImageCreateIM<BR>\n");
  if (width > 0 && height > 0) {
    image = (imageObj *)msSmallCalloc(1,sizeof(imageObj));
    imgStr.string = &(image->img.imagemap);
    imgStr.alloc_size = &(image->size);

    image->format = format;
    format->refcount++;

    image->width = width;
    image->height = height;
    image->imagepath = NULL;
    image->imageurl = NULL;
    image->resolution = resolution;
    image->resolutionfactor = resolution/defresolution;

    if( strcasecmp("ON",msGetOutputFormatOption( format, "DXF", "OFF" )) == 0) {
      dxf = 1;
      im_iprintf(&layerStr, "  2\nLAYER\n 70\n  10\n");
    } else
      dxf = 0;

    if( strcasecmp("ON",msGetOutputFormatOption( format, "SCRIPT", "OFF" )) == 0) {
      dxf = 2;
      im_iprintf(&layerStr, "");
    }

    /* get href formation string options */
    polyHrefFmt = makeFmtSafe(msGetOutputFormatOption
        ( format, "POLYHREF", "javascript:Clicked('%s');"), 1);
    polyMOverFmt = makeFmtSafe(msGetOutputFormatOption
        ( format, "POLYMOUSEOVER", ""), 1);
    polyMOutFmt = makeFmtSafe(msGetOutputFormatOption
        ( format, "POLYMOUSEOUT", ""), 1);
    symbolHrefFmt = makeFmtSafe(msGetOutputFormatOption
        ( format, "SYMBOLHREF", "javascript:SymbolClicked();"), 1);
    symbolMOverFmt = makeFmtSafe(msGetOutputFormatOption
        ( format, "SYMBOLMOUSEOVER", ""), 1);
    symbolMOutFmt = makeFmtSafe(msGetOutputFormatOption
        ( format, "SYMBOLMOUSEOUT", ""), 1);
    /* get name of client-side image map */
    mapName = msGetOutputFormatOption
      ( format, "MAPNAME", "map1" );
    /* should we suppress area declarations with no title? */
    if( strcasecmp("YES",msGetOutputFormatOption( format, "SUPPRESS", "NO" )) == 0) {
      suppressEmpty=1;
    }

    lname = msStrdup("NONE");
    *(imgStr.string) = msStrdup("");
    if (*(imgStr.string)) {
      *(imgStr.alloc_size) =
        imgStr.string_len = strlen(*(imgStr.string));
    } else {
      *(imgStr.alloc_size) =
        imgStr.string_len = 0;
    }
    if (imagepath) {
      image->imagepath = msStrdup(imagepath);
    }
    if (imageurl) {
      image->imageurl = msStrdup(imageurl);
    }

    return image;
  } else {
    msSetError(MS_IMGERR,
               "Cannot create IM image of size %d x %d.",
               "msImageCreateIM()", width, height );
  }
  return image;
}