Skip to content

Commit 7edccea

Browse files
refactor: Refactored Geometry models in swift & optional/nullable properties of the recently committed swift class. (#485)
1 parent b6bcdbe commit 7edccea

11 files changed

+171
-12
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2024 Google LLC
2+
//
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+
import GoogleMaps
16+
17+
/// Instances of this class represent a GeoJSON Feature object.
18+
/// TO-DO: Rename the class to `GMUFeature` once the linking is done and remove the objective c class.
19+
struct GMUFeature1: GMUGeometryContainer1 {
20+
// MARK: - Properties
21+
/// The geometry object in the container.
22+
var geometry: GMUGeometry
23+
/// Style information that should be applied to the contained geometry object.
24+
var style: GMUStyle?
25+
/// The identifier of the feature.
26+
private(set) var identifier: String?
27+
/// The properties of the geometry in the feature.
28+
private(set) var properties: [String : AnyObject]?
29+
/// The bounding box of the geometry in the feature.
30+
private(set) var boundingBox: GMSCoordinateBounds?
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2024 Google LLC
2+
//
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+
/// Instances of this class represent a GeometryCollection object.
17+
/// TO-DO: Rename the class to `GMUGeometryCollection` once the linking is done and remove the objective c class.
18+
struct GMUGeometryCollection1: GMUGeometry1 {
19+
// MARK: - Properties
20+
/// The type of the geometry.
21+
var type: String = "GeometryCollection"
22+
/// The array of geometry objects for the GeometryCollection.
23+
private(set) var geometries: [GMUGeometry]
24+
}
25+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2024 Google LLC
2+
//
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+
/// Instances of this class represent a Ground Overlay object.
16+
/// TO-DO: Rename the class to `GMUGroundOverlay` once the linking is done and remove the objective c class.
17+
struct GMUGroundOverlay1: GMUGeometry1 {
18+
// MARK: - Properties
19+
/// The type of the geometry.
20+
var type: String = "GroundOverlay"
21+
/// The North-East corner of the overlay.
22+
private(set) var northEast: CLLocationCoordinate2D
23+
/// The South-West corner of the overlay.
24+
private(set) var southWest: CLLocationCoordinate2D
25+
/// The Z-Index of the overlay.
26+
private(set) var zIndex: Int
27+
/// The rotation of the overlay on the map.
28+
private(set) var rotation: Double
29+
/// The image to be rendered on the overlay.
30+
private(set) var href: String
31+
}

Sources/GoogleMapsUtils/Geometry/Models/GMULineString1.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import GoogleMaps
1919
struct GMULineString1: GMUGeometry1 {
2020
// MARK: - Properties
2121
/// The type of the geometry.
22-
var type: String
22+
var type: String = "LineString"
2323
/// The path of the LineString.
2424
private(set) var path: GMSPath
2525
}

Sources/GoogleMapsUtils/Geometry/Models/GMUPlacemark1.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@
1414

1515
/// Represents a placemark which is either a Point, LineString, Polygon, or MultiGeometry. Contains
1616
/// the properties and styles of the place.
17-
/// TO-DO: Rename the class to `GMUPlacemarkSwift & GMUGeometryContainer` once the linking is done and remove the objective c class.
17+
/// TO-DO: Rename the class to `GMUPlacemarkSwift` once the linking is done and remove the objective c class.
1818
struct GMUPlacemark1: GMUGeometryContainer1 {
1919
// MARK: - Properties
2020
/// The geometry object in the container.
2121
var geometry: GMUGeometry
2222
/// Style information that should be applied to the contained geometry object.
23-
var style: GMUStyle
23+
var style: GMUStyle?
2424
/// The name element of the placemark.
25-
private(set) var title: String
25+
private(set) var title: String?
2626
/// The description element of the placemark.
27-
private(set) var snippet: String
27+
private(set) var snippet: String?
2828
/// The StyleUrl element of the placemark; used to reference a style defined in the file.
29-
private(set) var styleUrl: String
29+
private(set) var styleUrl: String?
3030

3131
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2024 Google LLC
2+
//
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+
/// Instances of this class represent a GeoJSON Feature object.
16+
/// TO-DO: Rename the class to `GMUPoint` once the linking is done and remove the objective c class.
17+
struct GMUPoint1: GMUGeometry1 {
18+
// MARK: - Properties
19+
/// The type of the geometry.
20+
var type: String = "Point"
21+
/// The 2D coordinate of the Point, containing a latitude and longitude.
22+
private(set) var coordinate: CLLocationCoordinate2D
23+
}
24+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2024 Google LLC
2+
//
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+
import GoogleMaps
16+
17+
/// Instances of this class represent a Polygon object.
18+
/// TO-DO: Rename the class to `GMUPolygon` once the linking is done and remove the objective c class.
19+
struct GMUPolygon1: GMUGeometry1 {
20+
// MARK: - Properties
21+
/// The type of the geometry.
22+
var type: String = "Polygon"
23+
/// The array of LinearRing paths for the Polygon. The first is the exterior ring of the Polygon; any subsequent rings are holes.
24+
private(set) var paths: [GMSPath]
25+
}

Sources/GoogleMapsUtils/Geometry/Models/GMUStyle1.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ struct GMUStyle1 {
2121
/// The unique identifier of the style
2222
private(set) var styleID: String
2323
/// The color for the stroke of a LineString or Polygon.
24-
private(set) var strokeColor: UIColor
24+
private(set) var strokeColor: UIColor?
2525
/// The color for the fill of a Polygon.
26-
private(set) var fillColor: UIColor
26+
private(set) var fillColor: UIColor?
2727
/// The width of a LineString
2828
private(set) var width: Float
2929
/// The scale that a Point's icon should be rendered at.
@@ -33,9 +33,9 @@ struct GMUStyle1 {
3333
/// The position within an icon that is anchored to the Point.
3434
private(set) var anchor: CGPoint
3535
/// The href for the icon to be used for a Point.
36-
private(set) var iconUrl: String
36+
private(set) var iconUrl: String?
3737
/// The title to use for a Point.
38-
private(set) var title: String
38+
private(set) var title: String?
3939
/// Whether the Polygon has a defined fill color.
4040
private(set) var hasFill: Bool
4141
/// Whether the LineString or Polygon has a defined stroke color.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2024 Google LLC
2+
//
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+
/// TO-DO: Rename the class to `GMUStyleMap` once the linking is done and remove the objective c class.
16+
struct GMUStyleMap1 {
17+
// MARK: - Properties
18+
/// The styleMapId of the geometry.
19+
private(set) var styleMapId: String
20+
/// The array of pairs for the GMUPair
21+
/// TO-DO: Rename the class to `GMUPair` once the linking is done and remove the objective c class.
22+
private(set) var pairs: [GMUPair1]
23+
}

Sources/GoogleMapsUtils/Geometry/Protocols/GMUGeometry1.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515

1616
/// Defines a generic geometry object.
17-
/// TO-DO: Rename the class to `GMUGeometryContainer` once the linking is done and remove the objective c class.
17+
/// TO-DO: Rename the class to `GMUGeometry` once the linking is done and remove the objective c class.
1818
protocol GMUGeometry1 {
1919
/// The type of the geometry.
2020
var type: String { get }

Sources/GoogleMapsUtils/Geometry/Protocols/GMUGeometryContainer1.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ protocol GMUGeometryContainer1 {
1818
/// The geometry object in the container.
1919
var geometry: GMUGeometry { get }
2020
/// Style information that should be applied to the contained geometry object.
21-
var style: GMUStyle { get set }
21+
var style: GMUStyle? { get set }
2222
}

0 commit comments

Comments
 (0)