Issue 54 location generic geometry#151
Conversation
Signed-off-by: mperryman2 <MPerryman@geiconsultants.com>
Add conversion notes to update script
MikeNeilson
left a comment
There was a problem hiding this comment.
I have a few comments.
Going to need to come back to it later though... that was long.
| l_srid mdsys.sdo_coord_ref_sys.srid%type; | ||
| l_geometry sdo_geometry; | ||
| begin | ||
| if :new.geometry is null then |
There was a problem hiding this comment.
the column is not null, shouldn't this just fail before it gets to here?
| location_code number(14) not null, | ||
| geometry sdo_geometry not null, | ||
| geometry_type number(2), | ||
| latitude number, |
There was a problem hiding this comment.
would it be better, perhaps from a index perspective to duplicate the centroid, to another geometry object so 2nd spatial index could be used?
NOTE: I'm assuming this is duplicated/shortcutting so the lat/long rendering is easier in the view for the lat/long columsn, so maybe both, or likely just overthinking it.
| :new.longitude := l_geometry.sdo_point.x; | ||
| end if; | ||
| else | ||
| ------------------------ |
There was a problem hiding this comment.
wouldn't pulling out the centroid here still be useful to get the nearest city?
| loc.search_doc, | ||
| nvl (ll.geometry, bll.geometry) as geometry, | ||
| nvl (ll.geometry_type, bll.geometry_type) as geometry_type | ||
| from -- join the base location metadata (bas) with the location (loc) |
There was a problem hiding this comment.
| from -- join the base location metadata (bas) with the location (loc) | |
| from cwms_20.at_physical_location loc | |
| -- join the base location metadata (bas) with the location (loc) | |
| left join cwms_20.at_physical_location bas on ( bas.location_code = loc.base_location_code ) | |
| left join cwms_20.at_base_location blo on ( blo.base_location_code = loc.base_location_code ) | |
| left outer join cwms_20.at_location_geometry ll on ( ll.location_code = loc.location_code ) | |
| left outer join cwms_20.at_location_geometry bll on ( bll.location_code = loc.base_location_code) |
That was rather difficult to reason about with the joins all basically inline.
PR Notes
Closes #54
TABLES
Addtional table AT_LOCATION_GEOMETRY
1 All GEOMETRY values are WGS 84 2-dimensional (SRID 4326).
2 These fields are populated by trigger AT_LOCATION_GEOMETRY_T01.
3 Value will be one of:
4 Values are in the datum specified in AT_PHYSICAL_LOCATION.HORIZONTAL_DATUM, if recognized. Otherwise they will be in WGS 84.
Modified table AT_PHYSICAL_LOCATION
VIEWS
AV_LOC
Added columns GEOMETRY and GEOMETRY_TYPE (from AT_LOCATION_GEOMETRY) at end. Columns LATITUDE and LONGITUDE are NULL if GEOMETRY_TYPE is NULL or != 1
AV_LOC2
Added columns GEOMETRY and GEOMETRY_TYPE (from AT_LOCATION_GEOMETRY) at end. Columns LATITUDE and LONGITUDE are NULL if GEOMETRY_TYPE is NULL or != 1
TYPES
PACKAGE SPECIFICATIONS
CWMS_LOC
Added STORE_LOCATION3 procedure which replaces the P_LATITUDE and P_LONGITUDE parameters of STORE_LOCATION2 with a single P_GEOMETRY parameter
Added RETRIEVE_LOCATION3 procedure which replaces the P_LATITUDE and P_LONGITUDE parameters of STORE_LOCATION2 with a single P_GEOMETRY parameter
Added STORE_GEOMETRY procedures
Added RETRIEVE_GEOMETRY functions
Added DELETE_GEOMETRY procedures
Added GET_LOCATION_SRID function to retrieve a location's SRID based on its hoizontal datum (returns NULL if not recognized)
Added GET_LOCATION_LAT_LON procedure, and GET_LOCATION_LAT and GET_LOCATION_LON functions to retrieve location latitude/longitude in various contexts.
PACKAGE BODIES
CWMS_CAT
CWMS_EMBANK
CWMS_LOC
CWMS_LOCK
CWMS_PROJECT
Update Script
Unlike a version update script, this one does not verify or update the CWMS schema version
The update script will transfer all LATITUDE and LONGITUDE values in the AT_PHYSICAL_LOCATION table to GEOMETRY values in the AT_LOCATION_GEOMETRY table.
If the LATITUDE or LONGITUDE value is null, the location will not have an entry in AT_LOCATION_GEOMETRY
If AT_PHYSICAL_LOCATION.HORIZONTAL_DATUM is recognized as valid, the GEOMETRY value will be properly converted to WGS 84.
If AT_PHYSICAL_LOCATION.HORIZONTAL_DATUM is NULL or not recognized, the GEOMETRY value will be created as if LATITUDE and LONGITUDE are in WGS 84.
The script stores a conversion note in AT_LATLON_CONVERSION, which can be dropped when it is no longer needed
The script outputs (via dbms_output) a summary of the conversions, similar to: