OrdnanceSurvey / osdatahub-js

A JavaScript package from Ordnance Survey, designed to make data from the OS Data Hub APIs readily accessible to developers.
https://www.npmjs.com/package/osdatahub
Other
7 stars 1 forks source link

Feature collection filtering by properties with enumeration missing #61

Open buildvoc10 opened 1 year ago

buildvoc10 commented 1 year ago

Good afternoon

  1. Have deployed OS NGD API – Features Retrieve items from a feature collection, I noticed that https://labs.os.uk/public/osngd/os-ngd-api-features/examples/queryables.html has the filters built into query, how do I update my app to include these filters? image

  2. Where in the code do I change the location of bbox? (greyed out) image

Thanks for making code open source really helpful in development of building-height.co.uk Building-Height is a system that can determine the attributes of historical buildings in England. The building part can be defined just by uploading a photo. If you would like to try the app here is a link to an example image in Farnham, Surrey. (currently only have a couple thousand OS polygons footprints in our database for testing.

tmnnrs commented 4 months ago

Hi @buildvoc10. Thanks for the feedback (and glad to hear that the resources have been helpful).

You will probably be interested in the /queryables endpoint for the service. This defines which properties can be filtered for the requested feature collection (using the filter query parameter). The examples demonstrate how to filter by the properties with enumerated values (however you can also filter by text strings or integers). You might find that https://labs.os.uk/public/osngd/tutorials/filtering-and-cql is a useful resource to better help understand filtering using CQL.

The bounding box (BBOX) can be defined using the bbox query parameter. For the purpose of the examples we have disabled this option to use a predefined/restricted extent; but in practice the value would be important in limiting your responses to the area of interest (otherwise features will be returned across the whole of GB).

Using theosdatahub-js wrapper you can implement the filter and bbox query parameters as follows: osdatahub.ngd.features("INSERT_API_KEY_HERE", "bld-fts-buildingpart", { bbox: [-3.545022,50.727083,-3.538596,50.728095], filter: "description = 'Building'", limit: 1000 })