performance problem

joerg pfeiffer superbla3000 at GMX.NET
Tue Dec 28 06:14:54 EST 2004


thanks a lot, you are completely right, of course.
Now it works fantastic!

best regards
joerg


Steve Lime wrote:
> As I read this you're creating 4000 line features, each one point longer
> than the first. So the first line contains 1 point (bad!), the second
> line contains 2 points, the third 3 points. Are you sure that's what you
> want? I can see why you have a bit of a performance issue. Shouldn't
> adding the track to the shape and layer happen outside the for loop?
> Like so:
>
> # build the track
> for($i=0;$i<count($pointlist);$i++){
>          $lat=$pointlist[$i][0];
>          $long=$pointlist[$i][1];
>          $pointObj->setXY($long,$lat);
>          $line->add($pointObj);
> }
>
> # create a feature from the track and add to feature
> $shp = ms_newShapeObj(MS_SHAPE_LINE);
> $shp->add($line);
> if($TrackLayerObj->addFeature($shp) == -1){
>          echo  "addFeature in lineLayer failed";
> }
>
> This would result in one 4000 point feature being added to the
> 'gpstrack' layer.
>
> Steve
>
>
>>>>joerg pfeiffer <superbla3000 at GMX.NET> 12/27/2004 10:57:44 AM >>>
>
> hello,
>
> I have a 4000 point track in mysql. I build my trackline with
>
> $TrackLayerObj = $this->map->getLayerByName('gpstrack');
> $pointObj = ms_newPointObj();
> $line = ms_newLineObj();
>
> for($i=0;$i<count($pointlist);$i++){
>          $lat=$pointlist[$i][0];
>          $long=$pointlist[$i][1];
>          $pointObj->setXY($long,$lat);
>          $line->add($pointObj);
>          $shp = ms_newShapeObj(MS_SHAPE_LINE);
>          $shp->add($line);
>          if($TrackLayerObj->addFeature($shp) == -1){
>                  echo  "addFeature in lineLayer failed";
>          }
> }
>
> If I choose just a few trackpoints, it's no problem. But when I want
> to
> show all 4000, linux 'top' shows php-cgi running and running and then
> I
> get a blank browser site, due to timeout I guess.
>
> Are 4000 points too much?
> Any ideas?
>
> Joerg
>
>



More information about the mapserver-users mailing list