GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — CS540_Project/queries.sql at main · PR0CK0/CS540_Project Expand file tree/ Copy pathqueries.sqlMore file actions 72 lines (59 loc) · 2.17 KB / Copy pathqueries.sqlFile metadata and controls72 lines (59 loc) · 2.17 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 -- RUN THIS QUERY FIRST -- -- IF YOU HAVE the contours_analysis2 table, you can skip this query and start at the third query -- Makes the contours_analysis table, finds all distances from parcel centroids to all contour lines select gp.altkey as parid, ST_Distance( ST_Centroid( ST_Transform( gp.geom, 2236 ) ), ST_Transform( ST_SetSRID(c.geom, 2236), 2236 ) ) as parcel_elevation_contour_distance, c.elev into volusia.contours_analysis from volusia.gis_parcels gp, volusia.contours c, volusia.situs s -- Update the zipcodes here to the ones you care about, or remove the ZIP code statements to do ALL of volusia (will take forever) where s.parid = gp.altkey and (s.zip1 ilike '32114' or s.zip1 ilike '32118'); -- END FIRST QUERY -- -- RUN THIS SECOND -- -- IF YOU HAVE the contours_analysis2 table, you can skip this query and start at the third query -- Makes the contours_analysis2 table, just has one parid corresponding to the closest elevation select ca.parid, ca.elev into volusia.contours_analysis2 from volusia.contours_analysis ca inner join ( select parid, min(parcel_elevation_contour_distance) as min_distance from volusia.contours_analysis group by parid ) t on ca.parid = t.parid and ca.parcel_elevation_contour_distance = t.min_distance; -- END SECOND QUERY -- -- IGNORE THIS, JUST TESTING -- AGAIN, IGNORE THIS ENTIRE QUERY (unless you are grading me or something lol) -- This is another version of query 1 that promises better computational speed, it's from one of Lehr's announcements about looping in SQL update volusia.parcel_elev set parcel_elevation = null; DO LANGUAGE plpgsql $$ DECLARE g1 geometry; rec RECORD; elev float; i int = 1; BEGIN for rec in select parid, geom from volusia.parcel_elev where parcel_elevation is NULL and geom IS NOT NULL loop g1:=rec.geom; select into elev c.elev from volusia.contours c order by ST_SetSRID(c.geom, 2236) <->(ST_Centroid(ST_Transform(g1, 2236))) limit 1; update volusia.parcel_elev set parcel_elevation = elev where parid=rec.parid ; RAISE NOTICE '% - set to % %', i, rec.parid, elev; i=i+1; END LOOP; End; $$; |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |