PostGIS  3.3.9dev-r@@SVN_REVISION@@

◆ ShpLoaderCreate()

SHPLOADERSTATE* ShpLoaderCreate ( SHPLOADERCONFIG config)

Definition at line 782 of file shp2pgsql-core.c.

783 {
784  SHPLOADERSTATE *state;
785 
786  /* Create a new state object and assign the config to it */
787  state = malloc(sizeof(SHPLOADERSTATE));
788  state->config = config;
789 
790  /* Set any state defaults */
791  state->hSHPHandle = NULL;
792  state->hDBFHandle = NULL;
793  state->has_z = 0;
794  state->has_m = 0;
795  state->types = NULL;
796  state->widths = NULL;
797  state->precisions = NULL;
798  state->col_names = NULL;
799  state->field_names = NULL;
800  state->num_fields = 0;
801  state->pgfieldtypes = NULL;
802 
803  state->from_srid = config->shp_sr_id;
804  state->to_srid = config->sr_id;
805 
806  /* If only one has a valid SRID, use it for both. */
807  if (state->to_srid == SRID_UNKNOWN)
808  {
809  if (config->geography)
810  {
811  state->to_srid = 4326;
812  }
813  else
814  {
815  state->to_srid = state->from_srid;
816  }
817  }
818 
819  if (state->from_srid == SRID_UNKNOWN)
820  {
821  state->from_srid = state->to_srid;
822  }
823 
824  /* If the geo col name is not set, use one of the defaults. */
825  state->geo_col = config->geo_col;
826 
827  if (!state->geo_col)
828  {
830  }
831 
832  colmap_init(&state->column_map);
833 
834  return state;
835 }
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:230
void * malloc(YYSIZE_T)
#define GEOGRAPHY_DEFAULT
#define GEOMETRY_DEFAULT
void colmap_init(colmap *map)
Definition: shpcommon.c:159
DBFFieldType * types
SHPHandle hSHPHandle
DBFHandle hDBFHandle
SHPLOADERCONFIG * config

References shp_loader_state::col_names, colmap_init(), shp_loader_state::column_map, shp_loader_state::config, shp_loader_state::field_names, shp_loader_state::from_srid, shp_loader_config::geo_col, shp_loader_state::geo_col, shp_loader_config::geography, GEOGRAPHY_DEFAULT, GEOMETRY_DEFAULT, shp_loader_state::has_m, shp_loader_state::has_z, shp_loader_state::hDBFHandle, shp_loader_state::hSHPHandle, malloc(), shp_loader_state::num_fields, shp_loader_state::pgfieldtypes, shp_loader_state::precisions, shp_loader_config::shp_sr_id, shp_loader_config::sr_id, SRID_UNKNOWN, shp_loader_state::to_srid, shp_loader_state::types, and shp_loader_state::widths.

Referenced by pgui_action_import(), test_ShpLoaderCreate(), and validate_remote_loader_columns().

Here is the call graph for this function:
Here is the caller graph for this function: