本文整理匯總了Java中de.schildbach.pte.dto.Location類的典型用法代碼示例。如果您正苦於以下問題:Java Location類的具體用法?Java Location怎麽用?Java Location使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Location類屬於de.schildbach.pte.dto包,在下文中一共展示了Location類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: test
import de.schildbach.pte.dto.Location; //導入依賴的package包/類
@RequestMapping(value = "/connectionRaw", method = RequestMethod.GET)
@ResponseBody
public List<Trip> test(@RequestParam(value = "from", required = true) String from, @RequestParam(value = "to", required = true) String to, @RequestParam(value = "provider", required = false) String providerName, @RequestParam(value = "product", required = true) char product, @RequestParam(value = "timeOffset", required = true, defaultValue = "0") int timeOffset) throws IOException {
NetworkProvider provider;
if(providerName != null)
{
provider = ProviderUtil.getObjectForProvider(providerName);
}
else
provider = new VagfrProvider();
plannedDepartureTime.setTime(new Date().getTime() + timeOffset * 60 * 1000);
char[] products = {product};
QueryTripsResult efaData = provider.queryTrips(new Location(LocationType.STATION, from), null, new Location(LocationType.STATION, to), plannedDepartureTime, true, Product.fromCodes(products), null, null, null, null);
return efaData.trips;
}
示例2: queryTrips
import de.schildbach.pte.dto.Location; //導入依賴的package包/類
public QueryTripsResult queryTrips(final Location from,
final @Nullable Location via, final Location to, final Date date,
final boolean dep, final @Nullable Set<Product> products,
final @Nullable WalkSpeed walkSpeed,
final @Nullable Accessibility accessibility,
final @Nullable Set<Option> options) throws IOException {
final QueryTripsResult queryTripsResult = networkProvider.queryTrips(
from, via, to, date, dep, products, walkSpeed, accessibility,
options);
if (queryTripsResult.status == QueryTripsResult.Status.SERVICE_DOWN) {
throw new IOException("Service down (queryTrips).");
} else {
return queryTripsResult;
}
}
示例3: findLocationWithGeocoder
import de.schildbach.pte.dto.Location; //導入依賴的package包/類
private void findLocationWithGeocoder(final double lat, final double lon) throws IOException {
Geocoder geocoder = new Geocoder(context, Locale.getDefault());
List<Address> addresses = geocoder.getFromLocation(lat, lon, 1);
if (addresses == null || addresses.size() == 0) throw new IOException("No results");
Address address = addresses.get(0);
String name = address.getThoroughfare();
if (name == null) throw new IOException("Empty Address");
if (address.getFeatureName() != null) name += " " + address.getFeatureName();
String place = address.getLocality();
int latInt = (int) (lat * 1E6);
int lonInt = (int) (lon * 1E6);
Location l = new Location(ADDRESS, null, latInt, lonInt, place, name);
callback.onLocationRetrieved(new WrapLocation(l));
}
示例4: getFavoriteLocationByUid
import de.schildbach.pte.dto.Location; //導入依賴的package包/類
@Test
public void getFavoriteLocationByUid() throws Exception {
// insert a minimal location
Location l1 = new Location(STATION, "id", 1, 1, "place", "name", null);
FavoriteLocation f1 = new FavoriteLocation(DB, l1);
long uid = dao.addFavoriteLocation(f1);
// retrieve by UID
FavoriteLocation f2 = dao.getFavoriteLocation(uid);
// assert that retrieval worked
assertNotNull(f2);
assertEquals(uid, f2.getUid());
assertEquals(DB, f2.getNetworkId());
assertEquals(l1.type, f2.type);
assertEquals(l1.id, f2.id);
assertEquals(l1.lat, f2.lat);
assertEquals(l1.lon, f2.lon);
assertEquals(l1.place, f2.place);
assertEquals(l1.name, f2.name);
assertEquals(l1.products, f2.products);
}
示例5: createDb
import de.schildbach.pte.dto.Location; //導入依賴的package包/類
@Before
@Override
public void createDb() throws Exception {
super.createDb();
dao = db.searchesDao();
LocationDao locationDao = db.locationDao();
// create simple locations
FavoriteLocation fTmp1 = new FavoriteLocation(DB, Location.coord(1, 1));
FavoriteLocation fTmp2 = new FavoriteLocation(DB, Location.coord(2, 2));
FavoriteLocation fTmp3 = new FavoriteLocation(DB, Location.coord(3, 3));
long uid1 = locationDao.addFavoriteLocation(fTmp1);
long uid2 = locationDao.addFavoriteLocation(fTmp2);
long uid3 = locationDao.addFavoriteLocation(fTmp3);
List<FavoriteLocation> locations = getValue(locationDao.getFavoriteLocations(DB));
assertEquals(3, locations.size());
f1 = locations.get(0);
f2 = locations.get(1);
f3 = locations.get(2);
assertEquals(uid1, f1.getUid());
assertEquals(uid2, f2.getUid());
assertEquals(uid3, f3.getUid());
}
示例6: suggest
import de.schildbach.pte.dto.Location; //導入依賴的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");
}
}
示例7: isIncluded
import de.schildbach.pte.dto.Location; //導入依賴的package包/類
private boolean isIncluded(Departure stationDeparture, String numberFilter, String toFilter) {
if (toFilter != null && !toFilter.equals("*")) {
Location dest = stationDeparture.destination;
if (!(dest != null && dest.name != null && toFilter.equalsIgnoreCase(dest.name))) {
return false;
}
}
if (numberFilter != null && !numberFilter.equals("*")) {
Line line = stationDeparture.line;
if (!(line != null && line.label != null && numberFilter.equalsIgnoreCase(line.label))) {
return false;
}
}
return true;
}
示例8: suggest
import de.schildbach.pte.dto.Location; //導入依賴的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");
}
}
示例9: connection
import de.schildbach.pte.dto.Location; //導入依賴的package包/類
@RequestMapping(value = "/connection", method = RequestMethod.GET)
@ResponseBody
public ResponseEntity connection(@RequestParam(value = "from", required = true) String from, @RequestParam(value = "to", required = true) String to, @RequestParam(value = "provider", required = false) String providerName, @RequestParam(value = "product", required = true) char product, @RequestParam(value = "timeOffset", required = true, defaultValue = "0") int timeOffset) throws IOException {
NetworkProvider provider;
if(providerName != null)
{
provider = ProviderUtil.getObjectForProvider(providerName);
}
else
provider = new VagfrProvider();
plannedDepartureTime.setTime(new Date().getTime() + timeOffset * 60 * 1000);
char[] products = {product};
QueryTripsResult efaData = provider.queryTrips(new Location(LocationType.STATION, from), null, new Location(LocationType.STATION, to), plannedDepartureTime, true, Product.fromCodes(products), null, null, null, null);
if (efaData.status.name().equals("OK")) {
List<TripData> list = filterTrips(efaData.trips, from, to, "normal");
if (list.size() < 1) {
List<TripData> retryList = findMoreTrips(efaData.context, from, to, "normal", provider);
if (retryList.size() < 1)
return ResponseEntity.status(HttpStatus.NOT_FOUND).body("No trip found.");
else
return ResponseEntity.status(HttpStatus.OK).contentType(MediaType.APPLICATION_JSON).body(retryList);
} else
return ResponseEntity.status(HttpStatus.OK).contentType(MediaType.APPLICATION_JSON).body(list);
}
return ResponseEntity.status(HttpStatus.NOT_FOUND).body("EFA error status: " + efaData.status.name());
}
示例10: departureEsp
import de.schildbach.pte.dto.Location; //導入依賴的package包/類
@RequestMapping(value = "/connectionEsp", method = RequestMethod.GET)
@ResponseBody
public ResponseEntity departureEsp(@RequestParam(value = "from", required = true) String from, @RequestParam(value = "to", required = true) String to, @RequestParam(value = "provider", required = false) String providerName, @RequestParam(value = "product", required = true) char product, @RequestParam(value = "timeOffset", required = true, defaultValue = "0") int timeOffset) throws IOException {
NetworkProvider provider;
if(providerName != null)
{
provider = ProviderUtil.getObjectForProvider(providerName);
}
else
provider = new VagfrProvider();
plannedDepartureTime.setTime(new Date().getTime() + timeOffset * 60 * 1000);
char[] products = {product};
QueryTripsResult efaData = provider.queryTrips(new Location(LocationType.STATION, from), null, new Location(LocationType.STATION, to), plannedDepartureTime, true, Product.fromCodes(products), null, null, null, null);
if (efaData.status.name().equals("OK")) {
List<TripData> list = filterTrips(efaData.trips, from, to, "esp");
if (list.size() < 1) {
List<TripData> retryList = findMoreTrips(efaData.context, from, to, "esp", provider);
if (retryList.size() < 1)
return ResponseEntity.status(HttpStatus.NOT_FOUND).body("No trip found.");
else
return ResponseEntity.status(HttpStatus.OK).contentType(MediaType.APPLICATION_JSON).body("{\"connections\":[{\"from\":{\"departureTime\":\"" + retryList.get(0).getDepartureTime() + "\",\"plannedDepartureTimestamp\":" + retryList.get(0).getPlannedDepartureTimestamp() + ",\"delay\":" + retryList.get(0).getDepartureDelay() / 60 + ",\"to\": \"" + retryList.get(0).getTo() + "\" }}]}");
} else
return ResponseEntity.status(HttpStatus.OK).contentType(MediaType.APPLICATION_JSON).body("{\"connections\":[{\"from\":{\"departureTime\":\"" + list.get(0).getDepartureTime() + "\",\"plannedDepartureTimestamp\":" + list.get(0).getPlannedDepartureTimestamp() + ",\"delay\":" + list.get(0).getDepartureDelay() / 60 + ",\"to\": \"" + list.get(0).getTo() + "\" }}]}");
}
return ResponseEntity.status(HttpStatus.NOT_FOUND).body("EFA error status: " + efaData.status.name());
}
示例11: TripSummary
import de.schildbach.pte.dto.Location; //導入依賴的package包/類
public TripSummary(Long requestId, Location from, Location to,
Long firstWalkDuration, long travelDuration, int numChanges) {
super();
this.requestId = requestId;
this.from = Validate.notNull(from);
this.to = Validate.notNull(to);
this.walkDuration = firstWalkDuration;
this.travelDuration = Validate.notNull(travelDuration);
this.numChanges = numChanges;
}
示例12: queryLocation
import de.schildbach.pte.dto.Location; //導入依賴的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);
}
}
}
}
示例13: queryTripSummary
import de.schildbach.pte.dto.Location; //導入依賴的package包/類
public TripSummary queryTripSummary(Long requestId, String origin,
String destination, Date startDate, Date endDate)
throws IOException {
final Location from = locationService.queryNonStationLocation(origin);
final Location to = locationService.queryLocation(destination);
if (from == null || to == null) {
return null;
} else {
final Date date = createTripDate(startDate);
return queryTripSummary(requestId, from, to, date);
}
}
示例14: queryTrips
import de.schildbach.pte.dto.Location; //導入依賴的package包/類
private QueryTripsResult queryTrips(Location from, Location to, Date date)
throws IOException {
final QueryTripsResult result = networkProviderService.queryTrips(from,
null, to, date, true, Product.ALL, WalkSpeed.NORMAL,
Accessibility.NEUTRAL, null);
return result;
}
示例15: successfullyQueriesNonStationLocation
import de.schildbach.pte.dto.Location; //導入依賴的package包/類
@Test
public void successfullyQueriesNonStationLocation() throws IOException {
final String address = "Köpenicker Str. 80, 10179 Berlin - Mitte, Deutschland";
final Location location = locationService
.queryNonStationLocation(address);
Assert.assertNotNull(location);
Assert.assertEquals("Berlin - Mitte", location.place);
Assert.assertEquals("Köpenicker Straße 80", location.name);
}