PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ ShpLoaderCreate()

SHPLOADERSTATE* ShpLoaderCreate ( SHPLOADERCONFIG config)

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

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