[mapserver-users] PPH Mapscript - limit to number of shape objects in a layer?
Alan Hale
alan.hale at btclick.com
Sat Oct 24 08:29:26 PDT 2009
Alan
Well, I think I just adapted code from Bill Kropla's "Beginning
Mapserver" (that was for point rather than polygon data). I should have
given it some more thought.
Your suggestion works fine and will run with a 32M limit.
Very many thanks for your help.
Alan
Alan Boudreault wrote:
> That's what I suspected too. I'm not sure if there is a reason why you
> keep ALL lineObj and shapeObj in arrays... but maybe you could try
> something like this:
>
> $i = 0;
> foreach($qresult as $row) {
> $ln = ms_newLineObj();
>
> $X = $row[1];
> $Y = $row[2];
> $ln->addXY($X-1000,$Y-1000);
> $ln->addXY($X+1000,$Y-1000);
> $ln->addXY($X+1000,$Y+1000);
> $ln->addXY($X-1000,$Y+1000);
> $ln->addXY($X-1000,$Y-1000);
>
> $shp = ms_newShapeObj(MS_SHAPE_POLYGON);
>
> $shp->add($ln);
> $shp->set(index, $row[0]);
>
> $layerPoi->addFeature( $shp );
> $i++;
> }
>
> This will of course reduce the memory usage of your script ... if you
> don't need all those lineObj and shapeObj arrays. (You can always get
> the shapeObjs of the layer again later)
>
> Alan
>
> Alan Hale wrote:
>> I've just figured out that this is a PHP memory limit issue - raising
>> the limit in php.ini to 128M from the default 32M fixes the problem.
>>
>> But can anyone suggest a more memory-efficient way of coding the
>> addition of square polygons to a dynamic layer?
>>
>> Many thanks
>>
>> Alan
>>
>>
>>
>> Alan Hale wrote:
>>> Hi Alan
>>>
>>> Thanks for the reply. I'm displaying the map image via Overlib and
>>> so not getting any error messages- just no image. I know the limit
>>> is 11528 just by setting LIMIT on the database query and iterating
>>> to the max value. I've been trying to debug the script that
>>> generates the image but this is proving more difficult than I
>>> thought since various parameters are passed via Overlib so I will
>>> have to insert some dummy values.
>>>
>>> Hope to get back with more information later.
>>>
>>> Regards
>>>
>>> Alan
>>>
>>> Alan Boudreault wrote:
>>>> Hi Alan,
>>>>
>>>> What's happen when you reach 11528? Is is a PHP error or a
>>>> mapserver error ? Could you show us the error?
>>>>
>>>> Alan
>>>>
>>>> On October 23, 2009 11:30:00 am Alan Hale wrote:
>>>>
>>>>> Hi
>>>>>
>>>>> I'm using PHP Mapscript to construct a layer with 2km square polygons
>>>>> based on coordinates from a database query - thus:
>>>>>
>>>>>
>>>>> $i = 0;
>>>>> foreach($qresult as $row) {
>>>>> $ln[$i] = ms_newLineObj();
>>>>>
>>>>> $X = $row[1];
>>>>> $Y = $row[2];
>>>>> $ln[$i]->addXY($X-1000,$Y-1000);
>>>>> $ln[$i]->addXY($X+1000,$Y-1000);
>>>>> $ln[$i]->addXY($X+1000,$Y+1000);
>>>>> $ln[$i]->addXY($X-1000,$Y+1000);
>>>>> $ln[$i]->addXY($X-1000,$Y-1000);
>>>>>
>>>>> $shp[$i] = ms_newShapeObj(MS_SHAPE_POLYGON);
>>>>>
>>>>> $shp[$i]->add($ln[$i]);
>>>>> $shp[$i]->set(index, $row[0]);
>>>>>
>>>>> $layerPoi->addFeature( $shp[$i] );
>>>>> $i++;
>>>>>
>>>>> This seems to work fine UNTIL the query result reaches more than
>>>>> 11528
>>>>> rows (this number is exact). Is there a limit? Am I expecting too
>>>>> much
>>>>> here?
>>>>>
>>>>> Many thanks
>>>>>
>>>>> Alan Hale
>>>>>
>>>>>
>>>>> __________ Information from ESET Smart Security, version of virus
>>>>> signature
>>>>> database 4536 (20091023) __________
>>>>>
>>>>> The message was checked by ESET Smart Security.
>>>>>
>>>>> http://www.eset.com
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> mapserver-users mailing list
>>>>> mapserver-users at lists.osgeo.org
>>>>> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>>
>>> __________ Information from ESET Smart Security, version of virus
>>> signature database 4537 (20091023) __________
>>>
>>> The message was checked by ESET Smart Security.
>>>
>>> http://www.eset.com
>>>
>>>
>>> _______________________________________________
>>> mapserver-users mailing list
>>> mapserver-users at lists.osgeo.org
>>> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>>>
>>> __________ Information from ESET Smart Security, version of virus
>>> signature database 4537 (20091023) __________
>>>
>>> The message was checked by ESET Smart Security.
>>>
>>> http://www.eset.com
>>>
>>>
>>>
>>>
>>
>>
>>
>> __________ Information from ESET Smart Security, version of virus
>> signature database 4537 (20091023) __________
>>
>> The message was checked by ESET Smart Security.
>>
>> http://www.eset.com
>>
>>
>> _______________________________________________
>> mapserver-users mailing list
>> mapserver-users at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>
>
__________ Information from ESET Smart Security, version of virus signature database 4538 (20091024) __________
The message was checked by ESET Smart Security.
http://www.eset.com
More information about the MapServer-users
mailing list