Datum postgis_proj_version(PG_FUNCTION_ARGS);
-#include "projects.h"
+#include "proj_api.h"
#include "utils/memutils.h"
#include "executor/spi.h"
#include "access/hash.h"
#include "utils/hsearch.h"
-PJ *make_project(char *str1);
+projPJ make_project(char *str1);
void to_rad(POINT4D *pt);
void to_dec(POINT4D *pt);
-int pj_transform_nodatum(PJ *srcdefn, PJ *dstdefn, long point_count, int point_offset, double *x, double *y, double *z );
-int transform_point(POINT4D *pt, PJ *srcdefn, PJ *dstdefn);
-static int lwgeom_transform_recursive(uchar *geom, PJ *inpj, PJ *outpj);
+int pj_transform_nodatum(projPJ srcdefn, projPJ dstdefn, long point_count, int point_offset, double *x, double *y, double *z );
+int transform_point(POINT4D *pt, projPJ srcdefn, projPJ dstdefn);
+static int lwgeom_transform_recursive(uchar *geom, projPJ inpj, projPJ outpj);
typedef struct struct_PROJ4SRSCacheItem
{
int srid;
- PJ *projection;
+ projPJ projection;
MemoryContext projection_mcxt;
} PROJ4SRSCacheItem;
/*
- * Backend PJ hash table
+ * Backend projPJ hash table
*
- * This hash table stores a key/value pair of MemoryContext/PJ * objects.
- * Whenever we create a PJ * object using pj_init(), we create a separate
+ * This hash table stores a key/value pair of MemoryContext/projPJ objects.
+ * Whenever we create a projPJ object using pj_init(), we create a separate
* MemoryContext as a child context of the current executor context.
- * The MemoryContext/PJ * object is stored in this hash table so
+ * The MemoryContext/projPJ object is stored in this hash table so
* that when PROJ4SRSCacheDelete() is called during query cleanup, we can
- * lookup the PJ * object based upon the MemoryContext parameter and hence
+ * lookup the projPJ object based upon the MemoryContext parameter and hence
* pj_free() it.
*/
static HTAB *PJHash = NULL;
typedef struct struct_PJHashEntry
{
MemoryContext ProjectionContext;
- PJ *projection;
+ projPJ projection;
} PJHashEntry;
uint32 mcxt_ptr_hash(const void *key, Size keysize);
static HTAB *CreatePJHash(void);
-static void AddPJHashEntry(MemoryContext mcxt, PJ *projection);
-static PJ *GetPJHashEntry(MemoryContext mcxt);
+static void AddPJHashEntry(MemoryContext mcxt, projPJ projection);
+static projPJ GetPJHashEntry(MemoryContext mcxt);
static void DeletePJHashEntry(MemoryContext mcxt);
/* Cache API */
bool IsInPROJ4SRSCache(PROJ4PortalCache *PROJ4Cache, int srid);
-PJ *GetProjectionFromPROJ4SRSCache(PROJ4PortalCache *PROJ4Cache, int srid);
+projPJ GetProjectionFromPROJ4SRSCache(PROJ4PortalCache *PROJ4Cache, int srid);
void AddToPROJ4SRSCache(PROJ4PortalCache *PROJ4Cache, int srid, int other_srid);
void DeleteFromPROJ4SRSCache(PROJ4PortalCache *PROJ4Cache, int srid);
static void
PROJ4SRSCacheDelete(MemoryContext context)
{
- PJ *projection;
+ projPJ projection;
- /* Lookup the PJ pointer in the global hash table so we can free it */
+ /* Lookup the projPJ pointer in the global hash table so we can free it */
projection = GetPJHashEntry(context);
if (!projection)
/*
- * PROJ4 PJ Hash Table functions
+ * PROJ4 projPJ Hash Table functions
*/
ctl.entrysize = sizeof(PJHashEntry);
ctl.hash = mcxt_ptr_hash;
- return hash_create("PostGIS PROJ4 Backend PJ MemoryContext Hash", PROJ4_BACKEND_HASH_SIZE, &ctl, (HASH_ELEM | HASH_FUNCTION));
+ return hash_create("PostGIS PROJ4 Backend projPJ MemoryContext Hash", PROJ4_BACKEND_HASH_SIZE, &ctl, (HASH_ELEM | HASH_FUNCTION));
}
-static void AddPJHashEntry(MemoryContext mcxt, PJ *projection)
+static void AddPJHashEntry(MemoryContext mcxt, projPJ projection)
{
bool found;
void **key;
}
}
-static PJ *GetPJHashEntry(MemoryContext mcxt)
+static projPJ GetPJHashEntry(MemoryContext mcxt)
{
void **key;
PJHashEntry *he;
* Return the projection object from the cache (we should
* already have checked it exists using IsInPROJ4SRSCache first)
*/
-PJ *
+projPJ
GetProjectionFromPROJ4SRSCache(PROJ4PortalCache *PROJ4Cache, int srid)
{
int i;
{
MemoryContext PJMemoryContext;
int spi_result;
- PJ *projection = NULL;
+ projPJ projection = NULL;
char *proj_str;
char proj4_spi_buffer[256];
int* pj_errno_ref;
void
to_rad(POINT4D *pt)
{
- pt->x *= PI/180.0;
- pt->y *= PI/180.0;
+ pt->x *= M_PI/180.0;
+ pt->y *= M_PI/180.0;
}
/* convert radians to decimal degress */
void
to_dec(POINT4D *pt)
{
- pt->x *= 180.0/PI;
- pt->y *= 180.0/PI;
+ pt->x *= 180.0/M_PI;
+ pt->y *= 180.0/M_PI;
}
/* given a string, make a PJ object */
-PJ *
+projPJ
make_project(char *str1)
{
int t;
char *params[1024]; /* one for each parameter */
char *loc;
char *str;
- PJ *result;
+ projPJ result;
if (str1 == NULL) return NULL;
* from inpj projection to outpj projection
*/
static int
-lwgeom_transform_recursive(uchar *geom, PJ *inpj, PJ *outpj)
+lwgeom_transform_recursive(uchar *geom, projPJ inpj, projPJ outpj)
{
LWGEOM_INSPECTED *inspected = lwgeom_inspect(geom);
int j, i;
PG_LWGEOM *geom;
PG_LWGEOM *result=NULL;
LWGEOM *lwgeom;
- PJ *input_pj,*output_pj;
+ projPJ input_pj, output_pj;
int32 result_srid ;
uchar *srl;
PG_LWGEOM *geom;
PG_LWGEOM *result=NULL;
LWGEOM *lwgeom;
- PJ *input_pj,*output_pj;
+ projPJ input_pj, output_pj;
char *input_proj4, *output_proj4;
text *input_proj4_text;
text *output_proj4_text;
int
-transform_point(POINT4D *pt, PJ *srcpj, PJ *dstpj)
+transform_point(POINT4D *pt, projPJ srcpj, projPJ dstpj)
{
int* pj_errno_ref;
POINT4D orig_pt;
orig_pt.y = pt->y;
orig_pt.z = pt->z;
- if (srcpj->is_latlong) to_rad(pt);
+ if (pj_is_latlong(srcpj)) to_rad(pt);
/* Perform the transform */
pj_transform(srcpj, dstpj, 1, 0, &(pt->x), &(pt->y), &(pt->z));
}
}
- if (dstpj->is_latlong) to_dec(pt);
+ if (pj_is_latlong(dstpj)) to_dec(pt);
return 1;
}