Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spatial conclusion #63

Closed
wants to merge 68 commits into from
Closed
Show file tree
Hide file tree
Changes from 66 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
ca78e62
Allow temporary entites.
ctieben Sep 5, 2018
cbbe37b
Add a RDFValue based Triple implementation and remove document from t…
ctieben Sep 6, 2018
d9b28f6
Add a RDFValue based variant of a Triple that is now be used in the R…
ctieben Sep 6, 2018
aa1d520
Remove RDFValueTriple Try
ctieben Sep 12, 2018
a624097
isEqual check for all ReferenceSystems
ctieben Sep 14, 2018
968dd6e
Fix isEqual for no parent of a local cs
ctieben Sep 14, 2018
4a25848
SpatialIndex now for a specific root reference system. \n Multiple Sp…
ctieben Sep 14, 2018
c9306ee
First Version of SpatialConclusion
ctieben Sep 17, 2018
2b4fcc5
SpatialConclusion as SpatialIndex Extension
ctieben Sep 17, 2018
646620b
R-Tree with cloned geometries
ctieben Sep 17, 2018
5f837b5
SpatialConclusion could also checks geometry and not only boxes
ctieben Sep 17, 2018
ce85470
R-Tree only for query not iterating
ctieben Sep 17, 2018
183aeed
Fix 2D in SpatialIndex by assume a very high box
ctieben Sep 18, 2018
7ed1837
Add first tests for spatial conclusion
ctieben Sep 18, 2018
593402e
SpatialIndexQuery for 2D or 3D by template parameter and a box/geomet…
ctieben Sep 20, 2018
796867f
SpatialIndex separate for 2D and 3D
ctieben Sep 21, 2018
17b7f3b
Fix static assert from eigen in SpatialIndexQuery2D
ctieben Sep 21, 2018
a6b2f98
Move type mapping and QueryType to SpatialIndexBase
ctieben Sep 21, 2018
9619bd6
Add support for Nearest, CoveredBy and Overlaps spatial queries.
ctieben Sep 21, 2018
eba14d7
Allow Geometry based spatial queries (not Box based) for intersection…
ctieben Sep 21, 2018
d27e690
Fix geometry check for Spatial Queries and update unit test
ctieben Sep 24, 2018
5a42d2c
SpatialConclusion for 2D and 3D. Add SpatialThing as example entity.
ctieben Sep 24, 2018
747838b
Fix shortcut in RDF Triple and add test for a SpatialConclusion based…
ctieben Sep 26, 2018
6c34475
check URI and RDF Shortcut in SpatialConclusion
ctieben Sep 26, 2018
dfb98c9
Add generic cardinal direction checker for WGS84
ctieben Oct 4, 2018
3b170a5
DirectionCheck now supportes different global coordinate systems
ctieben Oct 4, 2018
5d6a513
Add removeProperty for SemanticEntity
ctieben Oct 9, 2018
a50f627
Rename and move SpatialThing to GeometricObject
ctieben Oct 9, 2018
565de92
GeometricObject and SemanticEntity may be temporary and clean up the …
ctieben Oct 15, 2018
c56fe03
Merge remote-tracking branch 'origin/master' into spatial_conclusion
ctieben Oct 15, 2018
d62c201
GeometricObject will not notify about changes of himself
ctieben Oct 16, 2018
7ce6435
Update SpatialConclusion comments
ctieben Oct 23, 2018
273ccd2
Add a RDFValue based Triple implementation and remove document from t…
ctieben Sep 6, 2018
74f66ea
Add a RDFValue based variant of a Triple that is now be used in the R…
ctieben Sep 6, 2018
6b2e5bd
Remove RDFValueTriple Try
ctieben Sep 12, 2018
5539897
isEqual check for all ReferenceSystems
ctieben Sep 14, 2018
600f577
Fix isEqual for no parent of a local cs
ctieben Sep 14, 2018
e3122d8
SpatialIndex now for a specific root reference system. \n Multiple Sp…
ctieben Sep 14, 2018
272d61b
First Version of SpatialConclusion
ctieben Sep 17, 2018
db9256a
SpatialConclusion as SpatialIndex Extension
ctieben Sep 17, 2018
3797604
R-Tree with cloned geometries
ctieben Sep 17, 2018
f9c1e60
SpatialConclusion could also checks geometry and not only boxes
ctieben Sep 17, 2018
743f31c
R-Tree only for query not iterating
ctieben Sep 17, 2018
073e335
Fix 2D in SpatialIndex by assume a very high box
ctieben Sep 18, 2018
e5cf03e
Add first tests for spatial conclusion
ctieben Sep 18, 2018
c26e1c0
SpatialIndexQuery for 2D or 3D by template parameter and a box/geomet…
ctieben Sep 20, 2018
0d4c7b5
SpatialIndex separate for 2D and 3D
ctieben Sep 21, 2018
e8363c8
Fix static assert from eigen in SpatialIndexQuery2D
ctieben Sep 21, 2018
4b873f5
Move type mapping and QueryType to SpatialIndexBase
ctieben Sep 21, 2018
b60d0b3
Add support for Nearest, CoveredBy and Overlaps spatial queries.
ctieben Sep 21, 2018
cc7bc18
Allow Geometry based spatial queries (not Box based) for intersection…
ctieben Sep 21, 2018
af716a0
Fix geometry check for Spatial Queries and update unit test
ctieben Sep 24, 2018
432cfe1
SpatialConclusion for 2D and 3D. Add SpatialThing as example entity.
ctieben Sep 24, 2018
5b191e1
Fix shortcut in RDF Triple and add test for a SpatialConclusion based…
ctieben Sep 26, 2018
28e89b3
check URI and RDF Shortcut in SpatialConclusion
ctieben Sep 26, 2018
f0c0dc5
Add generic cardinal direction checker for WGS84
ctieben Oct 4, 2018
ff818ef
DirectionCheck now supportes different global coordinate systems
ctieben Oct 4, 2018
9444e99
Add removeProperty for SemanticEntity
ctieben Oct 9, 2018
8dc12fb
Rename and move SpatialThing to GeometricObject
ctieben Oct 9, 2018
a2c79f6
GeometricObject and SemanticEntity may be temporary and clean up the …
ctieben Oct 15, 2018
ff42d68
GeometricObject will not notify about changes of himself
ctieben Oct 16, 2018
fb4328d
Update SpatialConclusion comments
ctieben Oct 23, 2018
fd09057
Merge master into spatial_conclusion
ctieben Oct 25, 2018
0ccb17d
Merge branch 'master' into spatial_conclusion
ctieben Dec 10, 2018
b5e47bc
Fix CalculatePointsModule for changed SpatialIndex and update cmake v…
ctieben Dec 17, 2018
6be6b22
Update comment
ctieben Dec 17, 2018
617adf4
Merge branch 'master' into spatial_conclusion
ctieben Mar 1, 2019
cf1bee1
Fix nullptr exception in calculate pointclouds
ctieben Mar 20, 2019
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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(SEMPR_VERSION_MAJOR 0)
set(SEMPR_VERSION_MINOR 1)
set(SEMPR_VERSION_MINOR 3)
set(SEMPR_VERSION_PATCH 0)

