Definition at line 1544 of file shp2pgsql-core.c.
1545{
1550 char *escval;
1551 char *geometry=NULL, *ret;
1552 char *utf8str;
1554 int rv;
1555
1556
1561
1562
1564 {
1565 *strrecord = NULL;
1567 }
1568
1569
1571 {
1573 if (!obj)
1574 {
1577 }
1578
1579
1581 {
1583
1584 *strrecord = NULL;
1586 }
1587 }
1588
1589
1591 {
1593 {
1596 }
1597 else
1598 {
1601 }
1602 }
1603
1604
1605
1607 {
1608
1610 {
1613 else
1615 }
1616 else
1617 {
1618
1619 switch (state->
types[i])
1620 {
1625 {
1628 }
1629
1630
1631 if (val[0] == '\0')
1632 {
1633 val[0] = '0';
1634 val[1] = '\0';
1635 }
1636
1637
1638 if (val[strlen(val) - 1] == '.')
1639 val[strlen(val) - 1] = '\0';
1640 break;
1641
1646 {
1649 }
1650 break;
1651
1655 {
1658 }
1659 if (strlen(val) == 0)
1660 {
1663 else
1665 goto done_cell;
1666 }
1667 break;
1668
1669 default:
1671
1672
1677 }
1678
1680 {
1681 char *encoding_msg =
_(
"Try \"LATIN1\" (Western European), or one of the values described at http://www.postgresql.org/docs/current/static/multibyte.html.");
1682
1684
1686 {
1688 snprintf(state->
message,
SHPLOADERMSGLEN,
_(
"Unable to convert data value \"%s\" to UTF-8 (iconv reports \"%s\"). Current encoding is \"%s\". %s"), utf8str, strerror(errno), state->
config->
encoding, encoding_msg);
1690 snprintf(state->
message,
SHPLOADERMSGLEN,
_(
"Unable to convert data value to UTF-8 (iconv reports \"%s\"). Current encoding is \"%s\". %s"), strerror(errno), state->
config->
encoding, encoding_msg);
1691 else
1693
1696
1697
1702 }
1706
1707 }
1708
1709
1711 {
1714 }
1715 else
1716 {
1719 }
1720
1721
1722 if (val != escval)
1724 }
1725
1726done_cell:
1727
1728
1730 {
1733 else
1735 }
1736
1737
1738 }
1739
1740
1741
1743 {
1744
1745 char *oldlocale = setlocale(LC_NUMERIC, "C");
1746
1747
1749 {
1752 else
1754 }
1755 else
1756 {
1757
1759 {
1764 break;
1765
1770 break;
1771
1775
1778 break;
1779
1784 break;
1785
1786 default:
1791
1793 }
1794
1796 {
1797
1801
1803 }
1804
1805
1807 {
1809 {
1811 }
1813 }
1814
1816
1818 {
1820
1821
1823 {
1824
1825
1826
1829 else
1831 }
1832 }
1833
1835 }
1836
1837
1839
1840 setlocale(LC_NUMERIC, oldlocale);
1841 }
1842
1843
1846
1847
1848
1852
1853 *strrecord = ret;
1854
1855
1857 {
1860
1862 }
1863 else
1864 {
1865
1867
1869 }
1870}
int SHPAPI_CALL DBFGetFieldCount(DBFHandle psDBF)
const char SHPAPI_CALL1 * DBFReadStringAttribute(DBFHandle psDBF, int iRecord, int iField){ return STATIC_CAST(const char *, DBFReadAttribute(psDBF, iRecord, iField, 'C')
int SHPAPI_CALL DBFIsAttributeNULL(DBFHandle psDBF, int iRecord, int iField)
int SHPAPI_CALL DBFIsRecordDeleted(DBFHandle psDBF, int iShape)
void SHPAPI_CALL SHPDestroyObject(SHPObject *psObject)
SHPObject SHPAPI_CALL1 * SHPReadObject(SHPHandle hSHP, int iShape);int SHPAPI_CALL SHPWriteObject(SHPHandle hSHP, int iShape, SHPObject *psObject
static int utf8(const char *fromcode, char *inputbuf, char **outputbuf)
int GeneratePointGeometry(SHPLOADERSTATE *state, SHPObject *obj, char **geometry, int force_multi)
Generate an allocated geometry string for shapefile object obj using the state parameters if "force_m...
char * escape_insert_string(char *str)
Escape input string suitable for INSERT.
int GeneratePolygonGeometry(SHPLOADERSTATE *state, SHPObject *obj, char **geometry)
Generate an allocated geometry string for shapefile object obj using the state parameters.
char * escape_copy_string(char *str)
Escape input string suitable for COPY.
int GenerateLineStringGeometry(SHPLOADERSTATE *state, SHPObject *obj, char **geometry)
Generate an allocated geometry string for shapefile object obj using the state parameters.
#define SHPLOADERRECISNULL
#define SHPLOADERRECDELETED
stringbuffer_t * stringbuffer_create(void)
Allocate a new stringbuffer_t.
void stringbuffer_clear(stringbuffer_t *s)
Reset the stringbuffer_t.
int stringbuffer_aprintf(stringbuffer_t *s, const char *fmt,...)
Appends a formatted string to the current string buffer, using the format and argument list provided.
const char * stringbuffer_getstring(stringbuffer_t *s)
Returns a reference to the internal string being managed by the stringbuffer.
void stringbuffer_destroy(stringbuffer_t *s)
Free the stringbuffer_t and all memory managed within it.
char message[SHPLOADERMSGLEN]
References _, shp_loader_state::col_names, shp_loader_state::config, DBFGetFieldCount(), DBFIsAttributeNULL(), DBFIsRecordDeleted(), DBFReadStringAttribute(), shp_loader_config::dump_format, shp_loader_config::encoding, escape_copy_string(), escape_insert_string(), free(), shp_loader_state::from_srid, FTDate, FTDouble, FTInteger, FTLogical, FTString, GenerateLineStringGeometry(), GeneratePointGeometry(), GeneratePolygonGeometry(), shp_loader_config::geography, shp_loader_state::hDBFHandle, shp_loader_state::hSHPHandle, lwfree(), malloc(), MAXVALUELEN, shp_loader_state::message, tagSHPObject::nSHPType, shp_loader_config::null_policy, tagSHPObject::nVertices, POLICY_NULL_SKIP, shp_loader_config::readshape, shp_loader_config::schema, SHPDestroyObject(), SHPLOADERERR, SHPLOADERMSGLEN, SHPLOADEROK, SHPLOADERRECDELETED, SHPLOADERRECISNULL, SHPLOADERWARN, SHPReadObject(), SHPT_ARC, SHPT_ARCM, SHPT_ARCZ, SHPT_MULTIPOINT, SHPT_MULTIPOINTM, SHPT_MULTIPOINTZ, SHPT_POINT, SHPT_POINTM, SHPT_POINTZ, SHPT_POLYGON, SHPT_POLYGONM, SHPT_POLYGONZ, shp_loader_config::simple_geometries, stringbuffer_aprintf(), stringbuffer_clear(), stringbuffer_create(), stringbuffer_destroy(), stringbuffer_getstring(), shp_loader_config::table, shp_loader_state::to_srid, shp_loader_state::types, utf8(), UTF8_BAD_RESULT, UTF8_GOOD_RESULT, and UTF8_NO_RESULT.
Referenced by main(), and pgui_action_import().