Opened 20 years ago

Closed 16 years ago

Last modified 16 years ago

#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 (5)

comment:1 by tmelhuish@…, 20 years ago

I figured out my problem. I had to add a STYLE in my class as shown below. 
Even though I'm only doing labeling in this layer I still need to define a 
STYLE? 

NAME locate
  TYPE POINT
  STATUS Default
  CLASS
     STYLE   # added to fix problem
     END     # added to fix problem
     LABEL
      POSITION cc
      SIZE small
      COLOR 140 10 190
    END 
  END
#  FEATURE
#    POINTS  2058991 731248 END
#    TEXT 'Student Location'
#  END
END

comment:2 by sdlime, 20 years ago

Cc: lacroix@… added

comment:3 by sdlime, 20 years ago

*** Bug 499 has been marked as a duplicate of this bug. ***

comment:4 by tomkralidis, 16 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #495

comment:5 by tomkralidis, 16 years ago

make that #499

Note: See TracTickets for help on using tickets.