parent
e34eb69c00
commit
e2ad3b825c
7 changed files with 56 additions and 66 deletions
@ -0,0 +1,22 @@ |
|||||||
|
var g_GeoStore = {}; |
||||||
|
|
||||||
|
export function hash_geo_area(geo_area) { |
||||||
|
var hash = require('object-hash'); |
||||||
|
return hash(geo_area); |
||||||
|
} |
||||||
|
|
||||||
|
export function add_geo_area_to_store(area) { |
||||||
|
var h = hash_geo_area(area); |
||||||
|
if(!(h in g_GeoStore)) { |
||||||
|
g_GeoStore[h] = area; |
||||||
|
} |
||||||
|
|
||||||
|
return h; |
||||||
|
} |
||||||
|
|
||||||
|
export function get_geo_area_from_store(hash) { |
||||||
|
if(hash in g_GeoStore) { |
||||||
|
return g_GeoStore[hash]; |
||||||
|
} |
||||||
|
throw new Error("Requested non-existent geo area from store."); |
||||||
|
} |
@ -1,22 +0,0 @@ |
|||||||
var g_PolygonStore = {}; |
|
||||||
|
|
||||||
export function hash_polygon(polygon) { |
|
||||||
var hash = require('object-hash'); |
|
||||||
return hash(polygon); |
|
||||||
} |
|
||||||
|
|
||||||
export function add_polygon_to_store(polygon) { |
|
||||||
var h = hash_polygon(polygon); |
|
||||||
if(!(h in g_PolygonStore)) { |
|
||||||
g_PolygonStore[h] = polygon; |
|
||||||
} |
|
||||||
|
|
||||||
return h; |
|
||||||
} |
|
||||||
|
|
||||||
export function get_polygon_from_store(polygon_hash) { |
|
||||||
if(polygon_hash in g_PolygonStore) { |
|
||||||
return g_PolygonStore[polygon_hash]; |
|
||||||
} |
|
||||||
throw new Error("Requested non-existent polygon from store."); |
|
||||||
} |
|
Loading…
Reference in new issue