@ geonet/ geohash (英语)
Geohash 解码器/编码器
| 精确度 | 宽度 | 高度 |
|---|---|---|
| 1个 | ≤ 5,000km | × 5,000km |
| 2个 | ≤ 1,250km | × 625km |
| 3个 | ≤ 156km | × 156km |
| 页:1 | ≤ 39.1km | × 19.5km |
| 页:1 | ≤ 4.89km | × 4.89km |
| 6个 | ≤ 1.22km | × 0.61km |
| 第7条 | ≤ 153m | × 153m |
| 第8条 | ≤ 38.2m | × 19.1m |
| 第9条 | ≤ 4.77m | × 4.77m |
| 10个 | ≤ 1.19m | × 0.596m |
| 第11个 | ≤ 149mm | × 149mm |
| 第12条 | ≤ 37.2mm | × 18.6mm |
安装
npm i @geonet/geohash
部署
npm run lint
npm run test
rm -rf docs/ && npm run docs
npm run build
np
使用量
基本用途:
const Geohash = require( '@geonet/geohash' );
const hash = Geohash.encode( -77.480, 38.866, 7 ); // hash: 'dqbvhgk'
encode
将经度/纬度编码为地压,或为指定的精度,或为自动评价精度.
段落
lng以度为度.lat纬度是度数.precision{数} 生成的地压中字符数 .
返回时: 提供的经纬度/纬度的地貌.
const hash = Geohash.encode( -77.480, 38.866, 7 ); // hash: 'dqbvhgk'
decode
将地壳分解为经度/纬度(位置是地壳细胞的大约中心,为合理的精确度).
段落
geohash{string} 将 Geohash 字符串转换为经度/纬度 .
返回时: (地心)地上已覆盖的位置.
const latlng = Geohash.decode( 'dqbvhgk' ); // latlng: { lng: -77.4804, lat: 38.8662 }
neighbors
将相邻的 8 个单元格返回指定的地压.
段落
geohash寻找邻居.asObject{boolean} 在对象中返回地理阴影({c,n,ne,e,se,s,sw,w,nw}(中文(简体) )
返回时: 环绕地心线
const latlng = Geohash.neighbors( 'dqcjpxetzh6q' );
[
'dqcjpxetzh6r', 'dqcjpxetzh6x', 'dqcjpxetzh6w', 'dqcjpxetzh6t',
'dqcjpxetzh6m', 'dqcjpxetzh6j', 'dqcjpxetzh6n', 'dqcjpxetzh6p'
]
示例
Geohash.neighbors( 'dqcjpxetzh6q' );
┬────────────────────────────────────────────────────┐
│ 'west' 'center' 'east' │
┼──────────┼────────────────────────────────────────────────────┤
│ 'north' │ 'dqcjpxetzh6p' 'dqcjpxetzh6r' 'dqcjpxetzh6x' │
│ 'center' │ 'dqcjpxetzh6n' 'dqcjpxetzh6q' 'dqcjpxetzh6w' │
│ 'south' │ 'dqcjpxetzh6j' 'dqcjpxetzh6m' 'dqcjpxetzh6t' │
┴──────────┴────────────────────────────────────────────────────┘
地压结构
GeohashStream 装入BBox和小溪的地盘.
段落
minLng{数} bbox 分钟经度minLat{数目} bbox min 纬度maxLng{数} bbox 最大经度maxLat{数} bbox 最大纬度precision{数=7} 地压精度( 默认为 7)
new Geohash.GeohashStream( 0.1, 52.2, 0.2, 52.3, 3 )
.on( 'data', d => console.log( d.toString() ) )
.on( 'end', () => console.log( 'done' ) );
// u12
Geohash-Stream Geo-JSON 地球科学研究所
GeohashStreamGeoJSON 与 GeohashStream 但流回 GeoJSON
段落
minLng{数} bbox 分钟经度minLat{数目} bbox min 纬度maxLng{数} bbox 最大经度maxLat{数} bbox 最大纬度precision{数=7} 地压精度( 默认为 7)
new Geohash.GeohashStreamGeoJSON( 0.1, 52.2, 0.2, 52.3, 3 )
.on( 'data', d => console.log( d.toString() ) )
.on( 'end', () => console.log( 'done' ) );
// {
// "type": "Feature",
// "bbox": [ 0, 52.03125, 1.40625, 53.4375 ],
// "properties": {},
// "geometry": {
// "type": "Polygon",
// "coordinates": [ [
// [ 0, 52.03125 ],
// [ 1.40625, 52.03125 ],
// [ 1.40625, 53.4375 ],
// [ 0, 53.4375 ],
// [ 0, 52.03125 ]
// ] ]
// }
// }
