mysql - Use id made from latitude and longitude -
is possible use in database id (primary key) made localization (latitude , longitude) ? formula :
public long getkeyvalue() { return long.valueof((intlatitude + 90 * 1000) + "" + (intlongitude + 180 * 1000)); }
intlatitude
, intlongitude
both multiplied 1000 , rounded. respectively add 90 , 180 remap origin in order handle negative coordinates.
with given approach going have problems because of ambiguity. example 123 latitude 1 longitude 23 or latitude 12 longitude 3. should pad zeros or use separator.
why bother mapping 2 single value? database systems permit compound primary keys can use pair (lat, lon) directly key.
Comments
Post a Comment