@@ -2,43 +2,22 @@ import { EDGE_LENGTH } from "../../constant/edge";
2
2
import { Coord } from "../../data/types/coord" ;
3
3
import { LatLngToLiteral } from "../coordinates/coordinateTransform" ;
4
4
import distance from "../coordinates/distance" ;
5
+ import { interpolate } from "../interpolate" ;
5
6
6
7
/** 구면 보간 없이 계산한 결과 */
7
- export default function createSubNodes (
8
- spherical : typeof google . maps . geometry . spherical | null ,
9
- polyLine : google . maps . Polyline ,
10
- ) : Coord [ ] {
8
+ export default function createSubNodes ( polyLine : google . maps . Polyline ) : Coord [ ] {
11
9
const paths = polyLine . getPath ( ) ;
12
10
const [ startNode , endNode ] = paths . getArray ( ) . map ( ( el ) => LatLngToLiteral ( el ) ) ;
13
11
14
- const length = distance ( spherical , startNode , endNode ) ;
15
- console . log ( "구면 보간" , length ) ;
12
+ const length = distance ( startNode , endNode ) ;
16
13
17
14
const subEdgesCount = Math . ceil ( length / EDGE_LENGTH ) ;
18
15
19
16
const subNodes : Coord [ ] = [ startNode ] ;
20
17
21
- if ( spherical === null || ! spherical ) {
22
- const interval = {
23
- lat : ( endNode . lat - startNode . lat ) / subEdgesCount ,
24
- lng : ( endNode . lng - startNode . lng ) / subEdgesCount ,
25
- } ;
26
-
27
- for ( let i = 1 ; i < subEdgesCount ; i ++ ) {
28
- const subNode : Coord = {
29
- lat : startNode . lat + interval . lat * i ,
30
- lng : startNode . lng + interval . lng * i ,
31
- } ;
32
- subNodes . push ( subNode ) ;
33
- }
34
-
35
- subNodes . push ( endNode ) ;
36
- return subNodes ;
37
- }
38
-
39
18
for ( let i = 1 ; i < subEdgesCount ; i ++ ) {
40
19
const fraction = i / subEdgesCount ;
41
- subNodes . push ( LatLngToLiteral ( spherical . interpolate ( startNode , endNode , fraction ) ) ) ;
20
+ subNodes . push ( interpolate ( startNode , endNode , fraction ) ) ;
42
21
}
43
22
44
23
subNodes . push ( endNode ) ;
0 commit comments