Skip to content

Commit

Permalink
REMOVE orion::Circle
Browse files Browse the repository at this point in the history
  • Loading branch information
fgalan committed Aug 13, 2024
1 parent f2476c9 commit b7cdb87
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 282 deletions.
1 change: 0 additions & 1 deletion src/lib/ngsi/Scope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,6 @@ void Scope::areaTypeSet(const std::string& areaTypeString)
{
if (areaTypeString == "line") areaType = orion::LineType;
else if (areaTypeString == "polygon") areaType = orion::PolygonType;
else if (areaTypeString == "circle") areaType = orion::CircleType;
else if (areaTypeString == "point") areaType = orion::PointType;
else if (areaTypeString == "box") areaType = orion::BoxType;
else areaType = orion::NoArea;
Expand Down
1 change: 0 additions & 1 deletion src/lib/orionTypes/areas.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ namespace orion
typedef enum AreaType
{
NoArea,
CircleType,
PolygonType,
PointType,
LineType,
Expand Down
280 changes: 0 additions & 280 deletions test/unittests/mongoBackend/mongoQueryContextGeo_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,286 +167,6 @@ int getEntityIndex(ContextElementResponseVector& v, const std::string& id)



/* ****************************************************************************
*
* queryGeoCircleIn1 -
*
* Area: 14 km circle centered in Madrid
* Result: Madrid, Alcobendas
*
*/
TEST(mongoQueryContextGeoRequest, queryGeoCircleIn1)
{
utInit();

HttpStatusCode ms;
QueryContextRequest req;
QueryContextResponse res;

/* Prepare database */
prepareDatabase();

/* Forge the request (from "inside" to "outside") */
EntityId en(".*", "City", "true");
req.entityIdVector.push_back(&en);

/* Define area scope */
Scope sc;
sc.type = "FIWARE::Location";
sc.areaType = orion::CircleType;
sc.circle.center.latitudeSet("40.418889");
sc.circle.center.longitudeSet("-3.691944");
sc.circle.radiusSet("13600");
req.restriction.scopeVector.push_back(&sc);

/* Invoke the function in mongoBackend library */
ms = mongoQueryContext(&req, &res, "", servicePathVector, uriParams, options);

/* Check response is as expected */
EXPECT_EQ(SccOk, ms);

EXPECT_EQ(0, res.errorCode.code);
EXPECT_EQ(0, res.errorCode.reasonPhrase.size());
EXPECT_EQ(0, res.errorCode.details.size());

ASSERT_EQ(2, res.contextElementResponseVector.size());
int i;

/* Context Element response # 1 */
i = getEntityIndex(res.contextElementResponseVector, "Madrid");
ASSERT_GE(i, 0);
EXPECT_EQ("Madrid", RES_CER(i).id);
EXPECT_EQ("City", RES_CER(i).type);
EXPECT_EQ("false", RES_CER(i).isPattern);
ASSERT_EQ(2, RES_CER(i).attributeVector.size());
EXPECT_EQ("foo", RES_CER_ATTR(i, 0)->name);
EXPECT_EQ("string", RES_CER_ATTR(i, 0)->type);
EXPECT_EQ("attr_Mad", RES_CER_ATTR(i, 0)->stringValue);
EXPECT_EQ("pos", RES_CER_ATTR(i, 1)->name);
EXPECT_EQ("location", RES_CER_ATTR(i, 1)->type);
EXPECT_EQ("40.418889, -3.691944", RES_CER_ATTR(i, 1)->stringValue);
ASSERT_EQ(1, RES_CER_ATTR(i, 1)->metadataVector.size());
EXPECT_EQ("location", RES_CER_ATTR(i, 1)->metadataVector[0]->name);
EXPECT_EQ("string", RES_CER_ATTR(i, 1)->metadataVector[0]->type);
EXPECT_EQ("WGS84", RES_CER_ATTR(i, 1)->metadataVector[0]->stringValue);
EXPECT_EQ(SccOk, RES_CER_STATUS(i).code);
EXPECT_EQ("OK", RES_CER_STATUS(i).reasonPhrase);
EXPECT_EQ(0, RES_CER_STATUS(i).details.size());

/* Context Element response # 2 */
i = getEntityIndex(res.contextElementResponseVector, "Leganes");
ASSERT_GE(i, 0);
EXPECT_EQ("Leganes", RES_CER(i).id);
EXPECT_EQ("City", RES_CER(i).type);
EXPECT_EQ("false", RES_CER(i).isPattern);
ASSERT_EQ(2, RES_CER(i).attributeVector.size());
EXPECT_EQ("foo", RES_CER_ATTR(i, 0)->name);
EXPECT_EQ("string", RES_CER_ATTR(i, 0)->type);
EXPECT_EQ("attr_Leg", RES_CER_ATTR(i, 0)->stringValue);
EXPECT_EQ("pos", RES_CER_ATTR(i, 1)->name);
EXPECT_EQ("location", RES_CER_ATTR(i, 1)->type);
EXPECT_EQ("40.316667, -3.75", RES_CER_ATTR(i, 1)->stringValue);
ASSERT_EQ(1, RES_CER_ATTR(i, 1)->metadataVector.size());
EXPECT_EQ("location", RES_CER_ATTR(i, 1)->metadataVector[0]->name);
EXPECT_EQ("string", RES_CER_ATTR(i, 1)->metadataVector[0]->type);
EXPECT_EQ("WGS84", RES_CER_ATTR(i, 1)->metadataVector[0]->stringValue);
EXPECT_EQ(SccOk, RES_CER_STATUS(i).code);
EXPECT_EQ("OK", RES_CER_STATUS(i).reasonPhrase);
EXPECT_EQ(0, RES_CER_STATUS(i).details.size());

/* Release dynamic memory used by response (mongoBackend allocates it) */
res.contextElementResponseVector.release();

utExit();
}

/* ****************************************************************************
*
* queryGeoCircleIn2 -
*
* Area: 15 km circle centered in Madrid
* Result: Madrid, Alcobendas, Leganes
*
*/
TEST(mongoQueryContextGeoRequest, queryGeoCircleIn2)
{
utInit();

HttpStatusCode ms;
QueryContextRequest req;
QueryContextResponse res;

/* Prepare database */
prepareDatabase();

/* Forge the request (from "inside" to "outside") */
EntityId en(".*", "City", "true");
req.entityIdVector.push_back(&en);

/* Define area scope */
Scope sc;
sc.type = "FIWARE::Location";
sc.areaType = orion::CircleType;
sc.circle.center.latitudeSet("40.418889");
sc.circle.center.longitudeSet("-3.691944");
sc.circle.radiusSet("15000");
req.restriction.scopeVector.push_back(&sc);

/* Invoke the function in mongoBackend library */
ms = mongoQueryContext(&req, &res, "", servicePathVector, uriParams, options);

/* Check response is as expected */
EXPECT_EQ(SccOk, ms);

EXPECT_EQ(0, res.errorCode.code);
EXPECT_EQ(0, res.errorCode.reasonPhrase.size());
EXPECT_EQ(0, res.errorCode.details.size());

ASSERT_EQ(3, res.contextElementResponseVector.size());
int i;
/* Context Element response # 1 */

i = getEntityIndex(res.contextElementResponseVector, "Madrid");
ASSERT_GE(i, 0);
EXPECT_EQ("Madrid", RES_CER(i).id);
EXPECT_EQ("City", RES_CER(i).type);
EXPECT_EQ("false", RES_CER(i).isPattern);
ASSERT_EQ(2, RES_CER(i).attributeVector.size());
EXPECT_EQ("foo", RES_CER_ATTR(i, 0)->name);
EXPECT_EQ("string", RES_CER_ATTR(i, 0)->type);
EXPECT_EQ("attr_Mad", RES_CER_ATTR(i, 0)->stringValue);
EXPECT_EQ("pos", RES_CER_ATTR(i, 1)->name);
EXPECT_EQ("location", RES_CER_ATTR(i, 1)->type);
EXPECT_EQ("40.418889, -3.691944", RES_CER_ATTR(i, 1)->stringValue);
ASSERT_EQ(1, RES_CER_ATTR(i, 1)->metadataVector.size());
EXPECT_EQ("location", RES_CER_ATTR(i, 1)->metadataVector[0]->name);
EXPECT_EQ("string", RES_CER_ATTR(i, 1)->metadataVector[0]->type);
EXPECT_EQ("WGS84", RES_CER_ATTR(i, 1)->metadataVector[0]->stringValue);
EXPECT_EQ(SccOk, RES_CER_STATUS(i).code);
EXPECT_EQ("OK", RES_CER_STATUS(i).reasonPhrase);
EXPECT_EQ(0, RES_CER_STATUS(i).details.size());

/* Context Element response # 2 */
i = getEntityIndex(res.contextElementResponseVector, "Alcobendas");
ASSERT_GE(i, 0);
EXPECT_EQ("Alcobendas", RES_CER(i).id);
EXPECT_EQ("City", RES_CER(i).type);
EXPECT_EQ("false", RES_CER(i).isPattern);
ASSERT_EQ(2, RES_CER(i).attributeVector.size());
EXPECT_EQ("foo", RES_CER_ATTR(i, 0)->name);
EXPECT_EQ("string", RES_CER_ATTR(i, 0)->type);
EXPECT_EQ("attr_Alc", RES_CER_ATTR(i, 0)->stringValue);
EXPECT_EQ("pos", RES_CER_ATTR(i, 1)->name);
EXPECT_EQ("location", RES_CER_ATTR(i, 1)->type);
EXPECT_EQ("40.533333, -3.633333", RES_CER_ATTR(i, 1)->stringValue);
ASSERT_EQ(1, RES_CER_ATTR(i, 1)->metadataVector.size());
EXPECT_EQ("location", RES_CER_ATTR(i, 1)->metadataVector[0]->name);
EXPECT_EQ("string", RES_CER_ATTR(i, 1)->metadataVector[0]->type);
EXPECT_EQ("WGS84", RES_CER_ATTR(i, 1)->metadataVector[0]->stringValue);
EXPECT_EQ(SccOk, RES_CER_STATUS(i).code);
EXPECT_EQ("OK", RES_CER_STATUS(i).reasonPhrase);
EXPECT_EQ(0, RES_CER_STATUS(i).details.size());

/* Context Element response # 3 */
i = getEntityIndex(res.contextElementResponseVector, "Leganes");
ASSERT_GE(i, 0);
EXPECT_EQ("Leganes", RES_CER(i).id);
EXPECT_EQ("City", RES_CER(i).type);
EXPECT_EQ("false", RES_CER(i).isPattern);
ASSERT_EQ(2, RES_CER(i).attributeVector.size());
EXPECT_EQ("foo", RES_CER_ATTR(i, 0)->name);
EXPECT_EQ("string", RES_CER_ATTR(i, 0)->type);
EXPECT_EQ("attr_Leg", RES_CER_ATTR(i, 0)->stringValue);
EXPECT_EQ("pos", RES_CER_ATTR(i, 1)->name);
EXPECT_EQ("location", RES_CER_ATTR(i, 1)->type);
EXPECT_EQ("40.316667, -3.75", RES_CER_ATTR(i, 1)->stringValue);
ASSERT_EQ(1, RES_CER_ATTR(i, 1)->metadataVector.size());
EXPECT_EQ("location", RES_CER_ATTR(i, 1)->metadataVector[0]->name);
EXPECT_EQ("string", RES_CER_ATTR(i, 1)->metadataVector[0]->type);
EXPECT_EQ("WGS84", RES_CER_ATTR(i, 1)->metadataVector[0]->stringValue);
EXPECT_EQ(SccOk, RES_CER_STATUS(i).code);
EXPECT_EQ("OK", RES_CER_STATUS(i).reasonPhrase);
EXPECT_EQ(0, RES_CER_STATUS(i).details.size());

/* Release dynamic memory used by response (mongoBackend allocates it) */
res.contextElementResponseVector.release();

utExit();
}

/* ****************************************************************************
*
* queryGeoCircleOut -
*
* Area: 14 km circle centered in Madrid
* Result: Leganes
*
*/
TEST(mongoQueryContextGeoRequest, queryGeoCircleOut)
{
utInit();

HttpStatusCode ms;
QueryContextRequest req;
QueryContextResponse res;

/* Prepare database */
prepareDatabase();

/* Forge the request (from "inside" to "outside") */
EntityId en(".*", "City", "true");
req.entityIdVector.push_back(&en);

/* Define area scope */
Scope sc;
sc.type = "FIWARE::Location";
sc.areaType = orion::CircleType;
sc.circle.center.latitudeSet("40.418889");
sc.circle.center.longitudeSet("-3.691944");
sc.circle.radiusSet("13600");
sc.circle.invertedSet("true");
req.restriction.scopeVector.push_back(&sc);

/* Invoke the function in mongoBackend library */
ms = mongoQueryContext(&req, &res, "", servicePathVector, uriParams, options);

/* Check response is as expected */
EXPECT_EQ(SccOk, ms);

EXPECT_EQ(0, res.errorCode.code);
EXPECT_STREQ("", res.errorCode.reasonPhrase.c_str());
EXPECT_STREQ("", res.errorCode.details.c_str());

ASSERT_EQ(1, res.contextElementResponseVector.size());
int i;

/* Context Element response # 1 */
i = getEntityIndex(res.contextElementResponseVector, "Alcobendas");
ASSERT_GE(i, 0);
EXPECT_EQ("Alcobendas", RES_CER(i).id);
EXPECT_EQ("City", RES_CER(i).type);
EXPECT_EQ("false", RES_CER(i).isPattern);
ASSERT_EQ(2, RES_CER(i).attributeVector.size());
EXPECT_EQ("foo", RES_CER_ATTR(i, 0)->name);
EXPECT_EQ("string", RES_CER_ATTR(i, 0)->type);
EXPECT_EQ("attr_Alc", RES_CER_ATTR(i, 0)->stringValue);
EXPECT_EQ("pos", RES_CER_ATTR(i, 1)->name);
EXPECT_EQ("location", RES_CER_ATTR(i, 1)->type);
EXPECT_EQ("40.533333, -3.633333", RES_CER_ATTR(i, 1)->stringValue);
ASSERT_EQ(1, RES_CER_ATTR(i, 1)->metadataVector.size());
EXPECT_EQ("location", RES_CER_ATTR(i, 1)->metadataVector[0]->name);
EXPECT_EQ("string", RES_CER_ATTR(i, 1)->metadataVector[0]->type);
EXPECT_EQ("WGS84", RES_CER_ATTR(i, 1)->metadataVector[0]->stringValue);
EXPECT_EQ(SccOk, RES_CER_STATUS(i).code);
EXPECT_EQ("OK", RES_CER_STATUS(i).reasonPhrase);
EXPECT_EQ(0, RES_CER_STATUS(i).details.size());

/* Release dynamic memory used by response (mongoBackend allocates it) */
res.contextElementResponseVector.release();

utExit();
}

/* ****************************************************************************
*
* queryGeoPolygonIn1 -
Expand Down

0 comments on commit b7cdb87

Please sign in to comment.