959{
964 double azimuth = 0.0;
968
969
970 if ( PG_NARGS() < 2 || PG_ARGISNULL(0) || PG_ARGISNULL(1) )
971 PG_RETURN_NULL();
972
973
974 g = PG_GETARG_GSERIALIZED_P(0);
975
976
979 {
980 elog(ERROR, "ST_Project(geography) is only valid for point inputs");
981 PG_RETURN_NULL();
982 }
983
986
987
989 {
991 elog(ERROR, "ST_Project(geography) cannot project from an empty start point");
992 PG_RETURN_NULL();
993 }
994
995 if ( PG_NARGS() > 2 && ! PG_ARGISNULL(2) )
996 azimuth = PG_GETARG_FLOAT8(2);
997
998
1000
1001
1003 {
1004 PG_RETURN_POINTER(g);
1005 }
1006
1007
1009
1010
1011 if ( lwp_projected == NULL )
1012 {
1013 elog(ERROR, "lwgeom_project_spheroid returned null");
1014 PG_RETURN_NULL();
1015 }
1016
1017
1021
1022 PG_FREE_IF_COPY(g, 0);
1023 PG_RETURN_POINTER(g_out);
1024}
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.
uint32_t gserialized_get_type(const GSERIALIZED *g)
Extract the geometry type from the serialized form (it hides in the anonymous data area,...
LWGEOM * lwpoint_as_lwgeom(const LWPOINT *obj)
void lwpoint_free(LWPOINT *pt)
void lwgeom_free(LWGEOM *geom)
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
LWPOINT * lwgeom_project_spheroid(const LWPOINT *r, const SPHEROID *spheroid, double distance, double azimuth)
Calculate the location of a point on a spheroid, give a start point, bearing and distance.
static LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
static double distance(double x1, double y1, double x2, double y2)