Opened 12 years ago
Last modified 12 years ago
#4245 new defect
$rectObj->project() function very slow in MS 6
Reported by: | armin | Owned by: | aboudreault |
---|---|---|---|
Priority: | high | Milestone: | 6.2 release |
Component: | MapScript-PHP | Version: | 6.0 |
Severity: | normal | Keywords: | |
Cc: | bounds, rect, project |
Description
For layer query results I need to extract the bounding box of the features found with the query. I use the function
$bounds = $shpObj->bounds;
If map and layer projection are different it is necessary to reproject the bounds rectangle returned for the shapes of a layer to the projection of the map. This is applied with
$bounds->project($inProjObj, $outProjObj);
This works fine with MapServer 5.6, the projection does not cause the query to take noticeably more time than without projection. In MapServer 6 however the project() call causes a huge overhead. Just as a comparison:
a result for a point layer returned via $layer->queryByRect(), number of results = 996 records, takes the following time when applying the project() on every shape of the query result:
So MS 6 takes more than 200 times longer. If the project() call is disabled MS 6 is as fast as MS 5.6.
I attached the script that I use for the testing. The time measuring needs PEAR Benchmark package installed. I will add also a zip with map file and test shapefile.
Used environment is: Ubuntu 10.04-64, MapServer compiled from source.
Attachments (2)
Change History (6)
by , 12 years ago
Attachment: | projectRect.php added |
---|
by , 12 years ago
Attachment: | data.tar.gz added |
---|
comment:1 by , 12 years ago
comment:2 by , 12 years ago
I did a few more testing. The problem seems to be related to reprojection of point bounds where minx=maxx and miny=maxy. If I replace the line
$bounds->project($inProjObj, $outProjObj);
with
$oRect = ms_newRectObj(); $oRect->setExtent($bounds->minx, $bounds->miny, $bounds->minx + 0.01, $bounds->miny + 0.01); $oRect->project($inProjObj, $outProjObj);
then the speed is the same for MS 6 and 5.6.
comment:3 by , 12 years ago
Thanks armin for this interesting ticket. It is certainly something I need to check before 6.2.
comment:4 by , 12 years ago
Milestone: | → 6.2 release |
---|---|
Priority: | normal → high |
I made the test now on three different machines, two with Ubuntu 10.04 and PHP 5.3, one with Debian 6 and PHP 5.2. The same effect for all of them. When applying the project() call to the shape bounds, the script is ~200 times slower with MS 6 than with MS 5.6