PostGIS  2.3.8dev-r@@SVN_REVISION@@

◆ ShpLoaderCreate()

SHPLOADERSTATE* ShpLoaderCreate ( SHPLOADERCONFIG config)

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

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 main(), pgui_action_import(), test_ShpLoaderCreate(), and validate_remote_loader_columns().

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