MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / encode_decode_roundtrip

Function encode_decode_roundtrip

nodedb-spatial/src/geohash.rs:294–305  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

292
293 #[test]
294 fn encode_decode_roundtrip() {
295 // NYC: Times Square.
296 let hash = geohash_encode(-73.9857, 40.7580, 9);
297 assert_eq!(hash.len(), 9);
298
299 let bb = geohash_decode(&hash).unwrap();
300 // Center should be very close to original.
301 let center_lng = (bb.min_lng + bb.max_lng) / 2.0;
302 let center_lat = (bb.min_lat + bb.max_lat) / 2.0;
303 assert!((center_lng - (-73.9857)).abs() < 0.001);
304 assert!((center_lat - 40.7580).abs() < 0.001);
305 }
306
307 #[test]
308 fn encode_precision_1() {

Callers

nothing calls this directly

Calls 2

geohash_encodeFunction · 0.85
geohash_decodeFunction · 0.85

Tested by

no test coverage detected