01: package org.wfp.vam.intermap.services.map;
02:
03: import java.util.*;
04:
05: import org.jdom.*;
06:
07: import jeeves.interfaces.*;
08: import jeeves.server.*;
09: import jeeves.server.context.*;
10:
11: import org.wfp.vam.intermap.kernel.map.*;
12:
13: import org.wfp.vam.intermap.Constants;
14: import org.wfp.vam.intermap.kernel.map.mapServices.MapService;
15:
16: //=============================================================================
17:
18: /** main.result service. shows search results
19: */
20:
21: public class GetPrintImage implements Service {
22: public void init(String appPath, ServiceConfig config)
23: throws Exception {
24: }
25:
26: //--------------------------------------------------------------------------
27: //---
28: //--- Service
29: //---
30: //--------------------------------------------------------------------------
31:
32: public Element exec(Element params, ServiceContext context)
33: throws Exception {
34: // Get the MapMerger object from the user session
35: MapMerger mm = MapUtil.getMapMerger(context);
36:
37: String imagename = mm.merge(Constants.PRINT_WIDTH,
38: Constants.PRINT_HEIGHT);
39: String url = MapUtil.getTempUrl() + "/" + imagename;
40: String tool = MapUtil.getTool(context);
41:
42: // Sets the legends element, containing the URLs of the legends of all
43: // The layers in the map
44: Element legends = new Element("legends");
45: // for (Enumeration e = mm.getServices(); e.hasMoreElements(); ) {
46: // MapService ms = (MapService)e.nextElement();
47: for (MapService service : mm.getServices()) {
48: String u = service.getLegendUrl();
49: if (u != null && u != "")
50: legends.addContent(new Element("legend").addContent(u));
51: }
52:
53: // Bulid the XML response
54: return new Element("response").addContent(
55: new Element(Constants.URL).setText(url)).addContent(
56: new Element("tool").setText(tool)).addContent(
57: mm.toElement()).addContent(legends);
58: }
59:
60: }
61:
62: //=============================================================================
|