[mapserver-users] ms_newLineObj()
Daniel Morissette
morissette at dmsolutions.ca
Wed Oct 31 10:46:27 PST 2001
Jean-Francois,
The line and shape objects seem to be created properly internally, it's
just that the $line->numpoints and $shape->numlines members are not
properly updated in the PHP wrapper. This is definietely a bug, but the
internal data structures should be fine and you should be able to use
them to write to a shapeFileObj or simply to draw the shapes on a map.
One more for our list I guess... I've filed it in bugzilla to make sure
it gets fixed: http://mapserver.gis.umn.edu/bugs/show_bug.cgi?id=69
BTW, seems like there is lots of good testing of MapServer and PHP
MapScript going on out there! :) Keep reporting bugs... not sure when
we'll be able to fix them all, but we're better find them now than after
an official 3.5 release!
--
------------------------------------------------------------
Daniel Morissette morissette at dmsolutions.ca
DM Solutions Group http://www.dmsolutions.ca/
------------------------------------------------------------
Don't put for tomorrow what you can do today, because if
you enjoy it today you can do it again tomorrow.
Jean-François MONY wrote:
>
> I have a little problem with the ms_newLineObj() command.
> As you can see below I create some points and the goal is to make a polygon
> with those points, then I create a line.
> With the print_r function I'm sure that the points are well created, but I
> can't create the line and I don't understand why.
> If somebody have an idea.
> I use mapserver 3.5 (nightly build from the begining of september) with php
> 4.05.
>
> Thanks, Jef
>
> CODE
> =====
>
> <?
> session_start();
>
> require("../config.php");
>
> function split_string($sql, $delimiter)
> {
> $sql = trim($sql);
> $buffer = array();
> $ret = array();
> $in_string = false;
> for($i=0; $i<strlen($sql); $i++)
> {
> if($sql[$i] == $delimiter && !$in_string)
> {
> $ret[] = substr($sql, 0, $i);
> $sql = substr($sql, $i + 1);
> $i = 0;
> }
> if($in_string && ($sql[$i] == $in_string) && $buffer[0] != "\\")
> {
> $in_string = false;
> }
> elseif(!$in_string && ($sql[$i] == "\"" || $sql[$i] == "'") && $buffer[0] !
> = "\\")
> {
> $in_string = $sql[$i];
> }
> $buffer[0] = $buffer[1];
> $buffer[1] = $sql[$i];
> }
> if (!empty($sql))
> {
> $ret[] = $sql;
> }
> return($ret);
> }
>
> $polyarray=split_string($poly, ";");
>
> print("$poly<br>");
> $ligne = ms_newLineObj();
> for ($i=1; $i<$polyarray[0]+1;$i++)
> {
> $j=2*$i-1;
> $k=2*$i;
> $point=ms_newPointObj();
> $point->setXY($polyarray[$j], $polyarray[$k]);
> print_r($point);
> print("<br>");
> $ligne->add($point);
> print_r($ligne);
> print("<br>");
> }
> $shape = ms_newShapeObj(MS_SHAPE_POLYGON);
> $shape->add($ligne);
> print_r($shape);
> print("<br>");
> ?>
>
> RESULT
> =======
>
> 4;907249;2505661;909472;2486354;934669;2483012;919847;2504547;
> point Object ( [_handle_] => Resource id #2 [x] => 907249 [y] => 2505661 )
> line Object ( [_handle_] => Resource id #1 [numpoints] => 0 )
> point Object ( [_handle_] => Resource id #3 [x] => 909472 [y] => 2486354 )
> line Object ( [_handle_] => Resource id #1 [numpoints] => 0 )
> point Object ( [_handle_] => Resource id #4 [x] => 934669 [y] => 2483012 )
> line Object ( [_handle_] => Resource id #1 [numpoints] => 0 )
> point Object ( [_handle_] => Resource id #5 [x] => 919847 [y] => 2504547 )
> line Object ( [_handle_] => Resource id #1 [numpoints] => 0 )
> shape Object ( [_handle_] => Resource id #6 [numlines] => 0 [type] => 2 [index]
> => -1 [tileindex] => -1 [classindex] => 0 [numvalues] => 0 [text] => [bounds]
> => rect Object ( [_handle_] => Resource id #7 [minx] => -1 [miny] => -1 [maxx]
> => -1 [maxy] => -1 ) )
More information about the MapServer-users
mailing list