Skip to content

Instantly share code, notes, and snippets.

@tjmgis
Created April 30, 2015 15:51
Show Gist options
  • Save tjmgis/d39a7ab69b07ffffa1cd to your computer and use it in GitHub Desktop.
Save tjmgis/d39a7ab69b07ffffa1cd to your computer and use it in GitHub Desktop.
New TopographicLine SQL
ALTER TABLE osmm_topo.topographicline ADD COLUMN style_description VARCHAR;
COMMIT;
ALTER TABLE osmm_topo.topographicline ADD COLUMN style_code INTEGER;
COMMIT;
CREATE INDEX fc_topoline_idx ON osmm_topo.topographicline(featurecode);
COMMIT;
UPDATE osmm_topo.topographicline SET (style_description, style_code) = ('Building Overhead Line', 10) WHERE style_code IS NULL AND featurecode = '10019' AND physicalpresence = 'Overhead'; --Must appear above Building Outline
COMMIT;
UPDATE osmm_topo.topographicline SET (style_description, style_code) = ('Building Outline', 2) WHERE style_code IS NULL AND featurecode = '10019';
COMMIT;
UPDATE osmm_topo.topographicline SET (style_description, style_code) = ('Edge Line', 3) WHERE style_code IS NULL AND featurecode = '10046' AND physicalpresence = 'Edge / Limit';
COMMIT;
UPDATE osmm_topo.topographicline SET (style_description, style_code) = ('Road Or Track', 4) WHERE style_code IS NULL AND featurecode = '10168';
COMMIT;
UPDATE osmm_topo.topographicline SET (style_description, style_code) = ('Building Division Line', 5) WHERE style_code IS NULL AND featurecode = '10018';
COMMIT;
UPDATE osmm_topo.topographicline SET (style_description, style_code) = ('Polygon Closing Line', 6) WHERE style_code IS NULL AND featurecode = '10113';
COMMIT;
UPDATE osmm_topo.topographicline SET (style_description, style_code) = ('Inland Water Line', 7) WHERE style_code IS NULL AND featurecode = '10017' or featurecode = '10087';
COMMIT;
UPDATE osmm_topo.topographicline SET (style_description, style_code) = ('Property Closing Line', 8) WHERE style_code IS NULL AND featurecode = '10114';
COMMIT;
UPDATE osmm_topo.topographicline SET (style_description, style_code) = ('General Surface Natural Line', 9) WHERE style_code IS NULL AND featurecode = '10052' AND make = 'Natural';
COMMIT;
UPDATE osmm_topo.topographicline SET (style_description, style_code) = ('General Surface Natural Line', 9) WHERE style_code IS NULL AND featurecode = '10110';
COMMIT;
UPDATE osmm_topo.topographicline SET (style_description, style_code) = ('Bottom Of Slope', 11) WHERE style_code IS NULL AND featurecode = '10097';
COMMIT;
UPDATE osmm_topo.topographicline SET (style_description, style_code) = ('Top Of Slope', 12) WHERE style_code IS NULL AND featurecode = '10098';
COMMIT;
UPDATE osmm_topo.topographicline SET (style_description, style_code) = ('Step', 13) WHERE style_code IS NULL AND featurecode = '10058';
COMMIT;
UPDATE osmm_topo.topographicline SET (style_description, style_code) = ('Path', 14) WHERE style_code IS NULL AND featurecode = '10124';
COMMIT;
UPDATE osmm_topo.topographicline SET (style_description, style_code) = ('Mean High Water', 15) WHERE style_code IS NULL AND featurecode = '10211';
COMMIT;
UPDATE osmm_topo.topographicline SET (style_description, style_code) = ('Traffic Calming', 16) WHERE style_code IS NULL AND featurecode = '10175' AND descriptiveterm = '{"Traffic Calming"}';
COMMIT;
UPDATE osmm_topo.topographicline SET (style_description, style_code) = ('Standard Gauge Track', 17) WHERE style_code IS NULL AND featurecode = '10163';
COMMIT;
UPDATE osmm_topo.topographicline SET (style_description, style_code) = ('Bottom Of Cliff', 18) WHERE style_code IS NULL AND featurecode = '10103';
COMMIT;
UPDATE osmm_topo.topographicline SET (style_description, style_code) = ('Top Of Cliff', 19) WHERE style_code IS NULL AND featurecode = '10104';
COMMIT;
UPDATE osmm_topo.topographicline SET (style_description, style_code) = ('Mean Low Water', 20) WHERE style_code IS NULL AND featurecode = '10046' AND descriptiveterm = '{"Mean Low Water (Springs)"}';
COMMIT;
UPDATE osmm_topo.topographicline SET (style_description, style_code) = ('Mean Low Water', 20) WHERE style_code IS NULL AND featurecode = '10212';
COMMIT;
UPDATE osmm_topo.topographicline SET (style_description, style_code) = ('Overhead Construction', 21) WHERE style_code IS NULL AND featurecode = '10046' AND descriptiveterm = '{"Overhead Construction"}';
COMMIT;
UPDATE osmm_topo.topographicline SET (style_description, style_code) = ('Culvert', 22) WHERE style_code IS NULL AND featurecode = '10092';
COMMIT;
UPDATE osmm_topo.topographicline SET (style_description, style_code) = ('Pylon', 23) WHERE style_code IS NULL AND featurecode = '10189';
COMMIT;
UPDATE osmm_topo.topographicline SET (style_description, style_code) = ('Landform Natural', 24) WHERE style_code IS NULL AND featurecode = '10095' and make = 'Natural';
COMMIT;
UPDATE osmm_topo.topographicline SET (style_description, style_code) = ('Ridge Or Rock Line', 25) WHERE style_code IS NULL AND featurecode = '10101';
COMMIT;
UPDATE osmm_topo.topographicline SET (style_description, style_code) = ('Tunnel Edge', 26) WHERE style_code IS NULL AND featurecode = '10041' OR featurecode = '10083' or featurecode = '10125' OR featurecode = '10157' or featurecode = '10173';
COMMIT;
UPDATE osmm_topo.topographicline SET (style_description, style_code) = ('Historic Line', 27) WHERE style_code IS NULL AND featurecode = '10075';
COMMIT;
UPDATE osmm_topo.topographicline SET (style_description, style_code) = ('Narrow Gauge Track', 28) WHERE style_code IS NULL AND featurecode = '10164';
COMMIT;
UPDATE osmm_topo.topographicline SET (style_description, style_code) = ('Landform Manmande', 29) WHERE style_code IS NULL AND featurecode = '10095' and make = 'Manmade';
COMMIT;
UPDATE osmm_topo.topographicline SET (style_description, style_code) = ('Railway Buffer', 30) WHERE style_code IS NULL AND featurecode = '10160';
COMMIT;
UPDATE osmm_topo.topographicline SET (style_description, style_code) = ('Default Line', 1) WHERE style_code IS NULL AND featurecode = '10046' OR featurecode = '10052' or featurecode = '10155' or featurecode = '10175' or featurecode = '10180' or featurecode = '10195' or featurecode = '10208';
COMMIT;
UPDATE osmm_topo.topographicline SET (style_description, style_code) = ('Unclassified', 99) WHERE style_code IS NULL;
COMMIT;
COPY (SELECT count(*) as total_count, featurecode, descriptivegroup, descriptiveterm, make, physicalpresence, style_description, style_code FROM osmm_topo.topographicline GROUP BY featurecode, descriptivegroup, descriptiveterm, make, physicalpresence, style_description, style_code ORDER BY total_count DESC) TO 'C:/temp/topoline_style.csv' WITH CSV HEADER;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment