1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
/**********************************************************************
*
* PostGIS - Spatial Types for PostgreSQL
* http://postgis.net
* Copyright 2001-2003 Refractions Research Inc.
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU General Public Licence. See the COPYING file.
*
**********************************************************************/
#include "postgres.h"
#include "lwgeom_log.h"
#include "liblwgeom.h"
#include "lwgeom_pg.h"
/*
* Proj4 caching has it's own mechanism, and is
* stored globally as the cost of proj_create_crs_to_crs()
* is so high (20-40ms) that the lifetime of fcinfo->flinfo->fn_extra
* is too short to assist some work loads.
*/
/* An entry in the PROJ SRS cache */
typedef struct struct_PROJSRSCacheItem
{
int32_t srid_from;
int32_t srid_to;
uint64_t hits;
LWPROJ *projection;
}
PROJSRSCacheItem;
/* PROJ 4 lookup transaction cache methods */
#define PROJ_CACHE_ITEMS 128
/*
* The proj4 cache holds a fixed number of reprojection
* entries. In normal usage we don't expect it to have
* many entries, so we always linearly scan the list.
*/
typedef struct struct_PROJSRSCache
{
PROJSRSCacheItem PROJSRSCache[PROJ_CACHE_ITEMS];
uint32_t PROJSRSCacheCount;
MemoryContext PROJSRSCacheContext;
}
PROJSRSCache;
typedef struct srs_precision
{
int precision_xy;
int precision_z;
int precision_m;
} srs_precision;
/* Prototypes */
PROJSRSCache* GetPROJSRSCache();
int lwproj_lookup(int32_t srid_from, int32_t srid_to, LWPROJ **pj);
int lwproj_is_latlong(const LWPROJ *pj);
int spheroid_init_from_srid(int32_t srid, SPHEROID *s);
void srid_check_latlong(int32_t srid);
srs_precision srid_axis_precision(int32_t srid, int precision);
/**
* Builtin SRID values
* @{
*/
/** Start of the reserved offset */
#define SRID_RESERVE_OFFSET 999000
/** World Mercator, equivalent to EPSG:3395 */
#define SRID_WORLD_MERCATOR 999000
/** Start of UTM North zone, equivalent to EPSG:32601 */
#define SRID_NORTH_UTM_START 999001
/** End of UTM North zone, equivalent to EPSG:32660 */
#define SRID_NORTH_UTM_END 999060
/** Lambert Azimuthal Equal Area (LAEA) North Pole, equivalent to EPSG:3574 */
#define SRID_NORTH_LAMBERT 999061
/** PolarSteregraphic North, equivalent to EPSG:3995 */
#define SRID_NORTH_STEREO 999062
/** Start of UTM South zone, equivalent to EPSG:32701 */
#define SRID_SOUTH_UTM_START 999101
/** Start of UTM South zone, equivalent to EPSG:32760 */
#define SRID_SOUTH_UTM_END 999160
/** Lambert Azimuthal Equal Area (LAEA) South Pole, equivalent to EPSG:3409 */
#define SRID_SOUTH_LAMBERT 999161
/** PolarSteregraphic South, equivalent to EPSG:3031 */
#define SRID_SOUTH_STEREO 999162
/** LAEA zones start (6 latitude bands x up to 20 longitude bands) */
#define SRID_LAEA_START 999163
/** LAEA zones end (6 latitude bands x up to 20 longitude bands) */
#define SRID_LAEA_END 999283
/** @} */
|