2695{
2700 double az1, az2;
2702 int32_t srids[4];
2703 int i = 0;
2704 int j = 0;
2705 int err_code = 0;
2706 int n_args = PG_NARGS();
2707
2708
2709 for (i = 0; i < n_args; i++)
2710 {
2711 seri_geoms[i] = PG_GETARG_GSERIALIZED_P(i);
2713 {
2714 if (i == 3)
2715 {
2716 n_args = 3;
2717 }
2718 else
2719 {
2720 err_code = 1;
2721 break;
2722 }
2723 }
2724 else
2725 {
2727 {
2728 err_code = 2;
2729 break;
2730 }
2731 else
2732 {
2734 if (srids[0] != srids[i])
2735 {
2736 err_code = 3;
2737 break;
2738 }
2739 }
2740 }
2741 }
2742 if (err_code > 0)
2743 switch (err_code)
2744 {
2745 default:
2746 for (j = 0; j <= i; j++)
2747 PG_FREE_IF_COPY(seri_geoms[j], j);
2748
2749 case 1:
2750 lwpgerror("Empty geometry");
2751 PG_RETURN_NULL();
2752 break;
2753
2754 case 2:
2755 lwpgerror("Argument must be POINT geometries");
2756 PG_RETURN_NULL();
2757 break;
2758
2759 case 3:
2760 lwpgerror("Operation on mixed SRID geometries");
2761 PG_RETURN_NULL();
2762 break;
2763 }
2764
2765 for (i = 0; i < n_args; i++)
2766 {
2769 if (!lwpoint)
2770 {
2771 for (j = 0; j < n_args; j++)
2772 PG_FREE_IF_COPY(seri_geoms[j], j);
2773 lwpgerror("Error unserializing geometry");
2774 PG_RETURN_NULL();
2775 }
2776
2778 {
2779
2780
2781
2782 lwpgerror("Error extracting point");
2783 PG_RETURN_NULL();
2784 }
2785
2786
2787 }
2788
2789
2790
2791
2792
2793
2794 if (n_args == 3)
2795 {
2797 PG_RETURN_NULL();
2799 PG_RETURN_NULL();
2800 }
2801 else
2802 {
2804 PG_RETURN_NULL();
2806 PG_RETURN_NULL();
2807 }
2810 PG_RETURN_FLOAT8(
result);
2811}
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.
uint32_t gserialized_get_type(const GSERIALIZED *g)
Extract the geometry type from the serialized form (it hides in the anonymous data area,...
int azimuth_pt_pt(const POINT2D *p1, const POINT2D *p2, double *ret)
Compute the azimuth of segment AB in radians.
int getPoint2d_p(const POINTARRAY *pa, uint32_t n, POINT2D *point)
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
static LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)