Ticket #2526 (closed defect: fixed)

Opened 5 years ago

Last modified 5 years ago

(some) ImageMaps are Empty

Reported by: BobBruce Owned by: dmorissette
Priority: normal Milestone: 5.0.3 release
Component: MapServer C Library Version: 4.10
Severity: normal Keywords: imagemap
Cc:

Description (last modified by dmorissette) (diff)

I am trying to generate imagemaps of point symbols on my map and am finding that as soon as my map has large amount of point symbols on it the imagemap becomes empty except for the beginning and closing map statements. The imagemap for maps with a small amount of symbols are generated perfectly well.

I reported this to the mapserver-dev list under the subject "Is there a size limit on ImageMaps?, and if so can I increase it?" on February 24, 2008 and Daniel Morisette responded with a fix for MapServer 5. Here is his fix:

--- mapimagemap.c       (revision 7396)
+++ mapimagemap.c       (working copy)
@@ -2029,7 +2029,7 @@
                {
                    snprintf(workbuffer, sizeof(workbuffer), "%s", 
img->img.imagemap+iIndice );
                    workbuffer[nSize-1] = '\0';
-                  msIO_fprintf(stream, workbuffer);
+                  msIO_fwrite(workbuffer, strlen(workbuffer), 1, stream);
                    iIndice +=nSize-1;
                }
                if (iIndice < size)
@@ -2039,7 +2039,7 @@
                }
            }
            else
-            msIO_fprintf(stream, img->img.imagemap);
+              msIO_fwrite(img->img.imagemap, size, 1, stream);
           if( strcasecmp("OFF",msGetOutputFormatOption( format, 
"SKIPENDTAG", "OFF" )) == 0){
                   if (dxf == 2)
                           msIO_fprintf(stream, "END");

Since I was working with MapServer 4.10.2 I had to figure out how to implement it for that version, here are my comments as per the posting to the list:

I located the old code in function msSaveImageIM and it now reads like this:

	  } else {
	    msIO_fprintf(stream, "<map name=\"%s\" width=\"%d\" height=\"%d\">\n", mapName, img->width, img->height);
    	  }
/* BB - 25 Feb 2009 - next 2 lines */
	  /* msIO_fprintf(stream, img->img.imagemap); */
      msIO_fwrite(img->img.imagemap, strlen(img->img.imagemap), 1, stream);
	  if( strcasecmp("OFF",msGetOutputFormatOption( format, "SKIPENDTAG", "OFF" )) == 0){
		  if (dxf == 2)
			  msIO_fprintf(stream, "END");
		  else if (dxf)
			  msIO_fprintf(stream, "0\nENDSEC\n0\nEOF\n");
		  else 
/* BB - 25 Feb 2009 - next 2 lines */
			  /* msIO_fprintf(stream, "</map>"); */
              msIO_fwrite("</map>", 6, 1, stream);

and now the imagemap is fixed on my website. I have attached my new version of mapimagemap.c

Bob Bruce

Attachments

mapimagemap.c Download (77.9 KB) - added by BobBruce 5 years ago.
Repaired version of mapimagemap.c file

Change History

Changed 5 years ago by BobBruce

Repaired version of mapimagemap.c file

Changed 5 years ago by dmorissette

  • status changed from new to assigned
  • description modified (diff)
  • milestone set to 5.0.3 release

Changed 5 years ago by dmorissette

  • description modified (diff)

Changed 5 years ago by dmorissette

  • status changed from assigned to closed
  • resolution set to fixed

Fixed by using msIO_fwrite() instead of msIO_fprintf() to output the imagemap as per the proposed patch above, in branch-5-0 (r7425) and trunk (r7426).

Note: See TracTickets for help on using tickets.