Ghini / server

ghini reloaded - merging desktop & web
http://tanager.ghini.me
GNU Affero General Public License v3.0
2 stars 2 forks source link

allow for geographic selection #86

Closed mfrasca closed 5 years ago

mfrasca commented 5 years ago

it should be possible to draw a polygon on the map, and have all objects (all plants) that are included in the perimeter. first mentioned in #2.

I'm still doubting how to do this. first of all, I doubt I want to offer a polygon, and I'm thinking of no more than a rectangle.

could it be implicit? If we were selecting plants, as in a plant where … query, the rectangle could work as an extra implicit clause and geometry in rectangle. but this implicit clause becomes more complex the farther we move from plant: for accessions, it would be and plant.geometry in rectangle, for contact, it cannot be implicit, since a contact may be the source of the accession, or the person validating the accession. after all, also the geometry could be the place of collection or the current geographic placement. also, we would need an extra checkbox, enabling or disabling the geographic clause.

should it be explicit? then the user would decide whether or not to have a geographic clause in the query. easier for the the program, and clearer to the user.

so I decide for explicit, and that we only work with the clearly marked rectangle, not the moving map extents.

further, our API for the query accepts a GET, with a q parameter, and I wish to stay with GET, as opposed to moving to POST. staying with the GET, I would add a r parameter for the coordinates of the extremes of the selection rectangle. and I would encode the limits somehow, like using (base64.b64encode/decode + struct.pack/unpack).

whenever the user changes the text query, they need to press the search button to have the server execute the query. that's changing the q parameter. I would start with the selection rectangle automatically firing the query. that's changing the r parameter.

>>> base64.b64encode(struct.pack('<ffff', 12.43567,8.6553,12.34567,8.5653))
'gfhGQRx8CkHdh0VBeAsJQQ=='
>>> struct.unpack('<ffff', base64.b64decode(_))
(12.435669898986816, 8.65530014038086, 12.345669746398926, 8.565299987792969)

image

mfrasca commented 5 years ago

now testing