1 |
package dk.daoas.fulddaekning.osrm; |
package dk.daoas.fulddaekning.osrm; |
2 |
|
|
3 |
import java.io.IOException; |
import java.io.IOException; |
|
import java.util.ArrayList; |
|
4 |
import java.util.Collection; |
import java.util.Collection; |
|
import java.util.Iterator; |
|
|
import java.util.List; |
|
|
import java.util.concurrent.Future; |
|
5 |
import java.util.logging.Level; |
import java.util.logging.Level; |
6 |
import java.util.logging.Logger; |
import java.util.logging.Logger; |
7 |
|
|
8 |
|
import net.minidev.json.JSONValue; |
9 |
|
|
10 |
import org.apache.http.HttpEntity; |
import org.apache.http.HttpEntity; |
|
import org.apache.http.HttpHost; |
|
|
import org.apache.http.HttpRequest; |
|
11 |
import org.apache.http.HttpResponse; |
import org.apache.http.HttpResponse; |
12 |
import org.apache.http.client.ClientProtocolException; |
import org.apache.http.client.ClientProtocolException; |
13 |
import org.apache.http.client.ResponseHandler; |
import org.apache.http.client.ResponseHandler; |
14 |
import org.apache.http.client.methods.HttpGet; |
import org.apache.http.client.methods.HttpGet; |
15 |
import org.apache.http.impl.client.CloseableHttpClient; |
import org.apache.http.impl.client.CloseableHttpClient; |
16 |
import org.apache.http.impl.client.HttpClients; |
import org.apache.http.impl.client.HttpClients; |
|
import org.apache.http.impl.nio.client.CloseableHttpPipeliningClient; |
|
|
import org.apache.http.impl.nio.client.HttpAsyncClients; |
|
17 |
import org.apache.http.util.EntityUtils; |
import org.apache.http.util.EntityUtils; |
18 |
|
|
19 |
import com.google.gson.Gson; |
import com.google.gson.Gson; |
67 |
|
|
68 |
try { |
try { |
69 |
String txtResponse = HttpUtil.getContentString(sb.toString(), 500, "UTF-8"); |
String txtResponse = HttpUtil.getContentString(sb.toString(), 500, "UTF-8"); |
70 |
OSRMDistanceTable table = gson.fromJson(txtResponse, OSRMDistanceTable.class); |
//OSRMDistanceTable table = gson.fromJson(txtResponse, OSRMDistanceTable.class); |
71 |
|
OSRMDistanceTable table = JSONValue.parse(txtResponse, OSRMDistanceTable.class); |
72 |
if (table.status != 0) { |
if (table.status != 0) { |
73 |
logger.info("OSRM failed with message: " + table.status_message); |
logger.info("OSRM failed with message: " + table.status_message); |
74 |
return null; |
return null; |