@@ -40,163 +40,18 @@ The Geodesy class provides a collection of methods for performing various geodet
4040
4141Please see the details [ here] ( doc/CLASS.md ) .
4242
43+ ### Example
44+
45+ Please check out [ here] ( example/class_example.dart ) .
46+
4347## Static Methods
4448
4549Static methods are available without using Geodesy instance.
4650
4751Please see the details [ here] ( doc/METHODS.md ) .
52+ ### Example
4853
49- ## Example - Geodesy Class
50-
51- Please check out [ here] ( example/main.dart ) for more.
52-
53- ``` dart
54- import 'package:geodesy/geodesy.dart';
55-
56- void main() {
57- final Geodesy geodesy = Geodesy();
58- // Calculate Bounding Box
59- // Example central position (San Francisco)
60- final centerPoint = const LatLng(37.7749, -122.4194);
61- // Example distance in kilometers
62- final distanceInKm = 1.0;
63-
64- final boundingBox = geodesy.calculateBoundingBox(centerPoint, distanceInKm);
65-
66- print('[calculateBoundingBox]: ');
67- print(' > Top Left: ${boundingBox[0]}');
68- print(' > Bottom Right: ${boundingBox[1]}');
69-
70- // Polygon Centroid
71- List<LatLng> polygon = [
72- const LatLng(0, 0),
73- const LatLng(4, 0),
74- const LatLng(4, 4),
75- const LatLng(0, 4)
76- ];
77-
78- LatLng centroid = geodesy.findPolygonCentroid(polygon);
79-
80- print("Centroid: ${centroid.latitude}, ${centroid.longitude}");
81-
82- // Polygon Intersection
83- final List<LatLng> polygon1 = [
84- const LatLng(0, 0),
85- const LatLng(0, 2),
86- const LatLng(2, 2),
87- const LatLng(2, 0),
88- ];
89-
90- final List<LatLng> polygon2 = [
91- const LatLng(1, 1),
92- const LatLng(1, 3),
93- const LatLng(3, 3),
94- const LatLng(3, 1),
95- ];
96-
97- final List<LatLng> intersectionPoints =
98- geodesy.getPolygonIntersection(polygon1, polygon2);
99-
100- print('Intersection Points:');
101- for (final point in intersectionPoints) {
102- print('Latitude: ${point.latitude}, Longitude: ${point.longitude}');
103- }
104- }
105-
106- // Calculate Area
107- final outerPolygon = [
108- const LatLng(0.0, 0.0),
109- const LatLng(0.0, 1.0),
110- const LatLng(1.0, 1.0),
111- const LatLng(1.0, 0.0),
112- ];
113-
114- // Define a hole within the outer polygon
115- final hole1 = [
116- const LatLng(0.25, 0.25),
117- const LatLng(0.25, 0.75),
118- const LatLng(0.75, 0.75),
119- const LatLng(0.75, 0.25),
120- ];
121-
122- final holes = [hole1];
123- final calculatedArea =
124- geodesy.calculatePolygonWithHolesArea(outerPolygon, holes);
125- ```
126-
127- ## Example Static Methods
128-
129- ``` dart
130- import 'package:geodesy/geodesy.dart';
131-
132- void main() {
133- // Calculate Bounding Box
134- // Example central position (San Francisco)
135- final centerPoint = const LatLng(37.7749, -122.4194);
136- // Example distance in kilometers
137- final distanceInKm = 1.0;
138- // Static Method
139- final boundingBox =
140- BoundingBox.calculateBoundingBox(centerPoint, distanceInKm);
141-
142- print('[calculateBoundingBox]: ');
143- print(' > Top Left: ${boundingBox[0]}');
144- print(' > Bottom Right: ${boundingBox[1]}');
145-
146- // Polygon Centroid
147- List<LatLng> polygon = [
148- const LatLng(0, 0),
149- const LatLng(4, 0),
150- const LatLng(4, 4),
151- const LatLng(0, 4)
152- ];
153- // Static Method
154- final LatLng centroid = PolygonCentroid.findPolygonCentroid(polygon);
155-
156- print("Centroid: ${centroid.latitude}, ${centroid.longitude}");
157-
158- // Polygon Intersection
159- final List<LatLng> polygon1 = [
160- const LatLng(0, 0),
161- const LatLng(0, 2),
162- const LatLng(2, 2),
163- const LatLng(2, 0),
164- ];
165-
166- final List<LatLng> polygon2 = [
167- const LatLng(1, 1),
168- const LatLng(1, 3),
169- const LatLng(3, 3),
170- const LatLng(3, 1),
171- ];
172- // Static Method
173- final List<LatLng> intersectionPoints =
174- PolygonIntersection.getPolygonIntersection(polygon1, polygon2);
175-
176- print('Intersection Points:');
177- for (final point in intersectionPoints) {
178- print('Latitude: ${point.latitude}, Longitude: ${point.longitude}');
179- }
180- }
181- // Static Method
182- final outerPolygon = [
183- const LatLng(0.0, 0.0),
184- const LatLng(0.0, 1.0),
185- const LatLng(1.0, 1.0),
186- const LatLng(1.0, 0.0),
187- ];
188-
189- final hole1 = [
190- const LatLng(0.25, 0.25),
191- const LatLng(0.25, 0.75),
192- const LatLng(0.75, 0.75),
193- const LatLng(0.75, 0.25),
194- ];
195-
196- final holes = [hole1];
197- final area = Polygon.calculatePolygonWithHolesArea(outerPolygon, holes);
198- ```
199-
54+ Please check out [ here] ( example/static_example.dart ) .
20055## Code of Conduct
20156
20257See [ here] ( doc/CODE_OF_CONDUCT.md ) .
0 commit comments