1212{
1214 double from_fraction = PG_GETARG_FLOAT8(1);
1215 double to_fraction = PG_GETARG_FLOAT8(2);
1220 bool use_spheroid = true;
1221
1222 if ( PG_NARGS() > 3 && ! PG_ARGISNULL(3) )
1223 use_spheroid = PG_GETARG_BOOL(3);
1224
1225
1227 {
1228 PG_FREE_IF_COPY(gs, 0);
1229 PG_RETURN_NULL();
1230 }
1231
1232 if ( from_fraction < 0 || from_fraction > 1 )
1233 {
1234 elog(ERROR,"%s: second argument is not within [0,1]", __func__);
1235 PG_FREE_IF_COPY(gs, 0);
1236 PG_RETURN_NULL();
1237 }
1238 if ( to_fraction < 0 || to_fraction > 1 )
1239 {
1240 elog(ERROR,"%s: argument arg is not within [0,1]", __func__);
1241 PG_FREE_IF_COPY(gs, 0);
1242 PG_RETURN_NULL();
1243 }
1244 if ( from_fraction > to_fraction )
1245 {
1246 elog(ERROR, "%s: second argument must be smaller than third argument", __func__);
1247 PG_RETURN_NULL();
1248 }
1249
1251 if ( !lwline )
1252 {
1253 elog(ERROR,"%s: first argument is not a line", __func__);
1254 PG_FREE_IF_COPY(gs, 0);
1255 PG_RETURN_NULL();
1256 }
1257
1258
1260
1261 if ( ! use_spheroid )
1262 s.a =
s.b =
s.radius;
1263
1266
1268 PG_FREE_IF_COPY(gs, 0);
1270 result = geography_serialize(lwresult);
1272
1273 PG_RETURN_POINTER(
result);
1274}
char result[OUT_DOUBLE_BUFFER_SIZE]
int32_t gserialized_get_srid(const GSERIALIZED *g)
Extract the SRID from the serialized form (it is packed into three bytes so this is a handy function)...
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
int gserialized_is_empty(const GSERIALIZED *g)
Check if a GSERIALIZED is empty without deserializing first.
void lwgeom_set_geodetic(LWGEOM *geom, int value)
Set the FLAGS geodetic bit on geometry an all sub-geometries and pointlists.
void lwgeom_free(LWGEOM *geom)
LWGEOM * geography_substring(const LWLINE *line, const SPHEROID *s, double from, double to, double tolerance)
Return the part of a line between two fractional locations.
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
void lwline_free(LWLINE *line)
#define FP_TOLERANCE
Floating point comparators.