本文整理汇总了Java中com.google.maps.errors.ApiException类的典型用法代码示例。如果您正苦于以下问题:Java ApiException类的具体用法?Java ApiException怎么用?Java ApiException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ApiException类属于com.google.maps.errors包,在下文中一共展示了ApiException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDriveDist
import com.google.maps.errors.ApiException; //导入依赖的package包/类
public static long getDriveDist(String addrOne, String addrTwo) throws ApiException, InterruptedException, IOException{
//set up key
GeoApiContext distCalcer = new GeoApiContext.Builder()
.apiKey(API_KEY)
.build();
DistanceMatrixApiRequest req = DistanceMatrixApi.newRequest(distCalcer);
DistanceMatrix result = req.origins(addrOne)
.destinations(addrTwo)
.mode(TravelMode.DRIVING)
.avoid(RouteRestriction.TOLLS)
.language("en-US")
.await();
long distApart = result.rows[0].elements[0].distance.inMeters;
return distApart;
}
示例2: distanceMatrix
import com.google.maps.errors.ApiException; //导入依赖的package包/类
public static void distanceMatrix(String[] origins, String[] destinations) throws ApiException, InterruptedException, IOException{
GeoApiContext context = new GeoApiContext.Builder()
.apiKey(API_KEY)
.build();
DistanceMatrixApiRequest req=DistanceMatrixApi.newRequest(context);
DistanceMatrix t=req.origins(origins).destinations(destinations).mode(TravelMode.DRIVING).await();
//long[][] array=new long[origins.length][destinations.length];
File file=new File("Matrix.txt");
FileOutputStream out=new FileOutputStream(file);
DataOutputStream outFile=new DataOutputStream(out);
for(int i=0;i<origins.length;i++){
for(int j=0;j<destinations.length;j++){
//System.out.println(t.rows[i].elements[j].distance.inMeters);
outFile.writeLong(t.rows[i].elements[j].distance.inMeters);
}
}
outFile.close();
}
示例3: School
import com.google.maps.errors.ApiException; //导入依赖的package包/类
public School(String name, int enrollment, boolean boys,boolean girls,boolean HostSect,boolean HostReg,boolean HostSemi, LatLng coords) throws ApiException, InterruptedException, IOException, ClassNotFoundException{
this.name=name;
//this.location= lookupAddr();
//this.coords=EarthSearch.lookupCoordFromFile(name);
this.coords=coords;
this.enrollment=enrollment;
this.boys=boys;
this.girls=girls;
this.HostSect=HostSect;
this.HostReg=HostReg;
this.HostSemi=HostSemi;
this.classification=classify(this.enrollment);
if(this.isHostSect()==true)
sectNo++;
if(this.isHostReg()==true)
regNo++;
if(this.isHostSemi()==true)
semiNo++;
}
示例4: lookupAddr
import com.google.maps.errors.ApiException; //导入依赖的package包/类
public static String lookupAddr(String establishment) throws ApiException, InterruptedException, IOException {
//set up key
GeoApiContext lookupDoodad = new GeoApiContext.Builder()
.apiKey(API_KEY)
.build();
GeocodingResult[] results = GeocodingApi.geocode(lookupDoodad,
establishment).await();
//converts results into usable address
String address = (results[0].formattedAddress);
return address;
}
示例5: lookupCoord
import com.google.maps.errors.ApiException; //导入依赖的package包/类
public static LatLng lookupCoord(String establishment) throws ApiException, InterruptedException, IOException {
//set up key
GeoApiContext lookupDoodad = new GeoApiContext.Builder()
.apiKey(API_KEY)
.build();
GeocodingResult[] results = GeocodingApi.geocode(lookupDoodad,
establishment).await();
//converts results into usable Coordinates
LatLng coords = (results[0].geometry.location);
//System.out.println(results[0].geometry.location);
return coords;
}
示例6: getError
import com.google.maps.errors.ApiException; //导入依赖的package包/类
@Override
public ApiException getError() {
if (successful()) {
return null;
}
return ApiException.from(status, errorMessage);
}
示例7: getError
import com.google.maps.errors.ApiException; //导入依赖的package包/类
@Override
public ApiException getError() {
if (successful()) {
return null;
}
return ApiException.from(reason, message);
}
示例8: await
import com.google.maps.errors.ApiException; //导入依赖的package包/类
@Override
public T await() throws ApiException, IOException, InterruptedException {
try {
return parseResponse(this, call.get());
} catch (ExecutionException e) {
if (e.getCause() instanceof IOException) {
throw (IOException) e.getCause();
} else {
// According to
// https://cloud.google.com/appengine/docs/standard/java/javadoc/com/google/appengine/api/urlfetch/URLFetchService
// all exceptions should be subclass of IOException so this should not happen.
throw new UnknownErrorException("Unexpected exception from " + e.getMessage());
}
}
}
示例9: setIfExceptionIsAllowedToRetry
import com.google.maps.errors.ApiException; //导入依赖的package包/类
/**
* Allows specific API exceptions to be retried or not retried.
*
* @param exception The {@code ApiException} to allow or deny being re-tried.
* @param allowedToRetry Whether to allow or deny re-trying {@code exception}.
* @return Returns this builder for call chaining.
*/
public Builder setIfExceptionIsAllowedToRetry(
Class<? extends ApiException> exception, boolean allowedToRetry) {
if (allowedToRetry) {
exceptionsAllowedToRetry.add(exception);
} else {
exceptionsAllowedToRetry.remove(exception);
}
return this;
}
示例10: main
import com.google.maps.errors.ApiException; //导入依赖的package包/类
public static void main(String[] args) throws ApiException, InterruptedException, IOException, ClassNotFoundException {
// TODO Auto-generated method stub
File file=new File("All Schools Lists.txt");
Scanner scan =new Scanner(file).useDelimiter("\\*|\\n");
FileOutputStream fileOut=new FileOutputStream("Coords.dat");
ObjectOutputStream objOut=new ObjectOutputStream(fileOut);
ObjectInputStream objIn=new ObjectInputStream(new FileInputStream("Coords.dat"));
int c=0;
ArrayList<String>names=new ArrayList<String>();
while(scan.hasNext()){
String name=scan.next();
int enrollment=scan.nextInt();
boolean boys=assignBoolean(scan.next());
boolean girls=assignBoolean(scan.next());
boolean HostSect=assignBoolean(scan.next());
boolean HostReg=assignBoolean(scan.next());
boolean HostSemi=assignBoolean(scan.next());
names.add(name);
}
Coord []x=new Coord[names.size()];
System.out.println(x.length);
int j=0;
for( j=0;j<x.length;j++){
String tN=names.get(j);
LatLng tL=EarthSearch.lookupCoord(tN+",IN");
x[j]=new Coord(tN,tL);
objOut.writeObject(x[j]);
}
System.out.println(j);
//Coord []temp=new Coord[391-383];
//System.out.println(EarthSearch.lookupCoord("Evansville Reitz Memorial High School"));
/*
for(int k=383;k<391;k++){
System.out.println(names.get(k));
LatLng l=EarthSearch.lookupCoord(names.get(k)+",IN");
System.out.println(l.lat);
}*/
objOut.close();
fileOut.close();
System.out.println("Done writing");
int flag=1;
System.out.println("Read");
/*Coord temp[]=new Coord[names.size()];
for(int i=0;i<names.size();i++){
temp[i]=(Coord)objIn.readObject();
//System.out.println(temp.getNameSchool()+"\t"+temp.getCoords().lat);
}*/
try{
while((Coord)objIn.readObject()!=null){
Coord tempO=(Coord)objIn.readObject();
if(tempO==null)
break;
System.out.println("Name: "+tempO.getNameSchool()+"\t"+tempO.lat);
}
}
catch(EOFException e){
System.out.println("Reached EOF");
}
/*while((Coord)objIn.readObject()!=null){
Coord tempO=(Coord)objIn.readObject();
if(tempO==null)
break;
System.out.println("Name: "+tempO.getNameSchool()+"\t"+tempO.lat);
}*/
objIn.close();
}
示例11: main
import com.google.maps.errors.ApiException; //导入依赖的package包/类
public static void main(String[] args) throws ApiException, InterruptedException, IOException {
//String establishment = "Snider High School, Indiana";
//EarthSearch.lookupAddress(establishment);
// System.out.println(EarthSearch.computeDriveDistance("5901 Heywood Cove, Fort Wayne, IN 46815",
// "4600 Fairlawn Pass, Fort Wayne, IN 46815"));
// String establishment = "Snider High School, Indiana";
// System.out.println(EarthSearch.lookupAddr(establishment));
///////
//CREATES GUI!! I did it!
//Test URL string for window
// String url = "https://maps.googleapis.com/maps/api/staticmap?center=Indianapolis,IN&zoom=7&size=500x500&markers=color:green%7CHuntington+North+High+School";
//
//
// Display display = new Display();
//
// Shell shell = new Shell(display);
// shell.setSize(552, 575);
//
// new MapGUI(shell, SWT.NONE, url);
//
//// the layout manager handle the layout
//// of the widgets in the container
// shell.setLayout(new FillLayout());
//
// //add some widgets to the Shell
// shell.open();
// while (!shell.isDisposed()) {
// if (!display.readAndDispatch()) {
// display.sleep();
// }
// }
// display.dispose();
//
//new ViewGUI();
new InitGUI();
}
示例12: getError
import com.google.maps.errors.ApiException; //导入依赖的package包/类
@Override
public ApiException getError() {
return null;
}
示例13: getError
import com.google.maps.errors.ApiException; //导入依赖的package包/类
@Override
public ApiException getError() {
return ApiException.from(error.status, error.message);
}
示例14: retry
import com.google.maps.errors.ApiException; //导入依赖的package包/类
private T retry() throws IOException, ApiException, InterruptedException {
retryCounter++;
LOG.info("Retrying request. Retry #{}", retryCounter);
this.call = client.fetchAsync(request);
return this.await();
}
示例15: shouldRetry
import com.google.maps.errors.ApiException; //导入依赖的package包/类
private boolean shouldRetry(ApiException exception) {
return exceptionsAllowedToRetry.contains(exception.getClass())
&& cumulativeSleepTime < errorTimeOut
&& (maxRetries == null || retryCounter < maxRetries);
}