[Chameleon] MapTips future

Pierre Racine racine_pierre at hotmail.com
Mon Aug 29 08:54:20 EDT 2005


Thanks for this quick answer Paul. I appreciate.

My layer definition looks like this:

    LAYER
        NAME pointslayer
        CONNECTIONTYPE postgis
        CONNECTION "bla,bla, bla"
        DATA "geompoint from (SELECT geompoint,evorder,locname,days,oid FROM 
a2_eventpoint(3,3)) AS new_table USING UNIQUE oid USING SRID=4269"
        STATUS DEFAULT
        TYPE polygon
        TRANSPARENCY 50

        PROJECTION
            "init=epsg:4269"
        END

        CLASS
            STYLE
                #OUTLINECOLOR 50 50 50
                COLOR  255 0 0
                COLORRANGE 0 255 0 255 0 0
                DATARANGE 1 70
                RANGEITEM "evorder"
            END
        END
       TEMPLATE "ttt_query.html"
    END

If I look at (and debug using Zend Studio) the piece of code that gets the 
availables fields from the DATA in LayerAttributes.php :

function GetLayerAttributes( $oLayer )
{
    $aszAttributes = array();

    if (//$oLayer->type == MS_LAYER_RASTER &&
        $oLayer->connectiontype == MS_WMS)
    {
        //get the layer name from metadata if possible to avoid the problems
        //with context layers being renamed
        $szLayerName = $oLayer->getMetaData( "wms_name" );
        if ($szLayerName == "")
            $szLayerName = $oLayer->name;

        // get WFS the connection string
        //$szWFSConnection = getWFSConnection( $oLayer->connection, 
$szLayerName );
        $aszInfo = getWFSConnection( $oLayer->connection, $szLayerName );
        $szWFSConnection = $aszInfo['wfs'];

        $szWFSTypeName = "";
        $sep = '';
        // loop and build typename
        foreach( $aszInfo['typename'] as $szTypeName )
        {
            $szWFSTypeName .= $sep.$szTypeName;
            $sep = ',';
        }

        // check for false (meaning no associated WFS)
        if ( $szWFSConnection != "" )
        {
            $szWFSConnection = fixWFSURL( $szWFSConnection, $szWFSTypeName 
);

            // get the attribute types
            $aszAttributes['name'] = $oLayer->name;
            $aszAttributes['index'] = $oLayer->index;
            $aszAttributes['onlineresource'] = $szWFSConnection;
            $aszAttributes['minx'] = "";
            $aszAttributes['miny'] = "";
            $aszAttributes['maxx'] = "";
            $aszAttributes['maxy'] = "";
            $aszAttributes['fields'] = getAttributeTypes( $szWFSConnection.
                        'request=describefeaturetype', $szLayerName );
        }
    }
    elseif ($oLayer->type == MS_LAYER_POINT ||
        $oLayer->type == MS_LAYER_LINE ||
        $oLayer->type == MS_LAYER_POLYGON )
    {

        // process according to layer type
        switch( $oLayer->connectiontype )
        {
            case MS_WFS:
                //get the layer name from metadata if possible to avoid the 
problems
                //with context layers being renamed
                $szLayerName = $oLayer->getMetaData( "wms_name" );
                if ($szLayerName == "")
                    $szLayerName = $oLayer->name;

                // record the connection string
                $szWFSConnection = $oLayer->connection;

                // check the the WFS online resource contains the necessary 
params
                $szWFSConnection = fixWFSURL( $szWFSConnection, $szLayerName 
);

                // get the attribute types
                $aszAttributes['name'] = $oLayer->name;
                $aszAttributes['index'] = $oLayer->index;
                $aszAttributes['onlineresource'] = $szWFSConnection;
                $aszAttributes['minx'] = "";
                $aszAttributes['miny'] = "";
                $aszAttributes['maxx'] = "";
                $aszAttributes['maxy'] = "";
                $aszAttributes['fields'] = getAttributeTypes( 
$szWFSConnection.
                                'request=describefeaturetype', $szLayerName 
);


                break;


            default:
                // open the layer
                $oLayer->open();

                //handle tiled shapefiles correctly, otherwise they don't 
get
                //extents or attributes
                if ($oLayer->connectiontype == MS_TILED_SHAPEFILE ||
                    $oLayer->tileindex != "")
                {
                    //first tile is sufficient, assume that all attributes 
are the same
                    //in every tile (which is reasonable)
                    $nTile = 0;
                }
                else
                {
                    //use -1 in getShape for non-tiled sources
                    $nTile = -1;
                }
                // read the first line of the datasource to get
                // name, index, and fields
                $oShape = $oLayer->getShape($nTile, 0 );
                $aszAttributes['name'] = $oLayer->name;
                $aszAttributes['index'] = $oLayer->index;
                $oRect = $oShape->bounds;
                $aszAttributes['minx'] = $oRect->minx;
                $aszAttributes['miny'] = $oRect->miny;
                $aszAttributes['maxx'] = $oRect->maxx;
                $aszAttributes['maxy'] = $oRect->maxy;

                foreach($oShape->values as $key => $value)
                {
                    $aszAttributes['fields'][$key] = "string";
                }
                break;
        }
    }

    return $aszAttributes;
}

