Hello Agnes, Since you are posting to the Maps group, I think the messages Esa's referring to are the pinned posts displayed on the Google Groups Google-Maps-API home page:
http://groups.google.com/group/Google-Maps-API -Eric. On Fri, Aug 29, 2008 at 5:56 AM, agnes Laffitte <[EMAIL PROTECTED]>wrote: > Oh is this about a link, I don't have a link sorry, instead I will copy and > paste the whole code , not in fragments. sorry about that. Well there are > many classes, send me an email, I can send a jar file fo my entire classes. > Let me know what problem I am having. I get an error with waypoint from this > class. > > package de.herbstcampus.server; > > import java.io.IOException; > import java.io.PrintWriter; > import java.util.ArrayList; > import com.google.gwt.core.client.GWT; > import com.google.gwt.maps.client.MapWidget; > import com.google.gwt.maps.client.geocode.DirectionQueryOptions; > import com.google.gwt.maps.client.geocode.DirectionResults; > import com.google.gwt.maps.client.geocode.Directions; > import com.google.gwt.maps.client.geocode.DirectionsCallback; > import com.google.gwt.maps.client.geocode.DirectionsPanel; > import com.google.gwt.maps.client.geocode.StatusCodes; > import com.google.gwt.maps.client.geocode.Waypoint; > import com.google.gwt.user.client.Window; > > public class CVRPOutputs > { > > /* Instance fields */ > > private String outFile; > private ArrayList<Waypoint[]> costsMatrix; > private double[][] Distance1; > private int ii; > private int jj; > private int iii; > private int jjj; > String[] parts ; > String[] lines; > int NodeId; > int CustomerId; > String Name; > String Address; > String Postal_Code; > double x_coord; > double y_coord; > double Demand; > ArrayList<Node> nodesList = new ArrayList<Node>(); > ArrayList<Edge> edgesList = new ArrayList<Edge>(); > ArrayList<Waypoint[]> Distance = null; > > /* Class constructor */ > > public ArrayList<Waypoint[]> DistanceMatrix(String DM) { > lines= DM.split("\n"); > for(int i=0; i<lines.length;i++) > { > if(lines[i].length()>1) > { > parts = lines[i].split(","); > NodeId = Integer.parseInt(parts[0]); > CustomerId = Integer.parseInt(parts[1]); > Name = parts[2]; > Address = parts[3]; > Postal_Code = parts[4]; > x_coord = Double.parseDouble(parts[5]); > y_coord = Double.parseDouble(parts[6]); > Demand = Double.parseDouble(parts[7]); > Node aNode = new > Node(NodeId,CustomerId,Name,Address,Postal_Code, x_coord, y_coord, Demand); > nodesList.add(aNode); > > } > } > > > for(int i=0; i<nodesList.size(); i++) > { Node first= nodesList.get(i); > for(int j=1+i; j<nodesList.size(); j++) > { Node last = nodesList.get(j); > Waypoint from = new Waypoint(first.getAddress()); > Waypoint to = new Waypoint(last.getAddress()); > Waypoint[] query= {from, to}; > > Edge waypoint = new Edge(first,last,query); > > edgesList.add(waypoint); > > } > > } > > for(int i= 0; i<nodesList.size();i++) > { Node first= nodesList.get(i); > for(int j=1+i; j<nodesList.size();j++) > {Node last = nodesList.get(j); > Waypoint from = new Waypoint(first.getAddress()); > Waypoint to = new Waypoint(last.getAddress()); > > Waypoint[] yreuq={to,from}; > Edge tniopyaw = new Edge(last,first,yreuq); > edgesList.add(tniopyaw); > } > } > int dim =edgesList.size(); > > Distance= new ArrayList<Waypoint[]>(); > for(int i=0; i<dim;i++) > { > Distance.set(i, edgesList.get(i).getquery()); > } > return Distance; > } > > > > > > CVRPOutputs(String outputFileName,String DM) > { > outFile = outputFileName; > costsMatrix = DistanceMatrix(DM); > Distance1 = costsMatrix(costsMatrix); > > } > @SuppressWarnings("null") > public double[][] costsMatrix( ArrayList<Waypoint[]> costsMatrix){ > int index=0; > > int indey=(nodesList.size()*nodesList.size()-nodesList.size())/2; > Waypoint[][][] distmat = null; > MapWidget map= null; > DirectionsPanel directionsPanel=null; > DirectionQueryOptions opts = new DirectionQueryOptions(map, > directionsPanel); > > for(int i=0; i<nodesList.size();i++) > {for(int j=1+i; j<nodesList.size();j++) > { > distmat[i][j]=costsMatrix.get(index); > index ++; > } > } > for(int i=0; i<nodesList.size();i++) > { > for(int j=1+i;j<nodesList.size();j++) > { > distmat[j][i]=costsMatrix.get(indey); > indey++; > } > } > for(ii=0; ii<nodesList.size();ii++) > { > for(jj=0;jj<nodesList.size();jj++) > { > final int iiIndex = ii; > final int jjIndex = jj; > Directions.loadFromWaypoints(distmat[ii][jj], opts, new > DirectionsCallback() { > > public void onFailure(int statusCode) { > Window.alert("Failed to load directions: Status " > + StatusCodes.getName(statusCode) + " " + > statusCode); > } > > public void onSuccess(DirectionResults result) { > GWT.log("Successfully loaded directions.", null); > > Distance1[iiIndex][jjIndex]=result.getDistance().inMeters(); > } > > > > }); > > } > } > > for(iii=0; iii<nodesList.size();iii++) > { > for(jjj=0;jjj<nodesList.size();jjj++) > { > final int iiiIndex = iii; > final int jjjIndex = jjj; > Directions.loadFromWaypoints(distmat[jjj][iii], opts, new > DirectionsCallback() { > > public void onFailure(int statusCode) { > Window.alert("Failed to load directions: Status " > + StatusCodes.getName(statusCode) + " " + > statusCode); > } > > public void onSuccess(DirectionResults result) { > GWT.log("Successfully loaded directions.", null); > > Distance1[jjjIndex][iiiIndex]=result.getDistance().inMeters(); > } > > > > }); > > } > } > return Distance1; > } > > > public void printOutputFile() > { > try > { > PrintWriter out = new PrintWriter(System.currentTimeMillis() + > outFile); > > out.println("***************************************************"); > out.println("* > *"); > out.println("* RESULTS FROM SIMUROUTE PROJECT > *"); > out.println("* > *"); > > out.println("***************************************************"); > > out.println("\r\n"); > > out.println("***************************************************"); > out.println("* COSTS MATRIX > *"); > > out.println("***************************************************"); > out.println("\r\nCOSTS MATRIX:\n"); > for (int i = 0; i < nodesList.size(); i++) > for (int j = 0; j <= i; j++) > out.println(i + " " + j + " " + Distance1[i][j]); > > out.close(); > } > catch (IOException exception) > { > System.out.println("Error processing output file: " + > exception); > } > > } > } > > --- On *Fri, 8/29/08, Esa <[EMAIL PROTECTED]>* wrote: > > From: Esa <[EMAIL PROTECTED]> > Subject: Re: Problems with waypoint using the Java library for google maps > from gwt-maps.jar, official library from google > To: "Google Maps API" <[email protected]> > Date: Friday, August 29, 2008, 1:44 AM > > Thanks for a perfect example about usefulness of 'Read this first > before posting' section. > > > > > > -- Eric Z. Ayers - GWT Team - Atlanta, GA USA http://code.google.com/webtoolkit/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Maps API" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/Google-Maps-API?hl=en -~----------~----~----~----~------~----~------~--~---
