package com.lbslocal.cc.view;
import com.lbslocal.cc.common.Functions;
import com.lbslocal.cc.core.CommonAddress;
import com.lbslocal.cc.objects.v0.common.City;
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.objects.v4.addressFinder.Address;
import com.lbslocal.cc.objects.v4.addressFinder.AddressInfo;
import com.lbslocal.cc.objects.v4.addressFinder.AddressLocation;
import com.lbslocal.cc.objects.v4.addressFinder.AddressOptions;
import com.lbslocal.cc.objects.v4.addressFinder.CityLocationInfo;
import com.lbslocal.cc.objects.v4.addressFinder.District;
import com.lbslocal.cc.objects.v4.addressFinder.DistrictInfo;
import com.lbslocal.cc.objects.v4.addressFinder.IntersectionInfo;
import com.lbslocal.cc.objects.v4.addressFinder.POIInfo;
import com.lbslocal.cc.objects.v4.addressFinder.ResultRange;
import com.lbslocal.cc.objects.v4.addressFinder.Road;
import com.lbslocal.cc.objects.v4.addressFinder.RoadInfo;
public class CAddressFinderAPI {
CommonAddress ca;
// private String _maquina = "";
long iniDate;
public CAddressFinderAPI(String maquina, String server, int port, String output, String dns, String dataSource, String dataSourceRevGeo) {
// _maquina = maquina;
ca = new CommonAddress(server, port, maquina, output, dns, dataSource, dataSourceRevGeo);
}
public POIInfo findPOI(String name, City city, ResultRange resultRange, int idLicenca) throws Exception {
iniDate = System.currentTimeMillis();
POIInfo poii = new POIInfo();
try {
poii = ca.findPOI(name, city, resultRange, idLicenca);
Functions.gravarLogUnique(idLicenca, CommonAddress._findPOI, 0, iniDate, 0);
} catch (Exception e) {
throw e;
}
return poii;
}
public DistrictInfo findDistrict(District district, ResultRange rr, int idLicenca) throws Exception {
iniDate = System.currentTimeMillis();
DistrictInfo dii = new DistrictInfo();
try {
dii = ca.findDistrict(district, rr, idLicenca);
Functions.gravarLogUnique(idLicenca, CommonAddress._findPOI, 0, iniDate, 0);
} catch (Exception e) {
throw e;
}
return dii;
}
public RoadInfo findRoad(Road road, int idLicenca) throws Exception {
iniDate = System.currentTimeMillis();
RoadInfo ri = new RoadInfo();
try {
ri = ca.findRoad(road, idLicenca);
Functions.gravarLogUnique(idLicenca, CommonAddress._findPOI, 0, iniDate, 0);
} catch (Exception e) {
throw e;
}
return ri;
}
public Point getRoadXY(Road road, int idLicenca) throws Exception {
iniDate = System.currentTimeMillis();
Point pt = new Point();
try {
pt = ca.getRoadXY(road, idLicenca);
Functions.gravarLogUnique(idLicenca, CommonAddress._findPOI, 0, iniDate, 0);
} catch (Exception e) {
throw e;
}
return pt;
}
public AddressInfo findAddress(Address address, AddressOptions ao, int idLicenca) throws Exception {
iniDate = System.currentTimeMillis();
AddressInfo ai = new AddressInfo();
try {
ai = ca.findAddress(address, ao, idLicenca);
Functions.gravarLogUnique(idLicenca, CommonAddress._findAddress, 0, iniDate, 0);
} catch (Exception e) {
throw e;
}
return ai;
}
public CityLocationInfo findCity(City city, AddressOptions ao, int idLicenca) throws Exception {
iniDate = System.currentTimeMillis();
CityLocationInfo cityLocationInfo = new CityLocationInfo();
try {
cityLocationInfo = ca.findCity(city, ao, idLicenca);
Functions.gravarLogUnique(idLicenca, CommonAddress._findCity, 0, iniDate, 0);
} catch (Exception e) {
throw e;
}
return cityLocationInfo;
}
public AddressLocation getAddress(Point point, double tolerance, int idLicenca) throws Exception {
iniDate = System.currentTimeMillis();
AddressLocation al = new AddressLocation();
try {
al = ca.getAddress(point, tolerance, idLicenca, CommonAddress._getAddress, 0);
Functions.gravarLogUnique(idLicenca, CommonAddress._getAddress, 0, iniDate, 0);
} catch (Exception e) {
throw e;
}
return al;
}
public MapInfo getXYRadiusWithMap(Address address, MapOptions mo, int radius, int idLicenca) throws Exception {
iniDate = System.currentTimeMillis();
MapInfo mi = new MapInfo();
try {
mi = ca.getXYRadiusWithMap(address, mo, radius, idLicenca, CommonAddress._getXYRadiusWithMap);
Functions.gravarLogUnique(idLicenca, CommonAddress._getXYRadiusWithMap, 0, iniDate, 0);
} catch (Exception e) {
throw e;
}
return mi;
}
public Point getXY(Address address, int idLicenca) throws Exception {
iniDate = System.currentTimeMillis();
Point point = new Point();
try {
point = ca.getXY(address, idLicenca);
Functions.gravarLogUnique(idLicenca, CommonAddress._getXY, 0, iniDate, 0);
} catch (Exception e) {
throw e;
}
return point;
}
public Point getXY(String key, Address address, int idLicenca) throws Exception {
iniDate = System.currentTimeMillis();
Point point = new Point();
try {
point = ca.getXY(address, idLicenca);
Functions.gravarLogUnique(idLicenca, CommonAddress._getXY, 0, iniDate, 0);
} catch (Exception e) {
throw e;
}
return point;
}
public IntersectionInfo getIntersection(City city, String street1, String street2, int id_licenca) throws Exception {
iniDate = System.currentTimeMillis();
IntersectionInfo ii = new IntersectionInfo();
try {
ii = ca.getIntersection(city, street1, street2);
Functions.gravarLogUnique(id_licenca, CommonAddress._getIntersection, 0, iniDate, 0);
} catch (Exception e) {
throw e;
}
return ii;
}
}