All Downloads are FREE. Search and download functionalities are using the official Maven repository.

es.prodevelop.gvsig.mini.geom.impl.base.GPSPoint Maven / Gradle / Ivy

The newest version!
/* gvSIG. Geographic Information System of the Valencian Government
*
* Copyright (C) 2007-2008 Infrastructures and Transports Department
* of the Valencian Government (CIT)
* 
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* 
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
* MA  02110-1301, USA.
* 
*/

/*
* Prodevelop, S.L.
* Pza. Juan de Villarrasa, 14 - 5
* Valencia
* Spain
* Tel: +34 963510612
* e-mail: [email protected]
* http://www.prodevelop.es
*
*/
package es.prodevelop.gvsig.mini.geom.impl.base;

import es.prodevelop.geodetic.utils.conversion.ConversionCoords;
import es.prodevelop.gvsig.mobile.fmap.proj.CRSFactory;
import es.prodevelop.gvsig.mobile.fmap.proj.Projection;
import es.prodevelop.gvsig.mini.geom.impl.base.Point;
import es.prodevelop.gvsig.mini.utiles.Tags;

/**
 * A Point which contains longitude and latitude coordinates in WGS84.
 * @author Alberto Romeu Carrasco ([email protected])
 */
public class GPSPoint extends Point {

    /**
     * The azimuth
     */
    public float azimuth;
    
    
    public boolean isMagnetic;
    
    /**
     * The coordinates of this instance expressed in the projection of the current
     * base layer
     */
    public Point projectedCoordinates;

    /**
     * The constructor
     * @param p A point to set the coordinates
     */
    public GPSPoint(final Point p) {
        super(p.getX(), p.getY());
    }

    /**
     * The constructor
     * @param x Longitude
     * @param y Latitude
     */
    public GPSPoint(final double x, final double y) {
        super(x, y);
    }

    /**
     * Does nothing
     */
    public void destroy() {
    }    

    /**
     * Reprojects the longitude and latituted coordinates in WGS84 to the specified
     * projection (usually the base layer projection)
     * @param proj THe projection to reproject
     */
    public void calcProjectedCoordinates(final Projection proj) {
        try {
            final double[] xy = ConversionCoords.reproject(this.getX(), this.getY(), CRSFactory.getCRS(Tags.DEFAULT_SRS), proj);
            if (xy != null) {
                this.projectedCoordinates = new Point(xy);
            }
        } catch (final Exception e) {
            e.printStackTrace();
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy