2 |
|
|
3 |
import java.util.Collection; |
import java.util.Collection; |
4 |
import java.util.logging.Level; |
import java.util.logging.Level; |
|
import java.util.logging.Logger; |
|
5 |
|
|
6 |
import com.google.gson.Gson; |
import com.google.gson.Gson; |
7 |
|
|
8 |
import dk.daoas.adressevedligehold.ServiceConfig; |
import dk.daoas.adressevedligehold.ServiceConfig; |
9 |
import dk.daoas.adressevedligehold.beans.Address; |
import dk.daoas.adressevedligehold.beans.Address; |
10 |
|
import dk.daoas.adressevedligehold.tasks.TaskLogger; |
11 |
import dk.daoas.adressevedligehold.util.HttpUtil; |
import dk.daoas.adressevedligehold.util.HttpUtil; |
12 |
|
|
13 |
|
|
14 |
public class OSRMHelper { |
public class OSRMHelper { |
15 |
|
|
16 |
|
|
17 |
final static Logger logger = Logger.getLogger( OSRMHelper.class.toString() ); |
private TaskLogger logger = TaskLogger.getInstance(); |
18 |
|
|
19 |
|
|
20 |
Gson gson = new Gson(); |
Gson gson = new Gson(); |
21 |
|
|
22 |
final int port = 5000; |
final static int PORT = 5000; |
23 |
final String base_url = "http://" + ServiceConfig.getInstance().osrmHost + ":" + port; |
final String base_url = "http://" + ServiceConfig.getInstance().osrmHost + ":" + PORT; |
24 |
|
|
25 |
|
|
26 |
public Address getNearestTableHttp(Address a1, Collection<Address> haystack) throws Exception { |
public Address getNearestTableHttp(Address a1, Collection<Address> haystack) throws Exception { |
42 |
|
|
43 |
try { |
try { |
44 |
|
|
45 |
String txtResponse = HttpUtil.getContentString(sb.toString(), 500, "UTF-8"); |
String txtResponse = HttpUtil.getContentString(sb.toString(), 1000, "UTF-8"); |
46 |
|
|
47 |
OSRMDistanceTable table = gson.fromJson(txtResponse, OSRMDistanceTable.class); |
OSRMDistanceTable table = gson.fromJson(txtResponse, OSRMDistanceTable.class); |
48 |
|
|