Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: NFC M2M_2016_STM32 MyongjiElec_capstone1 IDW01M1_Cloud_IBM ... more
Fork of NDefLib by
RecordGeo.h
00001 /** 00002 ****************************************************************************** 00003 * @file RecordGEO.h 00004 * @author ST / Central Labs 00005 * @version V2.0.0 00006 * @date 28 Apr 2017 00007 * @brief Specialize the @{link RecordURI} to handle a location position, the location 00008 * is stored with latitude and longitude. 00009 ****************************************************************************** 00010 * @attention 00011 * 00012 * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> 00013 * 00014 * Redistribution and use in source and binary forms, with or without modification, 00015 * are permitted provided that the following conditions are met: 00016 * 1. Redistributions of source code must retain the above copyright notice, 00017 * this list of conditions and the following disclaimer. 00018 * 2. Redistributions in binary form must reproduce the above copyright notice, 00019 * this list of conditions and the following disclaimer in the documentation 00020 * and/or other materials provided with the distribution. 00021 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00022 * may be used to endorse or promote products derived from this software 00023 * without specific prior written permission. 00024 * 00025 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00026 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00027 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00028 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00029 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00030 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00031 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00032 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00033 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00034 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00035 * 00036 ****************************************************************************** 00037 */ 00038 00039 #ifndef NDEFLIB_RECORDTYPE_RECORDGEO_H_ 00040 #define NDEFLIB_RECORDTYPE_RECORDGEO_H_ 00041 00042 #include "RecordURI.h" 00043 00044 namespace NDefLib { 00045 00046 /** 00047 * Specialize the {@link RecordUri} to handle a location position, the location 00048 * is stored with latitude and longitude. 00049 * @par The coordinates are floats with 4 decimal positions. 00050 */ 00051 class RecordGeo: public RecordURI { 00052 public: 00053 00054 /** 00055 * Create an RecordGeo reading the data from the buffer. 00056 * @param header Record header. 00057 * @param buffer Buffer to read the data from. 00058 * @return an object of type RecordGeo or NULL 00059 * @par User is in charge of freeing the pointer returned by this function. 00060 */ 00061 static RecordGeo* parse(const RecordHeader &header, 00062 const uint8_t * const buffer); 00063 00064 00065 /** 00066 * Create a record that contains a gps coordinate. 00067 * @param lat Latitude. 00068 * @param lon Longitude. 00069 */ 00070 RecordGeo(const float lat, const float lon); 00071 00072 virtual ~RecordGeo() { }; 00073 00074 /** 00075 * Return the longitude coordinate 00076 * @return the longitude coordinate 00077 */ 00078 float get_longitude()const { 00079 return mLongitude; 00080 } 00081 00082 /** 00083 * Return the latitude coordinate 00084 * @return the latitude coordinate 00085 */ 00086 float get_latitude()const { 00087 return mLatitiude; 00088 } 00089 00090 /** 00091 * Change the latitude coordinate. 00092 * @param lat new latitude. 00093 */ 00094 void set_latitude(const float lat){ 00095 mContentIsChange=true; 00096 mLatitiude=lat; 00097 } 00098 00099 /** 00100 * Change the longitude coordinate. 00101 * @param lon new longitude 00102 */ 00103 void set_longitude(const float lon){ 00104 mContentIsChange=true; 00105 mLongitude=lon; 00106 } 00107 00108 /** 00109 * Get the record type. 00110 * @return TYPE_URI_GEOLOCATION 00111 */ 00112 virtual RecordType_t get_type() const { 00113 return TYPE_URI_GEOLOCATION; 00114 } //getType 00115 00116 /** 00117 * Compare two RecordGeo tags. 00118 * @return true if the two tags have the same latitude and longitude 00119 */ 00120 bool operator==(const RecordGeo &other) const { 00121 return (mLatitiude == other.mLatitiude) && 00122 (mLongitude == other.mLongitude) ; 00123 } 00124 00125 protected: 00126 00127 /** 00128 * This function updates the uri message to write into the tag. 00129 */ 00130 virtual void update_content(); 00131 00132 private: 00133 00134 /** 00135 * Latitude information. 00136 */ 00137 float mLatitiude; 00138 00139 /** 00140 * Longitude information. 00141 */ 00142 float mLongitude; 00143 00144 /** 00145 * True if the user has updated the latitude or longitude. 00146 */ 00147 bool mContentIsChange; 00148 00149 /** 00150 * Uri type to use for this record. 00151 */ 00152 static const std::string sGeoTag; 00153 }; 00154 00155 } /* namespace NDefLib */ 00156 00157 #endif /* NDEFLIB_RECORDTYPE_RECORDGEO_H_ */
Generated on Tue Jul 12 2022 14:14:48 by
1.7.2
