import java.awt.Point;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import javax.xml.parsers.ParserConfigurationException;
import org.alternativevision.gpx.GPXParser;
import org.alternativevision.gpx.beans.GPX;
import org.alternativevision.gpx.beans.Track;
import org.alternativevision.gpx.beans.Waypoint;
import org.xml.sax.SAXException;
public class PointParser {
private static Double latitude;
private static Double longitude;
private static Double elevation;
private static Date time;
public static void main (String[] args) throws ParserConfigurationException, SAXException, IOException{
FileInputStream input = new FileInputStream("E:\\sample.gpx");
GPXParser parser = new GPXParser();
GPX gpx = parser.parseGPX(input);
Track trk = new Track();
ArrayList<Waypoint> trkpt = trk.getTrackPoints();
Object[] pointArray = trkpt.toArray();
for (Object o : pointArray){
Point p = (Point) o;
}
Waypoint wp = new Waypoint();
latitude = wp.getLatitude();
longitude = wp.getLongitude();
elevation = wp.getElevation();
time = wp.getTime();
}
public static Double getLatitude() {
return latitude;
}
public static void setLatitude(Double latitude) {
PointParser.latitude = latitude;
}
public static Double getLongitude() {
return longitude;
}
public static void setLongitude(Double longitude) {
PointParser.longitude = longitude;
}
public static Double getElevation() {
return elevation;
}
public static void setElevation(Double elevation) {
PointParser.elevation = elevation;
}
public static Date getTime() {
return time;
}
public static void setTime(Date time) {
PointParser.time = time;
}
}
Hello, I'm new to java and GPXparser library. I have a GPX file which contains some track points. I want to extract 4 elements of longitude, latitude, time and elevation out of this file and use it in an algorithm in another class in my java code. when I run it I see this error:
"at PointParser.main(PointParser.java:23) Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger"
Can anyone help me with this? Am I using GPXparser correclty?!
Thank you in advance