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

Multiple Locations #52

Closed
smilehappy126 opened this issue May 3, 2018 · 14 comments
Closed

Multiple Locations #52

smilehappy126 opened this issue May 3, 2018 · 14 comments

Comments

@smilehappy126
Copy link

Hello,

I try to connect several Locations to one Thing through HTTP, however, the second location keep overwrite the first one and make this Thing's Location remain one location.

Did anyone occur same problem or solve it?

Any help will be appreciated. Thanks a lot.

@hylkevds
Copy link
Member

hylkevds commented May 3, 2018

A Thing can only have 1 real-world location. Therefore, if you add a new Location to a Thing, the old location is automatically removed.
A Thing can have multiple Location entities, but they have to be different encodings of the same real-world location.
To link these multiple Location entities to the Thing, you have to link them all in the same request.

@smilehappy126
Copy link
Author

Hi,
Thanks for replying. I've tried create new Things through Postman and link to two existed location as below.
image

However, I'd like to create Thing and also create two new Locations link it at the same times. I'd try to POST like this:
image

But the "test2" Location just automatically overwrite "test1" Location.
Am I missing something?

Thanks for any advices!

@hylkevds
Copy link
Member

hylkevds commented May 3, 2018

Your test2 JSON is not valid.
A JSON object is a set of key-value pairs, and each key is only allowed to exist once. Your test2 JSON has the key "Locations" twice, and thus only one of the two is ever available.

@smilehappy126
Copy link
Author

Hi,
Successfully create. However, it seems to be considered as one Location with two kinds of descriptions.
How can I create two different Locations Object just in one request.
image

Thanks for answering.

@hylkevds
Copy link
Member

hylkevds commented May 3, 2018

That JSON looks fine to me. Locations is an array, with two objects in it.
If you format your JSON properly it'll be easier to recognise.

@smilehappy126
Copy link
Author

Thanks a lot. The problem is fixed.

@smilehappy126
Copy link
Author

Hi,
Now with the Multiple Location, it seems that Observation can't automatically link Location as it's FeatureOfInterest.
How can I let the server automatically use the first Location object in Location Array as the Observation's FeatureOfInterest?

Thanks for answering.

@hylkevds hylkevds reopened this May 13, 2018
@hylkevds
Copy link
Member

Hmm, it seems it fetches the first Location it finds in the database. If that happens to be one of the non-geoJSON Locations, it'll fail. Which error message do you get?

@hylkevds hylkevds added the bug label May 13, 2018
@smilehappy126
Copy link
Author

This is how the Locations Table looks like in my PostgreSQL:
image
And the error code was "HTTP code 500", using Eclipse :
image

@hylkevds
Copy link
Member

Ok, that's the client side error, do you happen to have the server-side exception from the server logs?

@hylkevds
Copy link
Member

It should work in the master branch now.

@smilehappy126
Copy link
Author

Thanks for fixed it, the problem of FeatureOfInterest was solved.
However, there's something bad happened.

image
As the pic shows, the Location which was selected to be Observation's FeatureOfInterest disappeared in the /v1.0/Location, but it still remain in postgre's Location Table.
image

@hylkevds
Copy link
Member

Can you add an orderby to that query, to make sure it isn't somewhere else in the result set? Without an explicit orderby you never know which oder PostgreSQL gives you the results.

@smilehappy126
Copy link
Author

Oh, I found it when I orderby "@iot.id". Thanks a lot !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants