From: Johannes Z. <jza...@us...> - 2006-02-23 18:34:50
|
Update of /cvsroot/magicmap/magicmapclient/src/net/sf/magicmap/client/model/node In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4028/src/net/sf/magicmap/client/model/node Added Files: GeoPosNode.java InfoObject.java InfoObjectNode.java GeoPos.java Log Message: implemented routines for geo positions --- NEW FILE: GeoPosNode.java --- /** * */ package net.sf.magicmap.client.model.node; import java.util.ArrayList; /** * @author Johannes Zapotoczky (joh...@za...) * */ public class GeoPosNode extends Node { /** * @param model */ public GeoPosNode(NodeModel model) { super(model); } /* (non-Javadoc) * @see net.sf.magicmap.client.model.node.Node#getNeighbors() */ @Override public ArrayList getNeighbors() { // TODO Auto-generated method stub return null; } /* (non-Javadoc) * @see net.sf.magicmap.client.model.node.Node#getType() */ @Override public int getType() { // TODO Auto-generated method stub return 0; } } --- NEW FILE: InfoObject.java --- /** * */ package net.sf.magicmap.client.model.node; /** * @author Johannes Zapotoczky (joh...@za...) * */ public class InfoObject { } --- NEW FILE: GeoPos.java --- /** * */ package net.sf.magicmap.client.model.node; /** * Data structure for geo positions. Provides transformation * facilities to * * @author Johannes Zapotoczky (joh...@za...) */ public class GeoPos { /** * standard deviation (1m), most likely too optimistic */ public static final int GEO_STD_DEVIATION = 1000; /** * factor to transform ms into degrees */ private static final int GEO_MS2DEGREES_FACTOR = 3600000; /** * factor to transfrom internal resolution to displayed values */ private static final int GEO_M2N_FACTOR = 1000; /** * longitude in milliseconds */ private int longitude; /** * latitude in milliseconds */ private int latitude; /** * altitude in mm */ private int altitude; /** * accuracy in mm */ private int exactitude; /** * Constructor (with standard deviation for accuracy) * @param longitude - longitude in ms * @param latitude - latitude in ms * @param altitude - altitude in mm */ public GeoPos(int longitude, int latitude, int altitude) { this(longitude, latitude, altitude, GEO_STD_DEVIATION); } /** * Constructor * @param longitude - longitude in ms * @param latitude - latitude in ms * @param altitude - altitude in mm * @param exactitude - accuracy in mm */ public GeoPos(int longitude, int latitude, int altitude, int exactitude) { this.longitude = longitude; this.latitude = latitude; this.altitude = altitude; this.exactitude = exactitude; } /** * Constructor * @param east - <code>true</code> if the longitude is east, <code>false</code> if it is west * @param longDegrees - the longitude's degrees * @param longMinutes - the longitude's minutes * @param longSeconds - the longitude's seconds * @param north - <code>true</code> if the latitude is north, <code>false</code> if it is south * @param latDegrees - the latitude's degrees * @param latMinutes - the latitude's minutes * @param latSeconds - the latitude's seconds * @param altitude - the altitude in m * @param exactitude - the exactitude in m */ public GeoPos(boolean east, Integer longDegrees, Integer longMinutes, Double longSeconds, boolean north, Integer latDegrees, Integer latMinutes, Double latSeconds, Integer altitude, Integer exactitude) { // calculate and set longitude int tmpLongMs = longDegrees.intValue() * 3600000; tmpLongMs += longMinutes.intValue() * 60000; tmpLongMs += longSeconds.doubleValue() * 1000; if (east) { this.longitude = tmpLongMs; } else { this.longitude = -tmpLongMs; } // calculate and set latitude int tmpLatMs = latDegrees.intValue() * 3600000; tmpLatMs += latMinutes.intValue() * 60000; tmpLatMs += latSeconds.doubleValue() * GEO_M2N_FACTOR; if (north) { this.latitude = tmpLatMs; } else { this.latitude = -tmpLatMs; } this.altitude = altitude.intValue() * GEO_M2N_FACTOR; this.exactitude = exactitude.intValue() * GEO_M2N_FACTOR; } /** * Constructor * @param longitude - longitude in degrees * @param latitude - latitude in degrees * @param altitude - altitude in m * @param exactitude - exactitude in m */ public GeoPos(Double longitude, Double latitude, Integer altitude, Integer exactitude) { this.longitude = (int) longitude.doubleValue() * GEO_MS2DEGREES_FACTOR; this.latitude = (int) latitude.doubleValue() * GEO_MS2DEGREES_FACTOR; this.altitude = altitude.intValue() * GEO_M2N_FACTOR; this.exactitude = exactitude.intValue() * GEO_M2N_FACTOR; } /** * Constructor * @param longitude - longitude in degrees * @param latitude - latitude in degrees * @param altitude - altitude in m * @param exactitude - exactitude in m */ public GeoPos(double longitude, double latitude, double altitude, double exactitude) { this.longitude = (int) (longitude * GEO_MS2DEGREES_FACTOR); this.latitude = (int) (latitude * GEO_MS2DEGREES_FACTOR); this.altitude = (int) (altitude * GEO_M2N_FACTOR); this.exactitude = (int) (exactitude * GEO_M2N_FACTOR); } /** * Get the whole longitude in degrees * @return - the longitude in degrees */ public Double getWholeLongitudeInDegrees() { return new Double(longitude / (double) GEO_MS2DEGREES_FACTOR); } /** * Get the whole latitude in degrees * @return - the latitude in degrees */ public Double getWholeLatitudeInDegrees() { return new Double(latitude / (double) GEO_MS2DEGREES_FACTOR); } /** * Get the altitude in m * @return altitude in m */ public Double getAltitudeInM() { return new Double(altitude / (double) GEO_M2N_FACTOR); } /** * Get the accuracy in m * @return accuracy in m */ public Double getExactitude() { return new Double(exactitude / (double) GEO_M2N_FACTOR); } public Integer getLongitudeDegrees() { return new Integer(longitude % GEO_MS2DEGREES_FACTOR); } public Integer getLongitudeMinutes() { return new Integer(longitude % (GEO_MS2DEGREES_FACTOR / 60)); } public Integer getLongitudeSeconds() { return new Integer(0); } public String toString() { return "longitude: " + this.longitude + ", latitude: " + this.latitude + ", altitude: " + this.altitude + ", exactitude: " + this.exactitude; } public int getLatitude() { return latitude; } public int getLongitude() { return longitude; } public int getAltitude() { return altitude; } } --- NEW FILE: InfoObjectNode.java --- /** * */ package net.sf.magicmap.client.model.node; import java.util.ArrayList; /** * @author Johannes Zapotoczky (joh...@za...) * */ public class InfoObjectNode extends Node { /** * @param model */ public InfoObjectNode(NodeModel model) { super(model); } /* (non-Javadoc) * @see net.sf.magicmap.client.model.node.Node#getNeighbors() */ @Override public ArrayList getNeighbors() { // TODO Auto-generated method stub return null; } /* (non-Javadoc) * @see net.sf.magicmap.client.model.node.Node#getType() */ @Override public int getType() { // TODO Auto-generated method stub return 0; } } |