[Mapserver-users] adding shp to mapfile / projection

Paul Dymecki millardymecki at sympatico.ca
Sun Mar 2 09:48:54 PST 2003


This is a multi-part message in MIME format.

------=_NextPart_000_005B_01C2E0BA.1519DAB0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi=20
I have a php script that pulls a bunch of lat/longs and attribute data =
from a database and produces a shp file.
I was wondering if anyone can see a flaw with the code below?  It's =
produceing reasonable(at least it looks to me)output but the shp file =
produced is not displaying in mapserver,
thx,
Paul

function createPoint( $x, $y, $def )

      {

      // Create shape

    =20

=20

$dlat =3D doubleval($y);

            $dlon =3D doubleval($x);

=20

$projoutobj=3Dms_newprojectionObj("proj=3Dlcc,ellps=3DGRS80,lat_0=3D49,lo=
n_0=3D95,lat_1=3D49,lat_1=3D77");

$projinobj =3D =
ms_newprojectionObj("proj=3Dlatlong,ellps=3DGRS80,datum=3DNAD83");

=20

         $oPoint =3D ms_newPointObj();

         $oLine =3D ms_newLineObj();

         $oShp =3D ms_newShapeObj(MS_SHAPE_POINT);

         $oPoint->setXY($dlon,$dlat);

       =20

         $oPoint =3D $oPoint->project($projinobj, $projoutobj);

        =20

         $oLine -> add($oPoint);

=20

         $oShp->add($oLine);

         $this->shpFile->addShape( $oShp);

    =20

=20

         // Write attribute record

         if( dbase_add_record($this->dbfFile, $def) =3D=3D FALSE )

         {

             $message =3D "Adding a record to dbase failed"; =20

             $this->shpFile->free();

             $oPoint->free();

             return FALSE;

         }

 =20

         $oPoint->free();

         $oShp->free();

         $oLine->free();

          echo 'got here create 2';

         return TRUE;

       }

=20


------=_NextPart_000_005B_01C2E0BA.1519DAB0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I have a php script that pulls a bunch =
of lat/longs=20
and attribute data from a database and produces a shp file.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I was wondering if anyone can see a =
flaw with the=20
code below?  It's produceing reasonable(at least it looks to =
me)output but=20
the shp file produced is not displaying in mapserver,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>thx,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Paul</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV>
<P class=3DMsoNormal=20
style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'"><FONT size=3D2>function =
createPoint( $x, $y,=20
$def )<?xml:namespace prefix =3D o ns =3D =
"urn:schemas-microsoft-com:office:office"=20
/><o:p></o:p></FONT></SPAN></P>
<P class=3DMsoNormal=20
style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'"><FONT size=3D2><SPAN=20
style=3D"mso-tab-count: 1">     =20
</SPAN>{<o:p></o:p></FONT></SPAN></P>
<P class=3DMsoNormal=20
style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'"><FONT size=3D2><SPAN=20
style=3D"mso-tab-count: 1">      </SPAN>// =
Create=20
shape<o:p></o:p></FONT></SPAN></P>
<P class=3DMsoNormal=20
style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'"><FONT size=3D2><SPAN=20
style=3D"mso-spacerun: yes">    =20
</SPAN><o:p></o:p></FONT></SPAN></P>
<P class=3DMsoNormal=20
style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'"><FONT=20
size=3D2> <o:p></o:p></FONT></SPAN></P>
<P class=3DMsoNormal=20
style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'"><FONT size=3D2>$dlat =3D=20
doubleval($y);<o:p></o:p></FONT></SPAN></P>
<P class=3DMsoNormal=20
style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'"><FONT size=3D2><SPAN=20
style=3D"mso-tab-count: =
2">           =20
</SPAN>$dlon =3D doubleval($x);<o:p></o:p></FONT></SPAN></P>
<P class=3DMsoNormal=20
style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'"><FONT=20
size=3D2> <o:p></o:p></FONT></SPAN></P>
<P class=3DMsoNormal=20
style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'"><FONT=20
size=3D2>$projoutobj=3Dms_newprojectionObj("proj=3Dlcc,ellps=3DGRS80,lat_=
0=3D49,lon_0=3D95,lat_1=3D49,lat_1=3D77");<o:p></o:p></FONT></SPAN></P>
<P class=3DMsoNormal=20
style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'"><FONT size=3D2>$projinobj =3D=20
ms_newprojectionObj("proj=3Dlatlong,ellps=3DGRS80,datum=3DNAD83");<o:p></=
o:p></FONT></SPAN></P>
<P class=3DMsoNormal=20
style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'"><FONT size=3D2><SPAN=20
style=3D"mso-spacerun: yes"> </SPAN><o:p></o:p></FONT></SPAN></P>
<P class=3DMsoNormal=20
style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'"><FONT size=3D2><SPAN=20
style=3D"mso-tab-count: 1">      </SPAN><SPAN=20
style=3D"mso-spacerun: yes">   </SPAN>$oPoint =3D=20
ms_newPointObj();<o:p></o:p></FONT></SPAN></P>
<P class=3DMsoNormal=20
style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'"><FONT size=3D2><SPAN=20
style=3D"mso-spacerun: =
yes">        =20
</SPAN>$oLine =3D ms_newLineObj();<o:p></o:p></FONT></SPAN></P>
<P class=3DMsoNormal=20
style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'"><FONT size=3D2><SPAN=20
style=3D"mso-spacerun: =
yes">        =20
</SPAN>$oShp =3D =
ms_newShapeObj(MS_SHAPE_POINT);<o:p></o:p></FONT></SPAN></P>
<P class=3DMsoNormal=20
style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'"><FONT size=3D2><SPAN=20
style=3D"mso-spacerun: =
yes">        =20
</SPAN>$oPoint->setXY($dlon,$dlat);<o:p></o:p></FONT></SPAN></P>
<P class=3DMsoNormal=20
style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'"><FONT size=3D2><SPAN=20
style=3D"mso-spacerun: yes">       =20
</SPAN><o:p></o:p></FONT></SPAN></P>
<P class=3DMsoNormal=20
style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'"><FONT size=3D2><SPAN=20
style=3D"mso-spacerun: =
yes">        =20
</SPAN>$oPoint =3D $oPoint->project($projinobj,=20
$projoutobj);<o:p></o:p></FONT></SPAN></P>
<P class=3DMsoNormal=20
style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'"><FONT size=3D2><SPAN=20
style=3D"mso-spacerun: yes"> </SPAN><SPAN=20
style=3D"mso-spacerun: yes">       =20
</SPAN><o:p></o:p></FONT></SPAN></P>
<P class=3DMsoNormal=20
style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'"><FONT size=3D2><SPAN=20
style=3D"mso-spacerun: =
yes">        =20
</SPAN>$oLine -> add($oPoint);<o:p></o:p></FONT></SPAN></P>
<P class=3DMsoNormal=20
style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'"><FONT=20
size=3D2> <o:p></o:p></FONT></SPAN></P>
<P class=3DMsoNormal=20
style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'"><FONT size=3D2><SPAN=20
style=3D"mso-spacerun: =
yes">        =20
</SPAN>$oShp->add($oLine);<o:p></o:p></FONT></SPAN></P>
<P class=3DMsoNormal=20
style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'"><FONT size=3D2><SPAN=20
style=3D"mso-tab-count: 1">      </SPAN><SPAN=20
style=3D"mso-spacerun: yes">   =
</SPAN>$this->shpFile->addShape(=20
$oShp);<o:p></o:p></FONT></SPAN></P>
<P class=3DMsoNormal=20
style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'"><FONT size=3D2><SPAN=20
style=3D"mso-spacerun: yes">    =20
</SPAN><o:p></o:p></FONT></SPAN></P>
<P class=3DMsoNormal=20
style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'"><FONT=20
size=3D2> <o:p></o:p></FONT></SPAN></P>
<P class=3DMsoNormal=20
style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'"><FONT size=3D2><SPAN=20
style=3D"mso-tab-count: 1">      </SPAN><SPAN=20
style=3D"mso-spacerun: yes">   </SPAN>// Write attribute=20
record<o:p></o:p></FONT></SPAN></P>
<P class=3DMsoNormal=20
style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'"><FONT size=3D2><SPAN=20
style=3D"mso-tab-count: 1">      </SPAN><SPAN=20
style=3D"mso-spacerun: yes">   </SPAN>if(=20
dbase_add_record($this->dbfFile, $def) =3D=3D FALSE=20
)<o:p></o:p></FONT></SPAN></P>
<P class=3DMsoNormal=20
style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'"><FONT size=3D2><SPAN=20
style=3D"mso-tab-count: 1">      </SPAN><SPAN=20
style=3D"mso-spacerun: yes">   =
</SPAN>{<o:p></o:p></FONT></SPAN></P>
<P class=3DMsoNormal=20
style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'"><FONT size=3D2><SPAN=20
style=3D"mso-tab-count: =
2">           =20
</SPAN><SPAN style=3D"mso-spacerun: yes"> </SPAN>$message =3D =
"Adding a record=20
to dbase failed";<SPAN style=3D"mso-tab-count: 1"> =20
</SPAN><o:p></o:p></FONT></SPAN></P>
<P class=3DMsoNormal=20
style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'"><FONT size=3D2><SPAN=20
style=3D"mso-tab-count: =
2">           =20
</SPAN><SPAN=20
style=3D"mso-spacerun: =
yes"> </SPAN>$this->shpFile->free();<o:p></o:p></FONT></SPAN><=
/P>
<P class=3DMsoNormal=20
style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'"><FONT size=3D2><SPAN=20
style=3D"mso-tab-count: =
2">           =20
</SPAN><SPAN=20
style=3D"mso-spacerun: =
yes"> </SPAN>$oPoint->free();<o:p></o:p></FONT></SPAN></P>
<P class=3DMsoNormal=20
style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'"><FONT size=3D2><SPAN=20
style=3D"mso-tab-count: =
2">           =20
</SPAN><SPAN style=3D"mso-spacerun: yes"> </SPAN>return=20
FALSE;<o:p></o:p></FONT></SPAN></P>
<P class=3DMsoNormal=20
style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'"><FONT size=3D2><SPAN=20
style=3D"mso-tab-count: 1">      </SPAN><SPAN=20
style=3D"mso-spacerun: yes">   =
</SPAN>}<o:p></o:p></FONT></SPAN></P>
<P class=3DMsoNormal=20
style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'"><FONT size=3D2><SPAN=20
style=3D"mso-spacerun: yes">  </SPAN><o:p></o:p></FONT></SPAN></P>
<P class=3DMsoNormal=20
style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'"><FONT size=3D2><SPAN=20
style=3D"mso-tab-count: 1">      </SPAN><SPAN=20
style=3D"mso-spacerun: yes">  =20
</SPAN>$oPoint->free();<o:p></o:p></FONT></SPAN></P>
<P class=3DMsoNormal=20
style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'"><FONT size=3D2><SPAN=20
style=3D"mso-spacerun: =
yes">        =20
</SPAN>$oShp->free();<o:p></o:p></FONT></SPAN></P>
<P class=3DMsoNormal=20
style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'"><FONT size=3D2><SPAN=20
style=3D"mso-spacerun: =
yes">        =20
</SPAN>$oLine->free();<o:p></o:p></FONT></SPAN></P>
<P class=3DMsoNormal=20
style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'"><FONT size=3D2><SPAN=20
style=3D"mso-spacerun: =
yes">         =20
</SPAN>echo 'got here create 2';<o:p></o:p></FONT></SPAN></P>
<P class=3DMsoNormal=20
style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'"><FONT size=3D2><SPAN=20
style=3D"mso-tab-count: 1">      </SPAN><SPAN=20
style=3D"mso-spacerun: yes">   </SPAN>return=20
TRUE;<o:p></o:p></FONT></SPAN></P>
<P class=3DMsoNormal=20
style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'"><FONT size=3D2><SPAN=20
style=3D"mso-tab-count: 1">      </SPAN><SPAN=20
style=3D"mso-spacerun: yes"> </SPAN>}<o:p></o:p></FONT></SPAN></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT=20
size=3D2> <o:p></o:p></FONT></P></DIV></BODY></HTML>

------=_NextPart_000_005B_01C2E0BA.1519DAB0--




More information about the MapServer-users mailing list