/home/martin/workspace/OpenStreetNav/src/geoelements/Point.cpp
Go to the documentation of this file.
00001 /*
00002  * Point.cpp
00003  *
00004  *  Created on: Nov 12, 2011
00005  *      Author: martin
00006  */
00007 
00008 #include "Point.h"
00009 #include <cmath>
00010 #include <utility>
00011 #include "../util.h"
00012 
00013 namespace geo
00014 {
00015 
00016 Point::Point(double lat, double lon):
00017     lat(lat),
00018     lon(lon)
00019 {
00020 }
00021 
00022 bool Point::operator ==(const Point& other) const
00023 {
00024     return close(other, 0.0000001);
00025 }
00026 
00027 bool Point::operator !=(const Point& other) const
00028 {
00029     return util::not_eq_impl(*this, other);
00030 }
00031 
00032 bool Point::operator <=(const Point& other) const
00033 {
00034     return util::less_eq_impl(*this, other);
00035 }
00036 
00037 bool Point::operator >=(const Point& other) const
00038 {
00039     return util::greater_eq_impl(*this, other);
00040 }
00041 
00042 bool Point::operator >(const Point& other) const
00043 {
00044     return util::greater_than_impl(*this, other);
00045 }
00046 
00047 bool Point::operator <(const Point& other) const
00048 {
00049     return before(other, 0.0000001);
00050 }
00051 
00052 bool Point::before(Point const& other, double tolerance) const
00053 {
00054     if (std::abs(lat - other.lat) < tolerance)
00055     {
00056         return lon - other.lon < -tolerance;
00057     }
00058     return lat < other.lat;
00059 }
00060 
00061 bool Point::close(const Point& other, double tolerance) const
00062 {
00063     return std::abs(lat - other.lat) < tolerance && std::abs(lon - other.lon) < tolerance;
00064 }
00065 
00066 } /* namespace geo */
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines