980{
985 double azimuth = 0.0;
989
990
991 if ( PG_NARGS() < 2 || PG_ARGISNULL(0) || PG_ARGISNULL(1) )
992 PG_RETURN_NULL();
993
994
995 g = PG_GETARG_GSERIALIZED_P(0);
996
997
1000 {
1001 elog(ERROR, "ST_Project(geography) is only valid for point inputs");
1002 PG_RETURN_NULL();
1003 }
1004
1007
1008
1010 {
1012 elog(ERROR, "ST_Project(geography) cannot project from an empty start point");
1013 PG_RETURN_NULL();
1014 }
1015
1016 if ( PG_NARGS() > 2 && ! PG_ARGISNULL(2) )
1017 azimuth = PG_GETARG_FLOAT8(2);
1018
1019
1021
1022
1024 {
1025 PG_RETURN_POINTER(g);
1026 }
1027
1028
1030
1031
1032 if ( lwp_projected == NULL )
1033 {
1034 elog(ERROR, "lwgeom_project_spheroid returned null");
1035 PG_RETURN_NULL();
1036 }
1037
1038
1042
1043 PG_FREE_IF_COPY(g, 0);
1044 PG_RETURN_POINTER(g_out);
1045}
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)