[Chameleon-dev] [Bug 1139] [Chameleon - Widget] some widgets have problems with Postgis Layers

bugzilla-daemon at bugzilla.maptools.org bugzilla-daemon at bugzilla.maptools.org
Thu Sep 29 09:57:56 EDT 2005


------- Additional Comments From info at e-geodata.gr  2005-09-29 09:57 -------
Actualy, I think this is a mapserver issue and not a chameleon one. There's no
way to iterate a layer's features. Here's my post to the mapserver users list :

    Hi list,
    I had some problems accessing features from a dynamic postgis layer.
    After some research i discovered that php/mapscript function
    $layer->getShape(tileindex, shapeindex); does not have the expected
    behaviour, at least the one I was expecting :-) . This is not about the
    issue that shapeindex must begin from 1.

    Here is my map file :
            NAME "country"
            STATUS ON
            EXTENT 744723.842 4108421.689 757400.350 4121357.515
            SIZE 400 300
            SHAPEPATH "../data"
            SYMBOLSET "../etc/symbols.sym"
            FONTSET "../etc/fonts.txt"
            IMAGECOLOR 255 255 255
            UNITS METERS
            DEBUG ON
                "wms_title"          "country"
                "wms_srs"            "EPSG:4121"
                "wfs_title"          "country"
                "wfs_onlineresource" ""
                "wfs_srs"            "EPSG:4121"
            IMAGEPATH "/ms4w/tmp/ms_tmp/"
            IMAGEURL "/ms_tmp/"

    Here's my script :

        if (!extension_loaded( "mapscript" ))
            dl ("php_mapscript_46.dll" );

        $map = ms_newMapObj("mapfile.map");

        $layer = ms_newLayerObj($map);
        $layer->set("debug",          MS_ON);
        $layer->set("name",          "postgis_cities_layer");
        $layer->set("connectiontype", MS_POSTGIS);
        $layer->set("connection",    "user=postgres password=qwe123dbname=leros
host=localhost port=5432");
        $layer->set("status",         MS_ON);
        $layer->set("type",           MS_POLYGON);
        $layer->set("sizeunits",      MS_METERS);
        $layer->set("toleranceunits", MS_METERS);
        $layer->set("tolerance",      300);
        $layer->set("template",       "blank.html");
        $layer->set("data",           "the_geom from (SELECT * FROM cities WHERE
gid IN(5,6)) as foo using unique gid using srid=4121)");

        $shp_1 = $layer->getShape(-1, 1);
        $shp_2 = $layer->getShape(-1, 5);

        echo "<pre>";
        echo "</pre>";

        $c = ms_newClassObj($layer);
        $s = ms_newStyleObj($c);
        $s->color->setRGB(255, 0, 0);
        $img = $map->draw();
        $url = $img->saveWebImage();

        echo "<img src=\"$url\" />";

    The image is drawn perfectly.

    print_r($shp_1)  outputs nothing!
    print_r($shp_2) outputs a shape!

    In other words shapeindex in function  $layer->getShape(tileindex,
    shapeindex) corresponds to gid column in the postgis table cities

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.

Please do NOT reply to this email, use the link above instead to 
login to bugzilla and submit your comment. Any email reply to this
address will be lost.

More information about the Chameleon-dev mailing list