Call to undefined method getFeature
Pietro Giannini
pgiannini at BYTEWISE.IT
Thu Jun 28 07:21:06 PDT 2007
Chris,
I don't read the reference, which doc?
I use mapscript 4.10 and, like you, function getShape don't exists.
to get attributes I do:
$obj_layer = $obj_map->getLayerByName("name_of_layer");
$obj_layer->queryByRect($a_obj_rect);
// or queryBYPoint, or queryByAttributes...
$obj_layer->open();
$i_numres = $obj_layer->getNumResults();
for ($i=0;$i<$i_numres;$i++) {
$resCache = $obj_layer->getResult($i);
$sh = $obj_layer->getShape(resCache->tileindex,$resCache->shapeindex);
print_r($sh->values);
}
$obj_layer->close();
I hope it is useful.
ciao
...............................pg
Pietro Giannini
Bytewise srl - Area GIS
41°50'38.58"N 12°29'13.39"E
> Thanks Pietro, though the reference did mention that the getShape method
> was deprecated in favor of the getFeature one. This begs the question of
> exactly how I would get the attributes associated with a particular shape.
>
> Chris
>
> Pietro Giannini wrote:
>> Hi Christopher,
>>
>> there is no mapscript function layerobj::getFeature(), maybe you need
>> the
>> layeroby::getShape().
>>
>> (Effectively getFeature is a more exact name for this function: a
>> "shape"
>> don't have attributes, a "feature" is a shape with attributes)
>>
>> take a look here:
>> http://mapserver.gis.umn.edu/docs/reference/phpmapscript-class/classes/layerobj
>>
>> ciao
>> .........................pg
>>
>>
>>
>>
>> Pietro Giannini
>> Bytewise srl - Area GIS
>> 41°50'38.58"N 12°29'13.39"E
>>
>>
>>
>>
>>
>>> *Hi all,
>>>
>>> I'm having some trouble getting the getFeature method to work on a
>>> layer
>>> object. Here's the error I get:
>>>
>>> Fatal error*: Call to undefined method ms_layer_obj::getFeature() in
>>> *C:\ms4w\Apache\htdocs\test.php* on line *10
>>>
>>> And the php code:
>>>
>>> <?php
>>> dl("php_mapscript.dll");
>>> dl("php_dbase.dll");
>>> dl("php_curl.dll");
>>>
>>>
>>> $shape_id = 1;
>>> $map = ms_newMapObj("c:\ms4w\apache\htdocs\es.map");
>>> $this_layer = $map->getLayerByName('pn_points');
>>> $attribute = $this_layer->getFeature(1, -1);
>>> echo "ok";
>>> ?>
>>>
>>> and the mapfile:
>>>
>>> # This is our fifth map file
>>> NAME "es"
>>> UNITS meters
>>> EXTENT 167000 5814000 542300 5948000
>>> SIZE 640 480
>>> IMAGECOLOR 255 255 255
>>> IMAGETYPE PNG
>>> SHAPEPATH "c:\ms4w\apache\htdocs\wem\"
>>> FONTSET "c:\ms4w\apache\htdocs\fontset.txt"
>>>
>>> WEB
>>> IMAGEPATH "/ms_temp/"
>>> IMAGEURL "http://132.206.251.215/ms_temp/"
>>> END
>>>
>>> #####################################
>>> # placenames layer - points
>>> #
>>> LAYER
>>> NAME "pn_points"
>>> DATA "points_ID_real"
>>> STATUS on
>>> TYPE point
>>> CLASS
>>> STYLE
>>> SIZE 1
>>> COLOR 100 100 200
>>> END
>>> END
>>> END
>>>
>>>
>>> END # mapfile
>>>
>>> Any ideas? I'm totally stumped. I don't know if its the software
>>> (mapserver
>>> 4.10, mapscript 4.10, php 5)or a mistake I've made that is eluding me.
>>> *
>>>
>>> --
>>> Christopher Wellen
>>> M.Sc. Candidate
>>> Department of Geography
>>> McGill University
>>> Montreal, Quebec
>>> Burnside Hall room 428
>>> 805 Sherbrooke Street West
>>> Montreal, Quebec H3A 2K6
>>> skype: christopher.wellen
>>> MSN: christopher.wellen at mail.mcgill.ca
>>> home: 514-509-9476
>>> cell: 514-585-5138
>>>
>>>
>>
>>
>>
>
>
> --
> Christopher Wellen
> M.Sc. Candidate
> Department of Geography
> McGill University
> Montreal, Quebec
> Burnside Hall room 428
> 805 Sherbrooke Street West
> Montreal, Quebec H3A 2K6
> skype: christopher.wellen
> MSN: christopher.wellen at mail.mcgill.ca
> home: 514-509-9476
> cell: 514-585-5138
>
More information about the MapServer-users
mailing list