1 /* 2 * Copyright (C) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include "geocode_convert_address_request.h" 17 18 namespace OHOS { 19 namespace Location { GeocodeConvertAddressRequest()20GeocodeConvertAddressRequest::GeocodeConvertAddressRequest() 21 { 22 locale_ = ""; 23 maxItems_ = 0; 24 description_ = ""; 25 maxLatitude_ = 0.0; 26 maxLongitude_ = 0.0; 27 minLatitude_ = 0.0; 28 minLongitude_ = 0.0; 29 transId_ = ""; 30 country_ = ""; 31 } 32 ~GeocodeConvertAddressRequest()33GeocodeConvertAddressRequest::~GeocodeConvertAddressRequest() {} 34 GetLocale()35std::string GeocodeConvertAddressRequest::GetLocale() 36 { 37 return locale_; 38 } 39 SetLocale(std::string locale)40void GeocodeConvertAddressRequest::SetLocale(std::string locale) 41 { 42 locale_ = locale; 43 } 44 GetMaxItems()45int32_t GeocodeConvertAddressRequest::GetMaxItems() 46 { 47 return maxItems_; 48 } 49 SetMaxItems(int32_t maxItems)50void GeocodeConvertAddressRequest::SetMaxItems(int32_t maxItems) 51 { 52 maxItems_ = maxItems; 53 } 54 GetDescription()55std::string GeocodeConvertAddressRequest::GetDescription() 56 { 57 return description_; 58 } 59 SetDescription(std::string description)60void GeocodeConvertAddressRequest::SetDescription(std::string description) 61 { 62 description_ = description; 63 } 64 GetMaxLatitude()65double GeocodeConvertAddressRequest::GetMaxLatitude() 66 { 67 return maxLatitude_; 68 } 69 SetMaxLatitude(double maxLatitude)70void GeocodeConvertAddressRequest::SetMaxLatitude(double maxLatitude) 71 { 72 maxLatitude_ = maxLatitude; 73 } 74 GetMaxLongitude()75double GeocodeConvertAddressRequest::GetMaxLongitude() 76 { 77 return maxLongitude_; 78 } 79 SetMaxLongitude(double maxLongitude)80void GeocodeConvertAddressRequest::SetMaxLongitude(double maxLongitude) 81 { 82 maxLongitude_ = maxLongitude; 83 } 84 GetMinLatitude()85double GeocodeConvertAddressRequest::GetMinLatitude() 86 { 87 return minLatitude_; 88 } 89 SetMinLatitude(double minLatitude)90void GeocodeConvertAddressRequest::SetMinLatitude(double minLatitude) 91 { 92 minLatitude_ = minLatitude; 93 } 94 GetMinLongitude()95double GeocodeConvertAddressRequest::GetMinLongitude() 96 { 97 return minLongitude_; 98 } 99 SetMinLongitude(double minLongitude)100void GeocodeConvertAddressRequest::SetMinLongitude(double minLongitude) 101 { 102 minLongitude_ = minLongitude; 103 } 104 GetTransId()105std::string GeocodeConvertAddressRequest::GetTransId() 106 { 107 return transId_; 108 } 109 SetTransId(std::string transId)110void GeocodeConvertAddressRequest::SetTransId(std::string transId) 111 { 112 transId_ = transId; 113 } 114 GetCountry()115std::string GeocodeConvertAddressRequest::GetCountry() 116 { 117 return country_; 118 } 119 SetCountry(std::string country)120void GeocodeConvertAddressRequest::SetCountry(std::string country) 121 { 122 country_ = country; 123 } 124 Marshalling(Parcel & parcel) const125bool GeocodeConvertAddressRequest::Marshalling(Parcel& parcel) const 126 { 127 parcel.WriteString16(Str8ToStr16(locale_)); // locale 128 parcel.WriteString16(Str8ToStr16(description_)); // description 129 parcel.WriteInt32(maxItems_); // maxItems 130 parcel.WriteDouble(minLatitude_); // minLatitude 131 parcel.WriteDouble(minLongitude_); // minLongitude 132 parcel.WriteDouble(maxLatitude_); // maxLatitude 133 parcel.WriteDouble(maxLongitude_); // maxLongitude 134 parcel.WriteString16(Str8ToStr16(transId_)); // transId 135 parcel.WriteString16(Str8ToStr16(country_)); // country 136 return true; 137 } 138 Unmarshalling(Parcel & parcel)139GeocodeConvertAddressRequest* GeocodeConvertAddressRequest::Unmarshalling(Parcel& parcel) 140 { 141 auto geoConvertRequest = new GeocodeConvertAddressRequest(); 142 geoConvertRequest->ReadFromParcel(parcel); 143 return geoConvertRequest; 144 } 145 ReadFromParcel(Parcel & parcel)146void GeocodeConvertAddressRequest::ReadFromParcel(Parcel& parcel) 147 { 148 locale_ = Str16ToStr8(parcel.ReadString16()); // locale 149 description_ = Str16ToStr8(parcel.ReadString16()); // description 150 maxItems_ = parcel.ReadInt32(); // maxItems 151 minLatitude_ = parcel.ReadDouble(); // minLatitude 152 minLongitude_ = parcel.ReadDouble(); // minLongitude 153 maxLatitude_ = parcel.ReadDouble(); // maxLatitude 154 maxLongitude_ = parcel.ReadDouble(); // maxLongitude 155 transId_ = Str16ToStr8(parcel.ReadString16()); // transId 156 country_ = Str16ToStr8(parcel.ReadString16()); // country 157 } 158 UnmarshallingMessageParcel(MessageParcel & parcel)159std::unique_ptr<GeocodeConvertAddressRequest> GeocodeConvertAddressRequest::UnmarshallingMessageParcel( 160 MessageParcel& parcel) 161 { 162 auto geoConvertRequest = std::make_unique<GeocodeConvertAddressRequest>(); 163 geoConvertRequest->ReadFromMessageParcel(parcel); 164 return geoConvertRequest; 165 } 166 ReadFromMessageParcel(MessageParcel & parcel)167void GeocodeConvertAddressRequest::ReadFromMessageParcel(MessageParcel& parcel) 168 { 169 locale_ = Str16ToStr8(parcel.ReadString16()); // locale 170 description_ = Str16ToStr8(parcel.ReadString16()); // description 171 maxItems_ = parcel.ReadInt32(); // maxItems 172 minLatitude_ = parcel.ReadDouble(); // minLatitude 173 minLongitude_ = parcel.ReadDouble(); // minLongitude 174 maxLatitude_ = parcel.ReadDouble(); // maxLatitude 175 maxLongitude_ = parcel.ReadDouble(); // maxLongitude 176 transId_ = Str16ToStr8(parcel.ReadString16()); // transId 177 country_ = Str16ToStr8(parcel.ReadString16()); // country 178 } 179 } // namespace Location 180 } // namespace OHOS 181