[Mapserver-users] unclear on the concept
Joel Gwynn
joelman at joelman.com
Fri Jul 23 08:10:25 PDT 2004
I'm just going by this, from
http://mapserver.gis.umn.edu/doc35/perlmapscript-reference.html:
*_shapeObj:_*
<http://mapserver.gis.umn.edu/doc35/perlmapscript-reference.html#toc>
*Constructor:*
new shapeObj(type)
*Examples:* $shape = new shapeObj(-1);
The type parameter is just a general type used to make MapScript less
bulky.
With it MapScript can make decisions in a few comparison methods without
requiring specific methods.
Valid values are -1, MS_SHAPE_POINT, MS_SHAPE_LINE, & MS_SHAPE_POLYGON.
Other shape creation methods (see shapefileObj)
<http://mapserver.gis.umn.edu/doc35/perlmapscript-reference.html#shapefileobj>
populate this parameter correctly.
So I interpreted that to mean that a shapeObj could hold points, lines,
or polygons. "print $point->{x}" definitely returns nothing, though.
Lowell Filak wrote:
>I realize that. The $shape->get returns a line object not point. It's
>easy enough to verify, does "print $point->{x}.' '.$point->{y}" print a
>real x & y or 0?
>
>Lowell
>
>The following message was sent by Joel Gwynn <joelman at joelman.com> on
>Fri, 23 Jul 2004 09:56:44 -0400.
>
>
>
>>it's a point layer
>>
>>Lowell Filak wrote:
>>
>>
>>
>>>Doesn't $so need to be MS_SHAPE_LINE instead of MS_SHAPE_POINT ?
>>>
>>>Lowell
>>>
>>>The following message was sent by Joel Gwynn <joelman at joelman.com> on
>>>Fri, 23 Jul 2004 00:26:20 -0400.
>>>
>>>
>>>
>>>
>>>
>>>>The shapeindex numbers I'm getting don't seem to correspond to any
>>>>values in my "cities" table. Even so, I would hope that I could
>>>>retrieve all the feature info from the mapserver object without opening
>>>>up a separate database connection. Is this not so?
>>>>
>>>>I'm just having trouble finding the specific syntax to get information
>>>>about individual points on a point layer. Here's what I would think
>>>>might work, but of course it's not.
>>>>
>>>> my $so = new mapscript::shapeObj($mapscript::MS_SHAPE_POINT);
>>>> ...
>>>>if(my $r = $city_layer->queryByPoint($map, $boston,
>>>>$mapscript::MS_MULTIPLE,10)){
>>>> print "no results.\n";
>>>>}else{
>>>> my $i = 0;
>>>> print "status: $r\n";
>>>> while(my $rc = $city_layer->getResult($i)){
>>>> my $si = $rc->{shapeindex};
>>>> $r = $city_layer->getShape($so, 0, $si);
>>>> print "getShape: $r\n";
>>>> my $point = new mapscript::pointObj();
>>>> $point = $so->get(0);
>>>> print $point->{x}.' '.$point->{y}
>>>>}
>>>>
>>>>What really obvious syntax am I missing?
>>>>
>>>>Thanks,
>>>>Joel
>>>>
>>>>Lowell Filak wrote:
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>>I don't know postgis but I would suspect that the query you want to do
>>>>>could be done directly in postgis.
>>>>>Excluding that as a possibility, the shapeindexes you receive back
>>>>>should be the sequential number of the shape/attribute record as they
>>>>>occur in the postgres table. You should be able to retrieve the shape
>>>>>into a shapeObj via $layer->getShape($shape, 0, $si).
>>>>>
>>>>>HTH
>>>>>
>>>>>Lowell
>>>>>
>>>>>The following message was sent by Joel Gwynn <joelman at joelman.com> on
>>>>>Wed, 21 Jul 2004 23:43:20 -0400.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>Perhaps I'm going about this the wrong way. I'm using perl
>>>>>>
>>>>>>
>mapscript,
>
>
>>>>>>and I've got a postgis points layer and I want to get some points,
>>>>>>
>>>>>>
>say
>
>
>>>>>>within a certain radius of Boston:
>>>>>>
>>>>>>my $map = new mapscript::mapObj("$map_path/world_cities.map");
>>>>>>my $boston = new mapscript::pointObj(-71.1029968261719, 42.375);
>>>>>>my $city_layer = $map->getLayer(1);
>>>>>>
>>>>>>if(my $r = $city_layer->queryByPoint($map, $boston,
>>>>>>$mapscript::MS_MULTIPLE,10)){
>>>>>> print "no results.\n";
>>>>>>}else{
>>>>>> my $i = 0;
>>>>>> print "status: $r\n";
>>>>>> while(my $rc = $city_layer->getResult($i)){
>>>>>> my $si = $rc->{shapeindex};
>>>>>> print "shapeindex: $si\n";
>>>>>> $i++;
>>>>>> }
>>>>>>}
>>>>>>
>>>>>>This prints out a bunch of shapeindex numbers. What are those
>>>>>>
>>>>>>
>numbers?
>
>
>>>>>>They don't seem to show up in my cities table in the database. Can I
>>>>>>use the mapscript object to access the points?
>>>>>>_______________________________________________
>>>>>>Mapserver-users mailing list
>>>>>>Mapserver-users at lists.gis.umn.edu
>>>>>>http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>
>>>
>>>
>>>
>>_______________________________________________
>>Mapserver-users mailing list
>>Mapserver-users at lists.gis.umn.edu
>>http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
>>
>>
>
>
>
>
More information about the MapServer-users
mailing list