Ticket #2526 (closed defect: fixed)

Opened 6 months ago

Last modified 6 months ago

(some) ImageMaps are Empty

Reported by: BobBruce Assigned to: 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)

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 (77.9 kB) - added by BobBruce on 02/26/08 00:44:38.
Repaired version of mapimagemap.c file

Change History

02/26/08 00:44:38 changed by BobBruce

  • attachment mapimagemap.c added.

Repaired version of mapimagemap.c file

03/03/08 14:56:58 changed by dmorissette

  • status changed from new to assigned.
  • description changed.
  • milestone set to 5.0.3 release.

03/03/08 14:57:21 changed by dmorissette

  • description changed.

03/03/08 15:08:51 changed 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).