##
Expand Down
2 changes: 1 addition & 1 deletion cmake/UseODB.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function(odb_compile outvar)

#list(APPEND ODB_ARGS -x "${CMAKE_CXX_COMPILER}")

list(APPEND ODB_ARGS --show-sloc)
#list(APPEND ODB_ARGS --show-sloc)

if(PARAM_MULTI_DATABASE)
list(APPEND ODB_ARGS --multi-database "${PARAM_MULTI_DATABASE}")
Expand Down
106 changes: 56 additions & 50 deletions include/sempr/core/RDF.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,67 +3,73 @@

#include <string>
#include <vector>
#include <functional>

namespace sempr {
const std::string& baseURI();

const std::string buildURI(const std::string& id, const std::string& baseURI);
const std::string extractID(const std::string& uri, const std::string& baseURI);

namespace core {

namespace xsd {
const std::string& baseURI();
}
namespace xsd {
const std::string& baseURI();
}

namespace rdf {
const std::string& baseURI();
const std::string& type();
}
namespace rdf {
const std::string& baseURI();
const std::string& type();
}

namespace rdfs {
# define RDFS(name) const std::string& (name)();
RDFS(baseURI)
RDFS(Resource)
RDFS(Class)
RDFS(subClassOf)
RDFS(subPropertyOf)
RDFS(domain)
RDFS(range)
# undef RDFS
}
namespace rdfs {
const std::string& baseURI();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you add this line? const std::string& baseURI(); is already declared through the macro below:

#define RDFS(name) const std::string& (name)();
RDFS(baseURI)

Same goes for owl.

# define RDFS(name) const std::string& (name)();
RDFS(baseURI)
RDFS(Resource)
RDFS(Class)
RDFS(subClassOf)
RDFS(subPropertyOf)
RDFS(domain)
RDFS(range)
# undef RDFS
}

namespace owl {
# define OWL(name) const std::string& (name)();
OWL(baseURI)
OWL(Class)
OWL(FunctionalProperty)
OWL(Nothing)
OWL(ObjectProperty)
OWL(Restriction)
OWL(Thing)
OWL(allValuesFrom)
OWL(cardinality)
OWL(differentFrom)
OWL(disjointWith)
OWL(distinctMembers)
OWL(equivalentClass)
OWL(equivalentProperty)
OWL(hasValue)
OWL(intersectionOf)
OWL(inverseOf)
OWL(maxCardinality)
OWL(minCardinality)
OWL(onClass)
OWL(onDataRange)
OWL(onDatatype)
OWL(oneOf)
OWL(onProperty)
OWL(sameAs)
OWL(someValuesFrom)
OWL(unionOf)
# undef OWL
}
namespace owl {
const std::string& baseURI();
# define OWL(name) const std::string& (name)();
OWL(baseURI)
OWL(Class)
OWL(FunctionalProperty)
OWL(Nothing)
OWL(ObjectProperty)
OWL(Restriction)
OWL(Thing)
OWL(allValuesFrom)
OWL(cardinality)
OWL(differentFrom)
OWL(disjointWith)
OWL(distinctMembers)
OWL(equivalentClass)
OWL(equivalentProperty)
OWL(hasValue)
OWL(intersectionOf)
OWL(inverseOf)
OWL(maxCardinality)
OWL(minCardinality)
OWL(onClass)
OWL(onDataRange)
OWL(onDatatype)
OWL(oneOf)
OWL(onProperty)
OWL(sameAs)
OWL(someValuesFrom)
OWL(unionOf)
# undef OWL
}


} /* core */
} /* core */

} /* sempr */

