package br.com.maplink.decarta;
import br.com.maplink.decarta.bean.Address;
import br.com.maplink.decarta.bean.DecartaForm;
public class Templates {
public DecartaForm form;
public Templates(){
form = new DecartaForm();
}
public String Geocode(Address address) {
String format = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
format += "<ns1:XLS version=\"1.0\" ns1:lang=\"en\" xmlns:ns1=\"http://www.opengis.net/xls\">\n";
format += "<ns1:RequestHeader clientName=\"" + form.getUsername() + "\" sessionID=\"123\" configuration=\"maplink-tile\" clientPassword=\""+form.getPassword()+"\"/>\n";
format += "<ns1:Request requestID=\"1\" maximumResponses=\"1000\" version=\"1.0\" methodName=\"GeocodeRequest\">\n";
format += "<ns1:GeocodeRequest report=\""+form.debug+"\"><ns1:Address countryCode=\"BR\" language=\"PT\"><ns1:StreetAddress>\n";
format += "<ns1:Building number=\""+ address.getNumber() + "\"/>\n";
format += "<ns1:Street>"+address.getFullAddress()+"</ns1:Street>\n";
format += "</ns1:StreetAddress>\n";
format += "<ns1:Place type=\"CountrySubdivision\">"+address.getState()+"</ns1:Place>\n";
format += "<ns1:Place type=\"Municipality\">"+address.getCity()+"</ns1:Place>\n";
format += "</ns1:Address></ns1:GeocodeRequest></ns1:Request></ns1:XLS>\n";
return format;
}
public String Geocode_FreeForm(String freeFormAddress) {
String format = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>";
format += "<ns1:XLS ns1:lang=\"en\" version=\"1.0\" rel=\"4.6.1\" xmlns:ns1=\"http://www.opengis.net/xls\">";
format += "<ns1:RequestHeader sessionID=\"999\" clientPassword=\"maplink\" clientName=\"ws_maplink\"/>";
format += "<ns1:Request requestID=\"10\" methodName=\"GeocodeRequest\" maximumResponses=\"25\" version=\"1.0\">";
format += "<ns1:GeocodeRequest><ns1:Address language=\"PT\" countryCode=\"BR\">";
// FreeForm
format += "<ns1:freeFormAddress>" + freeFormAddress + "</ns1:freeFormAddress>";
format += "</ns1:Address></ns1:GeocodeRequest></ns1:Request></ns1:XLS>";
return format;
}
}