mirror of
https://github.com/mapillary/mapillary-js.git
synced 2026-01-25 14:07:28 +00:00
Store spatial nodes in dict for error handling.
This commit is contained in:
parent
e57ddc43b4
commit
a089ce78f7
@ -35,7 +35,7 @@ type NodeTiles = {
|
||||
}
|
||||
|
||||
type SpatialNodes = {
|
||||
all: NewNode[];
|
||||
all: { [key: string]: NewNode };
|
||||
cacheKeys: string[];
|
||||
cacheNodes: { [key: string]: NewNode };
|
||||
}
|
||||
@ -490,13 +490,13 @@ export class NewGraph {
|
||||
});
|
||||
|
||||
let spatialNodes: SpatialNodes = {
|
||||
all: [],
|
||||
all: {},
|
||||
cacheKeys: [],
|
||||
cacheNodes: {},
|
||||
};
|
||||
|
||||
for (let spatialItem of spatialItems) {
|
||||
spatialNodes.all.push(spatialItem.node);
|
||||
spatialNodes.all[spatialItem.node.key] = spatialItem.node;
|
||||
|
||||
if (!spatialItem.node.full) {
|
||||
spatialNodes.cacheKeys.push(spatialItem.node.key);
|
||||
@ -557,6 +557,10 @@ export class NewGraph {
|
||||
.catch(
|
||||
(error: Error): Observable<NewGraph> => {
|
||||
for (let batchKey of batch) {
|
||||
if (batchKey in spatialNodes.all) {
|
||||
delete spatialNodes.all[batchKey];
|
||||
}
|
||||
|
||||
if (batchKey in spatialNodes.cacheNodes) {
|
||||
delete spatialNodes.cacheNodes[batchKey];
|
||||
}
|
||||
@ -589,7 +593,17 @@ export class NewGraph {
|
||||
let nextKey: string = sequence.findNextKey(node.key);
|
||||
let prevKey: string = sequence.findPrevKey(node.key);
|
||||
|
||||
let potentialEdges: IPotentialEdge[] = this._edgeCalculator.getPotentialEdges(node, this._spatialNodes[key].all, fallbackKeys);
|
||||
let allSpatialNodes: { [key: string]: NewNode } = this._spatialNodes[key].all;
|
||||
let potentialNodes: NewNode[] = [];
|
||||
for (let spatialNodeKey in allSpatialNodes) {
|
||||
if (!allSpatialNodes.hasOwnProperty(spatialNodeKey)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
potentialNodes.push(allSpatialNodes[spatialNodeKey]);
|
||||
}
|
||||
|
||||
let potentialEdges: IPotentialEdge[] = this._edgeCalculator.getPotentialEdges(node, potentialNodes, fallbackKeys);
|
||||
|
||||
let edges: IEdge[] =
|
||||
this._edgeCalculator.computeStepEdges(
|
||||
|
||||
@ -61,7 +61,7 @@ export class EdgeCalculator {
|
||||
* be returned even if they do not meet
|
||||
* the criteria for a potential edge.
|
||||
*/
|
||||
public getPotentialEdges(node: NewNode, nodes: NewNode[], fallbackKeys: string[]): IPotentialEdge[] {
|
||||
public getPotentialEdges(node: NewNode, potentialNodes: NewNode[], fallbackKeys: string[]): IPotentialEdge[] {
|
||||
if (!node.full) {
|
||||
throw new ArgumentMapillaryError("Node has to be full.");
|
||||
}
|
||||
@ -77,7 +77,7 @@ export class EdgeCalculator {
|
||||
|
||||
let potentialEdges: IPotentialEdge[] = [];
|
||||
|
||||
for (let potential of nodes) {
|
||||
for (let potential of potentialNodes) {
|
||||
if (!potential.merged ||
|
||||
potential.key === node.key) {
|
||||
continue;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user