Sort by 2 fields? are there any hacks or with index.yaml? or geoPT?

q = WorldObject.all()
# define boundaries
# left
q.filter('x >=', x)
# right
q.filter('x <', x + width)
# top
q.filter('y >=', y)
# bottom
q.filter('y <', y + height)

#q.filter('world', world_key)

wobjects = q.fetch(1000)

I got an error: I cannot use multiple views

q = WorldObject.all()

q.filter('xy >=', db.GeoPt(1, 1))
q.filter('xy <', db.GeoPt(4, 4))

wobjects = q.fetch(1000)

I found this at http://www.spatialdatabox.com/ , which may be interesting as it uses Amazon EC3 to retrieve location data.

this query gives me the wrong world objects: with lat = 9 why? if i limit between 1 and 4? thank


Blockquote

+3
source share
3 answers

I need to do something thanks to GeoModel. What do you think? can it work on a large scale? I would like to know how many requests he makes under the hood, if possible. thank you for your help:

def get_world_objects_in_area(input):
    try:
        x = input.x
        y = input.y
        width = input.w
        height = input.h
        world_key = input.k
    except:
        return False

    # boundaries
    top = to_map_unit(y)
    bottom = to_map_unit(y-height) # this is "-" because in flash the vertical axis is inverted
    left = to_map_unit(x)
    right = to_map_unit(x+width)

    bounding_box = geo.geotypes.Box(top, right, bottom, left)

    query = WorldObject.all()
    query.filter('world', world_key)

    r = WorldObject.bounding_box_fetch(query,
                                       bounding_box,
                                       max_results=1000)

    return r

def to_map_unit(n):
    if n is not 0:
        divide_by = 1000000000000
        r = Decimal(n) / Decimal(divide_by)
        return float(r)
    else:
        return 0
0
source

google datastore . , , . GiS (), ().

, , , geohash

:

myquery = MyModel.all()
myquery.filter("x >=" x)
myquery.filter("x <" x+delta_x)

resultset = [result for result in myquery.fetch(1000) if y <= result.y < y+delta_y]
+2

App Engine , . , .

Google , - , . . Nick Johnson .

+2

Source: https://habr.com/ru/post/1767815/


All Articles