PostGIS  2.1.10dev-r@@SVN_REVISION@@
SHPLOADERSTATE* ShpLoaderCreate ( SHPLOADERCONFIG config)

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

References shp_loader_state::col_names, 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, 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().

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

Here is the caller graph for this function: