--- dao/DaoAdresseVedligehold/src/main/java/dk/daoas/adressevedligehold/afstandandenrute/OSRMHelper.java 2016/01/30 14:05:53 2878 +++ dao/DaoAdresseVedligehold/src/main/java/dk/daoas/adressevedligehold/afstandandenrute/OSRMHelper.java 2016/02/03 21:31:51 2908 @@ -2,31 +2,28 @@ import java.util.Collection; import java.util.logging.Level; -import java.util.logging.Logger; import com.google.gson.Gson; +import dk.daoas.adressevedligehold.ServiceConfig; import dk.daoas.adressevedligehold.beans.Address; +import dk.daoas.adressevedligehold.tasks.TaskLogger; import dk.daoas.adressevedligehold.util.HttpUtil; public class OSRMHelper { - final static Logger logger = Logger.getLogger( OSRMHelper.class.toString() ); + private TaskLogger logger = TaskLogger.getInstance(); + Gson gson = new Gson(); - //static OSRMBinding binding = null; + final static int PORT = 5000; + final String base_url = "http://" + ServiceConfig.getInstance().osrmHost + ":" + PORT; - final String host = "127.0.0.1"; - //final String host = "10.30.2.103"; - final int port = 5000; - final String base_url = "http://" + host + ":" + port; - - - public Address getNearestTableHttp(Address a1, Collection
haystack) { + public Address getNearestTableHttp(Address a1, Collection
haystack) throws Exception { Address bedsteAddress = null; @@ -45,7 +42,7 @@ try { - String txtResponse = HttpUtil.getContentString(sb.toString(), 500, "UTF-8"); + String txtResponse = HttpUtil.getContentString(sb.toString(), 750, "UTF-8"); OSRMDistanceTable table = gson.fromJson(txtResponse, OSRMDistanceTable.class); @@ -65,7 +62,7 @@ System.out.println(txtResponse); - System.exit(0); + throw new Exception("Wrong number of results in matrix"); } int bedsteTid = Integer.MAX_VALUE; @@ -82,7 +79,7 @@ logger.log(Level.SEVERE, "Lookup failed", e); System.out.println( sb.toString() ); System.out.println( a1 ); - System.exit(1); + throw e; //Re-throw } //return gson.fromJson(txtResponse, OSRMResponse.class);