how do you index aString variable. So far I have been trying to use:
...
private GeoPoint points[];
int counter = 0;
...
counter ++;
String[] RowData = line.split(",");
longitude = RowData[0];
latitude = RowData[1];
Double lat = new Double(latitude);
Double lng = new Double(longitude);
points[counter] = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6));
...
for(int i=0; i < pointsCounter-1; i++) {
geopoint1 = points[i];
geopoint2 = points[i+1];
}
...
Every time I test the above it force closes - any ideas? Thanks.
Sorry for the unclear question - what I am actually trying to do is draw a path on a map overlay - I can get all the geoPoints which enable me to draw a very nice dotted line, ie. from point 'a to b', and then from 'c to d' and so on, so I am trying to find a way of recording the previous geopoint so I can use it to go from 'b to c'. I am trying to use the index of points by using the 'counter' int to do this.
If I don't try and index 'points' it all works fine but as mentioned I get a dotted line.
I hope this makes sense - I have been going round in circles for the past day or so, sorry if I come across as a bit of a numpty (although I probably am!).
Here is the code in more detail;
try {
String line;
while ((line = reader.readLine()) != null) {
counter ++;
String[] RowData = line.split(",");
longitude = RowData[0];
latitude = RowData[1];
Double lat = new Double(latitude);
Double lng = new Double(longitude);
points[counter] = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6));
for(int i=0; i < pointsCounter-1; i++){
geopoint1 = points[i];
geopoint2 = points[i+1];
p1 = new Point();
p2 = new Point();
path = new Path();
Projection projection = mapv.getProjection();
projection.toPixels(geopoint1, p1);
projection.toPixels(geopoint2, p2);
path.moveTo(p2.x, p2.y);
path.lineTo(p1.x,p1.y);
canvas.drawPath(path, mPaint);
}
}
}
catch (IOException ex) {
// handle exception
}
Many thanks in advance
String. Also, proper java formatting would use camelCaseString[] rowData = ....