Changes between Version 56 and Version 57 of CCM2 download and load
- Timestamp:
- Apr 4, 2010 9:52:09 PM (15 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
CCM2 download and load
v56 v57 207 207 -- In the function I tried to create a wso type to simplify the text. Pb you need to specify 208 208 -- a tablename.columname%TYPE which will have to change along with the column, hence the big ugly script below... 209 DROP FUNCTION IF EXISTS ccm21. pricatch_from_catch(gid_ numeric);210 CREATE OR REPLACE FUNCTION ccm21. pricatch_from_catch(gid_ numeric) RETURNS setof int AS $$209 DROP FUNCTION IF EXISTS ccm21.mycatchment(gid_ numeric); 210 CREATE OR REPLACE FUNCTION ccm21.mycatchment(gid_ numeric) RETURNS setof int AS $$ 211 211 DECLARE 212 212 result RECORD; … … 357 357 $$ 358 358 LANGUAGE 'plpgsql' ; 359 COMMENT ON FUNCTION ccm21. pricatch_from_catch(gid_ numeric) IS 'Uses the gid from ccm21.riversegments, checks strahler, and select the catchment accordingly, then returns all primary catchments from this larger catchment';359 COMMENT ON FUNCTION ccm21.mycatchment (gid_ numeric) IS 'Uses the gid from ccm21.riversegments, checks strahler, and select the catchment accordingly, then returns all primary catchments from this larger catchment'; 360 360 }}} 361 361 {{{ 362 362 --examples of use 363 363 364 SELECT ccm21. pricatch_from_catch(234706); --la vilaine dans son ensemble364 SELECT ccm21.mycatchment(234706); --la vilaine dans son ensemble 365 365 -- NOTICE: result is (6) 366 366 -- NOTICE: WSO_6 used … … 368 368 -- durée=2s 369 369 -- 370 SELECT * from ccm21.catchments where wso1_id in (SELECT ccm21. pricatch_from_catch(234706));370 SELECT * from ccm21.catchments where wso1_id in (SELECT ccm21.mycatchment(234706)); 371 371 }}} 372 372 === Plpgsql function which returns the riversegments upstream from the riversegment selected === … … 392 392 -- loop 393 393 for gid_riversegments in select gid from ccm21.riversegments 394 where wso1_id in (SELECT ccm21. pricatch_from_catch(gid_))394 where wso1_id in (SELECT ccm21.mycatchment(gid_)) 395 395 and CAST( 396 396 substring(CAST(round(pfafstette) AS TEXT),1,pfafstette_chain_length) … … 403 403 $$ 404 404 LANGUAGE 'plpgsql' ; 405 COMMENT ON FUNCTION ccm21.upstream_segments(gid_ numeric) IS 'This function uses ccm21. pricatch_from_catchto get all the segments from a catchment and searches all segments with a pfafstetter higher than the segment in the bassin. The pfafstette are trucated to the level of the segment used as input in the function';405 COMMENT ON FUNCTION ccm21.upstream_segments(gid_ numeric) IS 'This function uses ccm21.mycatchment to get all the segments from a catchment and searches all segments with a pfafstetter higher than the segment in the bassin. The pfafstette are trucated to the level of the segment used as input in the function'; 406 406 }}} 407 407 Usage example