Example 2 - Geographic
Filter by location and sort the results
This example demonstrates how to build the following query in the AQS Builder:
Fetch all bollards within this area, sorted by unit number.
In AQS terms:
Fetch items of the Bollards design where their Geometry attribute is within a defined area, sorted by their Unit Number attribute in Ascending order.
1 Configure the root node
Select the root node and set:
- AQS Type - AQS Query
- Design or interface - Bollards
- Collection - Live
- Sorting - Ascending
- Sort attribute - Unit Number
- Attributes - Title, Subtitle, Unit Number
2 Add the comparison
Select Add node and choose Within.
To include items that only partly overlap your area, use Intersects instead. To find everything outside it, use Disjoint. See Geographic comparisons.
3 Read the item geometry
Select the left segment and choose Attribute. It defaults to the standard Geometry attribute, which is what we want here.
4 Define the area
Select the right segment, choose GeoJSON, then No geometry.
Select Set geometry to open the Geometry Editor and draw your area, or select Locations of interest to use a predefined area. Select Save.
5 Finish
Select Done (bottom-left) to finish.
See JSON code
This code may reference designs, interfaces, attributes or items that don't exist in your company project.
{
"type": "Query",
"properties": {
"attributes": ["attributes_itemsTitle", "attributes_itemsSubtitle", "attributes_streetLightingUnitsUnitNumber"],
"collectionCode": ["Live"],
"dodiCode": "designs_bollards",
"sortInfo": {
"attributeCode": "attributes_streetLightingUnitsUnitNumber",
"sortOrder": "Ascending"
}
},
"children": [
{
"type": "GeomWithin",
"children": [
{
"type": "Attribute",
"properties": {
"attributeCode": "attributes_itemsGeometry"
}
},
{
"type": "Geometry",
"properties": {
"value": {
"type": "Polygon",
"coordinates": [
[
[-1.528451, 52.291276],
[-1.532371, 52.290544],
[-1.535095, 52.288647],
[-1.534088, 52.28752],
[-1.527428, 52.290062],
[-1.528451, 52.291276]
]
]
}
}
}
]
}
]
}