[Geomoose-users] Problem in query.php if layer SRS different from map SRS

Brent Fraser bfraser at geoanalytic.com
Sun Jul 26 09:32:56 PDT 2015


Hi Developers (and others),

   While debugging a user's problem with using his data with query.php, 
I see that line 376 in github (or line 420-ish in GM 2.7.1):

     $ext = $queryLayer->getExtent();

then the layer's extent is used for the query a little later:

     $queryLayer->queryByRect($ext);

This fails to find any features since in my case the coordinate systems 
of the map and layer are different, and the queryByrect must be done 
using a rectangle in the MAP's SRS not the LAYER's SRS.  I did a little 
hack to re-project the extent just before the queryByRect:

                     // re-project the layer's extent into the map SRS 
for querying:
                     $map_projection_def = $map->getProjection();
                     $map_projection_obj = 
ms_newProjectionObj($map_projection_def);

                     if($queryLayer->getProjection() != NULL) {
                         $projection = $queryLayer->getProjection();
                     }
                     if($projection != NULL) {
                         # reproject the query shape as available.
                         $projection = ms_newProjectionObj($projection);
                     }
                     if($projection) {
                         $ext->project($projection, $map_projection_obj);
                     }
                     if($DEBUG) {
                         error_log(implode(',', 
array($ext->minx,$ext->miny,$ext->maxx,$ext->maxy)));
                         error_log("<br/>extent for query in map 
SRS.<br/>");
                     }

I thought I would get comments before filing an Issue.

So any comments?

-- 
Best Regards,
Brent Fraser




More information about the Geomoose-users mailing list