It does not handle Postgres. If I give it a try the "Configure MapTips" 
dialog pop with:

Warning: array_keys(): The first argument should be an array in 
D:\ms4w\apps\chameleon\htdocs\widgets\MapTips\MapTipsPopup.phtml on line 83

Warning: array_keys(): The first argument should be an array in 
D:\ms4w\apps\chameleon\htdocs\widgets\MapTips\MapTipsPopup.phtml on line 83

Warning: array_keys(): The first argument should be an array in 
D:\ms4w\apps\chameleon\htdocs\widgets\MapTips\MapTipsPopup.phtml on line 83

Warning: array_keys(): The first argument should be an array in 
D:\ms4w\apps\chameleon\htdocs\widgets\MapTips\MapTipsPopup.phtml on line 83

...inside. When the layer is of Postgres type, $oShape is null. My 
understanding is that a switch has to be implemented in order to extract the 
availables fields from the DATA declaration.

Am I on the right way?

I would be willing to give it a hand if I don't get lost too early...

Pierre

>From: Paul Spencer <pspencer at dmsolutions.ca>
>To: Pierre Racine <racine_pierre at hotmail.com>
>CC: chameleon at lists.maptools.org
>Subject: Re: [Chameleon] MapTips future
>Date: Mon, 29 Aug 2005 08:03:43 -0400
>
>Pierre,
>
>it should support fields from postgres as is, although I am not sure if I 
>have tried it specifically with postgres.  Are you including all the 
>attributes you want in the sql statement?
>
>I don't plan to enhance it to support jsapi at this moment, if someone has 
>a patch I would be willing to apply it.  JSAPI will probably get an 
>overhaul in 2006.
>
>Cheers
>
>Paul
>
>Pierre Racine wrote:
>>Hi,
>>
>>MapTips is a great, though a bit complex, widget. I have been playing with 
>>it a bit and I was wondering if:
>>
>>1) it will be expanded to support fields from Postgres? Right now it seems 
>>to support only Shapefile and WMS.
>>
>>2) support CWCJSAPI so that when we Zoom In/Out/Pan the imagemap gets 
>>updated properly?
>>
>>Is there any plan to do this?
>>
>>Thanks,
>>
>>Pierre
>>
>>
>>_______________________________________________
>>Chameleon mailing list
>>Chameleon at lists.maptools.org
>>http://lists.maptools.org/mailman/listinfo/chameleon
>>
>
>--
>+-----------------------------------------------------------------+
>|Paul Spencer                           pspencer at dmsolutions.ca   |
>+-----------------------------------------------------------------+
>|Applications & Software Development                              |
>|DM Solutions Group Inc                 http://www.dmsolutions.ca/|
>+-----------------------------------------------------------------+




More information about the Chameleon mailing list