Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions src/interaction/TrackData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,38 @@ export default class TrackData {
controlPoints: [],
};
const {segments, pois, controlPoints} = parsed;

for (const feature of features) {
const type = feature.get('type');
if (type === 'segment') {
console.assert(feature.getGeometry().getType() === 'LineString');
const g = feature.getGeometry();
if (g.getType() !== 'LineString') {
throw new Error('Some segment is not a LineString');
};
if (g.getLayout() !== 'XYZM') {
throw new Error('Some segment is not XYZM');
}
segments.push(feature as Feature<LineString>);
} else if (type === 'controlPoint') {
console.assert(feature.getGeometry().getType() === 'Point');
if (feature.getGeometry().getType() !== 'Point') {
throw new Error('Some controlPoint is not a Point');
};
controlPoints.push(feature as Feature<Point>);
} else if (type === 'POI') {
console.assert(feature.getGeometry().getType() === 'Point');
if (feature.getGeometry().getType() !== 'Point') {
throw new Error('Some POI is not a Point');
};
pois.push(feature as Feature<Point>);
}
}
controlPoints.forEach((p, i) => {
const sCoo = (i === controlPoints.length - 1) ? segments[i - 1].getGeometry().getLastCoordinate() : segments[i].getGeometry().getFirstCoordinate()
const cCoo = p.getGeometry().getCoordinates();
const dx = Math.abs(sCoo[0] - cCoo[0]);
const dy = Math.abs(sCoo[1] - cCoo[1]);
if (dx > 0.1 || dy > 0.1 ) {
console.error(`Control point ${i} is not on segment end ${sCoo} != ${cCoo} (dy=${dx}, dy=${dy})`);
}
})

return parsed;
}
Expand Down