@exabugs/dynamodb-client 1.1.2 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +50 -0
- package/dist/server/handler.cjs +379 -29
- package/dist/server/handler.cjs.map +4 -4
- package/dist/server/query/index.d.ts +1 -0
- package/dist/server/query/index.d.ts.map +1 -1
- package/dist/server/query/index.js +1 -0
- package/dist/server/query/index.js.map +1 -1
- package/dist/server/query/nearSearch.d.ts +50 -0
- package/dist/server/query/nearSearch.d.ts.map +1 -0
- package/dist/server/query/nearSearch.js +100 -0
- package/dist/server/query/nearSearch.js.map +1 -0
- package/dist/server/shadow/generator.d.ts.map +1 -1
- package/dist/server/shadow/generator.js +13 -1
- package/dist/server/shadow/generator.js.map +1 -1
- package/dist/shared/geohash/index.d.ts +6 -0
- package/dist/shared/geohash/index.d.ts.map +1 -0
- package/dist/shared/geohash/index.js +6 -0
- package/dist/shared/geohash/index.js.map +1 -0
- package/dist/shared/geohash/types.d.ts +103 -0
- package/dist/shared/geohash/types.d.ts.map +1 -0
- package/dist/shared/geohash/types.js +25 -0
- package/dist/shared/geohash/types.js.map +1 -0
- package/dist/shared/geohash/utils.d.ts +62 -0
- package/dist/shared/geohash/utils.d.ts.map +1 -0
- package/dist/shared/geohash/utils.js +135 -0
- package/dist/shared/geohash/utils.js.map +1 -0
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index.js +2 -0
- package/dist/shared/index.js.map +1 -1
- package/package.json +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,56 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [1.2.0] - 2026-01-02
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **GeoHash地理空間検索**: MongoDB互換の`$near`オペレータを実装
|
|
15
|
+
- 自動GeoHash変換: `{latitude, longitude}`オブジェクトを自動検出してシャドウインデックス生成
|
|
16
|
+
- 9ブロック検索: 中心 + 隣接8方向の合計9ブロックを検索して境界をまたぐ検索漏れを防止
|
|
17
|
+
- 段階的精度緩和: precision 6→5→4と段階的に検索範囲を拡大
|
|
18
|
+
- 距離計算・ソート: Haversine公式による正確な距離計算と自動ソート
|
|
19
|
+
- `__distance`フィールド: 検索地点からの距離(メートル)を自動付与
|
|
20
|
+
- `__geohash`フィールド: 検出されたGeoHashを自動付与
|
|
21
|
+
- フィールド名非依存: `location`固定ではなく、任意のフィールド名を自動検出
|
|
22
|
+
- 透過的実装: クライアントはGeoHashを意識せず、通常のオブジェクトとして扱える
|
|
23
|
+
- 設定可能なパラメータ: `GeoHashConfig`で精度や反復回数をカスタマイズ可能
|
|
24
|
+
|
|
25
|
+
- **新しいユーティリティ関数**:
|
|
26
|
+
- `isGeoCoordinates()`: 地理座標オブジェクトの自動検出
|
|
27
|
+
- `encodeGeoHash()`: 緯度・経度からGeoHashを生成
|
|
28
|
+
- `decodeGeoHash()`: GeoHashから緯度・経度を復元
|
|
29
|
+
- `getNeighborGeoHashes()`: 隣接8方向のGeoHashを取得
|
|
30
|
+
- `calculateDistance()`: Haversine公式による2点間の距離計算
|
|
31
|
+
- `extractCoordinatesFromNearQuery()`: $nearクエリから座標を抽出
|
|
32
|
+
- `extractMaxDistanceFromNearQuery()`: $nearクエリから最大距離を抽出
|
|
33
|
+
- `extractMinDistanceFromNearQuery()`: $nearクエリから最小距離を抽出
|
|
34
|
+
|
|
35
|
+
- **新しい型定義**:
|
|
36
|
+
- `GeoCoordinates`: 地理座標オブジェクト型
|
|
37
|
+
- `NearQuery`: MongoDB互換の$nearクエリ型(GeoJSON形式と簡易形式をサポート)
|
|
38
|
+
- `DocumentWithDistance`: 距離情報付きドキュメント型
|
|
39
|
+
- `GeoHashConfig`: GeoHash検索の設定型
|
|
40
|
+
- `DEFAULT_GEOHASH_CONFIG`: デフォルト設定定数
|
|
41
|
+
|
|
42
|
+
### Changed
|
|
43
|
+
|
|
44
|
+
- **シャドウレコード生成**: `generator.ts`を更新して地理座標の自動検出とGeoHashシャドウレコード生成を追加
|
|
45
|
+
- シャドウインデックスは8文字精度(±19m)で保存
|
|
46
|
+
- 検索は6文字精度(±610m)で開始し、段階的に緩和
|
|
47
|
+
- 既存のシャドウ化機能(文字列フィールド等)と共存
|
|
48
|
+
|
|
49
|
+
### Dependencies
|
|
50
|
+
|
|
51
|
+
- **追加**: `ngeohash@^0.6.3` - GeoHashエンコード・デコードライブラリ
|
|
52
|
+
- **追加**: `@types/ngeohash@^0.6.8` - ngeohashの型定義
|
|
53
|
+
|
|
54
|
+
### Notes
|
|
55
|
+
|
|
56
|
+
- この機能は後方互換性があります。既存のコードは変更なしで動作します。
|
|
57
|
+
- GeoHash検索を使用するには、`{latitude, longitude}`オブジェクトを持つフィールドを作成するだけです。
|
|
58
|
+
- 詳細な使用方法は [GeoHash Search Guide](./docs/geohash-search.md) を参照してください。
|
|
59
|
+
|
|
10
60
|
## [1.1.2] - 2025-01-02
|
|
11
61
|
|
|
12
62
|
### Fixed
|
package/dist/server/handler.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// @exabugs/dynamodb-client v1.
|
|
2
|
-
// Built: 2026-01-
|
|
1
|
+
// @exabugs/dynamodb-client v1.2.0
|
|
2
|
+
// Built: 2026-01-02T06:28:54.806Z
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
5
5
|
var __defProp = Object.defineProperty;
|
|
@@ -28605,6 +28605,320 @@ var require_dist_cjs66 = __commonJS({
|
|
|
28605
28605
|
}
|
|
28606
28606
|
});
|
|
28607
28607
|
|
|
28608
|
+
// node_modules/ngeohash/main.js
|
|
28609
|
+
var require_main = __commonJS({
|
|
28610
|
+
"node_modules/ngeohash/main.js"(exports2, module2) {
|
|
28611
|
+
var BASE32_CODES = "0123456789bcdefghjkmnpqrstuvwxyz";
|
|
28612
|
+
var BASE32_CODES_DICT = {};
|
|
28613
|
+
for (i4 = 0; i4 < BASE32_CODES.length; i4++) {
|
|
28614
|
+
BASE32_CODES_DICT[BASE32_CODES.charAt(i4)] = i4;
|
|
28615
|
+
}
|
|
28616
|
+
var i4;
|
|
28617
|
+
var ENCODE_AUTO = "auto";
|
|
28618
|
+
var MIN_LAT = -90;
|
|
28619
|
+
var MAX_LAT = 90;
|
|
28620
|
+
var MIN_LON = -180;
|
|
28621
|
+
var MAX_LON = 180;
|
|
28622
|
+
var SIGFIG_HASH_LENGTH = [0, 5, 7, 8, 11, 12, 13, 15, 16, 17, 18];
|
|
28623
|
+
var encode2 = /* @__PURE__ */ __name(function(latitude, longitude, numberOfChars) {
|
|
28624
|
+
if (numberOfChars === ENCODE_AUTO) {
|
|
28625
|
+
if (typeof latitude === "number" || typeof longitude === "number") {
|
|
28626
|
+
throw new Error("string notation required for auto precision.");
|
|
28627
|
+
}
|
|
28628
|
+
var decSigFigsLat = latitude.split(".")[1].length;
|
|
28629
|
+
var decSigFigsLong = longitude.split(".")[1].length;
|
|
28630
|
+
var numberOfSigFigs = Math.max(decSigFigsLat, decSigFigsLong);
|
|
28631
|
+
numberOfChars = SIGFIG_HASH_LENGTH[numberOfSigFigs];
|
|
28632
|
+
} else if (numberOfChars === void 0) {
|
|
28633
|
+
numberOfChars = 9;
|
|
28634
|
+
}
|
|
28635
|
+
var chars = [], bits = 0, bitsTotal = 0, hash_value = 0, maxLat = MAX_LAT, minLat = MIN_LAT, maxLon = MAX_LON, minLon = MIN_LON, mid;
|
|
28636
|
+
while (chars.length < numberOfChars) {
|
|
28637
|
+
if (bitsTotal % 2 === 0) {
|
|
28638
|
+
mid = (maxLon + minLon) / 2;
|
|
28639
|
+
if (longitude > mid) {
|
|
28640
|
+
hash_value = (hash_value << 1) + 1;
|
|
28641
|
+
minLon = mid;
|
|
28642
|
+
} else {
|
|
28643
|
+
hash_value = (hash_value << 1) + 0;
|
|
28644
|
+
maxLon = mid;
|
|
28645
|
+
}
|
|
28646
|
+
} else {
|
|
28647
|
+
mid = (maxLat + minLat) / 2;
|
|
28648
|
+
if (latitude > mid) {
|
|
28649
|
+
hash_value = (hash_value << 1) + 1;
|
|
28650
|
+
minLat = mid;
|
|
28651
|
+
} else {
|
|
28652
|
+
hash_value = (hash_value << 1) + 0;
|
|
28653
|
+
maxLat = mid;
|
|
28654
|
+
}
|
|
28655
|
+
}
|
|
28656
|
+
bits++;
|
|
28657
|
+
bitsTotal++;
|
|
28658
|
+
if (bits === 5) {
|
|
28659
|
+
var code = BASE32_CODES[hash_value];
|
|
28660
|
+
chars.push(code);
|
|
28661
|
+
bits = 0;
|
|
28662
|
+
hash_value = 0;
|
|
28663
|
+
}
|
|
28664
|
+
}
|
|
28665
|
+
return chars.join("");
|
|
28666
|
+
}, "encode");
|
|
28667
|
+
var encode_int = /* @__PURE__ */ __name(function(latitude, longitude, bitDepth) {
|
|
28668
|
+
bitDepth = bitDepth || 52;
|
|
28669
|
+
var bitsTotal = 0, maxLat = MAX_LAT, minLat = MIN_LAT, maxLon = MAX_LON, minLon = MIN_LON, mid, combinedBits = 0;
|
|
28670
|
+
while (bitsTotal < bitDepth) {
|
|
28671
|
+
combinedBits *= 2;
|
|
28672
|
+
if (bitsTotal % 2 === 0) {
|
|
28673
|
+
mid = (maxLon + minLon) / 2;
|
|
28674
|
+
if (longitude > mid) {
|
|
28675
|
+
combinedBits += 1;
|
|
28676
|
+
minLon = mid;
|
|
28677
|
+
} else {
|
|
28678
|
+
maxLon = mid;
|
|
28679
|
+
}
|
|
28680
|
+
} else {
|
|
28681
|
+
mid = (maxLat + minLat) / 2;
|
|
28682
|
+
if (latitude > mid) {
|
|
28683
|
+
combinedBits += 1;
|
|
28684
|
+
minLat = mid;
|
|
28685
|
+
} else {
|
|
28686
|
+
maxLat = mid;
|
|
28687
|
+
}
|
|
28688
|
+
}
|
|
28689
|
+
bitsTotal++;
|
|
28690
|
+
}
|
|
28691
|
+
return combinedBits;
|
|
28692
|
+
}, "encode_int");
|
|
28693
|
+
var decode_bbox = /* @__PURE__ */ __name(function(hash_string) {
|
|
28694
|
+
var isLon = true, maxLat = MAX_LAT, minLat = MIN_LAT, maxLon = MAX_LON, minLon = MIN_LON, mid;
|
|
28695
|
+
var hashValue = 0;
|
|
28696
|
+
for (var i5 = 0, l4 = hash_string.length; i5 < l4; i5++) {
|
|
28697
|
+
var code = hash_string[i5].toLowerCase();
|
|
28698
|
+
hashValue = BASE32_CODES_DICT[code];
|
|
28699
|
+
for (var bits = 4; bits >= 0; bits--) {
|
|
28700
|
+
var bit = hashValue >> bits & 1;
|
|
28701
|
+
if (isLon) {
|
|
28702
|
+
mid = (maxLon + minLon) / 2;
|
|
28703
|
+
if (bit === 1) {
|
|
28704
|
+
minLon = mid;
|
|
28705
|
+
} else {
|
|
28706
|
+
maxLon = mid;
|
|
28707
|
+
}
|
|
28708
|
+
} else {
|
|
28709
|
+
mid = (maxLat + minLat) / 2;
|
|
28710
|
+
if (bit === 1) {
|
|
28711
|
+
minLat = mid;
|
|
28712
|
+
} else {
|
|
28713
|
+
maxLat = mid;
|
|
28714
|
+
}
|
|
28715
|
+
}
|
|
28716
|
+
isLon = !isLon;
|
|
28717
|
+
}
|
|
28718
|
+
}
|
|
28719
|
+
return [minLat, minLon, maxLat, maxLon];
|
|
28720
|
+
}, "decode_bbox");
|
|
28721
|
+
var decode_bbox_int = /* @__PURE__ */ __name(function(hashInt, bitDepth) {
|
|
28722
|
+
bitDepth = bitDepth || 52;
|
|
28723
|
+
var maxLat = MAX_LAT, minLat = MIN_LAT, maxLon = MAX_LON, minLon = MIN_LON;
|
|
28724
|
+
var latBit = 0, lonBit = 0;
|
|
28725
|
+
var step = bitDepth / 2;
|
|
28726
|
+
for (var i5 = 0; i5 < step; i5++) {
|
|
28727
|
+
lonBit = get_bit(hashInt, (step - i5) * 2 - 1);
|
|
28728
|
+
latBit = get_bit(hashInt, (step - i5) * 2 - 2);
|
|
28729
|
+
if (latBit === 0) {
|
|
28730
|
+
maxLat = (maxLat + minLat) / 2;
|
|
28731
|
+
} else {
|
|
28732
|
+
minLat = (maxLat + minLat) / 2;
|
|
28733
|
+
}
|
|
28734
|
+
if (lonBit === 0) {
|
|
28735
|
+
maxLon = (maxLon + minLon) / 2;
|
|
28736
|
+
} else {
|
|
28737
|
+
minLon = (maxLon + minLon) / 2;
|
|
28738
|
+
}
|
|
28739
|
+
}
|
|
28740
|
+
return [minLat, minLon, maxLat, maxLon];
|
|
28741
|
+
}, "decode_bbox_int");
|
|
28742
|
+
function get_bit(bits, position) {
|
|
28743
|
+
return bits / Math.pow(2, position) & 1;
|
|
28744
|
+
}
|
|
28745
|
+
__name(get_bit, "get_bit");
|
|
28746
|
+
var decode2 = /* @__PURE__ */ __name(function(hashString) {
|
|
28747
|
+
var bbox = decode_bbox(hashString);
|
|
28748
|
+
var lat = (bbox[0] + bbox[2]) / 2;
|
|
28749
|
+
var lon = (bbox[1] + bbox[3]) / 2;
|
|
28750
|
+
var latErr = bbox[2] - lat;
|
|
28751
|
+
var lonErr = bbox[3] - lon;
|
|
28752
|
+
return {
|
|
28753
|
+
latitude: lat,
|
|
28754
|
+
longitude: lon,
|
|
28755
|
+
error: { latitude: latErr, longitude: lonErr }
|
|
28756
|
+
};
|
|
28757
|
+
}, "decode");
|
|
28758
|
+
var decode_int = /* @__PURE__ */ __name(function(hash_int, bitDepth) {
|
|
28759
|
+
var bbox = decode_bbox_int(hash_int, bitDepth);
|
|
28760
|
+
var lat = (bbox[0] + bbox[2]) / 2;
|
|
28761
|
+
var lon = (bbox[1] + bbox[3]) / 2;
|
|
28762
|
+
var latErr = bbox[2] - lat;
|
|
28763
|
+
var lonErr = bbox[3] - lon;
|
|
28764
|
+
return {
|
|
28765
|
+
latitude: lat,
|
|
28766
|
+
longitude: lon,
|
|
28767
|
+
error: { latitude: latErr, longitude: lonErr }
|
|
28768
|
+
};
|
|
28769
|
+
}, "decode_int");
|
|
28770
|
+
var neighbor = /* @__PURE__ */ __name(function(hashString, direction) {
|
|
28771
|
+
var lonLat = decode2(hashString);
|
|
28772
|
+
var neighborLat = lonLat.latitude + direction[0] * lonLat.error.latitude * 2;
|
|
28773
|
+
var neighborLon = lonLat.longitude + direction[1] * lonLat.error.longitude * 2;
|
|
28774
|
+
neighborLon = ensure_valid_lon(neighborLon);
|
|
28775
|
+
neighborLat = ensure_valid_lat(neighborLat);
|
|
28776
|
+
return encode2(neighborLat, neighborLon, hashString.length);
|
|
28777
|
+
}, "neighbor");
|
|
28778
|
+
var neighbor_int = /* @__PURE__ */ __name(function(hash_int, direction, bitDepth) {
|
|
28779
|
+
bitDepth = bitDepth || 52;
|
|
28780
|
+
var lonlat = decode_int(hash_int, bitDepth);
|
|
28781
|
+
var neighbor_lat = lonlat.latitude + direction[0] * lonlat.error.latitude * 2;
|
|
28782
|
+
var neighbor_lon = lonlat.longitude + direction[1] * lonlat.error.longitude * 2;
|
|
28783
|
+
neighbor_lon = ensure_valid_lon(neighbor_lon);
|
|
28784
|
+
neighbor_lat = ensure_valid_lat(neighbor_lat);
|
|
28785
|
+
return encode_int(neighbor_lat, neighbor_lon, bitDepth);
|
|
28786
|
+
}, "neighbor_int");
|
|
28787
|
+
var neighbors = /* @__PURE__ */ __name(function(hash_string) {
|
|
28788
|
+
var hashstringLength = hash_string.length;
|
|
28789
|
+
var lonlat = decode2(hash_string);
|
|
28790
|
+
var lat = lonlat.latitude;
|
|
28791
|
+
var lon = lonlat.longitude;
|
|
28792
|
+
var latErr = lonlat.error.latitude * 2;
|
|
28793
|
+
var lonErr = lonlat.error.longitude * 2;
|
|
28794
|
+
var neighbor_lat, neighbor_lon;
|
|
28795
|
+
var neighborHashList = [
|
|
28796
|
+
encodeNeighbor(1, 0),
|
|
28797
|
+
encodeNeighbor(1, 1),
|
|
28798
|
+
encodeNeighbor(0, 1),
|
|
28799
|
+
encodeNeighbor(-1, 1),
|
|
28800
|
+
encodeNeighbor(-1, 0),
|
|
28801
|
+
encodeNeighbor(-1, -1),
|
|
28802
|
+
encodeNeighbor(0, -1),
|
|
28803
|
+
encodeNeighbor(1, -1)
|
|
28804
|
+
];
|
|
28805
|
+
function encodeNeighbor(neighborLatDir, neighborLonDir) {
|
|
28806
|
+
neighbor_lat = lat + neighborLatDir * latErr;
|
|
28807
|
+
neighbor_lon = lon + neighborLonDir * lonErr;
|
|
28808
|
+
neighbor_lon = ensure_valid_lon(neighbor_lon);
|
|
28809
|
+
neighbor_lat = ensure_valid_lat(neighbor_lat);
|
|
28810
|
+
return encode2(neighbor_lat, neighbor_lon, hashstringLength);
|
|
28811
|
+
}
|
|
28812
|
+
__name(encodeNeighbor, "encodeNeighbor");
|
|
28813
|
+
return neighborHashList;
|
|
28814
|
+
}, "neighbors");
|
|
28815
|
+
var neighbors_int = /* @__PURE__ */ __name(function(hash_int, bitDepth) {
|
|
28816
|
+
bitDepth = bitDepth || 52;
|
|
28817
|
+
var lonlat = decode_int(hash_int, bitDepth);
|
|
28818
|
+
var lat = lonlat.latitude;
|
|
28819
|
+
var lon = lonlat.longitude;
|
|
28820
|
+
var latErr = lonlat.error.latitude * 2;
|
|
28821
|
+
var lonErr = lonlat.error.longitude * 2;
|
|
28822
|
+
var neighbor_lat, neighbor_lon;
|
|
28823
|
+
var neighborHashIntList = [
|
|
28824
|
+
encodeNeighbor_int(1, 0),
|
|
28825
|
+
encodeNeighbor_int(1, 1),
|
|
28826
|
+
encodeNeighbor_int(0, 1),
|
|
28827
|
+
encodeNeighbor_int(-1, 1),
|
|
28828
|
+
encodeNeighbor_int(-1, 0),
|
|
28829
|
+
encodeNeighbor_int(-1, -1),
|
|
28830
|
+
encodeNeighbor_int(0, -1),
|
|
28831
|
+
encodeNeighbor_int(1, -1)
|
|
28832
|
+
];
|
|
28833
|
+
function encodeNeighbor_int(neighborLatDir, neighborLonDir) {
|
|
28834
|
+
neighbor_lat = lat + neighborLatDir * latErr;
|
|
28835
|
+
neighbor_lon = lon + neighborLonDir * lonErr;
|
|
28836
|
+
neighbor_lon = ensure_valid_lon(neighbor_lon);
|
|
28837
|
+
neighbor_lat = ensure_valid_lat(neighbor_lat);
|
|
28838
|
+
return encode_int(neighbor_lat, neighbor_lon, bitDepth);
|
|
28839
|
+
}
|
|
28840
|
+
__name(encodeNeighbor_int, "encodeNeighbor_int");
|
|
28841
|
+
return neighborHashIntList;
|
|
28842
|
+
}, "neighbors_int");
|
|
28843
|
+
var bboxes = /* @__PURE__ */ __name(function(minLat, minLon, maxLat, maxLon, numberOfChars) {
|
|
28844
|
+
numberOfChars = numberOfChars || 9;
|
|
28845
|
+
var hashSouthWest = encode2(minLat, minLon, numberOfChars);
|
|
28846
|
+
var hashNorthEast = encode2(maxLat, maxLon, numberOfChars);
|
|
28847
|
+
var latLon = decode2(hashSouthWest);
|
|
28848
|
+
var perLat = latLon.error.latitude * 2;
|
|
28849
|
+
var perLon = latLon.error.longitude * 2;
|
|
28850
|
+
var boxSouthWest = decode_bbox(hashSouthWest);
|
|
28851
|
+
var boxNorthEast = decode_bbox(hashNorthEast);
|
|
28852
|
+
var latStep = Math.round((boxNorthEast[0] - boxSouthWest[0]) / perLat);
|
|
28853
|
+
var lonStep = Math.round((boxNorthEast[1] - boxSouthWest[1]) / perLon);
|
|
28854
|
+
var hashList = [];
|
|
28855
|
+
for (var lat = 0; lat <= latStep; lat++) {
|
|
28856
|
+
for (var lon = 0; lon <= lonStep; lon++) {
|
|
28857
|
+
hashList.push(neighbor(hashSouthWest, [lat, lon]));
|
|
28858
|
+
}
|
|
28859
|
+
}
|
|
28860
|
+
return hashList;
|
|
28861
|
+
}, "bboxes");
|
|
28862
|
+
var bboxes_int = /* @__PURE__ */ __name(function(minLat, minLon, maxLat, maxLon, bitDepth) {
|
|
28863
|
+
bitDepth = bitDepth || 52;
|
|
28864
|
+
var hashSouthWest = encode_int(minLat, minLon, bitDepth);
|
|
28865
|
+
var hashNorthEast = encode_int(maxLat, maxLon, bitDepth);
|
|
28866
|
+
var latlon = decode_int(hashSouthWest, bitDepth);
|
|
28867
|
+
var perLat = latlon.error.latitude * 2;
|
|
28868
|
+
var perLon = latlon.error.longitude * 2;
|
|
28869
|
+
var boxSouthWest = decode_bbox_int(hashSouthWest, bitDepth);
|
|
28870
|
+
var boxNorthEast = decode_bbox_int(hashNorthEast, bitDepth);
|
|
28871
|
+
var latStep = Math.round((boxNorthEast[0] - boxSouthWest[0]) / perLat);
|
|
28872
|
+
var lonStep = Math.round((boxNorthEast[1] - boxSouthWest[1]) / perLon);
|
|
28873
|
+
var hashList = [];
|
|
28874
|
+
for (var lat = 0; lat <= latStep; lat++) {
|
|
28875
|
+
for (var lon = 0; lon <= lonStep; lon++) {
|
|
28876
|
+
hashList.push(neighbor_int(hashSouthWest, [lat, lon], bitDepth));
|
|
28877
|
+
}
|
|
28878
|
+
}
|
|
28879
|
+
return hashList;
|
|
28880
|
+
}, "bboxes_int");
|
|
28881
|
+
function ensure_valid_lon(lon) {
|
|
28882
|
+
if (lon > MAX_LON)
|
|
28883
|
+
return MIN_LON + lon % MAX_LON;
|
|
28884
|
+
if (lon < MIN_LON)
|
|
28885
|
+
return MAX_LON + lon % MAX_LON;
|
|
28886
|
+
return lon;
|
|
28887
|
+
}
|
|
28888
|
+
__name(ensure_valid_lon, "ensure_valid_lon");
|
|
28889
|
+
function ensure_valid_lat(lat) {
|
|
28890
|
+
if (lat > MAX_LAT)
|
|
28891
|
+
return MAX_LAT;
|
|
28892
|
+
if (lat < MIN_LAT)
|
|
28893
|
+
return MIN_LAT;
|
|
28894
|
+
return lat;
|
|
28895
|
+
}
|
|
28896
|
+
__name(ensure_valid_lat, "ensure_valid_lat");
|
|
28897
|
+
var geohash = {
|
|
28898
|
+
"ENCODE_AUTO": ENCODE_AUTO,
|
|
28899
|
+
"encode": encode2,
|
|
28900
|
+
"encode_uint64": encode_int,
|
|
28901
|
+
// keeping for backwards compatibility, will deprecate
|
|
28902
|
+
"encode_int": encode_int,
|
|
28903
|
+
"decode": decode2,
|
|
28904
|
+
"decode_int": decode_int,
|
|
28905
|
+
"decode_uint64": decode_int,
|
|
28906
|
+
// keeping for backwards compatibility, will deprecate
|
|
28907
|
+
"decode_bbox": decode_bbox,
|
|
28908
|
+
"decode_bbox_uint64": decode_bbox_int,
|
|
28909
|
+
// keeping for backwards compatibility, will deprecate
|
|
28910
|
+
"decode_bbox_int": decode_bbox_int,
|
|
28911
|
+
"neighbor": neighbor,
|
|
28912
|
+
"neighbor_int": neighbor_int,
|
|
28913
|
+
"neighbors": neighbors,
|
|
28914
|
+
"neighbors_int": neighbors_int,
|
|
28915
|
+
"bboxes": bboxes,
|
|
28916
|
+
"bboxes_int": bboxes_int
|
|
28917
|
+
};
|
|
28918
|
+
module2.exports = geohash;
|
|
28919
|
+
}
|
|
28920
|
+
});
|
|
28921
|
+
|
|
28608
28922
|
// src/server/handler.ts
|
|
28609
28923
|
var handler_exports = {};
|
|
28610
28924
|
__export(handler_exports, {
|
|
@@ -28890,35 +29204,31 @@ var LAMBDA_MAX_PAYLOAD_SIZE_ASYNC = 256 * 1024;
|
|
|
28890
29204
|
var LAMBDA_MAX_RESPONSE_SIZE = 6 * 1024 * 1024;
|
|
28891
29205
|
var LAMBDA_MAX_ENV_VARS_SIZE = 4 * 1024;
|
|
28892
29206
|
|
|
28893
|
-
// src/
|
|
28894
|
-
var
|
|
29207
|
+
// src/shared/geohash/types.ts
|
|
29208
|
+
var DEFAULT_GEOHASH_CONFIG = {
|
|
29209
|
+
shadowPrecision: 8,
|
|
29210
|
+
// ±19m(建物レベル)
|
|
29211
|
+
searchPrecision: 6,
|
|
29212
|
+
// ±610m(近隣レベル)
|
|
29213
|
+
minPrecision: 4,
|
|
29214
|
+
// ±20km(大都市レベル)
|
|
29215
|
+
maxIterations: 5,
|
|
29216
|
+
candidateMultiplier: 3
|
|
29217
|
+
};
|
|
28895
29218
|
|
|
28896
|
-
// src/
|
|
28897
|
-
|
|
28898
|
-
|
|
28899
|
-
|
|
28900
|
-
}
|
|
28901
|
-
if (typeof value === "string") {
|
|
28902
|
-
if (/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/.test(value)) {
|
|
28903
|
-
return "datetime";
|
|
28904
|
-
}
|
|
28905
|
-
return "string";
|
|
28906
|
-
}
|
|
28907
|
-
if (typeof value === "number") {
|
|
28908
|
-
return "number";
|
|
28909
|
-
}
|
|
28910
|
-
if (typeof value === "boolean") {
|
|
28911
|
-
return "boolean";
|
|
28912
|
-
}
|
|
28913
|
-
if (Array.isArray(value)) {
|
|
28914
|
-
return "array";
|
|
28915
|
-
}
|
|
28916
|
-
if (typeof value === "object") {
|
|
28917
|
-
return "object";
|
|
28918
|
-
}
|
|
28919
|
-
return null;
|
|
29219
|
+
// src/shared/geohash/utils.ts
|
|
29220
|
+
var import_ngeohash = __toESM(require_main(), 1);
|
|
29221
|
+
function isGeoCoordinates(value) {
|
|
29222
|
+
return typeof value === "object" && value !== null && "latitude" in value && "longitude" in value && typeof value.latitude === "number" && typeof value.longitude === "number" && value.latitude >= -90 && value.latitude <= 90 && value.longitude >= -180 && value.longitude <= 180;
|
|
28920
29223
|
}
|
|
28921
|
-
__name(
|
|
29224
|
+
__name(isGeoCoordinates, "isGeoCoordinates");
|
|
29225
|
+
function encodeGeoHash(latitude, longitude, precision = 6) {
|
|
29226
|
+
return import_ngeohash.default.encode(latitude, longitude, precision);
|
|
29227
|
+
}
|
|
29228
|
+
__name(encodeGeoHash, "encodeGeoHash");
|
|
29229
|
+
|
|
29230
|
+
// src/server/operations/deleteMany.ts
|
|
29231
|
+
var import_lib_dynamodb2 = __toESM(require_dist_cjs66(), 1);
|
|
28922
29232
|
|
|
28923
29233
|
// src/shared/constants/formatting.ts
|
|
28924
29234
|
var NUMBER_FORMAT = {
|
|
@@ -28973,6 +29283,33 @@ function isDiffEmpty(diff) {
|
|
|
28973
29283
|
}
|
|
28974
29284
|
__name(isDiffEmpty, "isDiffEmpty");
|
|
28975
29285
|
|
|
29286
|
+
// src/server/shadow/typeInference.ts
|
|
29287
|
+
function inferFieldType(value) {
|
|
29288
|
+
if (value === null || value === void 0) {
|
|
29289
|
+
return null;
|
|
29290
|
+
}
|
|
29291
|
+
if (typeof value === "string") {
|
|
29292
|
+
if (/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/.test(value)) {
|
|
29293
|
+
return "datetime";
|
|
29294
|
+
}
|
|
29295
|
+
return "string";
|
|
29296
|
+
}
|
|
29297
|
+
if (typeof value === "number") {
|
|
29298
|
+
return "number";
|
|
29299
|
+
}
|
|
29300
|
+
if (typeof value === "boolean") {
|
|
29301
|
+
return "boolean";
|
|
29302
|
+
}
|
|
29303
|
+
if (Array.isArray(value)) {
|
|
29304
|
+
return "array";
|
|
29305
|
+
}
|
|
29306
|
+
if (typeof value === "object") {
|
|
29307
|
+
return "object";
|
|
29308
|
+
}
|
|
29309
|
+
return null;
|
|
29310
|
+
}
|
|
29311
|
+
__name(inferFieldType, "inferFieldType");
|
|
29312
|
+
|
|
28976
29313
|
// src/server/shadow/generator.ts
|
|
28977
29314
|
function normalizeJson(value) {
|
|
28978
29315
|
if (value === null || value === void 0) return value;
|
|
@@ -29074,6 +29411,19 @@ function generateShadowRecords(record, resourceName, config) {
|
|
|
29074
29411
|
if (value === null || value === void 0) {
|
|
29075
29412
|
continue;
|
|
29076
29413
|
}
|
|
29414
|
+
if (isGeoCoordinates(value)) {
|
|
29415
|
+
const geohash = encodeGeoHash(
|
|
29416
|
+
value.latitude,
|
|
29417
|
+
value.longitude,
|
|
29418
|
+
DEFAULT_GEOHASH_CONFIG.shadowPrecision
|
|
29419
|
+
);
|
|
29420
|
+
const sk2 = `${fieldName}#${geohash}#id#${record.id}`;
|
|
29421
|
+
shadows.push({
|
|
29422
|
+
PK: resourceName,
|
|
29423
|
+
SK: sk2
|
|
29424
|
+
});
|
|
29425
|
+
continue;
|
|
29426
|
+
}
|
|
29077
29427
|
const type = inferFieldType(value);
|
|
29078
29428
|
if (!type) {
|
|
29079
29429
|
continue;
|