Ticket #495 (closed defect: duplicate)
ShapeObj Text problem in 4.0
| Reported by: | tmelhuish@… | Owned by: | sdlime |
|---|---|---|---|
| Priority: | high | Milestone: | |
| Component: | MapScript | Version: | 4.1 |
| Severity: | normal | Keywords: | |
| Cc: |
Description
I create a ShapeObj as a "SHAPE_POINT" to place text on multiple parcels. This
code worked fine for MS 3.6 but doesn't work on MS 4.0 or 4.0.1. I get the
following error message:
Can't call method "save" on an undefined value at /my perl script line xx
It works sometimes in 4.0 on one or 2 particular parcels I select. I don't
know why these paticular couple parcels work and the text is displayed fine,
but all the others don't work and get the error message noted above.
Code out of Mapscript to create ShapeObj is:
+++++++++++++++++++++++++++++++++
$itemctr=0;
for ($i=2;$i<$NumCoor+1;$i=$i+2) {
$itemctr++;
my $point = new mapscript::pointObj() or die('Unable to create
point');
$point->{x} = $x1 = $in{WindowXmin}+($CursorCoords[$i-2+$_])
*$cx or die('Unable to add x value to point');
$point->{y} = $y1 = $in{WindowYmax}-($CursorCoords[$i-1+$_])
*$cy or die('Unable to add y value to point');
#print "**$x1,$y1 ** Point: $point**\n";
if ($in{SubOption} eq "MultParcelTax" ) {
$layerLoc = $map->getLayerByName('locate') or die
('Unable to get layer');
$layerLoc->{status} = $mapscript::MS_ON;
my $line = new mapscript::lineObj() or die('Unable to
create line');
$retval=$line->add($point);
$shape = new mapscript::shapeObj
($mapscript::MS_SHAPE_POINT);
$retval=$shape->add($line);
# Tried to add this in 4.0.1 but no help
#$retval=$shape->contains($point);
$shape->{text} = "$itemctr";
$retval=$layerLoc->addFeature($shape);
if ($retval ne 0) {
&AlertMsg("Unable to create point feature from
address entered.","error");
}
#print "**Plot:$retval\n";
}
}
++++++++++++++++++++++++++++++++++++
Here is the layer in my mapfile that I draw this text feature with
+++++++++++++++++++++++++++++++++
NAME locate
TYPE POINT
STATUS Default
CLASS
LABEL
POSITION cc
SIZE small
COLOR 140 10 190
END
END
# FEATURE
# POINTS 2058991 731248 END
# TEXT 'Student Location'
# END
END
Change History
Note: See
TracTickets for help on using
tickets.
