예제 #1
0
int KmlRenderer::mergeRasterBuffer(imageObj *image, rasterBufferObj *rb)
{
  assert(rb && rb->type == MS_BUFFER_BYTE_RGBA);
  char *tmpFileName = NULL;
  char *tmpUrl = NULL;
  FILE *tmpFile = NULL;

  tmpFileName = msTmpFile(NULL, MapPath, image->imagepath, "png");
  tmpFile = fopen(tmpFileName,"wb");
  if (tmpFile) {

    if (!aggFormat->vtable)
      msInitializeRendererVTable(aggFormat);

    msSaveRasterBuffer(map,rb,tmpFile,aggFormat);
    tmpUrl = msStrdup( image->imageurl);
    tmpUrl = msStringConcatenate(tmpUrl, (char *)(msGetBasename(tmpFileName)));
    tmpUrl = msStringConcatenate(tmpUrl, ".png");

    createGroundOverlayNode(LayerNode, tmpUrl, currentLayer);
    msFree(tmpFileName);
    msFree(tmpUrl);
    fclose(tmpFile);
    return MS_SUCCESS;
  } else {
    msSetError(MS_IOERR,"Failed to create file for kml overlay","KmlRenderer::mergeRasterBuffer()");
    return MS_FAILURE;
  }
}
예제 #2
0
char* KmlRenderer::lookupSymbolUrl(imageObj *img, symbolObj *symbol, symbolStyleObj *symstyle)
{
    char	symbolHexColor[32];
    /*	
        <Style id="randomColorIcon">
        <IconStyle>
        <color>ff00ff00</color>
        <colorMode>random</colorMode>
        <scale>1.1</scale>
        <Icon>
        <href>http://maps.google.com/mapfiles/kml/pal3/icon21.png</href>
        </Icon>
        </IconStyle>
        </Style>
    */

    sprintf(symbolHexColor,"%02x%02x%02x%02x", symstyle->style->color.alpha, symstyle->style->color.blue,
            symstyle->style->color.green, symstyle->style->color.red);
    snprintf(SymbolName, sizeof(SymbolName), "symbol_%s_%.1f_%s", symbol->name, symstyle->scale, symbolHexColor);

    char *symbolUrl = msLookupHashTable(StyleHashTable, SymbolName);
    if (!symbolUrl)
    {
        char iconFileName[MS_MAXPATHLEN];
        char iconUrl[MS_MAXPATHLEN];

        if (img->imagepath)
        {
            char *tmpFileName = msTmpFile(NULL, MapPath, img->imagepath, "png");
            snprintf(iconFileName, sizeof(iconFileName), "%s", tmpFileName);
            msFree(tmpFileName);
        }
        else
        {
            sprintf(iconFileName, "symbol_%s_%.1f.%s", symbol->name, symstyle->scale, "png");
        }

        if (createIconImage(iconFileName, symbol, symstyle) != MS_SUCCESS)
        {
            char errMsg[512];
            sprintf(errMsg, "Error creating icon file '%s'", iconFileName);
            msSetError(MS_IOERR, errMsg, "KmlRenderer::lookupSymbolStyle()" );
            return NULL;
        }

        if (img->imageurl)
          sprintf(iconUrl, "%s%s.%s", img->imageurl, msGetBasename(iconFileName), "png");
        else
          snprintf(iconUrl, sizeof(iconUrl), "%s", iconFileName);

        hashObj *hash = msInsertHashTable(StyleHashTable, SymbolName, iconUrl);
        symbolUrl = hash->data;
    }

    return symbolUrl;
}