OSMM MapBox Post Processing

CREATE TABLE osmm_mapbox.text AS SELECT ogc_fid, textstring, anchor, height, font, orientdeg, fcode,  (ST_Transform(wkb_geometry,3857))::geometry(Point, 3857) as geom FROM osmm_mapbox.cartographictext;
COMMIT;
ALTER TABLE osmm_mapbox.text ADD PRIMARY KEY (ogc_fid);
COMMIT;
CREATE INDEX text_geom_mapbox_idx ON osmm_mapbox.text USING GIST (geom);
COMMIT;
CREATE INDEX text_fcode_mapbox_idx ON osmm_mapbox.text (fcode);
COMMIT;
CLUSTER osmm_mapbox.text USING text_geom_mapbox_idx;
COMMIT;

CREATE TABLE osmm_mapbox.edgelines AS SELECT ogc_fid, (ST_Transform(wkb_geometry,3857))::geometry(MULTILINESTRING, 3857) as geom FROM osmm_mapbox.topographicline WHERE fcode = 2;
COMMIT;
ALTER TABLE osmm_mapbox.edgelines ADD PRIMARY KEY (ogc_fid);
COMMIT;
CREATE INDEX edgelines_geom_mapbox_idx ON osmm_mapbox.edgelines USING GIST (geom);
COMMIT;
CLUSTER osmm_mapbox.edgelines USING edgelines_geom_mapbox_idx;
COMMIT;


CREATE TABLE osmm_mapbox.otherlines AS SELECT ogc_fid, fcode, (ST_Transform(wkb_geometry,3857))::geometry(MULTILINESTRING, 3857) as geom FROM osmm_mapbox.topographicline WHERE fcode IN (
					3,4,5,6,7,8,9,12,14,17,18,19,20,22,23,24,25,26,27,28,29);
          COMMIT;
COMMIT;
ALTER TABLE osmm_mapbox.otherlines ADD PRIMARY KEY (ogc_fid);
COMMIT;
CREATE INDEX otherlines_geom_mapbox_idx ON osmm_mapbox.otherlines USING GIST (geom);
COMMIT;
CREATE INDEX otherlines_fcode_mapbox_idx ON osmm_mapbox.otherlines (fcode);
COMMIT;
CLUSTER osmm_mapbox.otherlines USING otherlines_fcode_mapbox_idx;
COMMIT;

CREATE TABLE osmm_mapbox.buildinglines AS SELECT ogc_fid, (ST_Transform(wkb_geometry,3857))::geometry(MULTILINESTRING, 3857) as geom FROM osmm_mapbox.topographicline WHERE fcode = 10;
COMMIT;
ALTER TABLE osmm_mapbox.buildinglines ADD PRIMARY KEY (ogc_fid);
COMMIT;
CREATE INDEX buildinglines_geom_mapbox_idx ON osmm_mapbox.buildinglines USING GIST (geom);
COMMIT;
CLUSTER osmm_mapbox.buildinglines USING buildinglines_geom_mapbox_idx;
COMMIT;

CREATE TABLE osmm_mapbox.buildingdivisionlines AS SELECT ogc_fid, (ST_Transform(wkb_geometry,3857))::geometry(MULTILINESTRING, 3857) as geom FROM osmm_mapbox.topographicline WHERE fcode = 11;
COMMIT;
ALTER TABLE osmm_mapbox.buildingdivisionlines ADD PRIMARY KEY (ogc_fid);
COMMIT;
CREATE INDEX buildingdivisionlines_geom_mapbox_idx ON osmm_mapbox.buildingdivisionlines USING GIST (geom);
COMMIT;
CLUSTER osmm_mapbox.buildingdivisionlines USING buildingdivisionlines_geom_mapbox_idx;
COMMIT;

CREATE TABLE osmm_mapbox.roadlines AS SELECT ogc_fid, (ST_Transform(wkb_geometry,3857))::geometry(MULTILINESTRING, 3857) as geom FROM osmm_mapbox.topographicline WHERE fcode = 13;
COMMIT;
ALTER TABLE osmm_mapbox.roadlines ADD PRIMARY KEY (ogc_fid);
COMMIT;
CREATE INDEX roadlines_geom_mapbox_idx ON osmm_mapbox.roadlines USING GIST (geom);
COMMIT;
CLUSTER osmm_mapbox.roadlines USING roadlines_geom_mapbox_idx;
COMMIT;


