Skip to content

Commit eb2e075

Browse files
committed
the feature store has been redone.
fixed potential issue when data providers receive remote data that's outside of the actual requested bounds. speedup provider.all() Signed-off-by: Tim Deubler <tim.deubler@here.com>
1 parent 5c6c3ad commit eb2e075

File tree

8 files changed

+130
-147
lines changed

8 files changed

+130
-147
lines changed

packages/core/src/features/RTree.ts

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,73 @@
1919

2020
import RBush from 'rbush/rbush.min.js';
2121
import {Feature} from './Feature';
22+
import {GeoJSONFeature} from '@here/xyz-maps-core';
23+
24+
type BBox = {
25+
minX: number,
26+
maxX: number,
27+
minY: number,
28+
maxY: number
29+
};
30+
31+
32+
interface FeatureIndex {
33+
clear();
34+
}
35+
2236

2337
class RTree extends RBush {
24-
constructor(d:number) {
38+
constructor(d: number) {
2539
super(d);
2640
}
2741

28-
toBBox(feature: Feature) {
42+
toBBox(feature: GeoJSONFeature): BBox {
2943
const {bbox} = feature;
3044
return {minX: bbox[0], minY: bbox[1], maxX: bbox[2], maxY: bbox[3]};
3145
}
3246

33-
compareMinX(feature1: Feature, feature2: Feature): number {
47+
compareMinX(feature1: GeoJSONFeature, feature2: GeoJSONFeature): number {
3448
return feature1.bbox[0] - feature2.bbox[0];
3549
}
3650

37-
compareMinY(feature1: Feature, feature2: Feature): number {
51+
compareMinY(feature1: GeoJSONFeature, feature2: GeoJSONFeature): number {
3852
return feature1.bbox[1] - feature2.bbox[1];
3953
}
54+
55+
import(data) {
56+
super.fromJSON(data);
57+
}
58+
59+
load?(features: GeoJSONFeature[]): void;
60+
61+
insert?(feature: GeoJSONFeature);
62+
63+
remove?(feature: GeoJSONFeature);
64+
65+
search?(bbox: BBox): GeoJSONFeature[];
66+
67+
clear?(): void;
68+
69+
all?(): GeoJSONFeature[];
70+
71+
// load(features: GeoJSONFeature[]) {
72+
// return super.load(features);
73+
// }
74+
//
75+
// insert(feature: GeoJSONFeature) {
76+
// return super.insert(feature);
77+
// }
78+
//
79+
// remove(feature: GeoJSONFeature) {
80+
// return super.remove(feature);
81+
// }
82+
//
83+
// search(bbox: BBox) {
84+
// return super.propertyIsEnumerable(bbox);
85+
// }
86+
// clear() {
87+
// super.clear();
88+
// }
4089
}
4190

4291
export default RTree;

packages/core/src/features/utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
import {Feature} from '../features/Feature';
21-
import {GeoJSONCoordinate} from '@here/xyz-maps-core';
21+
import {GeoJSONCoordinate, GeoJSONFeature} from '@here/xyz-maps-core';
2222
type Point = number[];
2323
type BBox = number[];
2424
type Coordinates = Array<Point>;
@@ -56,11 +56,11 @@ const updateLineStringBBox = (lineString: Coordinates, bbox?: BBox) => {
5656
}
5757
};
5858

59-
const calcBBox = (feature: Feature, bbox?: BBox): BBox | false => {
59+
const calcBBox = (feature: GeoJSONFeature, bbox?: BBox): BBox | false => {
6060
const geoType = feature.geometry.type;
6161

6262
if (geoType == 'Point') {
63-
const coordinates = (<Feature<'Point'>>feature).geometry.coordinates;
63+
const coordinates = (feature as GeoJSONFeature<'Point'>).geometry.coordinates;
6464
if (bbox) {
6565
updatePointBBox(<[number, number]>coordinates, bbox);
6666
} else {

packages/core/src/providers/EditableFeatureProvider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,11 +313,11 @@ export abstract class EditableFeatureProvider extends FeatureTileProvider {
313313
}
314314
};
315315

316-
_insert(o, tile?) {
316+
_insert(o) {
317317
if (this.blocked[o.id]) {
318318
return null;
319319
}
320-
return super._insert(o, tile);
320+
return super._insert(o);
321321
};
322322

323323
reserveId(createdFeatures, cb) {

0 commit comments

Comments
 (0)