Expand Down
47 changes: 47 additions & 0 deletions include/sempr/entity/GeometricObject.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#ifndef SEMPR_ENTITY_GEOMETRICOBJECT_H_
#define SEMPR_ENTITY_GEOMETRICOBJECT_H_

#include <sempr/entity/Entity.hpp>
#include <sempr/entity/spatial/Geometry.hpp>
#include <sempr/entity/SemanticEntity.hpp>
#include <sempr/core/RDF.hpp>
#include <odb/core.hxx>

#include <string>

namespace sempr { namespace entity {


#pragma db object
class GeometricObject : public SemanticEntity {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments would be nice. What is the purpose of this class?

SEMPR_ENTITY
public:
using Ptr = std::shared_ptr<GeometricObject>;

GeometricObject();
GeometricObject(bool temporary);
GeometricObject(const core::IDGenBase*, bool temporary = false);

const Geometry::Ptr geometry() const { return geometry_; }
void geometry(const Geometry::Ptr geometry);

const std::string type() const { return type_; }
void type(const std::string& type);

void registerProperty(const std::string& predicate, const std::string& object);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A method of the same name (but templated) already exists in SemanticEntity, which you derive from here. Is this on purpose? Or coincidental?

template <class T> void registerProperty(const std::string& predicate, T& property) { /* ... */ }
// ... and derivations ...

These methods are used to register member variables and make them visible in the rdf.


// Gives all related object by a known predicate. (could be empty for all related objects)
std::set<std::string> related(const std::string& predicate = "");

private:
friend class odb::access;

Geometry::Ptr geometry_;

std::string type_;
};

}}


#endif /* end of include guard: SEMPR_ENTITY_GEOMETRICOBJECT_H_ */
2 changes: 1 addition & 1 deletion include/sempr/entity/RDFEntity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class RDFEntity : public Entity {
virtual TripleIteratorWrapper end() const;

protected:
RDFEntity(const core::IDGenBase*);
RDFEntity(const core::IDGenBase*, bool temporary = false);
private:
friend class odb::access;
RDFEntity();
Expand Down
2 changes: 1 addition & 1 deletion include/sempr/entity/RDFPropertyMap.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef SEMPR_ENTITY_RDFPROPERTYMAP_HPP_
#define SEMPR_ENTITY_RDFPROPERTYMAP_HPP_

#include <sempr/entity/RDFVector.hpp>
#include <sempr/entity/RDFEntity.hpp>
#include <sempr/entity/RDFValue.hpp>
#include <Soprano/Soprano> // for conversion to rdf-literals.

Expand Down
3 changes: 3 additions & 0 deletions include/sempr/entity/RDFValue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
#define SEMPR_ENTITY_RDFVALUE_HPP_

#include <memory>
#include <string>
#include <tuple>
#include <type_traits>

#include <Soprano/Soprano>
#include <odb/core.hxx>
#include <sempr/entity/Entity.hpp>
Expand Down
17 changes: 8 additions & 9 deletions include/sempr/entity/RDFVector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@
#define SEMPR_ENTITY_RDFVECTOR_H_

#include <odb/core.hxx>
#include <sempr/core/RDF.hpp>
#include <sempr/entity/Entity.hpp>
#include <sempr/entity/Triple.hpp>
#include <sempr/entity/RDFEntity.hpp>

#include <sempr/core/EntityEvent.hpp>
#include <sempr/entity/RDFEntity.hpp>

#include <vector>

Expand All @@ -26,20 +22,19 @@ class RDFVectorIterator : public TripleIterator {
bool operator == (const TripleIterator& other) const override;
};



#pragma db object
class RDFVector : public RDFEntity {
SEMPR_ENTITY
public:
using Ptr = std::shared_ptr<RDFVector>;
RDFVector();
RDFVector(const core::IDGenBase*);
RDFVector(bool temporary);
RDFVector(const core::IDGenBase*, bool temporary = false);
virtual ~RDFVector(){}

void getTriples(std::vector<Triple>& triples) const;
const Triple& getTripleAt(const size_t index);
bool addTriple(const Triple& triple);
bool addTriple(const Triple& triple, bool replace = false); // if replace than an equal triple will be removed before, otherwise there a multiple entries possible
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the meaning of "replacing" an equivalent Triple? If there's a way to see a difference they were not equal. So replace = true would be the same as allow_duplicates = false. The other way round is still intuitive for allow_duplicates, but replace = false is ambiguous: What happens with an equivalent triple? Is it just discarded without "replacing" the old one, and there is still only one of present in the vector? Or is it added as a duplicate?

tl;dr: I'd suggest renaming bool replace to bool allow_duplicates.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, maybe the default should be to not allow duplicates? I don't see any use case for adding the same fact multiple times.

bool removeTriple(const Triple& triple);
void removeTripleAt(const size_t index);
void clear();
Expand All @@ -48,11 +43,15 @@ class RDFVector : public RDFEntity {
TripleIteratorWrapper begin() const override;
TripleIteratorWrapper end() const override;

bool validity(const Triple& triple) const;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this check? Does it depend on the RDFVector, or should this be moved to the Triple-class?


protected:
friend class odb::access;
std::vector<Triple> triples_;
};



}}

