# lucene-dev mailing list archives

##### Site index · List index
Message view
Top
From "John Berryman (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (LUCENE-4922) A SpatialPrefixTree based on the Hilbert Curve and variable grid sizes
Date Thu, 09 May 2013 07:01:21 GMT
```
[ https://issues.apache.org/jira/browse/LUCENE-4922?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13652785#comment-13652785
]

John Berryman edited comment on LUCENE-4922 at 5/9/13 7:00 AM:
---------------------------------------------------------------

{{# Converts from an x,y coordinate (vals[0],vals[1]) between min and max values to a point
on the Hilbert curve in base4}}
#
def hilbert_point(vals,depth,mins=[],maxs=[]):
"""
cell_names

3 2
0 1

"""
if(mins):
# then convert vals to some place in 1-by-1 grid at the origin
vals[0] = (vals[0]-mins[0])/(maxs[0]-mins[0])
vals[1] = (vals[1]-mins[1])/(maxs[1]-mins[1])

if(depth == 0):
return ''

if( vals[0]<=0.5 and vals[1]<=0.5 ):
cell_name = '0'
x = vals[1]*2
y = vals[0]*2
elif( vals[0]>=0.5 and vals[1]<=0.5 ):
cell_name = '1'
x = (vals[0] - 0.5)*2
y = vals[1]*2
elif( vals[0]>=0.5 and vals[1]>=0.5 ):
cell_name = '2'
x = (vals[0] - 0.5)*2
y = (vals[1] - 0.5)*2
elif( vals[0]<=0.5 and vals[1]>=0.5 ):
cell_name = '3'
x = 1 - (vals[1] - 0.5)*2
y = 1 - vals[0]*2

return cell_name + hilbert_point([x,y],depth-1)

was (Author: berryman):
{{
# Converts from an x,y coordinate (vals[0],vals[1]) between min and max values to a point
on the Hilbert curve in base4
#
def hilbert_point(vals,depth,mins=[],maxs=[]):
"""
cell_names

3 2
0 1

"""
if(mins):
# then convert vals to some place in 1-by-1 grid at the origin
vals[0] = (vals[0]-mins[0])/(maxs[0]-mins[0])
vals[1] = (vals[1]-mins[1])/(maxs[1]-mins[1])

if(depth == 0):
return ''

if( vals[0]<=0.5 and vals[1]<=0.5 ):
cell_name = '0'
x = vals[1]*2
y = vals[0]*2
elif( vals[0]>=0.5 and vals[1]<=0.5 ):
cell_name = '1'
x = (vals[0] - 0.5)*2
y = vals[1]*2
elif( vals[0]>=0.5 and vals[1]>=0.5 ):
cell_name = '2'
x = (vals[0] - 0.5)*2
y = (vals[1] - 0.5)*2
elif( vals[0]<=0.5 and vals[1]>=0.5 ):
cell_name = '3'
x = 1 - (vals[1] - 0.5)*2
y = 1 - vals[0]*2

return cell_name + hilbert_point([x,y],depth-1)
}}

> A SpatialPrefixTree based on the Hilbert Curve and variable grid sizes
> ----------------------------------------------------------------------
>
>                 Key: LUCENE-4922
>                 URL: https://issues.apache.org/jira/browse/LUCENE-4922
>             Project: Lucene - Core
>          Issue Type: New Feature
>          Components: modules/spatial
>            Reporter: David Smiley
>            Assignee: David Smiley
>              Labels: gsoc2013, mentor, newdev
>
> My wish-list for an ideal SpatialPrefixTree has these properties:
> * Hilbert Curve ordering
> * Variable grid size per level (ex: 256 at the top, 64 at the bottom, 16 for all in-between)
> * Compact binary encoding (so-called "Morton number")
> * Works for geodetic (i.e. lat & lon) and non-geodetic
> Some bonus wishes for use in geospatial:
> * Use an equal-area projection such that each cell has an equal area to all others at
the same level.
> * When advancing a grid level, if a cell's width is less than half its height. then divide
it as 4 vertically stacked instead of 2 by 2. The point is to avoid super-skinny cells which
occurs towards the poles and degrades performance.
> All of this requires some basic performance benchmarks to measure the effects of these
characteristics.

--
This message is automatically generated by JIRA.