1 /* 2 * Copyright (C) 2022 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 "geo_coding_mock_info.h" 17 18 #include <parcel.h> 19 20 #include "string_ex.h" 21 22 #include "constant_definition.h" 23 #include "geo_address.h" 24 25 namespace OHOS { 26 namespace Location { GeocodingMockInfo()27GeocodingMockInfo::GeocodingMockInfo() 28 { 29 location_ = std::make_shared<ReverseGeocodeRequest>(); 30 geoAddress_ = std::make_shared<GeoAddress>(); 31 } 32 GetLocation()33std::shared_ptr<ReverseGeocodeRequest> GeocodingMockInfo::GetLocation() 34 { 35 return location_; 36 } 37 GetGeoAddressInfo()38std::shared_ptr<GeoAddress> GeocodingMockInfo::GetGeoAddressInfo() 39 { 40 return geoAddress_; 41 } 42 SetLocation(std::shared_ptr<ReverseGeocodeRequest> request)43void GeocodingMockInfo::SetLocation(std::shared_ptr<ReverseGeocodeRequest> request) 44 { 45 location_ = request; 46 } 47 SetGeoAddressInfo(std::shared_ptr<GeoAddress> geoAddress)48void GeocodingMockInfo::SetGeoAddressInfo(std::shared_ptr<GeoAddress> geoAddress) 49 { 50 geoAddress_ = geoAddress; 51 } 52 ReadFromParcel(Parcel & parcel)53void GeocodingMockInfo::ReadFromParcel(Parcel& parcel) 54 { 55 location_->locale = Str16ToStr8(parcel.ReadString16()); 56 location_->latitude = parcel.ReadDouble(); 57 location_->longitude = parcel.ReadDouble(); 58 location_->maxItems = parcel.ReadInt32(); 59 geoAddress_ = GeoAddress::Unmarshalling(parcel); 60 } 61 Unmarshalling(Parcel & parcel)62std::unique_ptr<GeocodingMockInfo> GeocodingMockInfo::Unmarshalling(Parcel& parcel) 63 { 64 std::unique_ptr<GeocodingMockInfo> mockInfo = std::make_unique<GeocodingMockInfo>(); 65 mockInfo->ReadFromParcel(parcel); 66 return mockInfo; 67 } 68 Marshalling(Parcel & parcel) const69bool GeocodingMockInfo::Marshalling(Parcel& parcel) const 70 { 71 return parcel.WriteString16(Str8ToStr16(location_->locale)) && 72 parcel.WriteDouble(location_->latitude) && 73 parcel.WriteDouble(location_->longitude) && 74 parcel.WriteInt32(location_->maxItems) && 75 geoAddress_->Marshalling(parcel); 76 } 77 } // namespace Location 78 } // namespace OHOS