[Mapserver-users] Image not visible

Attri, Abhishek aattri at cba.ua.edu
Thu Apr 29 00:41:27 EDT 2004


I saved the new mapfile in the temp directory.  The mapscript code is
not adding any layers and classes, and I still get a blank image.

Here are the three sample codes for the input mapfile, mapscript file,
and the output map file.

*********INPUT Map File************

MAP
    NAME FIRSTMAP
    SIZE 500 500
    STATUS ON
    SYMBOLSET /home/tech/abhi/WWW/ms/symbols/symbols35.sym
    EXTENT -88.50 30.23 -84.88 35.02
    #UNITS MILES
    SHAPEPATH "/home/tech/abhi/WWW/ms/data"

    WEB
        IMAGEPATH "/home/tech/abhi/WWW/tmp/"
        IMAGEURL "/tmp/"
    END

END

*************mapscript************************
<?php

dl('php_mapscript.so');

    $map_path="/home/tech/abhi/WWW/ms/map_files/";
    $map_file="Newcounty.map";
    $map = ms_newMapObj($map_path.$map_file);
    
    $map->{name} = 'Test';
    $map->{status} = MS_ON;
    $map->{height} = 400;
    $map->{width} = 400;
    $map->{interlace} = MS_OFF;
    $map->{transparent} = MS_OFF;
    $map->{shapepath} = "/home/tech/abhi/WWW/ms/data";
    $map->{imagecolor}->{red} = 255;
    $map->{imagecolor}->{green} = 200;
    $map->{imagecolor}->{blue} = 255;
    $ext = ms_newRectObj();
    $ext->{minx} = -88.50;
    $ext->{miny} = 30.23;
    $ext->{maxx} = -84.88;
    $ext->{maxy} = 35.02;
    $map->{extent} = $ext;

        // create layer
        $layer = ms_newLayerObj($map);
        $layer->{name} = "world";
        $layer->{type} = MS_POLYGON;
        $layer->{status} = MS_ON;
        $layer->{data} = "counties";
        $layer->{tolerance} = 10;
            // create class
            $class = ms_newClassObj($layer);
            $class->{status}= MS_ON;
            $class->{name}= "Myclass";
                $style = ms_newStyleObj($class);
                $style->{color}->{red}= 110;
                $style->{color}->{green}= 100;
                $style->{color}->{blue}= 50;

            
                $style->{outlinecolor}->{red}= 200;
                $style->{outlinecolor}->{green}= 200;
                $style->{outlinecolor}->{blue}= 200;

            
                 //$style->{symbol} =0;
            


    //Draw Image
    $i= $map->save("/home/tech/abhi/WWW/tmp/finalTest.map");
    if ($i != -1){
        $image=$map->draw();
        //$map->{imagecolor}= $map->addColor(0,0,255);
        $image_url=$image->saveWebImage();
    }

?>
<HTML>
<HEAD>
<TITLE>Map 1</TITLE>
</HEAD>
<BODY>
<center>
<TABLE>
<TR><td>
<INPUT TYPE=IMaGe name=mapa src=<?php echo $image_url?>>
</td></TR>
</TABLE>
<center>
</BODY>
</HMTL>

========================================================================
==========================================================
output map file in the temp folder


MAP
  EXTENT -88.5 30.23 -84.88 35.02
  IMAGECOLOR 255 255 255
  IMAGETYPE png
  SYMBOLSET "/home/tech/abhi/WWW/ms/symbols/symbols35.sym"
  SHAPEPATH "/home/tech/abhi/WWW/ms/data"
  SIZE 500 500
  STATUS ON
  UNITS METERS
  NAME "FIRSTMAP"

  OUTPUTFORMAT
    NAME png
    MIMETYPE image/png
    DRIVER GD/PNG
    EXTENSION png
    IMAGEMODE PC256
    TRANSPARENT FALSE
  END

  LEGEND
      IMAGECOLOR 255 255 255
    KEYSIZE 20 10
    KEYSPACING 5 5
    LABEL
      SIZE MEDIUM
      TYPE BITMAP
      BUFFER 0
      COLOR 0 0 0
      FORCE FALSE
      MINDISTANCE -1
      MINFEATURESIZE -1
      OFFSET 0 0
      PARTIALS TRUE
      POSITION CC
    END
    POSITION LL
    STATUS OFF
  END

  QUERYMAP
      COLOR 255 255 0
    SIZE -1 -1
    STATUS OFF
    STYLE HILITE
  END

  SCALEBAR
      COLOR 0 0 0
    IMAGECOLOR 255 255 255
    INTERVALS 4
    LABEL
      SIZE MEDIUM
      TYPE BITMAP
      BUFFER 0
      COLOR 0 0 0
      FORCE FALSE
      MINDISTANCE -1
      MINFEATURESIZE -1
      OFFSET 0 0
      PARTIALS TRUE
    END
    POSITION LL
    SIZE 200 3
    STATUS OFF
    STYLE 0
    UNITS MILES
  END

  WEB
    IMAGEPATH "/home/tech/abhi/WWW/tmp/"
    IMAGEURL "/tmp/"
  END

  LAYER
    NAME "(null)"
    SIZEUNITS PIXELS
    STATUS OFF
    TOLERANCE 0
    TOLERANCEUNITS PIXELS
    UNITS METERS
    CLASS
      STYLE
        MAXSIZE 100
        MINSIZE 1
        SIZE 1
        SYMBOL 0
      END
    END
  END

END
=======================================================================


Somebody please help me understand, what I am doing wrong in
implementing such a simple thing.

Thanks a lot..........

Abhishek 




-----Original Message-----
From: Norbert Thieme [mailto:norbert.thieme at ilmenau.baw.de] 
Sent: Tuesday, April 27, 2004 2:22 AM
To: Attri, Abhishek
Subject: Re: [Mapserver-users] Image not visible

Attri, Abhishek schrieb:
> Hi there!
> 
> When I try to use the map->save method, I get the following error:-
> Fatal error: [MapServer Error]: msSaveMap()
> :(/home/tech/abhi/WWW/ms/map_files/filename.map) in
> /home/tech/aattri/public_html/mapExamples/Maptest.php on line --
> 
> I am not able to color the map. It just shows a blank image, probably
> the part that it reads from the map file itself. But the classes that
I
> add through the map script are not displayed. Please help me with
that.
> 
> With thanks a lot...
> 
> Abhishek
> 

I think that the problem with the save function is that you try to put 
it in your mapfile folder. But when I see it right the mapserver has no 
permissions to write in that folder. Simply try to use your mapserver 
temp directory.

Regards,
Norbert






More information about the mapserver-users mailing list