[Cartoweb-users] Error in HowToDisplayOnTheMapAPointFromADatabaseQuery

Alessandro Simplicio alessandrosimplicio at gmail.com
Mon Jun 12 19:14:13 EDT 2006


Hi, list. I try development the sample by
<http://www.cartoweb.org/cwiki/HowToDisplayOnTheMapAPointFromADatabaseQuery?action=fullsearch&value=linkto%3A%22HowToDisplayOnTheMapAPointFromADatabaseQuery%22&context=180>HowToDisplayOnTheMapAPointFromADatabaseQuery
on www.cartoweb.org, but my page gives the next error:
 Fatal error: Class 'ShapeStyle' not found in
/var/geo/www/cartoweb3/plugins/YourPluingName/client/ClientYourPluingName.php
on line 75

I put my archives in

/cartoweb3/plugins/YourPluingNa me/client/ClientYourPluingName.php
/cartoweb3/plugins/YourPluingName/common/YourPluingName.php
/cartoweb3/plugins/YourPluingName/common/YourPluingName.wsdl.inc
/cartoweb3/plugins/YourPluingName/server/ServerYourPluingName.php

**************************************************************************************

My ClientYourPluingName.php is


<?php
class ClientYourPluingName extends ClientPlugin
        implements ServerCaller  // 20060609 tirei e funcionou Pascoal pus
