43 |
|
|
44 |
//static OSRMBinding binding = null; |
//static OSRMBinding binding = null; |
45 |
|
|
46 |
final String host = "127.0.0.1"; |
//final String host = "127.0.0.1"; |
47 |
|
final String host = "10.30.2.103"; |
48 |
final int port = 5000; |
final int port = 5000; |
49 |
final String base_url = "http://" + host + ":" + port; |
final String base_url = "http://" + host + ":" + port; |
50 |
/* |
/* |
99 |
|
|
100 |
return bedsteAdresse; |
return bedsteAdresse; |
101 |
} |
} |
102 |
|
|
103 |
|
|
104 |
|
|
105 |
/* |
/* |
106 |
public Adresse getNearestTableJni(Adresse a1, Collection<Adresse> haystack) { |
public Adresse getNearestTableJni(Adresse a1, Collection<Adresse> haystack) { |
107 |
if (binding == null) { |
if (binding == null) { |
144 |
return bedsteAdresse; |
return bedsteAdresse; |
145 |
}*/ |
}*/ |
146 |
|
|
147 |
|
|
148 |
|
public Adresse getNearestMultitargetHttp(Adresse a1, Collection<Adresse> haystack) { |
149 |
|
|
150 |
|
Adresse bedsteAdresse = null; |
151 |
|
|
152 |
|
Adresse hayArray[] = new Adresse[ haystack.size() ]; |
153 |
|
haystack.toArray(hayArray); |
154 |
|
|
155 |
|
StringBuilder sb = new StringBuilder(); |
156 |
|
sb.append(base_url); |
157 |
|
sb.append("/multitarget?loc=").append(a1.latitude).append(",").append(a1.longitude); |
158 |
|
|
159 |
|
for(int i = 0; i<hayArray.length; i++) { |
160 |
|
Adresse a = hayArray[i]; |
161 |
|
sb.append("&loc=").append( a.latitude ).append(",").append(a.longitude); |
162 |
|
} |
163 |
|
|
164 |
|
try { |
165 |
|
String txtResponse = HttpUtil.getContentString(sb.toString(), 500, "UTF-8"); |
166 |
|
OSRMMultiTarget table = gson.fromJson(txtResponse, OSRMMultiTarget.class); |
167 |
|
|
168 |
|
|
169 |
|
double bedsteAfstand = Double.MAX_VALUE; |
170 |
|
|
171 |
|
for (int i = 1; i<table.distances.length; i++) { |
172 |
|
if (table.distances[i].distance < bedsteAfstand) { |
173 |
|
bedsteAfstand = table.distances[i].distance; |
174 |
|
bedsteAdresse = hayArray[i]; |
175 |
|
} |
176 |
|
} |
177 |
|
|
178 |
|
} catch (Exception e) { |
179 |
|
logger.log(Level.SEVERE, "Lookup failed", e); |
180 |
|
System.exit(1); |
181 |
|
} |
182 |
|
|
183 |
|
|
184 |
|
return bedsteAdresse; |
185 |
|
} |
186 |
|
|
187 |
public Adresse getNearestViarouteHttp(Adresse a1, Collection<Adresse> haystack) { |
public Adresse getNearestViarouteHttp(Adresse a1, Collection<Adresse> haystack) { |
188 |
int bedsteAfstand = Integer.MAX_VALUE; |
int bedsteAfstand = Integer.MAX_VALUE; |
189 |
Adresse bedsteAdresse = null; |
Adresse bedsteAdresse = null; |