[Cartoweb-dev] Programmatic Map display

Oliver Christen oliver.christen at camptocamp.com
Fri May 9 03:36:07 EDT 2008


Hi
The map extent (or bbox) is set once and for all in the mapfile. This is the value used in all cases.

To restrict an area for a user, you will need to dynamicaly modify the EXTENT value of the mapfile.
You can easily do that by extending the location coreplugin:

class ServerRestrictedLocation extends ServerLocation {

    public function replacePlugin() {
        return 'location';
    }

    public function initializeRequest($request) {
        $msMapObj = $this->serverContext->getMapObj();
        $minx = 452100; $miny = 5213328; $maxx = 606706; $maxy = 5321475;
        $msMapObj->setExtent($minx,$miny,$maxx,$maxy);
    }
}

But you will also need to define an initialMapStates so the initial view is also limited to the extend you want.
initialMapStates are defined in /server_conf/*your*project*/*your*project*.ini
For example: mapInfo.initialMapStates.A_NAME_FOR_THIS_MAPSTATE.location.bbox = "452100, 5213328, 606706, 5321475"
Then this is called via "initialState=A_NAME_FOR_THIS_MAPSTATE" in the url

The implementation above is a bit crude, you noticed I put the $minx,$miny,$maxx,$maxy in hard in the function initializeRequest.
To do it correctly, you need to pass the selected initialMapStates bbox from client side to server side and recover that value via $selectedBbox = $request->some_new_parameter_with_the_selected_bbox_value;

To get the selected initialMapStates bbox values on client side, do $bbox = $this->cartoclient->getInitialMapState()->location->bbox;

For passing value from client to server side, see the examples in the wiki's HowTo (http://www.cartoweb.org/cwiki/HowToDisplayOnTheMapAPointFromADatabaseQuery)
the idea is the parameter is set on client side via buildRequest(), it must be defined in the restrictedLocation/common/Location.php file and you can recover it from most of the functions on server side. http://www.cartoweb.org/doc/misc/plugins_diagram.pdf

regards
Oliver
  ----- Original Message ----- 
  From: E. Appora-Gnékindy 
  To: Oliver Christen 
  Cc: cartoweb-dev at lists.maptools.org 
  Sent: Thursday, May 08, 2008 3:32 PM
  Subject: [Cartoweb-dev] Programmatic Map display


  Thanks a lot Oliver, I took a look a the edit plugin and I 'll definitey use it. 
  Another requirement of our project is that volunteers be assigned a and shown only a given section of an image to work on. This seems to require a programmatic map display. I am not sure how to do this with static parameters in the mapfile configuration. 
  Any ideas on how to handle this?

  Best,

  Eloi


  2008/5/8 Oliver Christen <oliver.christen at camptocamp.com>:

    Hi

    use the edit plugin, it will save the point, line or polygones in a postgis database.
    see the demo http://www.cartoweb.org/demos/demoEdit.php and the usage manual http://www.cartoweb.org/cwiki/HowToUseTheEdition

    regards
    Oliver
      ----- Original Message ----- 
      From: E. Appora-Gnékindy 
      To: cartoweb-dev at lists.maptools.org 
      Sent: Thursday, May 08, 2008 2:26 PM
      Subject: [Cartoweb-dev] Customizing the Outline plugin for geo-databasequeries


      Hello,

      I am working on a volunteer-based project that would use Map Server, Cartoweb and PostGIS. The prpject would use volunteers on the Internet to look at sattelite imagery over the African continent and identify feature such as roads, fileds , bridges etc. These will be saved in a PostGIS geodatabase.

      Basically, users would draw points, lines and polylines on the map shown to them. My task is to write a cartoweb plugin to save the result in PostGIS. 
      Currently, features drawn with  the outline plugin seem to be persistent only for the current session. We want the plugin  to save figures drawn on the map into the database for future use. 
      If someone has ideas on how this can be achieved, I would be very grateful.

      Regards,
      Eloi

      University of Bangui
      Central African Republic




--------------------------------------------------------------------------


      _______________________________________________
      Cartoweb-dev mailing list
      Cartoweb-dev at lists.maptools.org
      http://lists.maptools.org/mailman/listinfo/cartoweb-dev




  -- 
  E. Appora-Gnékindy Ngagnan
  Laboratoire d'Informatique
  Faculté des Sciences
  Université de Bangui 

  Tel.:+236 75 56 77 38 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/cartoweb-dev/attachments/20080509/edd9bf42/attachment.html


More information about the Cartoweb-dev mailing list