Return the part of a line between two fractional locations.
109{
116 int nsegs, i;
117 double length, slength, tlength;
118 int state = 0;
119 uint32_t srid = lwline->
srid;
120
121
122
123
124
129
130
132
133
134 from = length * from;
135 to = length * to;
136 tlength = 0;
140 for (i = 0; i < nsegs; i++)
141 {
142 double dseg;
145
146
147
150
151 else
153
154
155 if (state == 0)
156 {
157 if (fabs ( from - ( tlength + slength ) ) <= tolerance)
158 {
159
161 state = 1;
162 goto END;
163 }
164 else if (fabs(from - tlength) <= tolerance)
165 {
166
168
169
170
171
172 state = 1;
173 }
174
175
176
177
178 else if (from > tlength + slength)
179 {
180 goto END;
181 }
182 else
183 {
184
185 dseg = (from - tlength) / slength;
188
189 state = 1;
190 }
191 }
192
193 if (state == 1)
194 {
195
196 if (fabs(to - ( tlength + slength ) ) <= tolerance )
197 {
199 break;
200 }
201
202
203
204
205 else if (fabs(to - tlength) <= tolerance)
206 {
208 break;
209 }
210
211
212
213
214 else if (to > tlength + slength)
215 {
217 goto END;
218 }
219
220
221
222
223 else if (to < tlength + slength )
224 {
225 dseg = (to - tlength) / slength;
228 break;
229 }
230 }
231
232 END:
233 tlength += slength;
234 memcpy(&p1, &p2,
sizeof(
POINT4D));
236 }
237
240 }
241 else {
243 }
244
245 return lwresult;
246}
LWGEOM * lwpoint_as_lwgeom(const LWPOINT *obj)
LWPOINT * lwpoint_construct(int32_t srid, GBOX *bbox, POINTARRAY *point)
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
#define FLAGS_GET_Z(flags)
LWLINE * lwline_construct(int32_t srid, GBOX *bbox, POINTARRAY *points)
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
#define FLAGS_GET_M(flags)
int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *point)
int ptarray_append_point(POINTARRAY *pa, const POINT4D *pt, int allow_duplicates)
Append a point to the end of an existing POINTARRAY If allow_duplicate is LW_FALSE,...
void geographic_point_init(double lon, double lat, GEOGRAPHIC_POINT *g)
Initialize a geographic point.
double ptarray_length_spheroid(const POINTARRAY *pa, const SPHEROID *s)
double sphere_distance(const GEOGRAPHIC_POINT *s, const GEOGRAPHIC_POINT *e)
Given two points on a unit sphere, calculate their distance apart in radians.
double spheroid_distance(const GEOGRAPHIC_POINT *a, const GEOGRAPHIC_POINT *b, const SPHEROID *spheroid)
Computes the shortest distance along the surface of the spheroid between two points,...
static void interpolate_point4d_spheroid(const POINT4D *p1, const POINT4D *p2, POINT4D *p, const SPHEROID *s, double f)
Find interpolation point p between geography points p1 and p2 so that the len(p1,p) == len(p1,...
Point in spherical coordinates on the world.