public Point getRoadXY(Road road, int idLicenca) throws Exception {
int iCount = 0, roadNumber = 0;
Point pt = new Point();
Pagination pg;
boolean hasState = (road.getCity().getState() != null && road.getCity().getState().compareTo("") != 0);
if (!hasState) {
throw (new Exception("O estado deve ser informado."));
}
if (Functions.IsNullOrEmpty(road.getCity().getCountry()))
road.getCity().setCountry("Brasil");
try {
// transformar valores null em "" para n�o dar null pointer
// exception
if (road.getName() == null)
road.setName("");
if (road.getRoadNumber() == null)
road.setRoadNumber("");
if (road.getCity().getName() == null)
road.getCity().setName("");
if (road.getCity().getState() == null)
road.getCity().setState("");
if (road.getZip() == null)
road.setZip("");
// validando n�mero
if (!road.getRoadNumber().equals("")) {
if (Functions.isNumeric(road.getRoadNumber().replace(".", "").replace(",", "").replace("-", "").replace("e", "")))
roadNumber = Integer.parseInt(road.getRoadNumber());
}
if (roadNumber == 0)
road.setRoadNumber("");
else
road.setRoadNumber(String.valueOf(roadNumber));
// se o valor de endere�o, cidade e estado for em branco erro
// se cepe o cep forem em brancos da a mensagem de erro
if (road.getZip() == "")
if ((road.getName() == "") && ((road.getCity().getName() == "") || (road.getCity().getState() == "")))
throw (new Exception(
"Os atributos address.street, city.name e city.state devem ser informados quando o atributo address.zip nao e informado."));
if (road.getZip().length() == 8)
road.setZip(road.getZip().substring(0, 5) + "-" + road.getZip().substring(5, 8));
Connection con = dataBase.getConnection(Functions.getDataBase(idLicenca, "Brasil").getSource());
CallableStatement cst = con.prepareCall("{call cp_WS_KM(?,?,?,?,?)}");
cst.setString(1, road.getRoadNumber());
cst.setString(2, road.getName());
cst.setString(3, road.getCity().getName());
cst.setString(4, road.getCity().getState());
cst.setString(5, road.getZip());
cst.execute();
ResultSet rs1 = cst.getResultSet();
CachedRowSetImpl crs = new CachedRowSetImpl();
crs.populate(rs1);
int TotalRecords = crs.size();
if (TotalRecords > 0) {
try {
pg = Functions.definePage(TotalRecords, 1, 0);
// RoadLocation[] rl;
if (pg.getRecordsInitial() <= TotalRecords) {
// rl = new RoadLocation[(pg.getRecordsFinal() -
// pg.getRecordsInitial()) + 1];
for (int intI = pg.getRecordsInitial(); intI <= pg.getRecordsFinal(); intI++) {
if (rs1.absolute(intI)) {
pt.setX(Double.parseDouble(rs1.getString("X")));
pt.setY(Double.parseDouble(rs1.getString("Y")));
iCount++;