Skip to content

Commit

Permalink
chore: updated core
Browse files Browse the repository at this point in the history
  • Loading branch information
Maximvdw committed May 16, 2024
1 parent 068454e commit b7908f0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
"@comunica/query-sparql-link-traversal": "0.2.0",
"@comunica/query-sparql-rdfjs": "^2.10.1",
"@comunica/runner": "^2.10.0",
"@openhps/core": "^0.7.0",
"@openhps/core": "^0.7.2",
"@openhps/fingerprinting": "^0.1.7",
"@openhps/geospatial": "^0.1.29",
"@openhps/rf": "^0.1.61",
Expand Down
5 changes: 2 additions & 3 deletions src/rdf/InternalRDFDeserializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,8 @@ export class InternalRDFDeserializer extends Deserializer {
})
.reduce((a, b) => [...a, ...b], []);
const sourcePredicates = Object.keys(sourceObject.predicates);
const priority = sourcePredicates.filter((predicate) =>
predicates.includes(predicate as IriString),
).length;
const priority =
sourcePredicates.filter((predicate) => predicates.includes(predicate as IriString)).length * 5;
const negativePriority =
predicates.filter((predicate) => !sourcePredicates.includes(predicate as IriString)).length /
10;
Expand Down
11 changes: 10 additions & 1 deletion test/specs/relative2d.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'mocha';
import { Absolute2DPosition, DataObject, LengthUnit, Relative2DPosition } from '@openhps/core';
import { Absolute2DPosition, DataObject, DataSerializerUtils, LengthUnit, Relative2DPosition, Relative3DPosition, RelativeAngle } from '@openhps/core';
import { RDFSerializer } from '../../src';
import { poso, rdf, sosa } from '../../src/vocab';
import { expect } from 'chai';
Expand All @@ -10,6 +10,8 @@ describe('Relative2DPosition', () => {
object.position.unit = LengthUnit.METER;
const virtual = new DataObject("abc")
.addRelativePosition(new Relative2DPosition(object, 1, 2, LengthUnit.CENTIMETER));
const virtual1 = new DataObject("abc")
.addRelativePosition(new Relative3DPosition(object, 1, 2, 3, LengthUnit.CENTIMETER));

describe('serialization', () => {
let serialized = undefined;
Expand Down Expand Up @@ -48,6 +50,13 @@ describe('Relative2DPosition', () => {
it('should deserialize the value', () => {
expect((deserialized.getRelativePosition(object.uid) as Relative2DPosition).x).to.eql(0.01);
});

it('should deserialize to a relative3d', () => {
expect(virtual1.getRelativePosition(object.uid)).to.be.instanceOf(Relative3DPosition);
const serialized = RDFSerializer.serialize(virtual1);
const deserialized = RDFSerializer.deserialize(serialized);
expect((deserialized as DataObject).getRelativePosition(object.uid)).to.be.instanceOf(Relative3DPosition);
});
});

});

0 comments on commit b7908f0

Please sign in to comment.