package com.lbslocal.api.connect;
import com.lbslocal.master.common.ConfigurationManager;
import com.lbslocal.api.objects.TokenValidated;
import com.lbslocal.api.proxy.Proxy;
import com.lbslocal.api.utils.Common;
import com.lbslocal.cc.objects.v0.common.City;
import com.lbslocal.cc.objects.v0.common.Extent;
import com.lbslocal.cc.objects.v0.common.MapInfo;
import com.lbslocal.cc.objects.v0.common.MapOptions;
import com.lbslocal.cc.objects.v0.common.Point;
import com.lbslocal.cc.view.CMapRenderAPI;
public class ControlMapRender {
final static int getMap = 0;
final static int getZoom = 1;
final static int getPan = 2;
final static int getZoomRadius = 3;
final static int getZoomWindow = 4;
final static int getZoomState = 5;
final static int getZoomCity = 6;
public static String runService(Proxy proxy, TokenValidated tk) throws Exception {
Object[] o;
MapInfo mInfo;
String respostaWs = "";
ConfigurationManager cm = ConfigurationManager.getInstance();
CMapRenderAPI mapRender = new CMapRenderAPI(cm.getAppSettings("Maquina"), cm.getAppSettings("Server"), 11188, cm.getAppSettings("dirOutPut"),
cm.getAppSettings("webOutPut"), cm.getAppSettings("M_BASEDECARTA_MAPAS"));
switch (getService(proxy.GetService())) {
case getMap:
o = Common.getArrayByJSon(proxy.getParameters("tjss"), new Class[] { String.class, Extent.class, MapOptions.class });
mInfo = mapRender.getMap((String) o[0], (Extent) o[1], (MapOptions) o[2], tk.getId());
respostaWs = Common.SerializeJSObject(mInfo);
break;
case getZoom:
o = Common.getArrayByJSon(proxy.getParameters("tjss"), new Class[] { String.class, Extent.class, Double.class, MapOptions.class });
mInfo = mapRender.getZoom((String) o[0], (Extent) o[1], (Double) o[2], (MapOptions) o[3], tk.getId());
respostaWs = Common.SerializeJSObject(mInfo);
break;
case getPan:
o = Common.getArrayByJSon(proxy.getParameters("tjss"), new Class[] { String.class, Integer.class, Double.class, Extent.class,
MapOptions.class });
double trans = ((Integer) o[2] * 1);
mInfo = mapRender.getPan((String) o[0], (Integer) o[1], trans, (Extent) o[3], (MapOptions) o[4], tk.getId());
respostaWs = Common.SerializeJSObject(mInfo);
break;
case getZoomRadius:
o = Common.getArrayByJSon(proxy.getParameters("tjss"), new Class[] { String.class, Point.class, Integer.class, MapOptions.class });
mInfo = mapRender.getZoomRadius((String) o[0], (Point) o[1], (Integer) o[2], (MapOptions) o[3], tk.getId(), "png");
respostaWs = Common.SerializeJSObject(mInfo);
break;
case getZoomWindow:
o = Common.getArrayByJSon(proxy.getParameters("tjss"), new Class[] { String.class, Extent.class, Extent.class, MapOptions.class });
mInfo = mapRender.getZoomWindow((String) o[0], (Extent) o[1], (Extent) o[2], (MapOptions) o[3], tk.getId());
respostaWs = Common.SerializeJSObject(mInfo);
break;
case getZoomState:
o = Common.getArrayByJSon(proxy.getParameters("tjss"), new Class[] { String.class, MapOptions.class, String.class });
mInfo = mapRender.getZoomState((String) o[0], (MapOptions) o[1], (String) o[2], tk.getId());
respostaWs = Common.SerializeJSObject(mInfo);
break;
case getZoomCity:
o = Common.getArrayByJSon(proxy.getParameters("tjss"), new Class[] { String.class, MapOptions.class, City.class });
mInfo = mapRender.getZoomCity((String) o[0], (MapOptions) o[1], (City) o[2], tk.getId());
respostaWs = Common.SerializeJSObject(mInfo);
break;
}
return respostaWs;
}
private static int getService(String service) {
int serv = -1;
if (service.equals("getMap"))
serv = getMap;
if (service.equals("getZoom"))
serv = getZoom;
if (service.equals("getPan"))
serv = getPan;
if (service.equals("getZoomRadius"))
serv = getZoomRadius;
if (service.equals("getZoomWindow"))
serv = getZoomWindow;
if (service.equals("getZoomState"))
serv = getZoomState;
if (service.equals("getZoomCity"))
serv = getZoomCity;
return serv;
}
}