Skip to content

Commit

Permalink
Merge pull request #757 from FIWARE/bug/altitude-in-uri-param-for-get…
Browse files Browse the repository at this point in the history
…-entities

bug/altitude-in-uri-param-for-get-entities
  • Loading branch information
kzangeli committed Mar 12, 2021
2 parents 5b408e4 + d75a974 commit cfc861a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
* Issue #280 Important concurrency fix - avoiding to download the same context mopre than once
* Issue #737 Removed the check for forbidden characters in variable names in the 'q' URL parameter
* Issue #280 Fixed the response code and payload body of BATCH Delete
* Issue #280 GET /entities?coordinates=[] didn't allow for the altitude to be present
29 changes: 23 additions & 6 deletions src/lib/ngsi/Scope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

#include "ngsi/Scope.h"
#include "parse/forbiddenChars.h"
#include "orionld/common/orionldState.h"

using namespace orion;

Expand Down Expand Up @@ -354,13 +355,29 @@ int Scope::fill

coords = stringSplit(pointStringV[ix], ',', coordV);

if ((coords != 2) && (geometry.areaType == "point"))
if (geometry.areaType == "point")
{
*errorStringP = "invalid coordinates for point";
LM_E(("geometry.parse: %s (%d coords)", errorStringP->c_str(), coords));
pointVectorRelease(pointV);
pointV.clear();
return -1;
//
// NGSIv2 only allows for 2 coords (no altitude) while NGSI-LD allows for 2 or three
//
bool error = false;

if (orionldState.apiVersion == NGSI_LD_V1)
{
if ((coords != 2) && (coords != 3))
error = true;
}
else if (coords != 2)
error = true;

if (error == true)
{
*errorStringP = "invalid coordinates for point";
LM_E(("geometry.parse: %s (%d coords)", errorStringP->c_str(), coords));
pointVectorRelease(pointV);
pointV.clear();
return -1;
}
}

if (coords < 2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ echo

echo "04. Geoquery with Max Distance 15 - nothing found"
echo "================================================="
orionCurl --url '/ngsi-ld/v1/entities?type=T_City&geometry=Point&coordinates=\[-3.7,40.4\]&georel=near;maxDistance==15'
orionCurl --url '/ngsi-ld/v1/entities?type=T_City&geometry=Point&coordinates=\[-3.7,40.4,0\]&georel=near;maxDistance==15'
echo
echo

Expand Down

0 comments on commit cfc861a

Please sign in to comment.