martin/tests/fixtures/tables/autodetect.sql
Binabh e3e6b3563f
adds support for id_column in tables for auto_publish (#790)
Resolves #682 

- [x] Get id_column string from config.yaml and use for id column
- [x] Support for list of strings
- [x] Add info/warnings if column is not there or is of wrong type
- [x] if column for the feature ID is found, remove it from properties
(see inline comment)
- [x] cleanup logging messages
- [x] need more tests to catch other edge cases

---------

Co-authored-by: Yuri Astrakhan <YuriAstrakhan@gmail.com>
2023-08-13 02:06:23 +00:00

115 lines
6.3 KiB
SQL

DROP SCHEMA IF EXISTS autodetect CASCADE;
CREATE SCHEMA autodetect;
CREATE TABLE autodetect.auto_table
(
gid SERIAL PRIMARY KEY,
feat_id INTEGER,
geom GEOMETRY(POINT, 4326)
);
-- INSERT INTO autodetect.auto_table
-- SELECT generate_series(1, 3) as id,
-- (random() * 100000)::int as feat_id,
-- (ST_DUMP(ST_GENERATEPOINTS(st_transform(st_tileenvelope(18, 235085, 122323), 4326), 3))).geom;
-- INSERT INTO autodetect.auto_table
-- SELECT generate_series(4, 30) as id,
-- (random() * 100000)::int as feat_id,
-- (ST_DUMP(ST_GENERATEPOINTS(st_transform(st_tileenvelope(0, 0, 0), 4326), 27))).geom;
--
-- To dump the data above, uncomment code the above, comment the INSERT code bellow, and run:
-- just restart
-- just pg_dump --data-only --inserts --rows-per-insert=100 --table=autodetect.auto_table
INSERT INTO autodetect.auto_table (gid, feat_id, geom)
values (1, 71951, '0101000020E6100000211700C9E6DA6140F510E7C8F4DA2740'),
(2, 9437, '0101000020E61000005DC569C7E9DA6140CEC346FD7FDA2740'),
(3, 10709, '0101000020E6100000325F66F8E7DA61402FEEB913C5DA2740'),
(4, 70797, '0101000020E61000001CB4FF744BBD25C0BA329AF5570E5540'),
(5, 55425, '0101000020E61000001A9CADC39CB264402CC28861D96609C0'),
(6, 34933, '0101000020E6100000D21D13F4388C45C08A99F840FD1149C0'),
(7, 78891, '0101000020E61000000E5F9A5AC5364540584BA4A03CF31C40'),
(8, 51663, '0101000020E6100000B81C879D88DD5FC0644E7CD053D439C0'),
(9, 93945, '0101000020E6100000DBB399E0178A584048183AEEFCDA5340'),
(10, 17259, '0101000020E61000009633C32DCCFE4F40B3146ED8D7B346C0'),
(11, 26778, '0101000020E6100000087148D449A02BC0F95A2F60F6E841C0'),
(12, 921, '0101000020E6100000E04D125E8D185EC039BAF402A28F4840'),
(13, 62646, '0101000020E6100000B7FA72B6A32B3BC0CCF234580EAC3440'),
(14, 56090, '0101000020E6100000952B6EA7470654C0B4BFE4DB36213A40'),
(15, 14681, '0101000020E61000001C61802A806E61403212918F4FAF45C0'),
(16, 2042, '0101000020E6100000D81618AA67453D4077068459211A5240'),
(17, 71290, '0101000020E6100000EEFC29E57F046540A8838DDFA4AE0A40'),
(18, 86526, '0101000020E61000004EDCE036C1765C405FB54DED58CB5040'),
(19, 42544, '0101000020E61000005EAF676356CF49C01C71E517855131C0'),
(20, 81737, '0101000020E6100000B3DADB584C84514019BFD2EE3C234340'),
(21, 52337, '0101000020E6100000A102D7D0DFDB64C05DB051C746B94AC0'),
(22, 29153, '0101000020E61000008E0CF54B76E35640C2B0F17CD34C5240'),
(23, 70091, '0101000020E6100000C5C9BC82DBAC434018C3058D1D652CC0'),
(24, 3334, '0101000020E6100000B28E82F0E58F61C00BA6D4F65F695440'),
(25, 71750, '0101000020E610000050527E5BE5691CC06B9DB1B09C2B41C0'),
(26, 24924, '0101000020E610000041AA2CDA78F963C07C118FE29D084240'),
(27, 50823, '0101000020E6100000313E08EFA54859C051F0059F9FB95240'),
(28, 76138, '0101000020E6100000E72E767A1FD941C06AFA84BD7ADB13C0'),
(29, 63733, '0101000020E61000009A34CC4D671844C0903C5B00CF1B1340'),
(30, 98054, '0101000020E6100000FCB7E4474EBA6140468D5E7496BD43C0');
CREATE INDEX ON autodetect.auto_table USING GIST (geom);
CLUSTER auto_table_geom_idx ON autodetect.auto_table;
CREATE TABLE autodetect.bigint_table
(
id SERIAL PRIMARY KEY,
big_feat_id BIGINT,
geom GEOMETRY(POINT, 4326)
);
-- INSERT INTO autodetect.bigint_table
-- SELECT generate_series(1, 3) as id,
-- (random() * 100000)::bigint as big_feat_id,
-- (ST_DUMP(ST_GENERATEPOINTS(st_transform(st_tileenvelope(18, 235085, 122323), 4326), 3))).geom;
-- INSERT INTO autodetect.bigint_table
-- SELECT generate_series(4, 30) as id,
-- (random() * 100000)::bigint as big_feat_id,
-- (ST_DUMP(ST_GENERATEPOINTS(st_transform(st_tileenvelope(0, 0, 0), 4326), 27))).geom;
--
-- To dump the data above, uncomment code the above, comment the INSERT code bellow, and run:
-- just restart
-- just pg_dump --data-only --inserts --rows-per-insert=100 --table=autodetect.bigint_table
INSERT INTO autodetect.bigint_table
VALUES (1, 89698, '0101000020E6100000D4F7A0E7E2DA61402E2E980CB9DA2740'),
(2, 97180, '0101000020E61000007A523359E5DA614005BA7E9C85DA2740'),
(3, 91401, '0101000020E6100000267D6637ECDA61404174148C04DB2740'),
(4, 19522, '0101000020E610000038BE427924075C40562A5373C3172B40'),
(5, 49248, '0101000020E610000056ACFE9B1B195040B046F6B4A23D4440'),
(6, 75734, '0101000020E6100000788397D6A1DC65C08EB80652655A3840'),
(7, 71026, '0101000020E6100000EC1697F79472644072CAA4A7825053C0'),
(8, 97852, '0101000020E6100000C6F5B3F147D7654069A3BA7DDAE75140'),
(9, 69521, '0101000020E6100000FC6AF6D55BBB56409A2D1063813A50C0'),
(10, 87053, '0101000020E6100000ED99CCB0CCE559C08127412EE0294840'),
(11, 12902, '0101000020E61000006217B1200EEB61C0244EB0D2B3343CC0'),
(12, 39932, '0101000020E61000004441096983A141405B2358D3501951C0'),
(13, 46528, '0101000020E61000000440A3130F2F22C0DA24320DBB884940'),
(14, 44983, '0101000020E6100000757C081A6AAF4C40F638AE6D76235240'),
(15, 67146, '0101000020E61000007362E3AC00ED5AC05E54ABF8767342C0'),
(16, 81358, '0101000020E61000002DFD3B5895995E40C2719E2453BC2E40'),
(17, 62090, '0101000020E610000088F832477C074D40D0BCE1674EF0EE3F'),
(18, 89445, '0101000020E6100000F842E68F1C3862C046498B626D844B40'),
(19, 26213, '0101000020E61000005CC3556056316440A8AF47A7B12750C0'),
(20, 32077, '0101000020E61000005A111ACFC82E6040D4815BF8B3735240'),
(21, 61633, '0101000020E6100000106F7D3FA780514078C38538196A31C0'),
(22, 78250, '0101000020E6100000C096DB4E2ECC4CC0BAD71FB916584C40'),
(23, 16594, '0101000020E6100000562AF86EEEAE5BC09253DCA354D24FC0'),
(24, 59198, '0101000020E61000002C1AA37C3C953C40EED3DEACD3904EC0'),
(25, 48619, '0101000020E61000008490A3B7F1984140EEAFFCB7C8C54A40'),
(26, 38695, '0101000020E61000005F575A5F50CD50C08E617B39FBDE3DC0'),
(27, 34060, '0101000020E6100000E8D20BA94C905D40A413D67AEBD73E40'),
(28, 36744, '0101000020E61000007E97BBCB8F2C54401C352F1857913A40'),
(29, 34349, '0101000020E6100000F25A591EB3AA5FC0809D251CD1694540'),
(30, 89548, '0101000020E610000052F29460E5F96140CAA28F5DB33C51C0');
CREATE INDEX ON autodetect.bigint_table USING GIST (geom);
CLUSTER bigint_table_geom_idx ON autodetect.bigint_table;