#endif /* end of include guard: SEMPR_ENTITY_RDFVECTOR_H_ */
41 changes: 37 additions & 4 deletions include/sempr/entity/SemanticEntity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ class RegisteredPropertyBase {
std::string predicate() const;
virtual std::string object() const = 0;
virtual bool isValid() const = 0;

bool operator==(const RegisteredPropertyBase& other) const;
};

/**
Expand Down Expand Up @@ -234,7 +236,7 @@ class RegisteredProperty : public RegisteredPropertyBase {

public:
MyEntity() {
registerPropetry("<http://some.ontology/somePredicate>", myInt_);
registerProperty("<http://some.ontology/somePredicate>", myInt_);
registerProperty("<http://some.ontology/someSubject>", "<http://some.ontology/somePredicate>", myFloat_);
}
};
Expand All @@ -250,9 +252,13 @@ class SemanticEntity : public RDFEntity {
#pragma db transient
std::vector<RegisteredPropertyBase*> properties_;

std::vector<RegisteredPropertyBase*>::iterator findProperty(const RegisteredPropertyBase& prop);

protected:
SemanticEntity(const core::IDGenBase*);
SemanticEntity();
SemanticEntity(bool temporary);
SemanticEntity(const core::IDGenBase*, bool temporary = false);


/**
Registers the property at this semantic entity. This will provide the RDF-Triple:
Expand All @@ -268,6 +274,13 @@ class SemanticEntity : public RDFEntity {
properties_.push_back(rprop);
}

template <class T>
void removeProperty(const std::string& predicate, T& property)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't unregisterProperty be a better name?
May I ask what this is used for? The registerProperty methods were intended to be used on construction of an object, only to export member variables to RDF. Why should you want to unregister such a member?

{
auto prop = findProperty(RegisteredProperty<T>(predicate, property));
properties_.erase(prop);
}

template <class T>
void registerPropertyPlain(const std::string& predicate, T& property)
{
Expand All @@ -276,20 +289,33 @@ class SemanticEntity : public RDFEntity {
properties_.push_back(rprop);
}

template <class T>
void removePropertyPlain(const std::string& predicate, T& property)
{
auto prop = findProperty(RegisteredProperty<T, sempr::rdf::traits::plain_string>(predicate, property));
properties_.erase(prop);
}

/**
Registers the property at this semantic entity. This allows setting both subject and
predicate of the resulting triple.

Assumes the given property is a member of this SemanticEntity.
*/
template <class T>
void registerProperty(const std::string& subject, const std::string& predicate,
T& property)
void registerProperty(const std::string& subject, const std::string& predicate, T& property)
{
RegisteredPropertyBase* rprop = new RegisteredProperty<T>(subject, predicate, property);
properties_.push_back(rprop);
}

template <class T>
void removeProperty(const std::string& subject, const std::string& predicate, T& property)
{
auto prop = findProperty(RegisteredProperty<T>(subject, predicate, property));
properties_.erase(prop);
}

template <class T>
void registerPropertyPlain(const std::string& subject, const std::string& predicate, T& property)
{
Expand All @@ -298,6 +324,13 @@ class SemanticEntity : public RDFEntity {
properties_.push_back(rprop);
}

template <class T>
void removePropertyPlain(const std::string& subject, const std::string& predicate, T& property)
{
auto prop = findProperty(RegisteredProperty<T, sempr::rdf::traits::plain_string>(subject, predicate, property));
properties_.erase(prop);
}

public:
~SemanticEntity();

Expand Down
Loading