generated from OpenDocCN/doc-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
0036.yaml
868 lines (868 loc) · 52.8 KB
/
0036.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
- en: Road Network Edge Matching With Triangles
id: totrans-0
prefs:
- PREF_H1
type: TYPE_NORMAL
zh: 道路网络边缘匹配与三角形
- en: 原文:[https://towardsdatascience.com/road-network-edge-matching-with-triangles-5dc989a77edf?source=collection_archive---------15-----------------------#2023-01-03](https://towardsdatascience.com/road-network-edge-matching-with-triangles-5dc989a77edf?source=collection_archive---------15-----------------------#2023-01-03)
id: totrans-1
prefs:
- PREF_BQ
type: TYPE_NORMAL
zh: 原文:[https://towardsdatascience.com/road-network-edge-matching-with-triangles-5dc989a77edf?source=collection_archive---------15-----------------------#2023-01-03](https://towardsdatascience.com/road-network-edge-matching-with-triangles-5dc989a77edf?source=collection_archive---------15-----------------------#2023-01-03)
- en: Triangles have mighty properties for geospatial queries
id: totrans-2
prefs:
- PREF_H2
type: TYPE_NORMAL
zh: 三角形在地理空间查询中具有强大的属性
- en: '[](https://medium.com/@joao.figueira?source=post_page-----5dc989a77edf--------------------------------)[![João
Paulo Figueira](../Images/54e4176f66e4ab0324d86ec71d8b033d.png)](https://medium.com/@joao.figueira?source=post_page-----5dc989a77edf--------------------------------)[](https://towardsdatascience.com/?source=post_page-----5dc989a77edf--------------------------------)[![Towards
Data Science](../Images/a6ff2676ffcc0c7aad8aaf1d79379785.png)](https://towardsdatascience.com/?source=post_page-----5dc989a77edf--------------------------------)
[João Paulo Figueira](https://medium.com/@joao.figueira?source=post_page-----5dc989a77edf--------------------------------)'
id: totrans-3
prefs: []
type: TYPE_NORMAL
zh: '[![João Paulo Figueira](../Images/54e4176f66e4ab0324d86ec71d8b033d.png)](https://medium.com/@joao.figueira?source=post_page-----5dc989a77edf--------------------------------)[](https://medium.com/@joao.figueira?source=post_page-----5dc989a77edf--------------------------------)[![Towards
Data Science](../Images/a6ff2676ffcc0c7aad8aaf1d79379785.png)](https://towardsdatascience.com/?source=post_page-----5dc989a77edf--------------------------------)
[João Paulo Figueira](https://medium.com/@joao.figueira?source=post_page-----5dc989a77edf--------------------------------)'
- en: ·
id: totrans-4
prefs: []
type: TYPE_NORMAL
zh: ·
- en: '[Follow](https://medium.com/m/signin?actionUrl=https%3A%2F%2Fmedium.com%2F_%2Fsubscribe%2Fuser%2F64bc009cedeb&operation=register&redirect=https%3A%2F%2Ftowardsdatascience.com%2Froad-network-edge-matching-with-triangles-5dc989a77edf&user=Jo%C3%A3o+Paulo+Figueira&userId=64bc009cedeb&source=post_page-64bc009cedeb----5dc989a77edf---------------------post_header-----------)
Published in [Towards Data Science](https://towardsdatascience.com/?source=post_page-----5dc989a77edf--------------------------------)
·13 min read·Jan 3, 2023[](https://medium.com/m/signin?actionUrl=https%3A%2F%2Fmedium.com%2F_%2Fvote%2Ftowards-data-science%2F5dc989a77edf&operation=register&redirect=https%3A%2F%2Ftowardsdatascience.com%2Froad-network-edge-matching-with-triangles-5dc989a77edf&user=Jo%C3%A3o+Paulo+Figueira&userId=64bc009cedeb&source=-----5dc989a77edf---------------------clap_footer-----------)'
id: totrans-5
prefs: []
type: TYPE_NORMAL
zh: '[关注](https://medium.com/m/signin?actionUrl=https%3A%2F%2Fmedium.com%2F_%2Fsubscribe%2Fuser%2F64bc009cedeb&operation=register&redirect=https%3A%2F%2Ftowardsdatascience.com%2Froad-network-edge-matching-with-triangles-5dc989a77edf&user=Jo%C3%A3o+Paulo+Figueira&userId=64bc009cedeb&source=post_page-64bc009cedeb----5dc989a77edf---------------------post_header-----------)
发布于 [Towards Data Science](https://towardsdatascience.com/?source=post_page-----5dc989a77edf--------------------------------)
·13 min read·2023年1月3日'
- en: --
id: totrans-6
prefs: []
type: TYPE_NORMAL
zh: --
- en: '[](https://medium.com/m/signin?actionUrl=https%3A%2F%2Fmedium.com%2F_%2Fbookmark%2Fp%2F5dc989a77edf&operation=register&redirect=https%3A%2F%2Ftowardsdatascience.com%2Froad-network-edge-matching-with-triangles-5dc989a77edf&source=-----5dc989a77edf---------------------bookmark_footer-----------)![](../Images/0394d8e4a49df7abe5e80601291b2049.png)'
id: totrans-7
prefs: []
type: TYPE_NORMAL
zh: '![](../Images/0394d8e4a49df7abe5e80601291b2049.png)[](https://medium.com/m/signin?actionUrl=https%3A%2F%2Fmedium.com%2F_%2Fbookmark%2Fp%2F5dc989a77edf&operation=register&redirect=https%3A%2F%2Ftowardsdatascience.com%2Froad-network-edge-matching-with-triangles-5dc989a77edf&source=-----5dc989a77edf---------------------bookmark_footer-----------)'
- en: Photo by [Pawel Czerwinski](https://unsplash.com/fr/@pawel_czerwinski?utm_source=medium&utm_medium=referral)
on [Unsplash](https://unsplash.com/?utm_source=medium&utm_medium=referral)
id: totrans-8
prefs: []
type: TYPE_NORMAL
zh: 照片由 [Pawel Czerwinski](https://unsplash.com/fr/@pawel_czerwinski?utm_source=medium&utm_medium=referral)
提供,来自 [Unsplash](https://unsplash.com/?utm_source=medium&utm_medium=referral)
- en: 'Triangles are shapes with many practical geometric properties. In this article,
I illustrate using such properties when performing opportunistic optimizations
while solving a particular geospatial problem: the recovery of missing map-matched
information.'
id: totrans-9
prefs: []
type: TYPE_NORMAL
zh: 三角形是具有许多实际几何属性的形状。在这篇文章中,我将阐述在解决特定地理空间问题时如何利用这些属性进行机会优化:恢复缺失的地图匹配信息。
- en: I started exploring the [Extended Vehicle Energy Dataset](https://arxiv.org/abs/2203.08630)¹
(EVED) [1] a while ago to search for compelling geospatial data analysis opportunities
in a city road network context. This dataset derives from a previous publication,
the [Vehicle Energy Dataset](https://arxiv.org/abs/1905.02081) [2], and contains
many enhancements, namely the vehicles’ map-matched GPS locations. The map-matching
process snaps the original GPS locations to the most likely edges of the underlying
road network.
id: totrans-10
prefs: []
type: TYPE_NORMAL
zh: 我开始探索[扩展车辆能量数据集](https://arxiv.org/abs/2203.08630)¹(EVED)[1],以寻找城市道路网络背景下有趣的地理空间数据分析机会。该数据集源自之前的出版物,[车辆能量数据集](https://arxiv.org/abs/1905.02081)
[2],并包含了许多增强功能,即车辆的地图匹配 GPS 位置。地图匹配过程将原始 GPS 位置快照到最可能的基础道路网络边缘上。
- en: '**Figure 1** below (taken from a [previous article](https://medium.com/towards-data-science/trajectory-queries-using-space-partitioning-773167d4184e))
illustrates how the map-matching process snaps the sampled GPS location to the
most likely road network edge.'
id: totrans-11
prefs: []
type: TYPE_NORMAL
zh: 下图**图 1**(取自[之前的文章](https://medium.com/towards-data-science/trajectory-queries-using-space-partitioning-773167d4184e))展示了地图匹配过程如何将采样的
GPS 位置快照到最可能的道路网络边缘上。
- en: '![](../Images/5f38410903905aef59131a3ce30e2f28.png)'
id: totrans-12
prefs: []
type: TYPE_IMG
zh: '![](../Images/5f38410903905aef59131a3ce30e2f28.png)'
- en: '**Figure 1** — The map-matching process snaps the noisy GPS measurement to
the most likely road network edge. Here you can see a depiction of the process
where the circles denoted with “n” represent the road network nodes, and the arrows
named “e” are the directed edges. The sampled GPS location in green matches another
one along the arc and gets recorded in the database. There is no information on
the matched edges, though. (Image source: Author)'
id: totrans-13
prefs: []
type: TYPE_NORMAL
zh: '**图 1** — 地图匹配过程将嘈杂的 GPS 测量值快照到最可能的道路网络边缘。这里展示了这一过程的图示,其中以“n”表示的圆圈代表道路网络节点,以“e”命名的箭头表示有向边缘。绿色的采样
GPS 位置与沿弧线的另一个位置匹配并记录在数据库中。然而,匹配边的信息并未提供。(图片来源:作者)'
- en: Unfortunately, the EVED dataset does not retain the underlying matched edge
information; only the snapped location. With the missing edge information, we
can make more inferences from the data, for example, to create a destination prediction
model. Can we retrieve that information from the matched GPS locations?
id: totrans-14
prefs: []
type: TYPE_NORMAL
zh: 不幸的是,EVED 数据集没有保留基础的匹配边信息;仅保留了位置快照。在缺少边信息的情况下,我们可以从数据中做出更多推断,例如,创建一个目的地预测模型。我们可以从匹配的
GPS 位置中恢复这些信息吗?
- en: 'The article authors used the [Valhalla](https://valhalla.readthedocs.io/en/latest/api/map-matching/api-reference/)
toolset to perform the map-matching operation using [Open Street Map](https://www.openstreetmap.org/)
data for the underlying road network. Armed with this information, we can recover
the missing mapped edge information using geospatial queries. We start by using
one very well-known off-the-shelf tool: [OSMnx](https://osmnx.readthedocs.io/en/stable/).
Our first task is to download the road network (aka graph).'
id: totrans-15
prefs: []
type: TYPE_NORMAL
zh: 文章作者使用了[Valhalla](https://valhalla.readthedocs.io/en/latest/api/map-matching/api-reference/)工具集,通过使用[Open
Street Map](https://www.openstreetmap.org/)数据对基础道路网络进行地图匹配操作。掌握这些信息后,我们可以利用地理空间查询恢复缺失的映射边信息。我们从使用一个非常著名的现成工具开始:[OSMnx](https://osmnx.readthedocs.io/en/stable/)。我们的第一项任务是下载道路网络(即图)。
- en: Downloading the Road Network
id: totrans-16
prefs:
- PREF_H1
type: TYPE_NORMAL
zh: 下载道路网络
- en: To download and prepare the road network data, we need to use OSMnx’s facilities,
as illustrated by the following code snippet².
id: totrans-17
prefs: []
type: TYPE_NORMAL
zh: 要下载和准备道路网络数据,我们需要使用 OSMnx 的功能,如以下代码片段²所示。
- en: '[PRE0]'
id: totrans-18
prefs: []
type: TYPE_PRE
zh: '[PRE0]'
- en: We start by downloading a non-simplified graph to retain most of the node detail.
Next, we add missing properties to the network, like edge speeds, travel times,
and bearings (the angle measured in degrees from true North in the clockwise direction).
The function returns the road network as a [NetworkX](https://networkx.org/) [3]
[directed graph object](https://networkx.org/documentation/stable/tutorial.html#multigraphs)
that allows [multiple edges](https://networkx.org/documentation/stable/tutorial.html#multigraphs)
between nodes.
id: totrans-19
prefs: []
type: TYPE_NORMAL
zh: 我们从下载一个未简化的图开始,以保留大部分节点细节。接下来,我们向网络中添加缺失的属性,如边缘速度、旅行时间和方位角(从真北开始按顺时针方向测量的角度)。该函数返回道路网络作为一个[NetworkX](https://networkx.org/)
[3] [有向图对象](https://networkx.org/documentation/stable/tutorial.html#multigraphs),允许[多个边缘](https://networkx.org/documentation/stable/tutorial.html#multigraphs)存在于节点之间。
- en: '[PRE1]'
id: totrans-20
prefs: []
type: TYPE_PRE
zh: '[PRE1]'
- en: Looking for Edges
id: totrans-21
prefs:
- PREF_H1
type: TYPE_NORMAL
zh: 寻找边缘
- en: As I mentioned, the EVED only contains the map-matched locations, not the edges
themselves, and our job is to reconstruct this information. The map-matching process
involves finding the network edges that maximize the matching probability between
the observed route and the known road network. More concretely, the operation
maps each GPS sample to the road network edge with the highest likelihood of representing
the actual traveled route. The map-matching process projects the sampled GPS location,
providing additional contextual information. The matched location belongs to the
edge-defining geodesic, and we will see how to use this to our advantage in what
follows.
id: totrans-22
prefs: []
type: TYPE_NORMAL
zh: 正如我提到的,EVED只包含地图匹配位置,而不是边本身,我们的任务是重建这些信息。地图匹配过程涉及找到最大化观察路线与已知道路网络之间匹配概率的网络边。更具体地说,该操作将每个GPS样本映射到最有可能代表实际行驶路线的道路网络边。地图匹配过程投影采样的GPS位置,提供额外的上下文信息。匹配的位置属于边界定义的大圆线段,我们将看到如何利用这一点。
- en: The OSMnx Way
id: totrans-23
prefs:
- PREF_H2
type: TYPE_NORMAL
zh: OSMnx 方法
- en: Let us now turn to OSMnx and discover a way to search for the road network edges
that the map-matched locations belong to. Fortunately, the package implements
functions to find the closest nodes and edges, which is where we will start.
id: totrans-24
prefs: []
type: TYPE_NORMAL
zh: 现在让我们转到OSMnx,发现一种搜索地图匹配位置所属道路网络边缘的方法。幸运的是,该软件包实现了查找最近节点和边的函数,我们将从这里开始。
- en: The first step is to project the road network coordinates into [UTM](https://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system)
[4]. This conversion projects the spherical GPS coordinates to a local planar
space where we can use regular geometry, and measurements are in meters.
id: totrans-25
prefs: []
type: TYPE_NORMAL
zh: 第一步是将道路网络坐标投影到[UTM](https://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system)
[4]。这种转换将球面GPS坐标投影到一个局部平面空间,在这里我们可以使用常规几何,测量单位为米。
- en: '[PRE2]'
id: totrans-26
prefs: []
type: TYPE_PRE
zh: '[PRE2]'
- en: The function call above projects the road network coordinates to the UTM zone
corresponding to the area’s center. We can now call OSMnx’s edge detection function
using a coordinate pair from the database.
id: totrans-27
prefs: []
type: TYPE_NORMAL
zh: 上面的函数调用将道路网络坐标投影到与区域中心对应的UTM区域。我们现在可以使用数据库中的坐标对调用OSMnx的边检测函数。
- en: '[PRE3]'
id: totrans-28
prefs: []
type: TYPE_PRE
zh: '[PRE3]'
- en: 'Instead of a single location, the function supports latitude and longitude
collections, returning the corresponding edge list. As for the above call, we
can inspect its result using the following code:'
id: totrans-29
prefs: []
type: TYPE_NORMAL
zh: 该函数支持纬度和经度集合,而不是单个位置,返回相应的边列表。至于上述调用,我们可以使用以下代码检查其结果:
- en: '[PRE4]'
id: totrans-30
prefs: []
type: TYPE_PRE
zh: '[PRE4]'
- en: The result is a Python dictionary containing the nearest edge properties, as
depicted below.
id: totrans-31
prefs: []
type: TYPE_NORMAL
zh: 结果是一个包含最近边属性的Python字典,如下所示。
- en: '[PRE5]'
id: totrans-32
prefs: []
type: TYPE_PRE
zh: '[PRE5]'
- en: Unfortunately, this function is slow. If we want to convert the whole EVED database
to assign the closest edge to every point, we should try another way.
id: totrans-33
prefs: []
type: TYPE_NORMAL
zh: 不幸的是,这个函数很慢。如果我们想将整个EVED数据库转换为为每个点分配最近的边,我们应该尝试另一种方法。
- en: The Triangular Way
id: totrans-34
prefs:
- PREF_H2
type: TYPE_NORMAL
zh: 三角形方法
- en: The solution I’m presenting in this section was the first to come to mind. As
stated above, map-matched locations live in the edge’s geodesic line segment that
connects the end nodes. This allows us to use triangle properties to find the
best network edge for a specific point.
id: totrans-35
prefs: []
type: TYPE_NORMAL
zh: 我在本节中提出的解决方案是我首先想到的。正如上文所述,地图匹配位置位于连接端节点的边界大圆线段上。这使我们能够使用三角形性质来找到特定点的最佳网络边。
- en: Before explaining further, I invite you to read an older article exploring triangle
properties to perform high-speed geospatial queries.
id: totrans-36
prefs: []
type: TYPE_NORMAL
zh: 在进一步解释之前,我邀请你阅读一篇较早的文章,探讨三角形性质以执行高速地理空间查询。
- en: '[](https://medium.com/tblx-insider/using-the-triangle-inequality-to-query-geographic-data-7148a1b103a0?source=post_page-----5dc989a77edf--------------------------------)
[## Using the Triangle Inequality to Query Geographic Data'
id: totrans-37
prefs: []
type: TYPE_NORMAL
zh: '[](https://medium.com/tblx-insider/using-the-triangle-inequality-to-query-geographic-data-7148a1b103a0?source=post_page-----5dc989a77edf--------------------------------)
[## 使用三角形不等式查询地理数据'
- en: A fast and straightforward method of querying large sets of locations.
id: totrans-38
prefs:
- PREF_H3
type: TYPE_NORMAL
zh: 一种快速且简单的方法来查询大量位置。
- en: medium.com](https://medium.com/tblx-insider/using-the-triangle-inequality-to-query-geographic-data-7148a1b103a0?source=post_page-----5dc989a77edf--------------------------------)
id: totrans-39
prefs: []
type: TYPE_NORMAL
zh: medium.com](https://medium.com/tblx-insider/using-the-triangle-inequality-to-query-geographic-data-7148a1b103a0?source=post_page-----5dc989a77edf--------------------------------)
- en: 'Here, I use an updated version of that article’s code to perform the basic
search queries on the road network: the *K nearest neighbors* and the *radius
query*. The updated code version uses [Numba](https://numba.pydata.org/)-based
optimizations to improve its execution performance.'
id: totrans-40
prefs: []
type: TYPE_NORMAL
zh: 在这里,我使用了该文章代码的更新版本来执行道路网络上的基本搜索查询:*K 最近邻* 和 *半径查询*。更新的代码版本使用了 [Numba](https://numba.pydata.org/)
基于优化以提高执行性能。
- en: Besides using the triangle inequality to supercharge the geospatial queries,
we will also use it to select the best edge for a given map-matched GPS sample.
The idea is quite simple, and I illustrate it in **Figure 2** below.
id: totrans-41
prefs: []
type: TYPE_NORMAL
zh: 除了使用三角不等式来加速地理空间查询外,我们还将使用它来选择给定地图匹配 GPS 样本的最佳边缘。这个想法非常简单,我在下面的 **图 2** 中进行了说明。
- en: '![](../Images/2b5c74d0dbd32fdaf17e213b7914011d.png)'
id: totrans-42
prefs: []
type: TYPE_IMG
zh: '![](../Images/2b5c74d0dbd32fdaf17e213b7914011d.png)'
- en: '**Figure 2** — When the matched GPS point does not align with a given road
network edge geodesic, the three points define a triangle (top), and the distances
verify **b + c > a**. When the point aligns (bottom), we have a degenerate triangle,
and **b + c = a**. (Image source: Author)'
id: totrans-43
prefs: []
type: TYPE_NORMAL
zh: '**图 2** — 当匹配的 GPS 点与给定道路网络边缘地理测地线不对齐时,三个点定义了一个三角形(上图),并且距离验证 **b + c > a**。当点对齐(下图)时,我们得到一个退化三角形,**b
+ c = a**。(图片来源:作者)'
- en: To match a given road network edge to a GPS point, we need to calculate the
distances between said point to the nodes (**b** and **c** in **Figure 2**). The
edge length (**a**) is a property of the downloaded road network data. We calculate
the following ratio as a metric of fit.
id: totrans-44
prefs: []
type: TYPE_NORMAL
zh: 为了将给定的道路网络边缘与 GPS 点匹配,我们需要计算该点到节点(**b** 和 **c** 在 **图 2** 中)的距离。边缘长度(**a**)是下载的道路网络数据的一个属性。我们计算以下比率作为拟合的度量。
- en: '![](../Images/9f714e9897ee661681ab64a3731bf99d.png)'
id: totrans-45
prefs: []
type: TYPE_IMG
zh: '![](../Images/9f714e9897ee661681ab64a3731bf99d.png)'
- en: '**Figure 3** — The ratio above is 1 when the matched GPS location lies in the
road network edge geodesic; otherwise, it will be greater. The best-fitting edge
will have the lowest possible value. (Image source: Author)'
id: totrans-46
prefs: []
type: TYPE_NORMAL
zh: '**图 3** — 上述比率为 1 当匹配的 GPS 位置位于道路网络边缘地理测地线上;否则,它将更大。最适合的边缘将具有最低可能值。(图片来源:作者)'
- en: The best-fitting road network edge will have the lowest possible value for this
metric. But this is not the only criterion we must use, as the segment’s heading
is also essential.
id: totrans-47
prefs: []
type: TYPE_NORMAL
zh: 最适合的道路网络边缘将具有此度量的最低值。但这不是我们必须使用的唯一标准,因为段的方向也很重要。
- en: We query a network edge using the identifiers for the end nodes, and their order
is important. By reversing the node identifiers in the network query, we get different
properties for the reverse direction (if it exists), namely the calculated bearing
or heading. **Figure 4** below shows what these properties might look like.
id: totrans-48
prefs: []
type: TYPE_NORMAL
zh: 我们使用端节点的标识符来查询网络边缘,其顺序是重要的。通过反转网络查询中的节点标识符,我们可以获得反向方向的不同属性(如果存在),即计算出的方位角或方向。下面的
**图 4** 显示了这些属性可能是什么样的。
- en: '![](../Images/e662fa0190b9d7ad345e83e5ebf12755.png)'
id: totrans-49
prefs: []
type: TYPE_IMG
zh: '![](../Images/e662fa0190b9d7ad345e83e5ebf12755.png)'
- en: '**Figure 4** — By reversing the end node identifiers, we get different properties
for the road segment, namely the bearing. (Image source: Author; Data: © OpenStreetMap
contributors)'
id: totrans-50
prefs: []
type: TYPE_NORMAL
zh: '**图 4** — 通过反转端节点标识符,我们可以获得道路段的不同属性,即方位角。(图片来源:作者;数据:© OpenStreetMap 贡献者)'
- en: To correctly match the road network edge, we must also know the GPS heading
or, as is the case, the inferred one. You can read the article below about calculating
the EVED bearings from the matched GPS locations.
id: totrans-51
prefs: []
type: TYPE_NORMAL
zh: 为了正确匹配道路网络边缘,我们还必须知道 GPS 方位角,或者如情况所示,推断出的方位角。您可以阅读下面的文章,了解如何从匹配的 GPS 位置计算 EVED
方位角。
- en: '[](/travel-time-estimation-using-quadkeys-ecf6d54823b4?source=post_page-----5dc989a77edf--------------------------------)
[## Travel Time Estimation Using Quadkeys'
id: totrans-52
prefs: []
type: TYPE_NORMAL
zh: '[](/travel-time-estimation-using-quadkeys-ecf6d54823b4?source=post_page-----5dc989a77edf--------------------------------)
[## 使用 Quadkeys 进行旅行时间估计'
- en: This article explains how to estimate travel times using known speed vectors
indexed by quadkeys.
id: totrans-53
prefs:
- PREF_H3
type: TYPE_NORMAL
zh: 本文解释了如何使用已知速度向量并通过 quadkeys 索引来估计旅行时间。
- en: towardsdatascience.com](/travel-time-estimation-using-quadkeys-ecf6d54823b4?source=post_page-----5dc989a77edf--------------------------------)
id: totrans-54
prefs: []
type: TYPE_NORMAL
zh: towardsdatascience.com](/travel-time-estimation-using-quadkeys-ecf6d54823b4?source=post_page-----5dc989a77edf--------------------------------)
- en: We are now ready to search for the best-fitting edge, but how should we search
for it in an arbitrarily large road network? A brute-force approach would search
through all available road segments, but that would not be a good use of computing
power as we can do much better. We can select a small set of nearby candidates
and then search within those only.
id: totrans-55
prefs: []
type: TYPE_NORMAL
zh: 我们现在准备寻找最佳适配的边缘,但如何在一个任意大的道路网络中搜索它呢?一种暴力方法是搜索所有可用的道路段,但这不是有效利用计算能力的好方法,因为我们可以做得更好。我们可以选择一小部分附近的候选节点,然后只在这些节点中搜索。
- en: The criterion for selecting this candidate set is straightforward — we will
use a radius query from the input GPS location. The radius comprises two parts,
the smallest distance from the query point to the network and the maximum road
segment length. By adding these two distances, we obtain a radius where we are
sure that the closest edge nodes will reside. **Figure 5** below illustrates this
concept.
id: totrans-56
prefs: []
type: TYPE_NORMAL
zh: 选择这个候选集的标准很简单——我们将使用来自输入 GPS 位置的半径查询。半径由两部分组成:从查询点到网络的最小距离和最大道路段长度。通过将这两个距离相加,我们获得一个半径,我们可以确定最近的边缘节点将位于该半径内。**图
5** 下面展示了这一概念。
- en: '![](../Images/69c32c80d146b6ea2fea7ea1285bed60.png)'
id: totrans-57
prefs: []
type: TYPE_IMG
zh: '![](../Images/69c32c80d146b6ea2fea7ea1285bed60.png)'
- en: '**Figure 5** — The schema above illustrates how to determine the search radius:
add the shortest distance from the query location (red) to the road network (blue)
to the maximum segment size (green). All the nodes inside the green circle are
candidates. Note that the query circle is centered in the query location. (Image
source: Author)'
id: totrans-58
prefs: []
type: TYPE_NORMAL
zh: '**图 5** —— 上面的示意图展示了如何确定搜索半径:将查询位置(红色)到道路网络(蓝色)的最短距离与最大段大小(绿色)相加。所有在绿色圆圈内的节点都是候选节点。请注意,查询圆圈的中心在查询位置。(图片来源:作者)'
- en: Once we have determined the candidate node set, we only consider the existing
links within the search radius.
id: totrans-59
prefs: []
type: TYPE_NORMAL
zh: 一旦确定了候选节点集,我们只考虑搜索半径内的现有链接。
- en: 'Let’s see what the code looks like. We start with the class declaration that
handles the road network:'
id: totrans-60
prefs: []
type: TYPE_NORMAL
zh: 让我们看看代码是什么样的。我们从处理道路网络的类声明开始:
- en: '[PRE6]'
id: totrans-61
prefs: []
type: TYPE_PRE
zh: '[PRE6]'
- en: To initialize this class, we call the function that downloads and prepares the
OSM road network and feeds its result as the constructor parameter. The constructor
then collects all the locations and passes them to the indexer object, described
in the previously-mentioned article. Note that we will not need to project any
coordinates for this method.
id: totrans-62
prefs: []
type: TYPE_NORMAL
zh: 要初始化这个类,我们调用下载和准备 OSM 道路网络的函数,并将其结果作为构造函数参数。构造函数随后收集所有位置并将它们传递给前述文章中描述的索引器对象。请注意,我们不需要为此方法投影任何坐标。
- en: 'The function that collects the geospatial coordinates is simple enough:'
id: totrans-63
prefs: []
type: TYPE_NORMAL
zh: 收集地理空间坐标的函数非常简单:
- en: '[PRE7]'
id: totrans-64
prefs: []
type: TYPE_PRE
zh: '[PRE7]'
- en: Now, we can get to the algorithm’s core, the query process itself. For each
query point, we want to select the most likely road network nodes that might delimit
the edge’s geodesic segment. The function below takes location coordinates and
finds the road network edge with the minimal value for the fit metric (**Figure
3**).
id: totrans-65
prefs: []
type: TYPE_NORMAL
zh: 现在,我们可以进入算法的核心——查询过程本身。对于每个查询点,我们希望选择最有可能限定边缘大地测量段的道路网络节点。下面的函数接收位置坐标,并找到具有最小适配度指标值的道路网络边缘(**图
3**)。
- en: '[PRE8]'
id: totrans-66
prefs: []
type: TYPE_PRE
zh: '[PRE8]'
- en: The code starts by finding the closest road network node and its distance. It
then calculates the search radius by adding this distance to the largest road
network edge length. The ensuing radius query returns the set of candidate nodes
and their distances to the query location. We now use the node identifiers as
keys to a dictionary of the distances for faster retrieval.
id: totrans-67
prefs: []
type: TYPE_NORMAL
zh: 代码首先找到最近的道路网络节点及其距离。然后通过将这个距离加上最大的道路网络边缘长度来计算搜索半径。随后的半径查询返回候选节点集合及其到查询位置的距离。我们现在使用节点标识符作为字典中距离的键,以便更快地检索。
- en: The main loop iterates through the candidate nodes and finds the adjacent nodes
within the query radius that still need to be iterated. Finally, the code calculates
the fit ratio and retains the best road network edge.
id: totrans-68
prefs: []
type: TYPE_NORMAL
zh: 主循环遍历候选节点,找到查询半径内需要继续遍历的邻近节点。最后,代码计算适配比率并保留最佳的道路网络边缘。
- en: 'But there is a final test in the returned road network edge: its orientation.
We can go about this if we have the sample GPS heading. As I previously explained,
we have the inferred heading value that we can use. You can see this in the final
part of the code, which only works if you provide a bearing and if the reverse
edge exists. The function that fixes the edge bearing is shown below.'
id: totrans-69
prefs: []
type: TYPE_NORMAL
zh: 但在返回的道路网络边缘中还有一个最终测试:其方向。如果我们有样本 GPS 方位角,我们可以解决这个问题。正如我之前解释的,我们有可以使用的推断方位角值。你可以在代码的最后部分看到这一点,只有在你提供了航向角并且反向边存在时,代码才会有效。修正边缘航向角的函数如下所示。
- en: '[PRE9]'
id: totrans-70
prefs: []
type: TYPE_PRE
zh: '[PRE9]'
- en: You can test this code using the accompanying [Jupyter notebook](https://github.com/joaofig/eved-explore/blob/main/07-edge-matching.ipynb)
in the [GitHub repository](https://github.com/joaofig/eved-explore). In my MacBook
Pro, this code offers a performance improvement of over three times over the OSMnx
approach.
id: totrans-71
prefs: []
type: TYPE_NORMAL
zh: 你可以使用附带的[Jupyter notebook](https://github.com/joaofig/eved-explore/blob/main/07-edge-matching.ipynb)来测试这段代码,代码存放在[GitHub
仓库](https://github.com/joaofig/eved-explore)中。在我的 MacBook Pro 上,这段代码的性能比 OSMnx
方法提高了三倍以上。
- en: The Distance Way
id: totrans-72
prefs:
- PREF_H2
type: TYPE_NORMAL
zh: 距离方式
- en: One might argue that the previous arrangement performs better under rigorous
assumptions, namely that the query locations already live over the road segment’s
geodesic. What if that is not the case? Can we develop a more general approach
based on the same search principles? We can! But we must assume that distances
are small³, so we do not have to project the coordinates, which is, fortunately,
the case.
id: totrans-73
prefs: []
type: TYPE_NORMAL
zh: 有人可能会争辩说,在严格假设下,前面的安排表现更好,即查询位置已经在道路段的测地线上。如果情况并非如此呢?我们能否基于相同的搜索原理开发一种更通用的方法?可以!但我们必须假设距离很小³,因此我们不必进行坐标投影,幸运的是,这种情况是符合的。
- en: Instead of using the aforementioned triangle ratio metric, we can calculate
the distance between the GPS location and any nearby road segment without requiring
any geospatial projection (like UTM mentioned above). Again, we rely on triangle
properties to calculate the distance using two alternate methods of computing
the triangle area and other triangle inequalities [5].
id: totrans-74
prefs: []
type: TYPE_NORMAL
zh: 与使用上述三角形比率度量不同,我们可以在不需要任何地理空间投影(如上文提到的 UTM)的情况下计算 GPS 位置与任何附近道路段之间的距离。我们再次依赖三角形的属性,使用两种不同的方法计算三角形的面积和其他三角形不等式[5]。
- en: When calculating the distance from a given point to a line segment, we have
two cases to consider, when we can make an orthogonal projection of the point
to the segment and when we cannot. Let us visualize the first case in **Figure
6** below.
id: totrans-75
prefs: []
type: TYPE_NORMAL
zh: 在计算给定点到线段的距离时,我们需要考虑两种情况:可以将点正交投影到线段上,以及不能投影的情况。让我们在下面的**图 6**中可视化第一种情况。
- en: '![](../Images/473a6ba1eba68950383cab8ea328ac22.png)'
id: totrans-76
prefs: []
type: TYPE_IMG
zh: '![](../Images/473a6ba1eba68950383cab8ea328ac22.png)'
- en: '**Figure 6** — The query point, in red, projects orthogonally into the road
segment (in blue). The distance between both (in black) is the unknown triangle''s
height, and we know all lengths. (Image source: Author)'
id: totrans-77
prefs: []
type: TYPE_NORMAL
zh: '**图 6** — 查询点(红色)正交投影到道路段(蓝色)。两者之间的距离(黑色)是未知三角形的高度,而我们知道所有长度。(图片来源:作者)'
- en: For this case, our unknown is the triangle’s height, which is the shortest distance
from the point to the road segment. So how do we calculate it? One of the best-known
triangle area formulas uses that quantity and is shown in **Figure 7** below.
id: totrans-78
prefs: []
type: TYPE_NORMAL
zh: 对于这种情况,我们的未知量是三角形的高度,即从点到道路段的最短距离。那么我们如何计算它呢?其中一个最著名的三角形面积公式使用了这个量,见下面的**图 7**。
- en: '![](../Images/ce8c2a6733e1a317e30bc9666ad06cb6.png)'
id: totrans-79
prefs: []
type: TYPE_IMG
zh: '![](../Images/ce8c2a6733e1a317e30bc9666ad06cb6.png)'
- en: '**Figure 7** — A triangle area equals the product of its base and its height
divided by two. (Image source: Author)'
id: totrans-80
prefs: []
type: TYPE_NORMAL
zh: '**图 7** — 三角形的面积等于其底边和高度的乘积除以二。(图片来源:作者)'
- en: If the area is known, we can quickly derive the height using simple algebra.
Can we calculate the triangle’s area using just the side lengths?
id: totrans-81
prefs: []
type: TYPE_NORMAL
zh: 如果已知面积,我们可以通过简单的代数迅速推导出高度。我们可以仅使用边长计算三角形的面积吗?
- en: Another probably less well-known triangle area formula got its name from [Heron
of Alexandria](https://en.wikipedia.org/wiki/Hero_of_Alexandria) [6], who proved
it “first.” Interestingly, this formula only depends on things that we already
know — the size of the triangle sides. This formula has several forms, and the
most famous is probably the one in **Figure 8** below.
id: totrans-82
prefs: []
type: TYPE_NORMAL
zh: 另一个可能不太为人所知的三角形面积公式得名于[亚历山大里的赫伦](https://en.wikipedia.org/wiki/Hero_of_Alexandria)
[6],他是第一个证明这个公式的人。有趣的是,这个公式仅依赖于我们已经知道的东西——三角形的边长。这个公式有几种形式,其中最著名的可能是下面的**图 8**中的形式。
- en: '![](../Images/69a88bd090256a9b4688fd4b0f5464af.png)'
id: totrans-83
prefs: []
type: TYPE_IMG
zh: '![](../Images/69a88bd090256a9b4688fd4b0f5464af.png)'
- en: '**Figure 8** — The Heron formula only computes the triangle area using side
lengths. Quantity “**s**” is the semi-perimeter. (Image source: Author)'
id: totrans-84
prefs: []
type: TYPE_NORMAL
zh: '**图 8** — 海伦公式仅使用边长来计算三角形的面积。量“**s**”是半周长。(图片来源:作者)'
- en: Using this formula, we can compute the triangle area and use it in the previous
one to get the distance from the sample point to the segment. Unfortunately, this
formulation is known to have numerical stability issues, especially when applied
to very “flat” triangles with very sharp angles. We will use a known stable alternative
depicted in **Figure 9** below.
id: totrans-85
prefs: []
type: TYPE_NORMAL
zh: 使用这个公式,我们可以计算三角形的面积,并将其用于前面的公式中,以获得从样本点到段的距离。不幸的是,这种公式已知在数值稳定性方面存在问题,特别是当应用于具有非常锐角的“平坦”三角形时。我们将使用**图
9**中所示的一个已知稳定的替代方案。
- en: '![](../Images/e8988cc23eee839b510a0552fb749fba.png)'
id: totrans-86
prefs: []
type: TYPE_IMG
zh: '![](../Images/e8988cc23eee839b510a0552fb749fba.png)'
- en: '**Figure 9** — The numerically stable Heron formula requires **a ≥ b ≥ c**.
(Image source: Author)'
id: totrans-87
prefs: []
type: TYPE_NORMAL
zh: '**图 9** — 数值稳定的海伦公式要求**a ≥ b ≥ c**。(图片来源:作者)'
- en: What happens when we cannot orthogonally project the query point to the road
segment? We visualize this situation if **Figure 10** below.
id: totrans-88
prefs: []
type: TYPE_NORMAL
zh: 当我们无法将查询点正交投影到道路段上时会发生什么?我们可以通过下面的**图 10**来可视化这种情况。
- en: '![](../Images/73fff67c4e6976e7a984860ffc3255f9.png)'
id: totrans-89
prefs: []
type: TYPE_IMG
zh: '![](../Images/73fff67c4e6976e7a984860ffc3255f9.png)'
- en: '**Figure 10** — We cannot make an orthogonal projection of the query point
to the road segment. In this case, the distance between both is “**a**.” (Image
source: Author)'
id: totrans-90
prefs: []
type: TYPE_NORMAL
zh: '**图 10** — 我们无法将查询点正交投影到道路段上。在这种情况下,两者之间的距离是“**a**”。(图片来源:作者)'
- en: In this situation, we have it easy as the distance is already calculated. But
how do we know the geometry using side lengths only? One observation we can make
distinguishes the triangles in **Figure 6** and **Figure 10**. In **Figure 6**,
the angles that segments “***a***” and “***c***” make with “***b***” are both
acute, while in **Figure 10**, one of them is obtuse (larger than 90 degrees).
id: totrans-91
prefs: []
type: TYPE_NORMAL
zh: 在这种情况下,我们很容易,因为距离已经计算出来。但我们如何仅使用边长来了解几何形状呢?我们可以通过一个观察来区分**图 6**和**图 10**中的三角形。在**图
6**中,段“***a***”和“***c***”与“***b***”形成的角度都是锐角,而在**图 10**中,其中一个角是钝角(大于90度)。
- en: Fortunately, geometry helps us with a different set of triangle inequalities
that help us determine if an internal triangle angle is either acute, obtuse,
or straight. In the case of **Figure 9**, we have ***c² > a² + b²***. In the symmetric
case, where the opposing angle is obtuse, we would have ***a² > b² + c²***. These
two tests tell the two situations apart and are very fast to execute.
id: totrans-92
prefs: []
type: TYPE_NORMAL
zh: 幸运的是,几何学帮助我们通过另一组三角形不等式来确定内部三角形角度是锐角、钝角还是直角。在**图 9**的情况下,我们有***c² > a² + b²***。在对称情况下,即对角是钝角时,我们会有***a²
> b² + c²***。这两个测试可以区分这两种情况,并且执行速度非常快。
- en: The code below illustrates the query that uses distances instead of a simple
fitness ratio.
id: totrans-93
prefs: []
type: TYPE_NORMAL
zh: 下面的代码演示了使用距离而不是简单适应度比率的查询。
- en: '[PRE10]'
id: totrans-94
prefs: []
type: TYPE_PRE
zh: '[PRE10]'
- en: Finally, the following function calculates Heron’s formula from three arbitrary
triangle side lengths. Note how the code starts by sorting the side lengths appropriately.
id: totrans-95
prefs: []
type: TYPE_NORMAL
zh: 最后,以下函数根据三个任意的三角形边长计算海伦公式。注意代码如何通过适当地排序边长来开始。
- en: '[PRE11]'
id: totrans-96
prefs: []
type: TYPE_PRE
zh: '[PRE11]'
- en: Let’s see if all this effort was called for.
id: totrans-97
prefs: []
type: TYPE_NORMAL
zh: 让我们看看所有这些努力是否是值得的。
- en: Performance
id: totrans-98
prefs:
- PREF_H1
type: TYPE_NORMAL
zh: 性能
- en: I obtained the performance results below using a 16-inch MacBook Pro from 2019
with a 2.6 GHz 6-Core Intel Core i7 CPU, 32 GB RAM, and Ventura 13.0\. All three
methods queried the same 868-point trajectory taken from the EVED.
id: totrans-99
prefs: []
type: TYPE_NORMAL
zh: 我使用2019年16英寸MacBook Pro,配备2.6 GHz 6核Intel Core i7 CPU,32 GB RAM,和Ventura 13.0获取了下面的性能结果。所有三种方法都查询了相同的868点轨迹,该轨迹来自EVED。
- en: In **Figure 11** below, you can see the benchmark results of the three algorithms
in the order I presented them in this article.
id: totrans-100
prefs: []
type: TYPE_NORMAL
zh: 在下面的**图 11**中,你可以看到这篇文章中介绍的三种算法的基准结果。
- en: '![](../Images/159cbe17545fb8a2dbb24b0155027872.png)'
id: totrans-101
prefs: []
type: TYPE_IMG
zh: '![](../Images/159cbe17545fb8a2dbb24b0155027872.png)'
- en: '**Figure 11** — The above performance measurements reflect the average time
each algorithm takes to process a path with 868 locations with duplicates. (Image
source: Author)'
id: totrans-102
prefs: []
type: TYPE_NORMAL
zh: '**图 11** — 上述性能测量反映了每种算法处理868个地点(含重复项)的路径所需的平均时间。(图片来源:作者)'
- en: As you can see, I am using a cache to handle the duplicates and avoid unnecessary
processing. This might provide an unfair advantage over the OSMnx algorithm, and
to clarify, I decided to run the same benchmark with the set of 203 unique locations
from the same path. The results are displayed below in **Figure 12**.
id: totrans-103
prefs: []
type: TYPE_NORMAL
zh: 如您所见,我使用了缓存来处理重复项并避免不必要的处理。这可能会对OSMnx算法提供不公平的优势,为了澄清,我决定使用相同路径中的203个唯一位置运行相同的基准测试。结果显示在**图12**下方。
- en: '![](../Images/d499bbffb5d21d716c78d4c9278f81e6.png)'
id: totrans-104
prefs: []
type: TYPE_IMG
zh: '![](../Images/d499bbffb5d21d716c78d4c9278f81e6.png)'
- en: '**Figure 12** — There seems to be a slight performance improvement when we
reduce the input trajectory to have only 203 unique locations. Nevertheless, the
performance profile does not change significantly. (Image source: Author)'
id: totrans-105
prefs: []
type: TYPE_NORMAL
zh: '**图12** — 当我们将输入轨迹减少到仅有203个唯一位置时,性能似乎有所改善。然而,性能曲线没有显著变化。(图片来源:作者)'
- en: Note that for OSMnx versions before **1.3.0**, the performance difference was
dramatically worse.
id: totrans-106
prefs: []
type: TYPE_NORMAL
zh: 请注意,对于**1.3.0**之前的OSMnx版本,性能差异显著更差。
- en: We have used our triangle properties and found a speedy algorithm to match edges.
Still, I should conduct further tests to investigate edge cases and larger road
networks to ensure this is a solid algorithm.
id: totrans-107
prefs: []
type: TYPE_NORMAL
zh: 我们利用了三角形属性并找到了一种快速的边匹配算法。然而,我应该进行更多测试,以调查边缘情况和更大的道路网络,以确保这是一个可靠的算法。
- en: Conclusion
id: totrans-108
prefs:
- PREF_H1
type: TYPE_NORMAL
zh: 结论
- en: In this article, I developed a fast algorithm to search for the missing map-matched
edges of the EVED locations. By assuming that these locations lie on a road network
edge geodesic, I developed a fast fit metric using the triangle inequality property.
Next, I enriched the algorithm to use the geometric concept of the distance of
a point to a line segment. I used more triangle properties and inequalities to
consider side lengths only. Finally, I benchmarked the solution and confirmed
the performance improvement of the new algorithms over the OSMnx one.
id: totrans-109
prefs: []
type: TYPE_NORMAL
zh: 在本文中,我开发了一种快速算法,用于搜索EVED位置的缺失地图匹配边。通过假设这些位置位于道路网络边缘的测地线上,我开发了一种快速的拟合度量,使用了三角形不等式属性。接着,我丰富了算法,使用了点到线段的几何概念。我使用了更多的三角形属性和不等式,仅考虑了边长。最后,我对解决方案进行了基准测试,并确认了新算法在性能上的提升,超过了OSMnx算法。
- en: Finally, let me stress that the performance gains result from the strong assumptions
I could make from the problem definition. The performance of this algorithm degrades
by increasing the search radius, which is highly dependent on the road network
structure, and node density.
id: totrans-110
prefs: []
type: TYPE_NORMAL
zh: 最后,我要强调的是,性能提升源于我对问题定义所能做出的强假设。该算法的性能会随着搜索半径的增加而下降,这高度依赖于道路网络结构和节点密度。
- en: Please get the code from the [GitHub repository](https://github.com/joaofig/eved-explore).
id: totrans-111
prefs: []
type: TYPE_NORMAL
zh: 请从[GitHub存储库](https://github.com/joaofig/eved-explore)获取代码。
- en: Notes
id: totrans-112
prefs:
- PREF_H1
type: TYPE_NORMAL
zh: 注释
- en: The original paper authors licensed the dataset under the Apache 2.0 License
(see the [VED](https://github.com/gsoh/VED) and [EVED](https://github.com/zhangsl2013/eVED)
GitHub repositories). Note that this also applies to derivative work.
id: totrans-113
prefs:
- PREF_OL
type: TYPE_NORMAL
zh: 原作者将数据集授权为Apache 2.0许可证(参见[VED](https://github.com/gsoh/VED)和[EVED](https://github.com/zhangsl2013/eVED)
GitHub存储库)。请注意,这也适用于衍生作品。
- en: I licensed all the code in this article and the accompanying GitHub repository
using the MIT License.
id: totrans-114
prefs:
- PREF_OL
type: TYPE_NORMAL
zh: 我将本文及附带的GitHub存储库中的所有代码授权为MIT许可证。
- en: We are dealing with relatively small distances with this dataset. The maximum
road segment length for the downloaded data is less than 600 meters (0.37 miles
or 1968 feet). You can probably use larger distances safely without a significant
error, but I suggest checking whether the incurred error is acceptable.
id: totrans-115
prefs:
- PREF_OL
type: TYPE_NORMAL
zh: 我们处理的数据集涉及相对较小的距离。下载数据的最大道路段长度小于600米(0.37英里或1968英尺)。您可能可以安全地使用更大的距离而不会产生显著误差,但我建议检查所产生的误差是否在可接受范围内。
- en: References
id: totrans-116
prefs:
- PREF_H1
type: TYPE_NORMAL
zh: 参考文献
- en: '**[1]** Zhang, S., Fatih, D., Abdulqadir, F., Schwarz, T., & Ma, X. (2022).
Extended vehicle energy dataset (eVED): an enhanced large-scale dataset for deep
learning on vehicle trip energy consumption. *arXiv*. [https://doi.org/10.48550/arXiv.2203.08630](https://doi.org/10.48550/arXiv.2203.08630)'
id: totrans-117
prefs: []
type: TYPE_NORMAL
zh: '**[1]** 张松,法提赫,阿卜杜勒卡迪尔,施瓦茨,马晓。 (2022). 扩展车辆能量数据集 (eVED): 一个增强的大规模数据集,用于深度学习车辆旅行能量消耗。*arXiv*。[https://doi.org/10.48550/arXiv.2203.08630](https://doi.org/10.48550/arXiv.2203.08630)'
- en: '**[2]** Oh, G. S., Leblanc, D. J., & Peng, H. (2019). Vehicle Energy Dataset
(VED), A Large-scale Dataset for Vehicle Energy Consumption Research. *arXiv*.
[https://doi.org/10.48550/arXiv.1905.02081](https://doi.org/10.48550/arXiv.1905.02081)'
id: totrans-118
prefs: []
type: TYPE_NORMAL
zh: '**[2]** Oh, G. S., Leblanc, D. J., & Peng, H. (2019). 车辆能源数据集 (VED),用于车辆能源消耗研究的大规模数据集。*arXiv*.
[https://doi.org/10.48550/arXiv.1905.02081](https://doi.org/10.48550/arXiv.1905.02081)'
- en: '**[3]** Aric A. Hagberg, Daniel A. Schult, and Pieter J. Swart, [“Exploring
network structure, dynamics, and function using NetworkX](https://conference.scipy.org/proceedings/SciPy2008/paper_2/),”
in [Proceedings of the 7th Python in Science Conference (SciPy2008)](https://conference.scipy.org/proceedings/SciPy2008/index.html),
Gäel Varoquaux, Travis Vaught, and Jarrod Millman (Eds), (Pasadena, CA USA), pp.
11–15, Aug 2008'
id: totrans-119
prefs: []
type: TYPE_NORMAL
zh: '**[3]** Aric A. Hagberg, Daniel A. Schult 和 Pieter J. Swart, [“使用 NetworkX
探索网络结构、动态和功能](https://conference.scipy.org/proceedings/SciPy2008/paper_2/)”, 见于
[第七届科学会议(SciPy2008)论文集](https://conference.scipy.org/proceedings/SciPy2008/index.html),
Gäel Varoquaux, Travis Vaught 和 Jarrod Millman (编辑), (美国加州帕萨迪纳), 第11–15页, 2008年8月'
- en: '**[4]** Universal Transverse Mercator coordinate system. (2022, June 16). In
*Wikipedia*. [https://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system](https://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system)'
id: totrans-120
prefs: []
type: TYPE_NORMAL
zh: '**[4]** 通用横坐标系统。 (2022年6月16日). 见于*维基百科*. [https://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system](https://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system)'
- en: '**[5]** List of triangle inequalities. (2022, December 17). In *Wikipedia*.
[https://en.wikipedia.org/wiki/List_of_triangle_inequalities](https://en.wikipedia.org/wiki/List_of_triangle_inequalities)'
id: totrans-121
prefs: []
type: TYPE_NORMAL
zh: '**[5]** 三角不等式列表。 (2022年12月17日). 见于*维基百科*. [https://en.wikipedia.org/wiki/List_of_triangle_inequalities](https://en.wikipedia.org/wiki/List_of_triangle_inequalities)'
- en: '**[6]** Heron’s formula. (2022, December 17). In *Wikipedia*. [https://en.wikipedia.org/wiki/Heron%27s_formula](https://en.wikipedia.org/wiki/Heron%27s_formula)'
id: totrans-122
prefs: []
type: TYPE_NORMAL
zh: '**[6]** 赫伦公式。 (2022年12月17日). 见于*维基百科*. [https://en.wikipedia.org/wiki/Heron%27s_formula](https://en.wikipedia.org/wiki/Heron%27s_formula)'
- en: João Paulo Figueira works as a Data Scientist at [tb.lx by Daimler Trucks and
Buses](https://tblx.io/) in Lisbon, Portugal.
id: totrans-123
prefs: []
type: TYPE_NORMAL
zh: João Paulo Figueira 在[tb.lx by Daimler Trucks and Buses](https://tblx.io/)担任数据科学家,工作地点在葡萄牙里斯本。