smnorris / fwapg

PostgreSQL tools for working with British Columbia's Freshwater Atlas
https://smnorris.github.io/fwapg
MIT License
9 stars 5 forks source link

FWA_WatershedAtMeasure fails on 0 measures #37

Open smnorris opened 3 years ago

smnorris commented 3 years ago

https://github.com/poissonconsulting/fwatlasbc/issues/16

# select fwa_watershedatmeasure(356528119, 0);
ERROR:  more than one row returned by a subquery used as an expression
CONTEXT:  PL/pgSQL function fwa_watershedatmeasure(integer,double precision) line 26 at RETURN QUERY
smnorris commented 3 years ago

If a point is a measure zero, no convoluted logic is needed - just select everything upstream. Even an upstream query is not needed, an ltree comparison of the watershed code is fine.