CREATE TABLE osmm_mapbox.waterlines AS SELECT ogc_fid, (ST_Transform(wkb_geometry,3857))::geometry(MULTILINESTRING, 3857) as geom FROM osmm_mapbox.topographicline WHERE fcode = 21;
COMMIT;
ALTER TABLE osmm_mapbox.waterlines ADD PRIMARY KEY (ogc_fid);
COMMIT;
CREATE INDEX waterlines_geom_mapbox_idx ON osmm_mapbox.waterlines USING GIST (geom);
COMMIT;
CLUSTER osmm_mapbox.waterlines USING waterlines_geom_mapbox_idx;
COMMIT;


CREATE TABLE osmm_mapbox.defaultlines AS SELECT ogc_fid, (ST_Transform(wkb_geometry,3857))::geometry(MULTILINESTRING, 3857) as geom FROM osmm_mapbox.topographicline WHERE fcode = 1;
COMMIT;
ALTER TABLE osmm_mapbox.defaultlines ADD PRIMARY KEY (ogc_fid);
COMMIT;
CREATE INDEX defaultlines_geom_mapbox_idx ON osmm_mapbox.defaultlines USING GIST (geom);
COMMIT;
CLUSTER osmm_mapbox.defaultlines USING defaultlines_geom_mapbox_idx;
COMMIT;

CREATE TABLE osmm_mapbox.buildingpolygon AS SELECT ogc_fid, (ST_Transform(wkb_geometry,3857))::geometry(MULTIPOLYGON, 3857) as geom FROM osmm_mapbox.topographicarea WHERE fcode = 2;
COMMIT;
ALTER TABLE osmm_mapbox.buildingpolygon ADD PRIMARY KEY (ogc_fid);
COMMIT;
CREATE INDEX buildingpolygon_geom_mapbox_idx ON osmm_mapbox.buildingpolygon USING GIST (geom);
COMMIT;
CLUSTER osmm_mapbox.buildingpolygon USING buildingpolygon_geom_mapbox_idx;
COMMIT;

CREATE TABLE osmm_mapbox.structurepolygon AS SELECT ogc_fid, (ST_Transform(wkb_geometry,3857))::geometry(MULTIPOLYGON, 3857) as geom, fcode FROM osmm_mapbox.topographicarea WHERE fcode IN
						(1,3,4,5,22,30,31,32);
            COMMIT;
ALTER TABLE osmm_mapbox.structurepolygon ADD PRIMARY KEY (ogc_fid);
COMMIT;
CREATE INDEX structurepolygon_geom_mapbox_idx ON osmm_mapbox.structurepolygon USING GIST (geom);
COMMIT;
CREATE INDEX structurepolygon_fcode_mapbox_idx ON osmm_mapbox.structurepolygon (fcode);
COMMIT;
CLUSTER osmm_mapbox.structurepolygon USING structurepolygon_geom_mapbox_idx;
COMMIT;


CREATE TABLE osmm_mapbox.landformpolygon AS SELECT ogc_fid, (ST_Transform(wkb_geometry,3857))::geometry(MULTIPOLYGON, 3857) as geom, fcode FROM osmm_mapbox.topographicarea WHERE fcode IN
						(7,8,9,10);
            COMMIT;
ALTER TABLE osmm_mapbox.landformpolygon ADD PRIMARY KEY (ogc_fid);
COMMIT;
CREATE INDEX landformpolygon_geom_mapbox_idx ON osmm_mapbox.landformpolygon USING GIST (geom);
COMMIT;
CREATE INDEX landformpolygon_fcode_mapbox_idx ON osmm_mapbox.landformpolygon (fcode);
COMMIT;
CLUSTER osmm_mapbox.landformpolygon USING landformpolygon_geom_mapbox_idx;
COMMIT;

CREATE TABLE osmm_mapbox.waterpolygon AS SELECT ogc_fid, (ST_Transform(wkb_geometry,3857))::geometry(MULTIPOLYGON, 3857) as geom, fcode FROM osmm_mapbox.topographicarea WHERE fcode IN
						(6,33,34);
            COMMIT;
ALTER TABLE osmm_mapbox.waterpolygon ADD PRIMARY KEY (ogc_fid);
COMMIT;
CREATE INDEX waterpolygon_geom_mapbox_idx ON osmm_mapbox.waterpolygon USING GIST (geom);
COMMIT;
CREATE INDEX waterpolygon_fcode_mapbox_idx ON osmm_mapbox.waterpolygon (fcode);
COMMIT;
CLUSTER osmm_mapbox.waterpolygon USING waterpolygon_geom_mapbox_idx;
COMMIT;


