[Cartoweb-users] Make Outline plugin draw a ms_shape_obj

Simon ORTET simon.ortet at silogic.fr
Fri Oct 12 09:18:17 EDT 2007


Well i did something to make it work.

In my plugin server file, instead of
    $pluginManager->outline->draw($this->shapes);
i make a
    $pluginManager->outline->drawDirect($this->shapes);

And i coded this function in ServerOutline.php like this:

    /public function drawDirect($shapes) {/
    /        /
    /        if (empty($shapes)) {/
    /            return 0;/
    /        }/
    /                /
    /        $msMapObj = $this->serverContext->getMapObj();/
    /        foreach ($shapes as $shape) {/
    /           
    $this->drawFeatureDirect($shape,$this->getConfig()->polygonLayer);/
    /        }/

    /        $this->drawMap($msMapObj);/

    /        return 0;/
    /    }/

The drawFeatureDirect is just like drawFeature except i replaced the
    $f = $this->toShapeObj($shape->shape);
by
    $f = $shape->shape[0];


My problem now is that i've got all the layer drawn and i don't 
understand why.
the $f variable is a ms_shape_obj extracted from a layer. I see it 
rendered with the correct style on the map. So the modifications work.
But the plugin activates the whole layer and it's drawn too (whereas i 
didn't activate it) and i don't understand why.

I someone sees why in the code i posted... otherwise i'll keep you posted.

Thanks.


Simon ORTET a écrit :
> Hi,
>
> I made a plugin that uses outline plugin. It takes coordinates, make a 
> Cartoweb Shape of it and send it to outline with
>
>    $pluginManager->outline->draw($this->shapes);
>
> It works fine. Now i need this plugin to deal with shapes extracted 
> from my postgis database (ms_ShapeObj). Here's what i did to implement 
> this. In Server[myPlugin].php (handlePreDrawing function):
>                              $mySelection = new IdSelection();
>                $mySelection->layerId = $this->objTable; // The name of 
> my postgis layer
>                $mySelection->idAttribute = $this->objField;
>                $mySelection->idType = "string";
>                $mySelection->selectedIds = array($this->objValue);
>                          $styledShape = new StyledShape();
>                $styledShape->shape = 
> $pluginManager->mapquery->queryByIdSelection($mySelection);
>
>                $shapeStyle = new StyleOverlay();
>                $shapeStyle->size = 20;
>                $shapeStyle->color->setFromRGB(-1, -1, -1);
>                $shapeStyle->outlineColor->setFromRGB(120, 20, 20);
>
>                $styledShape->shapeStyle = $shapeStyle;           
>                $this->shapes = array($styledShape);
>
> And then i do the
>                $pluginManager->outline->draw($this->shapes);
>
> So i expected my plugin to deal with both coordinates requests and 
> postgis requests. But i've got an error "unknown shape type". So i 
> guess the outline plugin only takes Cartoweb Shapes.
>
> Is there a way to convert my ms_ShapeObj to a cartoweb shape? Or to 
> make outline plugin draw my ms_ShapeObj?
>
> Thanks
>
> Simon Ortet
> Silogic
> _______________________________________________
> Cartoweb-users mailing list
> Cartoweb-users at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/cartoweb-users
>


More information about the Cartoweb-users mailing list