Class GreatCircleBasedSpatialModel

  • All Implemented Interfaces:
    ObservableIfc, GetNameIfc, IdentityIfc

    public class GreatCircleBasedSpatialModel
    extends SpatialModel
    This class represents the distance between two coordinates using the Great Circle Distance. (http://en.wikipedia.org/wiki/Great_circle_distance) Distance is assumed to be in kilometers Coordinates are assumed to be given as: X1 - latitude, in degrees, [-90,90] X2 - longitude, in degrees [-180,180] X3 - not used By convention North is considered positive latitude By convention West is considered negative longitude
    • Field Detail

      • ROADS

        public static final double ROADS
        The ciruity addFactor for road networks, see pg 559 of Ballou
        See Also:
        Constant Field Values
      • RAIL

        public static final double RAIL
        The ciruity addFactor for rail networks, see pg 559 of Ballou
        See Also:
        Constant Field Values
      • DEFAULT_EARTH_RADIUS

        protected static final double DEFAULT_EARTH_RADIUS
        The default radius for the earth, @see (http://en.wikipedia.org/wiki/Great_circle_distance)
        See Also:
        Constant Field Values
      • myEarthRadius

        protected double myEarthRadius
        Holds teh radius of the earth for calculating great circle distance
      • myCircuityFactor

        protected double myCircuityFactor
        Can be set to adjust computed great circle distance to account for the circuity of the road/rail network, by default 1.0
    • Constructor Detail

      • GreatCircleBasedSpatialModel

        public GreatCircleBasedSpatialModel()
        Creates a spatial model that uses the great circle distance as the basis for computing distance between two coordinates.
      • GreatCircleBasedSpatialModel

        public GreatCircleBasedSpatialModel​(java.lang.String name)
        Creates a spatial model that uses the great circle distance as the basis for computing distance between two coordinates.
        Parameters:
        name - , An optional name for the spatial model
      • GreatCircleBasedSpatialModel

        public GreatCircleBasedSpatialModel​(java.lang.String name,
                                            double circuityFactor)
        Creates a spatial model that uses the great circle distance as the basis for computing distance between two coordinates.
        Parameters:
        name - , An optional name for the spatial model
        circuityFactor - Can be used to adjust distance for network effects
    • Method Detail

      • getCoordinate

        public CoordinateIfc getCoordinate​(double lat,
                                           double lon,
                                           double x3)
        Returns a valid coordinate
        Specified by:
        getCoordinate in class SpatialModel
        Parameters:
        lat - must be between -90 and 90 degrees
        lon - must be between -180 and 180 degrees
        x3 - not used
        Returns:
      • getDefaultCoordinate

        public CoordinateIfc getDefaultCoordinate()
        Description copied from class: SpatialModel
        Returns a default set of coordinates to be used to initialize the location of spatial elements if necessary.
        Specified by:
        getDefaultCoordinate in class SpatialModel
        Returns:
      • getCoordinate

        public static CoordinateIfc getCoordinate​(GreatCircleBasedSpatialModel.Direction latD,
                                                  double latd,
                                                  double latm,
                                                  double lats,
                                                  GreatCircleBasedSpatialModel.Direction lonD,
                                                  double lond,
                                                  double lonm,
                                                  double lons)
        Returns a valid coordinate
        Parameters:
        latD - latitude direction
        latd - latitude degrees
        latm - latitude minutes
        lats - latitude seconds
        lonD - longitude direction
        lond - longitude degrees
        lonm - longitude minutes
        lons - longitude seconds
        Returns:
      • getLatitude

        public static final double getLatitude​(GreatCircleBasedSpatialModel.Direction direction,
                                               double degrees,
                                               double minutes)
        Returns a latitude in degrees
        Parameters:
        direction -
        degrees -
        minutes -
        Returns:
      • getLatitude

        public static double getLatitude​(GreatCircleBasedSpatialModel.Direction direction,
                                         double degrees,
                                         double minutes,
                                         double seconds)
        Returns a latitude in degrees
        Parameters:
        direction -
        degrees -
        minutes -
        seconds -
        Returns:
      • getLongitude

        public static final double getLongitude​(GreatCircleBasedSpatialModel.Direction direction,
                                                double degrees,
                                                double minutes)
        Returns a longitude in degrees
        Parameters:
        direction -
        degrees -
        minutes -
        Returns:
      • getLongitude

        public static double getLongitude​(GreatCircleBasedSpatialModel.Direction direction,
                                          double degrees,
                                          double minutes,
                                          double seconds)
        Returns a longitude in degrees
        Parameters:
        direction -
        degrees -
        minutes -
        seconds -
        Returns:
      • isValid

        public boolean isValid​(CoordinateIfc coordinate)
        Description copied from class: SpatialModel
        Checks to see if the supplied coordinate is physically valid within the spatial model. This depends on the underlying spatial representation. This method should check whether the coordinate can be represented spatially within this spatial model. If so, this method should return true.
        Specified by:
        isValid in class SpatialModel
        Returns:
      • comparePositions

        public boolean comparePositions​(CoordinateIfc coordinate1,
                                        CoordinateIfc coordinate2)
        Description copied from class: SpatialModel
        Returns true if the first coordinate is the same as second coordinate within the underlying spatial model. This is not object reference equality, but rather whether or not the positions within the underlying spatial model can be considered spatially (equivalent). Requirement: The coordinates must be valid within the spatial model. If they are not valid within same spatial model, then this method should return false.
        Specified by:
        comparePositions in class SpatialModel
        Returns:
      • getEarthRadius

        public final double getEarthRadius()
        The earth's radius for great circle calculation
        Returns:
        Returns the earth's Radius.
      • setEarthRadius

        public final void setEarthRadius​(double radius)
        The earth's radius for great circle calculation
        Parameters:
        radius - The radius for the earth to set.
      • getCircuityFactor

        public final double getCircuityFactor()
        The network circuity addFactor for adjusting the distance.
        Returns:
        Returns the circuityFactor.
      • setCircuityFactor

        protected final void setCircuityFactor​(double circuityFactor)
        Parameters:
        circuityFactor - The circuityFactor to set.
      • main

        public static void main​(java.lang.String[] args)