0

I am attempting to transition from text/HTML to application/JSON info_format in my GetFeatureInfo requests. The issue I'm running into is that when I use a GetFeatureInfo request with a PostgreSQL view the properties are returned in alphabetical order as opposed to the ordering specified in the view. This is not the case when I use GetFeatureInfo on a table or when I use the text/HTML info_format on a PostgreSQL view.

Does anyone know a way around this?

3
  • You really can't control the order without an ORDER BY in the query. The result set is unordered, and therefore equivalent. If you need a specific order, can't you apply it afterwards?
    – Vince
    Commented Dec 24, 2021 at 1:57
  • I suppose that the question is not about ordering the features but the attributes geometry, attr_1, attr_2 vs. geometry, attr_2, attr_1.
    – user30184
    Commented Dec 24, 2021 at 9:23
  • Yes, I'm talking about ordering the properties not the features.
    – giscoder12
    Commented Dec 25, 2021 at 2:13

1 Answer 1

1

That's an artefact of the way the JSON code loops over the attributes, however since you are expected to do something with the returned JSON it doesn't really matter what order it is returned in.

If it is absolutely essential to have a fixed order (i.e. you have a very dumb client) then you can write a FreeMarker template to enforce it.

1
  • This looks like it will work, thanks. The client is very dumb on purpose (I prefer to think of it as generic) so that I can specify which fields to include as well as the ordering of the fields with views at the database level.
    – giscoder12
    Commented Dec 25, 2021 at 2:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.