本文整理汇总了Java中de.schildbach.pte.dto.SuggestLocationsResult类的典型用法代码示例。如果您正苦于以下问题:Java SuggestLocationsResult类的具体用法?Java SuggestLocationsResult怎么用?Java SuggestLocationsResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SuggestLocationsResult类属于de.schildbach.pte.dto包,在下文中一共展示了SuggestLocationsResult类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: suggest
import de.schildbach.pte.dto.SuggestLocationsResult; //导入依赖的package包/类
@RequestMapping(value = "/v2/station/suggest", method = RequestMethod.GET)
@ResponseBody
public ResponseEntity suggest(@RequestParam("q") final String query, @RequestParam(value = "provider", required = false) String providerName, @RequestParam(value = "locationType", required = false) String stationType) throws IOException {
NetworkProvider provider = getNetworkProvider(providerName);
if (provider == null)
return ResponseEntity.status(HttpStatus.NOT_FOUND).body("Provider " + providerName + " not found or can not instantiated...");
SuggestLocationsResult suggestLocations = provider.suggestLocations(query);
if (SuggestLocationsResult.Status.OK.equals(suggestLocations.status)) {
Iterator<Location> iterator = suggestLocations.getLocations().iterator();
LocationType locationType = getLocationType(stationType);
List<Location> resultList = new ArrayList<>();
if (locationType == null) {
return ResponseEntity.status(HttpStatus.NOT_FOUND).body("LocationType " + stationType + " not found or can not instantiated...");
} else if (!LocationType.ANY.equals(locationType)) {
while (iterator.hasNext()) {
Location loc = iterator.next();
if (locationType.equals(loc.type)) {
resultList.add(loc);
}
}
} else {
resultList.addAll(suggestLocations.getLocations());
}
return ResponseEntity.status(HttpStatus.OK).contentType(MediaType.APPLICATION_JSON).body(resultList);
} else {
return ResponseEntity.status(HttpStatus.REQUEST_TIMEOUT).body("Remote Service is down or temporarily not available");
}
}
示例2: suggest
import de.schildbach.pte.dto.SuggestLocationsResult; //导入依赖的package包/类
@RequestMapping(value = "/station/suggest", method = RequestMethod.GET)
@ResponseBody
public ResponseEntity suggest(@RequestParam("q") final String query, @RequestParam(value = "provider", required = false) String providerName, @RequestParam(value = "locationType", required = false) String stationType) throws IOException {
NetworkProvider provider;
if (providerName != null) {
provider = ProviderUtil.getObjectForProvider(providerName);
} else
provider = new VagfrProvider();
if (provider == null)
return ResponseEntity.status(HttpStatus.NOT_FOUND).body("Provider " + providerName + " not found or can not instantiated...");
SuggestLocationsResult suggestLocations = provider.suggestLocations(query);
if (SuggestLocationsResult.Status.OK.equals(suggestLocations.status)) {
Iterator<Location> iterator = suggestLocations.getLocations().iterator();
LocationType locationType = getLocationType(stationType);
List<Location> resultList = new ArrayList<>();
if (locationType == null) {
return ResponseEntity.status(HttpStatus.NOT_FOUND).body("LocationType " + stationType + " not found or can not instantiated...");
} else if (!LocationType.ANY.equals(locationType)) {
while (iterator.hasNext()) {
Location loc = iterator.next();
if (locationType.equals(loc.type)) {
resultList.add(loc);
}
}
} else {
resultList.addAll(suggestLocations.getLocations());
}
return ResponseEntity.status(HttpStatus.OK).contentType(MediaType.APPLICATION_JSON).body(resultList);
} else {
return ResponseEntity.status(HttpStatus.REQUEST_TIMEOUT).body("Remote Service is down or temporarily not available");
}
}
示例3: queryLocation
import de.schildbach.pte.dto.SuggestLocationsResult; //导入依赖的package包/类
private Location queryLocation(String constraint, Set<LocationType> types)
throws IOException {
Validate.notNull(constraint);
Validate.noNullElements(types);
final SuggestLocationsResult suggestLocationsResult = networkProviderService
.suggestLocations(constraint);
if (suggestLocationsResult == null
|| suggestLocationsResult.status != Status.OK) {
return null;
} else {
final List<Location> originalSuggestedLocations = suggestLocationsResult
.getLocations();
if (originalSuggestedLocations.isEmpty()) {
return null;
} else {
final List<Location> suggestedLocations = new ArrayList<Location>(
suggestLocationsResult.getLocations());
for (Iterator<Location> suggestedLocationsIterator = suggestedLocations
.iterator(); suggestedLocationsIterator.hasNext();) {
final Location suggestedLocation = suggestedLocationsIterator
.next();
if (!types.contains(suggestedLocation.type)) {
suggestedLocationsIterator.remove();
}
}
if (!suggestedLocations.isEmpty()) {
return suggestedLocations.get(0);
} else {
return originalSuggestedLocations.get(0);
}
}
}
}
示例4: suggestLocations
import de.schildbach.pte.dto.SuggestLocationsResult; //导入依赖的package包/类
public SuggestLocationsResult suggestLocations(final CharSequence constraint)
throws IOException {
final SuggestLocationsResult suggestLocationsResult = networkProvider
.suggestLocations(constraint);
if (suggestLocationsResult.status == SuggestLocationsResult.Status.SERVICE_DOWN) {
throw new IOException("Service down (suggestLocations).");
} else {
return suggestLocationsResult;
}
}
示例5: testStation
import de.schildbach.pte.dto.SuggestLocationsResult; //导入依赖的package包/类
@Test
public void testStation() throws IOException {
final SuggestLocationsResult result = provider
.suggestLocations("Berlin U-Bahn Jannowitzbrücke");
final List<Location> locations = result.getLocations();
Assert.assertFalse(locations.isEmpty());
Location location = locations.get(0);
Assert.assertEquals("8089019", location.id);
}
示例6: testAddress
import de.schildbach.pte.dto.SuggestLocationsResult; //导入依赖的package包/类
@Test
public void testAddress() throws IOException {
final SuggestLocationsResult result = provider
.suggestLocations("Singerstr. 109, 10179 Berlin - Mitte, Deutschland");
final List<Location> locations = result.getLocations();
Assert.assertFalse(locations.isEmpty());
Location location = locations.get(0);
Assert.assertEquals("Singerstraße 109", location.name);
Assert.assertEquals("Berlin - Mitte", location.place);
}
示例7: testQueryTrips
import de.schildbach.pte.dto.SuggestLocationsResult; //导入依赖的package包/类
@Test
public void testQueryTrips() throws IOException {
final SuggestLocationsResult hotelLocationsResult = provider
.suggestLocations("Singerstr. 109, 10179 Berlin - Mitte, Deutschland");
final List<Location> hotelLocations = hotelLocationsResult
.getLocations();
Assert.assertFalse(hotelLocations.isEmpty());
final Location hotelLocation = hotelLocations.get(0);
final SuggestLocationsResult destinationLocationsResult = provider
.suggestLocations("Berlin U-Bahn Jannowitzbrücke");
final List<Location> destinationLocations = destinationLocationsResult
.getLocations();
Assert.assertFalse(destinationLocations.isEmpty());
final Location destinationLocation = destinationLocations.get(0);
final QueryTripsResult result = provider.queryTrips(hotelLocation,
null, destinationLocation, new Date(), true, Product.ALL,
WalkSpeed.NORMAL, Accessibility.NEUTRAL, null);
Assert.assertFalse(result.trips.isEmpty());
final Trip trip = result.trips.get(0);
int numChanges = trip.numChanges;
boolean firstLeg = true;
long walkDuration = 0;
for (Leg leg : trip.legs) {
if (firstLeg) {
firstLeg = false;
if (leg instanceof Individual) {
final Individual individual = (Individual) leg;
if (individual.type == Trip.Individual.Type.WALK) {
walkDuration = individual.getArrivalTime().getTime()
- individual.getDepartureTime().getTime();
}
}
}
}
long travelDuration = trip.getDuration() - walkDuration;
}
示例8: onSuggestLocationsResult
import de.schildbach.pte.dto.SuggestLocationsResult; //导入依赖的package包/类
@Override
public void onSuggestLocationsResult(@Nullable SuggestLocationsResult suggestLocationsResult) {
ui.progress.setVisibility(GONE);
if (suggestLocationsResult == null) return;
if (getAdapter() != null) {
getAdapter().swapSuggestedLocations(suggestLocationsResult.suggestedLocations, ui.location.getText().toString());
}
}
示例9: doInBackground
import de.schildbach.pte.dto.SuggestLocationsResult; //导入依赖的package包/类
@Nullable
@Override
protected SuggestLocationsResult doInBackground(String... strings) {
String search = strings[0];
if(search.length() < LocationAdapter.TYPING_THRESHOLD) return null;
NetworkProvider np = network.getNetworkProvider();
try {
return np.suggestLocations(search);
} catch(Exception e) {
return null;
}
}
示例10: onPostExecute
import de.schildbach.pte.dto.SuggestLocationsResult; //导入依赖的package包/类
@Override
protected void onPostExecute(SuggestLocationsResult suggestLocationsResult) {
callback.onSuggestLocationsResult(suggestLocationsResult);
}
示例11: onSuggestLocationsResult
import de.schildbach.pte.dto.SuggestLocationsResult; //导入依赖的package包/类
void onSuggestLocationsResult(@Nullable SuggestLocationsResult suggestLocationsResult);