CREATE TABLE osmm_mapbox.vegetationpolygon AS SELECT ogc_fid, (ST_Transform(wkb_geometry,3857))::geometry(MULTIPOLYGON, 3857) as geom, fcode FROM osmm_mapbox.topographicarea WHERE fcode IN
						(11,12,13,14,15,16,17,18,19,20,21);
            COMMIT;
ALTER TABLE osmm_mapbox.vegetationpolygon ADD PRIMARY KEY (ogc_fid);
COMMIT;
CREATE INDEX vegetationpolygon_geom_mapbox_idx ON osmm_mapbox.vegetationpolygon USING GIST (geom);
COMMIT;
CREATE INDEX vegetationpolygon_fcode_mapbox_idx ON osmm_mapbox.vegetationpolygon (fcode);
COMMIT;
CLUSTER osmm_mapbox.vegetationpolygon USING vegetationpolygon_geom_mapbox_idx;
COMMIT;

CREATE TABLE osmm_mapbox.railpolygon AS SELECT ogc_fid, (ST_Transform(wkb_geometry,3857))::geometry(MULTIPOLYGON, 3857) as geom, fcode FROM osmm_mapbox.topographicarea WHERE fcode IN
						(23,24,25);
            COMMIT;
ALTER TABLE osmm_mapbox.railpolygon ADD PRIMARY KEY (ogc_fid);
COMMIT;
CREATE INDEX railpolygon_geom_mapbox_idx ON osmm_mapbox.railpolygon USING GIST (geom);
COMMIT;
CREATE INDEX railpolygon_fcode_mapbox_idx ON osmm_mapbox.railpolygon (fcode);
COMMIT;
CLUSTER osmm_mapbox.railpolygon USING railpolygon_geom_mapbox_idx;
COMMIT;

CREATE TABLE osmm_mapbox.roadpolygon AS SELECT ogc_fid, (ST_Transform(wkb_geometry,3857))::geometry(MULTIPOLYGON, 3857) as geom, fcode FROM osmm_mapbox.topographicarea WHERE fcode IN
						(26,27,28,29);
            COMMIT;
ALTER TABLE osmm_mapbox.roadpolygon ADD PRIMARY KEY (ogc_fid);
COMMIT;
CREATE INDEX roadpolygon_geom_mapbox_idx ON osmm_mapbox.roadpolygon USING GIST (geom);
COMMIT;
CREATE INDEX roadpolygon_fcode_mapbox_idx ON osmm_mapbox.roadpolygon (fcode);
COMMIT;
CLUSTER osmm_mapbox.roadpolygon USING roadpolygon_geom_mapbox_idx;
COMMIT;

CREATE TABLE osmm_mapbox.manmadepolygon AS SELECT ogc_fid, (ST_Transform(wkb_geometry,3857))::geometry(MULTIPOLYGON, 3857) as geom FROM osmm_mapbox.topographicarea WHERE fcode = 35;
COMMIT;
ALTER TABLE osmm_mapbox.manmadepolygon ADD PRIMARY KEY (ogc_fid);
COMMIT;
CREATE INDEX manmadepolygon_geom_mapbox_idx ON osmm_mapbox.manmadepolygon USING GIST (geom);
COMMIT;
CLUSTER osmm_mapbox.manmadepolygon USING manmadepolygon_geom_mapbox_idx;
COMMIT;

CREATE TABLE osmm_mapbox.naturalpolygon AS SELECT ogc_fid, (ST_Transform(wkb_geometry,3857))::geometry(MULTIPOLYGON, 3857) as geom FROM osmm_mapbox.topographicarea WHERE fcode = 36;
COMMIT;
ALTER TABLE osmm_mapbox.naturalpolygon ADD PRIMARY KEY (ogc_fid);
COMMIT;
CREATE INDEX naturalpolygon_geom_mapbox_idx ON osmm_mapbox.naturalpolygon USING GIST (geom);
COMMIT;
CLUSTER osmm_mapbox.naturalpolygon USING naturalpolygon_geom_mapbox_idx;
COMMIT;


CREATE TABLE osmm_mapbox.multiplepolygon AS SELECT ogc_fid, (ST_Transform(wkb_geometry,3857))::geometry(MULTIPOLYGON, 3857) as geom FROM osmm_mapbox.topographicarea WHERE fcode = 37;
COMMIT;
ALTER TABLE osmm_mapbox.multiplepolygon ADD PRIMARY KEY (ogc_fid);
COMMIT;
CREATE INDEX multiplepolygon_geom_mapbox_idx ON osmm_mapbox.multiplepolygon USING GIST (geom);
COMMIT;
CLUSTER osmm_mapbox.multiplepolygon USING multiplepolygon_geom_mapbox_idx;
COMMIT;