2668{
2673 double az1, az2;
2675 int32_t srids[4];
2676 int i = 0;
2677 int j = 0;
2678 int err_code = 0;
2679 int n_args = PG_NARGS();
2680
2681
2682 for (i = 0; i < n_args; i++)
2683 {
2684 seri_geoms[i] = PG_GETARG_GSERIALIZED_P(i);
2686 {
2687 if (i == 3)
2688 {
2689 n_args = 3;
2690 }
2691 else
2692 {
2693 err_code = 1;
2694 break;
2695 }
2696 }
2697 else
2698 {
2700 {
2701 err_code = 2;
2702 break;
2703 }
2704 else
2705 {
2707 if (srids[0] != srids[i])
2708 {
2709 err_code = 3;
2710 break;
2711 }
2712 }
2713 }
2714 }
2715 if (err_code > 0)
2716 switch (err_code)
2717 {
2718 default:
2719 for (j = 0; j <= i; j++)
2720 PG_FREE_IF_COPY(seri_geoms[j], j);
2721
2722 case 1:
2723 lwpgerror("Empty geometry");
2724 PG_RETURN_NULL();
2725 break;
2726
2727 case 2:
2728 lwpgerror("Argument must be POINT geometries");
2729 PG_RETURN_NULL();
2730 break;
2731
2732 case 3:
2733 lwpgerror("Operation on mixed SRID geometries");
2734 PG_RETURN_NULL();
2735 break;
2736 }
2737
2738 for (i = 0; i < n_args; i++)
2739 {
2742 if (!lwpoint)
2743 {
2744 for (j = 0; j < n_args; j++)
2745 PG_FREE_IF_COPY(seri_geoms[j], j);
2746 lwpgerror("Error unserializing geometry");
2747 PG_RETURN_NULL();
2748 }
2749
2751 {
2752
2753
2754
2755 lwpgerror("Error extracting point");
2756 PG_RETURN_NULL();
2757 }
2758
2759
2760 }
2761
2762
2763
2764
2765
2766
2767 if (n_args == 3)
2768 {
2770 PG_RETURN_NULL();
2772 PG_RETURN_NULL();
2773 }
2774 else
2775 {
2777 PG_RETURN_NULL();
2779 PG_RETURN_NULL();
2780 }
2783 PG_RETURN_FLOAT8(
result);
2784}
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)