01: package org.wfp.vam.intermap.services.map;
02:
03: import org.jdom.*;
04:
05: import jeeves.interfaces.*;
06: import jeeves.server.*;
07: import jeeves.server.context.*;
08:
09: import org.wfp.vam.intermap.kernel.map.mapServices.BoundingBox;
10:
11: //=============================================================================
12:
13: /** main.result service. shows search results
14: */
15:
16: public class SetAoi implements Service {
17: public void init(String appPath, ServiceConfig config)
18: throws Exception {
19: }
20:
21: //--------------------------------------------------------------------------
22: //---
23: //--- Service
24: //---
25: //--------------------------------------------------------------------------
26:
27: public Element exec(Element params, ServiceContext context)
28: throws Exception {
29: int minx = Integer.parseInt(params.getChildText("minx"));
30: int miny = Integer.parseInt(params.getChildText("miny"));
31: int maxx = Integer.parseInt(params.getChildText("maxx"));
32: int maxy = Integer.parseInt(params.getChildText("maxy"));
33:
34: BoundingBox bb = MapUtil.getMapMerger(context).getBoundingBox();
35:
36: int imageWidth = MapUtil.getImageWidth(context);
37: int imageHeight = MapUtil.getImageHeight(context);
38:
39: float mapx = bb.getWest() + (bb.getEast() - bb.getWest())
40: * minx / imageWidth;
41: float mapy = bb.getNorth() - (bb.getNorth() - bb.getSouth())
42: * miny / imageHeight;
43: float mapx2 = bb.getWest() + (bb.getEast() - bb.getWest())
44: * maxx / imageWidth;
45: float mapy2 = bb.getNorth() - (bb.getNorth() - bb.getSouth())
46: * maxy / imageHeight;
47:
48: MapUtil.setAoi(context, mapx, mapy, mapx2, mapy2);
49:
50: //System.out.println(MapUtil.getAoi(context)); // DEBUG
51:
52: return null;
53: }
54:
55: }
56:
57: //=============================================================================
|