Should geo:within of http://docs.basex.org/wiki/Geo_Module help?
The functions of the Geo Module don't use any index structures, so I am afraid they won't speed up the query.
One more idea: you could convert all latitudes and longitudes to strings with a fixed number of digits.... _____________________________________
(:~ Allowed range. :) declare variable $RANGE := 999999; (:~ Maximum latitude. :) declare variable $LAT-MIN := -90; (:~ Maximum longitude. :) declare variable $LAT-MAX := 90;
(:~ : Converts a double value to a normalized string value : with a fixed size of digits. : @param $num number to be converted : @param $min minimum allowed value : @param $max maximum allowed value : @return resulting value :) declare function local:normalize( $num as xs:double, $min as xs:integer, $max as xs:integer ) { let $norm := $RANGE * ($num - $min) div ($max - $min) return format-number($norm, '000000') };
(: Run code for various latitude values :) for $latitude in (-90, -89.9999, -13.345, 0, 89.99999) return local:normalize($latitude, $LAT-MIN, $LAT-MAX) _____________________________________
Next, you could to do string comparisons on these values:
for $doc in db:open("CDI") let $lat := $doc//latitude let $lon := $doc//longitude where $lat >= "883387" and $lat <= "893463" and $lon >= "173467" and $lon <= "178745" return db:node-pre($doc)
It should be fast enough if the maximum value is not much bigger than the minimum value.