@@ -114,6 +114,62 @@ exports["test: centroid"] = function() {
114114
115115} ;
116116
117+ exports [ "test: interpolatePoint" ] = function ( ) {
118+ var line = new GEOM . LineString ( [
119+ [ 1137466.548141059 , 650434.9943107369 ] ,
120+ [ 1175272.4129268457 , 648011.541439853 ] ,
121+ [ 1185935.6055587344 , 632986.1336403737 ]
122+ ] ) ;
123+
124+ // Interpolate Point Start
125+ var pt1 = line . interpolatePoint ( 0 ) ;
126+ ASSERT . ok ( pt1 . equals ( line . startPoint ) , "interpolate 0 should return start point" ) ;
127+
128+ // Interpolate Point Middle
129+ var pt2 = line . interpolatePoint ( 0.5 ) ;
130+ ASSERT . ok ( pt2 . equals ( new GEOM . Point ( [ 1165562.9204493894 , 648633.9448037925 ] ) ) , "interpolate 0.5 should return mid point" ) ;
131+
132+ // Interpolate Point End
133+ var pt3 = line . interpolatePoint ( 1.0 ) ;
134+ ASSERT . ok ( pt3 . equals ( line . endPoint ) , "interpolate 1 should return end point" ) ;
135+ } ;
136+
137+ exports [ "test: locatePoint" ] = function ( ) {
138+ var line = new GEOM . LineString ( [
139+ [ 1137466.548141059 , 650434.9943107369 ] ,
140+ [ 1175272.4129268457 , 648011.541439853 ] ,
141+ [ 1185935.6055587344 , 632986.1336403737 ]
142+ ] ) ;
143+ var point = new GEOM . Point ( [ 1153461.34 , 649950.30 ] ) ;
144+ var position = line . locatePoint ( point ) ;
145+ ASSERT . deepEqual ( 0.284 , position . toFixed ( 3 ) , "locate point position should be 0.284" ) ;
146+ } ;
147+
148+ exports [ "test: placePoint" ] = function ( ) {
149+ var line = new GEOM . LineString ( [
150+ [ 1137466.548141059 , 650434.9943107369 ] ,
151+ [ 1175272.4129268457 , 648011.541439853 ] ,
152+ [ 1185935.6055587344 , 632986.1336403737 ]
153+ ] ) ;
154+ var point = new GEOM . Point ( [ 1153461.34 , 649950.30 ] ) ;
155+ var placedPoint = line . placePoint ( point ) ;
156+ ASSERT . ok ( placedPoint . equals ( new GEOM . Point ( [ 1153426.8271476042 , 649411.899502625 ] ) ) ,
157+ "placed point should be POINT (1153426.8271476042 649411.899502625)" ) ;
158+ } ;
159+
160+ exports [ "test: subLine" ] = function ( ) {
161+ var line = new GEOM . LineString ( [
162+ [ 1137466.548141059 , 650434.9943107369 ] ,
163+ [ 1175272.4129268457 , 648011.541439853 ] ,
164+ [ 1185935.6055587344 , 632986.1336403737 ]
165+ ] ) ;
166+ var subLine = line . subLine ( 0.33 , 0.67 ) ;
167+ ASSERT . ok (
168+ new GEOM . LineString ( [ [ 1156010.153864557 , 649246.3016361536 ] , [ 1175115.6870342216 , 648021.5879714314 ] ] ) . equals ( subLine ) ,
169+ "subline should be LINESTRING (1156010.153864557 649246.3016361536, 1175115.6870342216 648021.5879714314)"
170+ )
171+ } ;
172+
117173
118174if ( require . main == module . id ) {
119175 system . exit ( require ( "test" ) . run ( exports ) ) ;
0 commit comments