[Chameleon-dev] [Bug 1277] ExtractWFSData: assumes geometry attribute is called Name

bugzilla-daemon at bugzilla.maptools.org bugzilla-daemon at bugzilla.maptools.org
Tue Feb 7 04:38:16 EST 2006


http://bugzilla.maptools.org/show_bug.cgi?id=1277





------- Additional Comments From bartvde at xs4all.nl  2006-02-07 04:38 -------
The problem here is that the spatial filter is built before the $szWFSConnection
and $szTypeName are known. Also, there should be some shared file for building
the filters, as now this widget and the ExpressionBuilder widget duplicate the code.

Proposed changes (although it could be done in a nicer more generic way):

1. remove condition for checking the $szWFSConnection since we need it already
when building the spatial filter:
                // get the connection info only if extracting
                //if ( isset( $_FORM["txtExtract"] ) && $_FORM["txtExtract"] == 1 )
                if (true)

2. determine the name of the spatial attribute:

if ( strlen( $nSelectedLayer ) > 0 )
{
    // get layer
    $oLayer = $oMapSession->oMap->getLayer( $nSelectedLayer );

    // bartvde, get the attribute types, we need $szWFSConnection and
$szTypeName for that

    // check last char for ? or &
    if ( substr( $szWFSConnection, -1 ) != "?" && substr( $szWFSConnection, -1 )
!= "&" )
    {
      // check for ?
      if ( strpos( $szWFSConnection, "?" ) === false )
      {
        $szWFSConnection .= "?";
      }
      else
        $szWFSConnection .= "&";
    }

    // get the type name
    if ( isset( $aszWFSConnection['typename'] ) )
    {
      $szTypeName =  '';
      foreach( $aszWFSConnection['typename'] as $szCurrentTypeName )
      {
        $szTypeName .= $szCurrentTypeName.',';
      }
      // remove final ','
      if ( substr( $szTypeName, -1, 1 ) == ',' )
      {
        $szTypeName = substr( $szTypeName, 0, -1 );
      }
    }
    else
    {
      $szTypeName = $szSelectedLayerName;
    }
    $aszAttributes = getAttributeTypes( $szWFSConnection.
                            'request=DescribeFeatureType', $szTypeName );

    foreach( $aszAttributes as $key=>$value )
    {
        if (strpos($value, "gml:") !== false)
        {
            $szGeometryAttribute = $key;
       }
    }

    // build new spacial filter for current ROI or extent
    $szSpacialFilter = buildSpacialFilterString( $oMapSession->oMap, $oLayer,
$szGeometryAttribute );

3. add parameter to buildSpacialFilterString:

function buildSpacialFilterString( $oMap, $oLayer, $szGeometryAttribute )
{

                    $szThisBbox = buildRectFilter( $szTmpROI['aGeoCoords'],
                                                            $szProjection,
$szGeometryAttribute );

..
        $szBbox = buildRectFilter(
                    array( $oMap->extent->minx,
                           $oMap->extent->miny,
                           $oMap->extent->maxx,
                           $oMap->extent->maxy ),
                    $szProjection, $szGeometryAttribute );

4. add parameter to buildRectFilter etc. and use in the filter

function buildRectFilter( $adCoords, $szProjection, $szGeometryAttribute )
{
     return '<BBOX><PropertyName>'.$szGeometryAttribute.'</PropertyName>'.
                "<gml:Box srsName='".$szProjection."'><coordinates>".
                $adCoords[0].','.
                $adCoords[1].' '.
                $adCoords[2].','.
                $adCoords[3].
                '</coordinates></gml:Box></BBOX>';
}




------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.


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