de nova pra fazer a query
{

   private $vehiculeCoords;

   public function initialize()
   {
        $this->vehiculeCoords = array();
        // get coord from db
        $db = $this->getDb();

        $sql = "SELECT x, y FROM s_ocr_geo_rel WHERE gid = 5062";
//ocorrrencia no bairro guaira rua alagoas - Pascoal
//        $sql = 'SELECT * FROM "your_table_with_values" WHERE
any_condition_you_want'; //linha original

        $result = $db->query($sql);
        if (DB::isError($result))
        {
            throw new CartoclientException($result->getMessage());
        }
        $row = NULL;
        while ($result->fetchInto($row, DB_FETCHMODE_ASSOC))
        {
            $this->vehiculeCoords['x'] = $row['x'];
            $this->vehiculeCoords['y'] = $row['y'];
//            print $this->vehiculeCoords['x']."<br>";
//            print $this->vehiculeCoords['y'];

//            $this->vehiculeCoordsY['y'] =
$row['name_of_the_y_coord_column'];            // linha original
        }
    }

    private function getDb()
    {

        if (is_null($this->db))
        {


        $dsn = "pgsql://demo:demo@localhost/demo_plugins";
        //    $dsn = $this->getConfig()->databaseDsn;
           // print "dsn= ".$dsn."<br>";

            if (!$dsn)
            {
                throw new CartoclientException('Search database DSN not
found');
            }

            $this->db = DB::connect($dsn);

            //check for db connection error, throw exception if needed
            Utils::checkDbError($dsn," ");     // erro aqui - faltavam
parametros do checkdberror ($db e $msg) - pascoal

        }
        return $this->db;
    }

    /**
     * @see ServerCaller::buildRequest()
     */
    public function buildRequest()
    {

        // we call for a new shape only if we have a x and y
        if ($this->vehiculeCoords['x'] != '' and $this->vehiculeCoords['y']
!= '')
        {

            $newElement = new
Point($this->vehiculeCoords['x'],$this->vehiculeCoords['y']);
            //tinha um erro aqui - pascoal   - original - $newElement = new
Point($this->vehiculeCoords['x'], $this->$this->vehiculeCoords['y']);

            $styledShape = new StyledShape();
            $styledShape->shape = $newElement;

            $shapeStyle = new ShapeStyle();

            $shapeStyle->symbol = 2;
//            $shapeStyle->symbol = $this->type;

            $shapeStyle->size = 20;
            $shapeStyle->color->setFromRGB(51, 0, 204);
            $shapeStyle->outlineColor->setFromRGB(0, 0, 0);

            $styledShape->shapeStyle = $shapeStyle;

            $YourPluingNameRequest = new YourPluingNameRequest();
            $YourPluingNameRequest->shapes = array($styledShape);

            return $YourPluingNameRequest;
        }
    }


    /**
     * @see ServerCaller::initializeResult()
     */
    public function initializeResult($YourPluingNameResult)
    {
    }


    /**
     * @see ServerCaller::handleResult()
     */
    public function handleResult($YourPluingNameResult)
    {
    }
}?>
*
*
**************************************************************************************

My YourPluingName.php is

<?php

class YourPluingNameRequest extends CwSerializable
{

      /**
       * Styled shapes to be drawn
       * @var array
       */
   public $shapes;

      /**
       * @see CwSerializable::unserialize()
       */
   public function unserialize($struct)
   {
        $this->shapes = self::unserializeObjectMap($struct,
'shapes','StyledShape');
   }
}
    /**
     * Result
     * @package Plugins
     */
    class YourPluingNameResult
    {
    }
    ?>

**************************************************************************************

My YourPluingName.wsdl.inc is

      <!-- outline -->

      <complexType name="Color">
        <all>
          <element name="r" type="xsd:int"/>
          <element name="g" type="xsd:int"/>
          <element name="b" type="xsd:int"/>
        </all>
      </complexType>

      <complexType name="ShapeStyle">
        <all>
          <element name="symbol" type="xsd:int"/>
          <element name="size" type="xsd:int"/>
          <element name="color" type="types:Color"/>
          <element name="outlineColor" type="types:Color"/>
          <element name="backgroundColor" type="types:Color"/>
          <element name="transparency" type="xsd:int"/>
        </all>
      </complexType>

      <complexType name="LabelStyle">
        <all>
          <element name="font" type="xsd:int"/>
          <element name="size" type="xsd:int"/>
          <element name="color" type="types:Color"/>
          <element name="outlineColor" type="types:Color"/>
          <element name="backgroundColor" type="types:Color"/>
        </all>
      </complexType>

      <complexType name="StyledShape">
        <all>
          <element name="shapeStyle" type="types:ShapeStyle"/>
          <element name="labelStyle" type="types:LabelStyle"/>
          <element name="shape" type="types:Shape"/>
          <element name="label" type="xsd:string"/>
        </all>
      </complexType>

      <complexType name="ArrayOfStyledShape">
        <complexContent>
          <restriction base="enc11:Array">
            <attribute ref="enc11:arrayType"
wsdl:arrayType="types:StyledShape[]"/>
          </restriction>
        </complexContent>
      </complexType>

      <complexType name="OutlineRequest">
        <all>
          <element name="className" type="xsd:string"/>
          <element name="shapes" type="types:ArrayOfStyledShape"/>
          <element name="maskMode" type="xsd:boolean"/>
        </all>
      </complexType>

      <complexType name="OutlineResult">
        <all>
          <element name="className" type="xsd:string"/>
          <element name="area" type="xsd:double"/>
        </all>
      </complexType>


**************************************************************************************

My ServerYourPluingName.php is

<?php
class ServerYourPluingName extends ClientResponderAdapter
{

    /**
     * @var Logger
     */
    private $log;

    /**
     * @var objet
     */
    private $shapes;


    /**
     * Constructor
     */
    function __construct()
    {
        parent::__construct();
        $this->log =& LoggerManager::getLogger(__CLASS__);
    }


    /**
     * @see ClientResponder::initializeRequest()
     */
    function initializeRequest($requ)
    {
        if ($requ) $this->shapes = $requ->shapes;
    }


    /**
     * Result is set in initializeRequest but Outline must be called
     * in handlePreDrawing
     * @see ClientResponder::handlePreDrawing()
     */
    function handlePreDrawing($requ)
    {
        if ($requ)
        {
            $pluginManager = $this->serverContext->getPluginManager();
            if (empty($pluginManager->outline))
                throw new CartoserverException("outline plugin not loaded,
"."and needed to draw the new element");
            $pluginManager->outline->draw($this->shapes);
        }
    }
}?>

***************************************************************************************

What's wrong?

Thank you

Alessandro Simplício - Brazil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/cartoweb-users/attachments/20060612/6e2da1d1/attachment-0001.html


More information about the Cartoweb-users mailing list