[Cartoweb-users] How to query mapOverlay

Carolin Latze carolin.latze at unifr.ch
Mon Dec 10 11:01:10 EST 2007


Hi again,

well, I solved that one... I had to define the mapOverlay in
initializeRequest instead of in handlePreDrawing. But there arose
another question... Is there a method to retrieve the values of the
shape attributes of a postgis layer? Using shapefiles, I did this using
layer->getshape and shape->values. That doesn't seem to work anymore
(seems to return empty set). Is there any other function to use on
postgis layers?

Regards
Carolin

Carolin Latze wrote:
> Hi list,
>
> I declared the following layer in my mapfile:
>
>   LAYER
>     TRANSPARENCY 100
>     NAME "BackmehlBetriebe122000"
>     CONNECTIONTYPE postgis
>     TEMPLATE "ttt"
>     LABELCACHE on
>     STATUS ON
>     DEBUG false
>     TRANSFORM true
>     CONNECTION 'XXX'
>     DATA 'the_geom FROM Backmehl311200 USING UNIQUE gid USING SRID=-1'
>     TYPE POINT
>     CLASS
>       NAME '>3226.31'
>       EXPRESSION ([menge]>=3226.31)
>       STYLE
>         SYMBOL "square"
>         SIZE 12
>         COLOR 30 110 222
>         OUTLINECOLOR 0 0 0
>       END
>     END
>     CLASS
>       NAME '1107.4-3226.31'
>       EXPRESSION ([menge]>=1107.4 AND [menge]<3226.31)
>       STYLE
>         SYMBOL "square"
>         SIZE 10
>         COLOR 30 110 222
>         OUTLINECOLOR 0 0 0
>       END
>     END
>     CLASS
>       NAME '309.5-1107.4'
>       EXPRESSION ([menge]>=309.5 AND [menge]<1107.4)
>       STYLE
>         SYMBOL "square"
>         SIZE 8
>         COLOR 30 110 222
>         OUTLINECOLOR 0 0 0
>       END
>     END
>     CLASS
>       NAME '91.45-309.5'
>       EXPRESSION ([menge]>=91.45 AND [menge]<309.5)
>       STYLE
>         SYMBOL "square"
>         SIZE 4
>         COLOR 30 110 222
>         OUTLINECOLOR 0 0 0
>       END
>     END
>     CLASS
>       NAME '<91.45'
>       EXPRESSION ([menge] < 91.45)
>       STYLE
>         SYMBOL "square"
>         SIZE 2
>         COLOR 30 110 222
>         OUTLINECOLOR 0 0 0
>       END
>     END
>     METADATA
>       "id_attribute_string" "id|int"
>     END
>   END
>
> This layer can be displayed and queried. To modify the DATA value, I
> wrote a plugin containing this code sniplet:
>
>      //BEGIN Overlay
>     $overlay=new LayerOverlay();
>     $overlay->name="BackmehlBetriebe122000";
>     $overlay->data='the_geom FROM (SELECT gid,id,btrname,SUM(menge) AS
> menge,the_geom FROM Backmehl311200 GROUP BY gid,id,btrname,the_geom) AS
> FilteredBackmehl311200 USING UNIQUE gid USING SRID=-1';
>
>     $mapOverlay=$this->serverContext->getPluginManager()->mapOverlay;
>     $mapOverlay->updateMap($overlay);
>     $this->serverContext->getMapObj()->save('./debug.map');
>     //END Overlay
>
> This plugins seems to work... if I read out the attributes I see that it
> only shows the ones, I want to see. But I cannot query this layer
> anymore. There is no error message, it simply does not output anything .
> The debug.map looks as follows:
>
>   LAYER
>     CONNECTION "XXX"
>     CONNECTIONTYPE POSTGIS
>     DATA "the_geom FROM (SELECT gid,id,btrname,SUM(menge) AS
> menge,the_geom FROM Backmehl311200 GROUP BY gid,id,btrname,the_geom) AS
> FilteredBackmehl311200 USING UNIQUE gid USING SRID=-1"
>     METADATA
>       "id_attribute_string"    "id|int"
>     END
>     NAME "BackmehlBetriebe122000"
>     STATUS ON
>     TEMPLATE "ttt"
>     TYPE POINT
>     UNITS METERS
>     CLASS
>       NAME ">3226.31"
>       EXPRESSION ([menge]>=3226.31)
>       STYLE
>         ANGLE 360
>         COLOR 30 110 222
>         OPACITY 100
>         OUTLINECOLOR 0 0 0
>         SIZE 12
>         SYMBOL "square"
>       END
>     END
>     CLASS
>       NAME "1107.4-3226.31"
>       EXPRESSION ([menge]>=1107.4 AND [menge]<3226.31)
>       STYLE
>         ANGLE 360
>         COLOR 30 110 222
>         OPACITY 100
>         OUTLINECOLOR 0 0 0
>         SIZE 10
>         SYMBOL "square"
>       END
>     END
>     CLASS
>       NAME "309.5-1107.4"
>       EXPRESSION ([menge]>=309.5 AND [menge]<1107.4)
>       STYLE
>         ANGLE 360
>         COLOR 30 110 222
>         OPACITY 100
>         OUTLINECOLOR 0 0 0
>         SIZE 8
>         SYMBOL "square"
>       END
>     END
>     CLASS
>       NAME "91.45-309.5"
>       EXPRESSION ([menge]>=91.45 AND [menge]<309.5)
>       STYLE
>         ANGLE 360
>         COLOR 30 110 222
>         OPACITY 100
>         OUTLINECOLOR 0 0 0
>         SIZE 4
>         SYMBOL "square"
>       END
>     END
>     CLASS
>       NAME "<91.45"
>       EXPRESSION ([menge] < 91.45)
>       STYLE
>         ANGLE 360
>         COLOR 30 110 222
>         OPACITY 100
>         OUTLINECOLOR 0 0 0
>         SIZE 2
>         SYMBOL "square"
>       END
>     END
>   END
>
> That look ok, doesn't it? Does anybody have a hint?
>
> Regards
> Carolin
> _______________________________________________
> Cartoweb-users mailing list
> Cartoweb-users at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/cartoweb-users
>   

-- 
Carolin Latze
Research Assistant

Department of Computer Science
Boulevard de Pérolles 90
CH-1700 Fribourg

phone: +41 26 300 83 30




More information about the Cartoweb-users mailing list