Skip to content

Commit 235a8c4

Browse files
authored
Add get/set vertical datum info series routines (#80)
* Add get/set vertical datum info series routines Replace scattered vert datum regex ops with normalization functions * Remove hard-coded office ID from test
1 parent 7962146 commit 235a8c4

File tree

3 files changed

+901
-82
lines changed

3 files changed

+901
-82
lines changed

schema/src/cwms/cwms_loc_pkg.sql

Lines changed: 209 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,45 @@ AS
3737
*/
3838
v_package_log_prop_text varchar2(30);
3939
function package_log_property_text return varchar2;
40-
/*
41-
* undocumented function store_local_datum_name
42-
*
43-
* If p_vertical_datum_id is not a standard vertical datum id, then store the
44-
* value as the local datum name for the location and return 'LOCAL'.
40+
/**
41+
* Normalizes and stores the local vertical datum for a location.
42+
* <ul>
43+
* <li>If P_Vertical_Datum_Id is some recognized form of 'NGVD29' or 'NAVD88' then stores the normalized form in AT_PHYSICAL_LOCATION.</li>
44+
* <li>Otherwise
45+
* <ul>
46+
* <li>Stores 'LOCAL' in AT_PHYSICAL_LOCATION</li>
47+
* <li>Stores P_Vertical_Datum_Id in AT_VERT_DATUM_LOCAL if not 'LOCAL' or 'OTHER'</li>
48+
* </ul></li>
49+
* </ul>
4550
*
46-
* Otherwise return p_vertical_datum_id unchanged.
51+
* @param p_location_code The unique numeric identifier associated with the location in the database
52+
* @param p_vertical_datum_id The vertical datum identifier
53+
* @return The value stored in AT_PHYSICAL_LOCATION: 'NGVD29', 'NAVD88', or 'LOCAL'
4754
*/
4855
function store_local_datum_name(
4956
p_location_code in integer,
5057
p_vertical_datum_id in varchar2)
5158
return varchar2 deterministic;
52-
59+
/**
60+
* Normalizes recognized forms of 'NGVD29' and 'NAVD88' (accepts any case and space or hyphen before digits) and converts 'OTHER' to 'LOCAL'.
61+
* If P_Vertical_Datum_Id is not recognized as one of these forms its value is returned unaltered.
62+
*
63+
* @param p_vertical_datum_id The vertical datum id to normalize.
64+
* @return 'NGVD29', 'NAVD88', 'LOCAL', or p_vertical_datum_id
65+
*/
66+
function normalize_vertical_datum_in(
67+
p_vertical_datum_id in varchar2)
68+
return varchar2 deterministic;
69+
/**
70+
* Normalizes recognized forms of 'NGVD-29' and 'NAVD-88' (accepts any case and space or lack of hyphen before digits) and converts 'LOCAL' to 'OTHER'.
71+
* If P_Vertical_Datum_Id is not recognized as one of these forms its value is returned unaltered.
72+
*
73+
* @param p_vertical_datum_id The vertical datum id to normalize.
74+
* @return 'NGVD29', 'NAVD88', 'LOCAL', or p_vertical_datum_id
75+
*/
76+
function normalize_vertical_datum_out(
77+
p_vertical_datum_id in varchar2)
78+
return varchar2 deterministic;
5379
/**
5480
* Clears all session-level caches associated with this package
5581
*/
@@ -2097,7 +2123,7 @@ AS
20972123
p_office_id in varchar2 default null)
20982124
return varchar2;
20992125
/**
2100-
* Retrieves a XML string containing the elevation, native datum, and elevation offsets to other datums for the specified location
2126+
* Retrieves a XML string containing the elevation, native datum, and current elevation offsets to other datums for the specified location
21012127
*
21022128
* @since CWMS 2.2
21032129
*
@@ -2110,7 +2136,7 @@ AS
21102136
p_location_code in number,
21112137
p_unit in varchar2);
21122138
/**
2113-
* Retrieves a XML string containing the elevation, native datum, and elevation offsets to other datums for the specified location or locations.
2139+
* Retrieves a XML string containing the elevation, native datum, and current elevation offsets to other datums for the specified location or locations.
21142140
* The in and out parmeters are limited to 4000 characters since they are of type varchar2.
21152141
*
21162142
* @since CWMS 2.2
@@ -2171,7 +2197,7 @@ AS
21712197
p_unit in varchar2,
21722198
p_office_id in varchar2 default null);
21732199
/**
2174-
* Retrieves a XML string containing the elevation, native datum, and elevation offsets to other datums for the specified location or locations
2200+
* Retrieves a XML string containing the elevation, native datum, and current elevation offsets to other datums for the specified location or locations
21752201
* The in and out parmeters (except p_unit) are not limited in length.
21762202
*
21772203
* @param p_vert_datum_info The XML-encoded vertical datum information string. If p_location_id is a recordset the XML root element will be
@@ -2230,7 +2256,7 @@ AS
22302256
p_unit in varchar2,
22312257
p_office_id in clob default null);
22322258
/**
2233-
* Returns a XML string containing the elevation, native datum, and elevation offsets to other datums for the specified location
2259+
* Returns a XML string containing the elevation, native datum, and current elevation offsets to other datums for the specified location
22342260
*
22352261
* @since CWMS 2.2
22362262
*
@@ -2244,7 +2270,7 @@ AS
22442270
p_unit in varchar2)
22452271
return varchar2;
22462272
/**
2247-
* Returns a XML string containing the elevation, native datum, and elevation offsets to other datums for the specified location
2273+
* Returns a XML string containing the elevation, native datum, and current elevation offsets to other datums for the specified location
22482274
*
22492275
* @since CWMS 2.2
22502276
*
@@ -2304,6 +2330,177 @@ AS
23042330
p_unit in varchar2,
23052331
p_office_id in varchar2 default null)
23062332
return varchar2;
2333+
/**
2334+
* Returns a XML string containing the elevation, native datum, and series of elevation offsets to other datums for the specified location.
2335+
*
2336+
* @param p_location_code The unique numeric code that identifies the location in the database
2337+
* @param p_unit The unit to return the elevation and elevation offsets in
2338+
*
2339+
* @return The XML-encoded vertical datum information string in the following format:
2340+
* <pre><big>
2341+
* &lt;vertical-datum-info-series office="SWT" unit="ft"&gt;
2342+
* &lt;location&gt;TestLoc1&lt;/location&gt;
2343+
* &lt;native-datum&gt;OTHER&lt;/native-datum&gt;
2344+
* &lt;elevation&gt;500&lt;/elevation&gt;
2345+
* &lt;local-datum-name&gt;TestDatum&lt;/local-datum-name&gt;
2346+
* &lt;offset time="2000-01-01T00:00:00Z" estimate="false"&gt;
2347+
* &lt;to-datum&gt;NGVD29&lt;/to-datum&gt;
2348+
* &lt;value&gt;1.1&lt;/value&gt;
2349+
* &lt;description&gt;1st Offset&lt;/description&gt;
2350+
* &lt;/offset&gt;
2351+
* &lt;offset time="2000-01-01T00:00:00Z" estimate="true"&gt;
2352+
* &lt;to-datum&gt;NAVD88&lt;/to-datum&gt;
2353+
* &lt;value&gt;1.15&lt;/value&gt;
2354+
* &lt;description/&gt;
2355+
* &lt;/offset&gt;
2356+
* &lt;offset time="2010-01-01T00:00:00Z" estimate="false"&gt;
2357+
* &lt;to-datum&gt;NGVD29&lt;/to-datum&gt;
2358+
* &lt;value&gt;1.3&lt;/value&gt;
2359+
* &lt;description&gt;2nd Offset&lt;/description&gt;
2360+
* &lt;/offset&gt;
2361+
* &lt;offset time="2010-01-01T00:00:00Z" estimate="true"&gt;
2362+
* &lt;to-datum&gt;NAVD88&lt;/to-datum&gt;
2363+
* &lt;value&gt;1.35&lt;/value&gt;
2364+
* &lt;description/&gt;
2365+
* &lt;/offset&gt;
2366+
* &lt;offset time="2012-05-11T00:00:00Z" estimate="false"&gt;
2367+
* &lt;to-datum&gt;NAVD88&lt;/to-datum&gt;
2368+
* &lt;value&gt;1.785&lt;/value&gt;
2369+
* &lt;description/&gt;
2370+
* &lt;/offset&gt;
2371+
* &lt;offset time="2020-01-01T00:00:00Z" estimate="false"&gt;
2372+
* &lt;to-datum&gt;NGVD29&lt;/to-datum&gt;
2373+
* &lt;value&gt;1.5&lt;/value&gt;
2374+
* &lt;description&gt;3rd Offset&lt;/description&gt;
2375+
* &lt;/offset&gt;
2376+
* &lt;offset time="2020-01-01T00:00:00Z" estimate="false"&gt;
2377+
* &lt;to-datum&gt;NAVD88&lt;/to-datum&gt;
2378+
* &lt;value&gt;1.985&lt;/value&gt;
2379+
* &lt;description/&gt;
2380+
* &lt;/offset&gt;
2381+
* &lt;/vertical-datum-info-series&gt;
2382+
* </big></pre>
2383+
*/
2384+
function get_vertical_datum_info_series_f(
2385+
p_location_code in number,
2386+
p_unit in varchar2)
2387+
return clob;
2388+
/**
2389+
* Returns a XML string containing the elevation, native datum, and series of elevation offsets to other datums for the specified location.
2390+
*
2391+
* @param p_location_id The text name the location
2392+
* @param p_unit The unit to return the elevation and elevation offsets in
2393+
* @param p_office_id The office that owns the location. If not specified or NULL, the session user's default office is used.
2394+
*
2395+
* @return The XML-encoded vertical datum information string in the following format:
2396+
* <pre><big>
2397+
* &lt;vertical-datum-info-series office="SWT" unit="ft"&gt;
2398+
* &lt;location&gt;TestLoc1&lt;/location&gt;
2399+
* &lt;native-datum&gt;OTHER&lt;/native-datum&gt;
2400+
* &lt;elevation&gt;500&lt;/elevation&gt;
2401+
* &lt;local-datum-name&gt;TestDatum&lt;/local-datum-name&gt;
2402+
* &lt;offset time="2000-01-01T00:00:00Z" estimate="false"&gt;
2403+
* &lt;to-datum&gt;NGVD29&lt;/to-datum&gt;
2404+
* &lt;value&gt;1.1&lt;/value&gt;
2405+
* &lt;description&gt;1st Offset&lt;/description&gt;
2406+
* &lt;/offset&gt;
2407+
* &lt;offset time="2000-01-01T00:00:00Z" estimate="true"&gt;
2408+
* &lt;to-datum&gt;NAVD88&lt;/to-datum&gt;
2409+
* &lt;value&gt;1.15&lt;/value&gt;
2410+
* &lt;description/&gt;
2411+
* &lt;/offset&gt;
2412+
* &lt;offset time="2010-01-01T00:00:00Z" estimate="false"&gt;
2413+
* &lt;to-datum&gt;NGVD29&lt;/to-datum&gt;
2414+
* &lt;value&gt;1.3&lt;/value&gt;
2415+
* &lt;description&gt;2nd Offset&lt;/description&gt;
2416+
* &lt;/offset&gt;
2417+
* &lt;offset time="2010-01-01T00:00:00Z" estimate="true"&gt;
2418+
* &lt;to-datum&gt;NAVD88&lt;/to-datum&gt;
2419+
* &lt;value&gt;1.35&lt;/value&gt;
2420+
* &lt;description/&gt;
2421+
* &lt;/offset&gt;
2422+
* &lt;offset time="2012-05-11T00:00:00Z" estimate="false"&gt;
2423+
* &lt;to-datum&gt;NAVD88&lt;/to-datum&gt;
2424+
* &lt;value&gt;1.785&lt;/value&gt;
2425+
* &lt;description/&gt;
2426+
* &lt;/offset&gt;
2427+
* &lt;offset time="2020-01-01T00:00:00Z" estimate="false"&gt;
2428+
* &lt;to-datum&gt;NGVD29&lt;/to-datum&gt;
2429+
* &lt;value&gt;1.5&lt;/value&gt;
2430+
* &lt;description&gt;3rd Offset&lt;/description&gt;
2431+
* &lt;/offset&gt;
2432+
* &lt;offset time="2020-01-01T00:00:00Z" estimate="false"&gt;
2433+
* &lt;to-datum&gt;NAVD88&lt;/to-datum&gt;
2434+
* &lt;value&gt;1.985&lt;/value&gt;
2435+
* &lt;description/&gt;
2436+
* &lt;/offset&gt;
2437+
* &lt;/vertical-datum-info-series&gt;
2438+
* </big></pre>
2439+
*/
2440+
function get_vertical_datum_info_series_f(
2441+
p_location_id in varchar2,
2442+
p_unit in varchar2,
2443+
p_office_id in varchar2)
2444+
return clob;
2445+
/**
2446+
* Sets the vertical datum info for a location, overwriting any existing vertical datum info with the following exceptions:
2447+
* <ul>
2448+
* <li>A missing (null) elevation in the XML will not overwrite an existing elevation in the database</li>
2449+
* <li>A missing (null) local datum name (if the native datum in 'LOCAL' or 'OTHER') will not overwrite an existing local datum name in the database</li>
2450+
* </ul>
2451+
* The vertical datum information is specified in the following format:
2452+
* <pre><big>
2453+
* &lt;vertical-datum-info-series office="SWT" unit="ft"&gt;
2454+
* &lt;location&gt;TestLoc1&lt;/location&gt;
2455+
* &lt;native-datum&gt;OTHER&lt;/native-datum&gt;
2456+
* &lt;elevation&gt;500&lt;/elevation&gt;
2457+
* &lt;local-datum-name&gt;TestDatum&lt;/local-datum-name&gt;
2458+
* &lt;offset time="2000-01-01T00:00:00Z" estimate="false"&gt;
2459+
* &lt;to-datum&gt;NGVD29&lt;/to-datum&gt;
2460+
* &lt;value&gt;1.1&lt;/value&gt;
2461+
* &lt;description&gt;1st Offset&lt;/description&gt;
2462+
* &lt;/offset&gt;
2463+
* &lt;offset time="2000-01-01T00:00:00Z" estimate="true"&gt;
2464+
* &lt;to-datum&gt;NAVD88&lt;/to-datum&gt;
2465+
* &lt;value&gt;1.15&lt;/value&gt;
2466+
* &lt;description/&gt;
2467+
* &lt;/offset&gt;
2468+
* &lt;offset time="2010-01-01T00:00:00Z" estimate="false"&gt;
2469+
* &lt;to-datum&gt;NGVD29&lt;/to-datum&gt;
2470+
* &lt;value&gt;1.3&lt;/value&gt;
2471+
* &lt;description&gt;2nd Offset&lt;/description&gt;
2472+
* &lt;/offset&gt;
2473+
* &lt;offset time="2010-01-01T00:00:00Z" estimate="true"&gt;
2474+
* &lt;to-datum&gt;NAVD88&lt;/to-datum&gt;
2475+
* &lt;value&gt;1.35&lt;/value&gt;
2476+
* &lt;description/&gt;
2477+
* &lt;/offset&gt;
2478+
* &lt;offset time="2012-05-11T00:00:00Z" estimate="false"&gt;
2479+
* &lt;to-datum&gt;NAVD88&lt;/to-datum&gt;
2480+
* &lt;value&gt;1.785&lt;/value&gt;
2481+
* &lt;description/&gt;
2482+
* &lt;/offset&gt;
2483+
* &lt;offset time="2020-01-01T00:00:00Z" estimate="false"&gt;
2484+
* &lt;to-datum&gt;NGVD29&lt;/to-datum&gt;
2485+
* &lt;value&gt;1.5&lt;/value&gt;
2486+
* &lt;description&gt;3rd Offset&lt;/description&gt;
2487+
* &lt;/offset&gt;
2488+
* &lt;offset time="2020-01-01T00:00:00Z" estimate="false"&gt;
2489+
* &lt;to-datum&gt;NAVD88&lt;/to-datum&gt;
2490+
* &lt;value&gt;1.985&lt;/value&gt;
2491+
* &lt;description/&gt;
2492+
* &lt;/offset&gt;
2493+
* &lt;/vertical-datum-info-series&gt;
2494+
* </big></pre>
2495+
* Note that specifying an XML instance with no <pre><big>&lt;offset&gt;</big></pre> elements will remove all vertical datum offsets for the location from the database.
2496+
*
2497+
* @param p_vert_datum_info The vertical datum information in the format above
2498+
* @param p_fail_if_exists A flag ('T'/'F') specifying whether to fail if existing vertical datum information would be overwritten.
2499+
*/
2500+
procedure set_vertical_datum_info_series(
2501+
p_vert_datum_info in varchar2,
2502+
p_fail_if_exists in varchar2);
2503+
23072504
/**
23082505
* Sets vertical datum info for one or more locations
23092506
*

0 commit comments

Comments
 (0)