Android Open Source - android-augment-reality-framework Physical Location






From Project

Back to project page android-augment-reality-framework.

License

The source code is released under:

GNU General Public License

If you think the Android project android-augment-reality-framework listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.jwetherell.augmented_reality.data;
//  w  ww . j  a v  a2s.c  o m
import com.jwetherell.augmented_reality.common.Vector;

import android.location.Location;

/**
 * This class is used to represent a physical locations which have a latitude,
 * longitude, and alitude.
 * 
 * @author Justin Wetherell <phishman3579@gmail.com>
 */
public class PhysicalLocation {

    private double latitude = 0.0;
    private double longitude = 0.0;
    private double altitude = 0.0;

    private static float[] x = new float[1];
    private static double y = 0.0d;
    private static float[] z = new float[1];

    public PhysicalLocation() {
    }

    public PhysicalLocation(PhysicalLocation pl) {
        if (pl == null) throw new NullPointerException();

        set(pl.latitude, pl.longitude, pl.altitude);
    }

    /**
     * Set this objects parameters. This should be used instead of creating new
     * objects.
     * 
     * @param latitude
     *            Latitude of the location in decimal format (example
     *            39.931269).
     * @param longitude
     *            Longitude of the location in decimal format (example
     *            -75.051261).
     * @param altitude
     *            Altitude of the location in meters (>0 is above sea level).
     */
    public void set(double latitude, double longitude, double altitude) {
        this.latitude = latitude;
        this.longitude = longitude;
        this.altitude = altitude;
    }

    /**
     * Set the Latitude of the PhysicalLocation.
     * 
     * @param latitude
     *            Latitude of the location in decimal format (example
     *            39.931269).
     */
    public void setLatitude(double latitude) {
        this.latitude = latitude;
    }

    /**
     * Get the Latitude of the PhysicalLocation.
     * 
     * @return double representation the latitude of the location in decimal
     *         format (example 39.931269).
     */
    public double getLatitude() {
        return latitude;
    }

    /**
     * Set the Longitude of the PhysicalLocation.
     * 
     * @param longitude
     *            Longitude of the location in decimal format (example
     *            -75.051261).
     */
    public void setLongitude(double longitude) {
        this.longitude = longitude;
    }

    /**
     * Get the Longitude of the PhysicalLocation.
     * 
     * @return double representation the longitude of the location in decimal
     *         format (example -75.051261).
     */
    public double getLongitude() {
        return longitude;
    }

    /**
     * Set the Altitude of the PhysicalLocation.
     * 
     * @param altitude
     *            Altitude of the location in meters (>0 is above sea level).
     */
    public void setAltitude(double altitude) {
        this.altitude = altitude;
    }

    /**
     * Get the Altitude of the PhysicalLocation.
     * 
     * @return double representation the altitude of the location in meters (>0
     *         is above sea level).
     */
    public double getAltitude() {
        return altitude;
    }

    /**
     * Converts a Location to a Vector given a PhysicalLocation.
     * 
     * @param org
     *            Origin Location.
     * @param gp
     *            Current PhysicalLocation.
     * @param v
     *            Vector to populate.
     * @throws NullPointerException
     *             if Location, PhysicalLocation, or Vector is NULL.
     */
    public static void convLocationToVector(Location org, PhysicalLocation gp, Vector v) {
        if (org == null || gp == null || v == null) throw new NullPointerException("Location, PhysicalLocation, and Vector cannot be NULL.");

        Location.distanceBetween(org.getLatitude(), org.getLongitude(), gp.getLatitude(), org.getLongitude(), z);

        Location.distanceBetween(org.getLatitude(), org.getLongitude(), org.getLatitude(), gp.getLongitude(), x);
        y = gp.getAltitude() - org.getAltitude();
        if (org.getLatitude() < gp.getLatitude()) z[0] *= -1;
        if (org.getLongitude() > gp.getLongitude()) x[0] *= -1;

        v.set(x[0], (float) y, z[0]);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public String toString() {
        return "(lat=" + latitude + ", lng=" + longitude + ", alt=" + altitude + ")";
    }
}




Java Source Code List

com.jwetherell.augmented_reality.activity.AugmentedReality.java
com.jwetherell.augmented_reality.activity.AugmentedView.java
com.jwetherell.augmented_reality.activity.Demo.java
com.jwetherell.augmented_reality.activity.SensorsActivity.java
com.jwetherell.augmented_reality.camera.CameraCompatibility.java
com.jwetherell.augmented_reality.camera.CameraModel.java
com.jwetherell.augmented_reality.camera.CameraSurface.java
com.jwetherell.augmented_reality.common.LowPassFilter.java
com.jwetherell.augmented_reality.common.Matrix.java
com.jwetherell.augmented_reality.common.Navigation.java
com.jwetherell.augmented_reality.common.Orientation.java
com.jwetherell.augmented_reality.common.ReusableString.java
com.jwetherell.augmented_reality.common.Vector.java
com.jwetherell.augmented_reality.data.ARData.java
com.jwetherell.augmented_reality.data.BuzzDataSource.java
com.jwetherell.augmented_reality.data.DataSource.java
com.jwetherell.augmented_reality.data.GooglePlacesDataSource.java
com.jwetherell.augmented_reality.data.LocalDataSource.java
com.jwetherell.augmented_reality.data.NetworkDataSource.java
com.jwetherell.augmented_reality.data.PhysicalLocation.java
com.jwetherell.augmented_reality.data.ScreenPosition.java
com.jwetherell.augmented_reality.data.TwitterDataSource.java
com.jwetherell.augmented_reality.data.WikipediaDataSource.java
com.jwetherell.augmented_reality.ui.IconMarker.java
com.jwetherell.augmented_reality.ui.Marker.java
com.jwetherell.augmented_reality.ui.Radar.java
com.jwetherell.augmented_reality.ui.objects.PaintableBox.java
com.jwetherell.augmented_reality.ui.objects.PaintableBoxedText.java
com.jwetherell.augmented_reality.ui.objects.PaintableCircle.java
com.jwetherell.augmented_reality.ui.objects.PaintableGps.java
com.jwetherell.augmented_reality.ui.objects.PaintableIcon.java
com.jwetherell.augmented_reality.ui.objects.PaintableLine.java
com.jwetherell.augmented_reality.ui.objects.PaintableObject.java
com.jwetherell.augmented_reality.ui.objects.PaintablePoint.java
com.jwetherell.augmented_reality.ui.objects.PaintablePosition.java
com.jwetherell.augmented_reality.ui.objects.PaintableRadarPoints.java
com.jwetherell.augmented_reality.ui.objects.PaintableText.java
com.jwetherell.augmented_reality.widget.VerticalSeekBar.java
com.jwetherell.augmented_reality.widget.VerticalTextView.java