1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "locationsJson": [
12 {
13 "location_id": "inside",
14 "latitude": 1,
15 "longitude": 1
16 },
17 {
18 "location_id": "outside",
19 "latitude": 20,
20 "longitude": 20
21 },
22 {
23 "location_id": "boundary",
24 "latitude": 0,
25 "longitude": 5
26 },
27 {
28 "location_id": "overlap",
29 "latitude": 8,
30 "longitude": 8
31 },
32 {
33 "location_id": "hole",
34 "latitude": 4,
35 "longitude": 4
36 },
37 {
38 "location_id": "invalid",
39 "latitude": 95,
40 "longitude": 1
41 },
42 {
43 "location_id": "duplicate",
44 "latitude": 1,
45 "longitude": 1
46 }
47 ],
48 "serviceAreasGeoJson": {
49 "type": "FeatureCollection",
50 "features": [
51 {
52 "type": "Feature",
53 "id": "central",
54 "properties": {},
55 "geometry": {
56 "type": "Polygon",
57 "coordinates": [
58 [
59 [
60 0,
61 0
62 ],
63 [
64 10,
65 0
66 ],
67 [
68 10,
69 10
70 ],
71 [
72 0,
73 10
74 ],
75 [
76 0,
77 0
78 ]
79 ],
80 [
81 [
82 3,
83 3
84 ],
85 [
86 3,
87 5
88 ],
89 [
90 5,
91 5
92 ],
93 [
94 5,
95 3
96 ],
97 [
98 3,
99 3
100 ]
101 ]
102 ]
103 }
104 },
105 {
106 "type": "Feature",
107 "id": "east",
108 "properties": {},
109 "geometry": {
110 "type": "Polygon",
111 "coordinates": [
112 [
113 [
114 7,
115 7
116 ],
117 [
118 12,
119 7
120 ],
121 [
122 12,
123 12
124 ],
125 [
126 7,
127 12
128 ],
129 [
130 7,
131 7
132 ]
133 ]
134 ]
135 }
136 }
137 ]
138 },
139 "areaPriority": []
140};
141
142
143const run = await client.actor("afkdigital/service-area-coverage-validator").call(input);
144
145
146console.log('Results from dataset');
147console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
148const { items } = await client.dataset(run.defaultDatasetId).listItems();
149items.forEach((item) => {
150 console.dir(item);
151});
152
153