<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1458" name=GENERATOR></HEAD>
<BODY style="MARGIN: 4px 4px 1px; FONT: 10pt Tahoma">
<DIV>Nicol,</DIV>
<DIV> </DIV>
<DIV>I have the same problem. Stepan made me aware of this. I am not sure why this happens. Hopefully someone on the list can explain.</DIV>
<DIV> </DIV>
<DIV>Rene<BR><BR>>>> Nicol Hermann <mapserver@geoworld.de> 2004-09-17 9:34:41 AM >>><BR></DIV>
<DIV style="COLOR: #000000">Hi Rene,<BR><BR>i have a question to your implementation of Stepan's c-code.<BR>You identify e.g. the number of points with:<BR>$theShape->line[0]->numpoints<BR><BR>According to the docs i expect the following line<BR>$theShape->line(0)->numpoints<BR><BR>unfortunately this statement returns the following error:<BR>Parse error: parse error, unexpected T_OBJECT_OPERATOR in<BR>/home/nicol/public_html/mapserver/dev/area_calculation.php on line 23<BR><BR>Your statement returns NULL. <BR>Do you know what i am doing wrong.<BR><BR>Thank you very much<BR>Nicol<BR><BR><BR>Am Do, den 16.09.2004 schrieb Rene Teniere um 15:07:<BR>> Hi all,<BR>>  <BR>> I have been implementing Stepan Kafka's c-code for calculating area of<BR>> a polygon in php/mapscript. His code seems to work fine. The only<BR>> problem is that I keep getting a numlines result of 1 and numpoints<BR>> result of NULL for my shape BEFORE I get a chance to use it in the<BR>> area code. This, of course will give me an invalid area of 0. The<BR>> numshapes variable within the shapefile object works great, always<BR>> gives me the correct result.<BR>>  <BR>> Wonder if anyone could let me know what they think is going on?<BR>>  <BR>> Thanks,<BR>> Rene<BR>>  <BR>> Here is the output:<BR>> [15-Sep-2004 15:47:23] Numshapes:2<BR>> [15-Sep-2004 15:47:23] Numlines:1<BR>> [15-Sep-2004 15:47:23] Numpoints:<BR>> [15-Sep-2004 15:47:23] --------------------------<BR>> [15-Sep-2004 15:47:23] Numlines:1<BR>> [15-Sep-2004 15:47:23] Numpoints:<BR>> [15-Sep-2004 15:47:23] The sum2:0<BR>> [15-Sep-2004 15:47:23] Area is:0<BR>>  <BR>> Here is the code:<BR>> error_log('Numshapes:'.$oShapeFile->numshapes);<BR>> $theShape = $oShapeFile->getShape(0);<BR>> error_log('Numlines:'.$theShape->numlines);<BR>> error_log('Numpoints:'.$theShape->line[0]->numpoints);<BR>> $shpArea = shapeArea($theShape);<BR>> error_log('Area is:'.$shpArea);<BR>>  <BR>> function shapeArea($myShape)<BR>> {<BR>>   $area = 0;<BR>>   if($myShape->type!=MS_SHAPE_POLYGON)<BR>>   {<BR>>     error_log('Not a Polygon!');<BR>>     return $area;<BR>>   }<BR>>   error_log('--------------------------');<BR>>   error_log('Numlines:'.$myShape->numlines);<BR>>   error_log('Numpoints:'.$myShape->line[0]->numpoints);<BR>>   for($i=0;$i<$myShape->numlines;$i++)<BR>>   {<BR>>     $sum = 0;<BR>>     for ($v=0;$v<$myShape->line[$i]->numpoints-2;$v++)<BR>>     {<BR>>      <BR>> $sum+=(($myShape->line[$i]->point[0]->x)*($myShape->line[$i]->point[$v]->y)-($myShape->line[$i]->point[0]->y)*($myShape->line[$i]->point[$v]->x)+($myShape->line[$i]->point[0]->y)*($myShape->line[$i]->point[$v+1]->x)-($myShape->line[$i]->point[0]->x)*($myShape->line[$i]->point[$v+1]->y)+($myShape->line[$i]->point[$v]->x)*($myShape->line[$i]->point[$v+1]->y)-($myShape->line[$i]->point[$v+1]->x)*($myShape->line[$i]->point[$v]->y));<BR>>       error_log('The sum1:'.$sum);<BR>>     }<BR>>     error_log('The sum2:'.$sum);<BR>>     $sum = $sum;<BR>>     //test if line lies inside other ones<BR>>     for($v=0;$v<$i;$v++)<BR>>     {<BR>>       if(pointInLine($myShape->line[$v],$myShape->line[$i]->point[0]))<BR>>       {<BR>>        $sum = -$sum;<BR>>    $area += $sum;<BR>>       }<BR>>     }<BR>>     return $area/2;<BR>>   }<BR>> }<BR>>  <BR>> function pointInLine($myLine,$myPoint)<BR>> {<BR>>   //test - point in poly - for one arc of shape<BR>>  <BR>>   $status=0;<BR>>   for ($i=0, $j=$myLine->numpoints-1; i<$myLine->numpoints; $j=$i++)<BR>>   {<BR>>     if (((($myLine->point[$i]->y <= $myPoint->y) && ($myPoint->y <<BR>> $myLine->point[$j]->y)) || (($myLine->point[$j]->y <= $myPoint->y) &&<BR>> ($myPoint->y < $myLine->point[$i]->y))) && ($myPoint->x <<BR>> ($myLine->point[$j]->x - $myLine->point[$i]->x) * ($myPoint->y -<BR>> $myLine->point[$i]->y) / ($myLine->point[$j]->y -<BR>> $myLine->point[$i]->y) + $myLine->point[$i]->x))<BR>>          $status = !$status;<BR>>   }<BR>>   return $status;<BR>> }<BR>>  <BR>-- <BR>Dipl.-Geogr. Nicol Hermann<BR>GDV Gesellschaft für geografische Datenverarbeitung mbH<BR>Binger Straße 49-51<BR>55218 Ingelheim<BR>Tel. 06132-7148-18<BR>Fax: 06132-7148-28<BR><BR></DIV></BODY></HTML>