PostGIS  2.2.7dev-r@@SVN_REVISION@@
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::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->types = NULL;
786  state->widths = NULL;
787  state->precisions = NULL;
788  state->col_names = NULL;
789  state->field_names = NULL;
790 
791  state->from_srid = config->shp_sr_id;
792  state->to_srid = config->sr_id;
793 
794  /* If only one has a valid SRID, use it for both. */
795  if (state->to_srid == SRID_UNKNOWN)
796  {
797  if (config->geography)
798  {
799  state->to_srid = 4326;
800  }
801  else
802  {
803  state->to_srid = state->from_srid;
804  }
805  }
806 
807  if (state->from_srid == SRID_UNKNOWN)
808  {
809  state->from_srid = state->to_srid;
810  }
811 
812  /* If the geo col name is not set, use one of the defaults. */
813  state->geo_col = config->geo_col;
814 
815  if (!state->geo_col)
816  {
817  state->geo_col = strdup(config->geography ? GEOGRAPHY_DEFAULT : GEOMETRY_DEFAULT);
818  }
819 
820  colmap_init(&state->column_map);
821 
822  return state;
823 }
SHPLOADERCONFIG * config
DBFFieldType * types
DBFHandle hDBFHandle
#define GEOGRAPHY_DEFAULT
void colmap_init(colmap *map)
Definition: shpcommon.c:79
#define GEOMETRY_DEFAULT
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:172
SHPHandle hSHPHandle
void * malloc(YYSIZE_T)

Here is the call graph for this function:

Here is the caller graph for this function: