File tree Expand file tree Collapse file tree 7 files changed +98
-22
lines changed Expand file tree Collapse file tree 7 files changed +98
-22
lines changed Original file line number Diff line number Diff line change 18
18
19
19
NS_ASSUME_NONNULL_BEGIN
20
20
21
- namespace firebase {
22
- namespace firestore {
23
- class GeoPoint;
24
- } // namespace firestore
25
- } // namespace firebase
26
-
27
- namespace firestore = firebase::firestore;
28
-
29
21
/* * Internal FIRGeoPoint API we don't want exposed in our public header files. */
30
22
@interface FIRGeoPoint (Internal)
31
23
32
24
- (NSComparisonResult )compare : (FIRGeoPoint *)other ;
33
25
34
- - (firestore::GeoPoint)toGeoPoint ;
35
-
36
26
@end
37
27
38
28
NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change @@ -88,10 +88,6 @@ - (NSComparisonResult)compare:(FIRGeoPoint *)other {
88
88
}
89
89
}
90
90
91
- - (firestore::GeoPoint)toGeoPoint {
92
- return firestore::GeoPoint (self.latitude , self.longitude );
93
- }
94
-
95
91
@end
96
92
97
93
NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change 30
30
#import " Firestore/Source/API/FIRFieldValue+Internal.h"
31
31
#import " Firestore/Source/API/FIRFirestore+Internal.h"
32
32
#import " Firestore/Source/API/FIRGeoPoint+Internal.h"
33
+ #import " Firestore/Source/API/converters.h"
33
34
#import " Firestore/Source/Model/FSTFieldValue.h"
34
35
#import " Firestore/Source/Model/FSTMutation.h"
35
36
49
50
#include " absl/strings/match.h"
50
51
51
52
namespace util = firebase::firestore::util;
53
+ using firebase::firestore::GeoPoint;
52
54
using firebase::firestore::api::ThrowInvalidArgument;
53
55
using firebase::firestore::core::ParsedSetData;
54
56
using firebase::firestore::core::ParsedUpdateData;
@@ -455,8 +457,7 @@ - (nullable FSTFieldValue *)parseScalarValue:(nullable id)input context:(ParseCo
455
457
return [FSTTimestampValue timestampValue: truncatedTimestamp];
456
458
457
459
} else if ([input isKindOfClass: [FIRGeoPoint class ]]) {
458
- FIRGeoPoint *geoPoint = input;
459
- return FieldValue::FromGeoPoint ([geoPoint toGeoPoint ]).Wrap ();
460
+ return FieldValue::FromGeoPoint (api::MakeGeoPoint (input)).Wrap ();
460
461
461
462
} else if ([input isKindOfClass: [NSData class ]]) {
462
463
NSData *inputData = input;
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2019 Google
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #ifndef FIRESTORE_SOURCE_API_CONVERTERS_H_
18
+ #define FIRESTORE_SOURCE_API_CONVERTERS_H_
19
+
20
+ #if !defined(__OBJC__)
21
+ #error "This header only supports Objective-C++"
22
+ #endif // !defined(__OBJC__)
23
+
24
+ #import < Foundation/Foundation.h>
25
+
26
+ @class FIRGeoPoint;
27
+
28
+ NS_ASSUME_NONNULL_BEGIN
29
+
30
+ namespace firebase {
31
+ namespace firestore {
32
+
33
+ class GeoPoint;
34
+
35
+ namespace api {
36
+
37
+ /* * Converts a user-supplied FIRGeoPoint to the equivalent C++ GeoPoint. */
38
+ GeoPoint MakeGeoPoint (FIRGeoPoint* geo_point);
39
+
40
+ /* * Converts a C++ GeoPoint to the equivalent Objective-C FIRGeoPoint. */
41
+ FIRGeoPoint* MakeFIRGeoPoint (const GeoPoint& geo_point);
42
+
43
+ } // namespace api
44
+ } // namespace firestore
45
+ } // namespace firebase
46
+
47
+ NS_ASSUME_NONNULL_END
48
+
49
+ #endif // FIRESTORE_SOURCE_API_CONVERTERS_H_
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2019 Google
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #include " Firestore/Source/API/converters.h"
18
+
19
+ #import " FIRGeoPoint.h"
20
+
21
+ #include " Firestore/core/include/firebase/firestore/geo_point.h"
22
+
23
+ NS_ASSUME_NONNULL_BEGIN
24
+
25
+ namespace firebase {
26
+ namespace firestore {
27
+ namespace api {
28
+
29
+ GeoPoint MakeGeoPoint (FIRGeoPoint* geo_point) {
30
+ return GeoPoint (geo_point.latitude , geo_point.longitude );
31
+ }
32
+
33
+ FIRGeoPoint* MakeFIRGeoPoint (const GeoPoint& geo_point) {
34
+ return [[FIRGeoPoint alloc ] initWithLatitude: geo_point.latitude ()
35
+ longitude: geo_point.longitude ()];
36
+ }
37
+
38
+ } // namespace api
39
+ } // namespace firestore
40
+ } // namespace firebase
41
+
42
+ NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change 26
26
#include " Firestore/core/src/firebase/firestore/model/field_value_options.h"
27
27
28
28
@class FIRTimestamp;
29
- @class FIRGeoPoint;
30
29
31
30
namespace model = firebase::firestore::model;
32
31
Original file line number Diff line number Diff line change 23
23
#import " FIRTimestamp.h"
24
24
25
25
#import " Firestore/Source/API/FIRGeoPoint+Internal.h"
26
+ #import " Firestore/Source/API/converters.h"
26
27
#import " Firestore/Source/Model/FSTDocumentKey.h"
27
28
#import " Firestore/Source/Util/FSTClasses.h"
28
29
35
36
#include " Firestore/core/src/firebase/firestore/util/string_apple.h"
36
37
37
38
namespace util = firebase::firestore::util;
38
- using firebase::firestore::GeoPoint ;
39
+ using firebase::firestore::api::MakeFIRGeoPoint ;
39
40
using firebase::firestore::model::DatabaseId;
40
41
using firebase::firestore::model::FieldMask;
41
42
using firebase::firestore::model::FieldPath;
@@ -685,10 +686,8 @@ - (id)value {
685
686
return MakeNSData (self.internalValue .blob_value ());
686
687
case FieldValue::Type::Reference:
687
688
HARD_FAIL (" TODO(rsgowman): implement" );
688
- case FieldValue::Type::GeoPoint: {
689
- GeoPoint value = self.internalValue .geo_point_value ();
690
- return [[FIRGeoPoint alloc ] initWithLatitude: value.latitude () longitude: value.longitude ()];
691
- }
689
+ case FieldValue::Type::GeoPoint:
690
+ return MakeFIRGeoPoint (self.internalValue .geo_point_value ());
692
691
case FieldValue::Type::Array:
693
692
case FieldValue::Type::Object:
694
693
HARD_FAIL (" TODO(rsgowman): implement" );
You can’t perform that action at this time.
0 commit comments