Skip to content

Commit 6d24c24

Browse files
committed
#666 touchups
1 parent c785727 commit 6d24c24

File tree

11 files changed

+270
-84
lines changed

11 files changed

+270
-84
lines changed

API/Backend/Geodatasets/routes/geodatasets.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,6 @@ function get(reqtype, req, res, next) {
9898
}
9999
}
100100

101-
console.log(spatialFilter);
102-
console.log(filters);
103-
104101
//First Find the table name
105102
Geodatasets.findOne({ where: { name: layer } })
106103
.then((result) => {
@@ -138,10 +135,6 @@ function get(reqtype, req, res, next) {
138135
table
139136
)}`;
140137

141-
if (req.query?.limited) {
142-
q += ` ORDER BY id DESC LIMIT 3`;
143-
}
144-
145138
let hasBounds = false;
146139
let minx = req.query?.minx;
147140
let miny = req.query?.miny;
@@ -210,11 +203,11 @@ function get(reqtype, req, res, next) {
210203

211204
if (get_group_id != null) {
212205
q += `${
213-
q.indexOf(" WHERE ") == -1 ? " WHERE " : " AND "
206+
q.indexOf(" WHERE ") === -1 ? " WHERE " : " AND "
214207
}group_id = :get_group_id`;
215208
} else if (get_id != null) {
216209
q += `${
217-
q.indexOf(" WHERE ") == -1 ? " WHERE " : " AND "
210+
q.indexOf(" WHERE ") === -1 ? " WHERE " : " AND "
218211
}id = :get_id`;
219212
}
220213

@@ -280,9 +273,12 @@ function get(reqtype, req, res, next) {
280273
}${filterSQL.join(` AND `)}`;
281274
}
282275

276+
if (req.query?.limited) {
277+
q += ` ORDER BY id DESC LIMIT 3`;
278+
}
279+
283280
q += `;`;
284281

285-
console.log(q);
286282
sequelize
287283
.query(q, {
288284
replacements: replacements,
@@ -538,7 +534,7 @@ router.get("/aggregations", function (req, res, next) {
538534
q += t;
539535
}
540536

541-
q += ` ORDER BY id DESC LIMIT :limit;`;
537+
q += ` ORDER BY RANDOM() DESC LIMIT :limit;`;
542538

543539
sequelize
544540
.query(q, {

configure/src/metaconfigs/layer-query-config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -925,10 +925,10 @@
925925
]
926926
},
927927
{
928-
"name": "Behavior",
928+
"name": "Performance",
929929
"rows": [
930930
{
931-
"name": "Behavior",
931+
"name": "Performance",
932932
"subname": "Dynamic Extent",
933933
"components": [
934934
{

configure/src/metaconfigs/layer-vector-config.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -845,12 +845,11 @@
845845
}
846846
]
847847
},
848-
849848
{
850-
"name": "Behavior",
849+
"name": "Performance",
851850
"rows": [
852851
{
853-
"name": "Behavior",
852+
"name": "Performance",
854853
"subname": "Dynamic Extent",
855854
"components": [
856855
{

configure/src/metaconfigs/layer-vectortile-config.json

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -824,26 +824,6 @@
824824
"rows": [
825825
{
826826
"name": "Behavior",
827-
"subname": "Dynamic Extent",
828-
"components": [
829-
{
830-
"field": "variables.dynamicExtent",
831-
"name": "Enabled",
832-
"description": "If true, tries to only query the vector features present in the user's current map viewport. This can be very performant for large vector datasets especially if minimum and maximum zooms are set for the layer. Pan and zooming causes requeries. If used with a geodataset, the time and extent queries will work out-of-the-box. Otherwise, if using an external server, the following parameters in {} will be automatically replaced on query in the url: 'starttime={starttime}&endtime={endtime}&startprop={startprop}&endprop={endprop}&crscode={crscode}&zoom={zoom}&minx={minx}&miny={miny}&maxx={maxx}&maxy={maxy}'. This setting is not advised if the data source is a straight geojson file because it expects a server that can crop the data to given extents.",
833-
"type": "switch",
834-
"width": 3,
835-
"defaultChecked": false
836-
},
837-
{
838-
"field": "variables.dynamicExtentMoveThreshold",
839-
"name": "Threshold",
840-
"description": "If dynamicExtent is true, only requery if the map was panned past the stated threshold. Unit is in meters. If a zoom-dependent threshold is desired, set this value to a string ending in '/z'. This will then internally use 'dynamicExtentMoveThreshold / Math.pow(2, zoom)' as the threshold value.",
841-
"type": "text",
842-
"width": 3
843-
}
844-
]
845-
},
846-
{
847827
"subname": "Miscellaneous",
848828
"components": [
849829
{

docs/mmgis-openapi.json

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2531,6 +2531,16 @@
25312531
"type": "string"
25322532
}
25332533
},
2534+
{
2535+
"name": "filters",
2536+
"in": "query",
2537+
"description": "Filter based on feature properties. The input is of the form: key+op+type+value,key+op+type+value,... 'key' is a properties field key. 'op' is '>', '<', '=', or 'in'. If 'op' is 'in', 'value' is a list separated by dollar signs. 'type' is either 'string' or 'number'.",
2538+
"example": "passDirection+=+string+Ascending,fractionLand+<+number+0.10274648744404924",
2539+
"required": false,
2540+
"schema": {
2541+
"type": "string"
2542+
}
2543+
},
25342544
{
25352545
"name": "limited",
25362546
"in": "query",
@@ -2753,6 +2763,16 @@
27532763
"type": "string"
27542764
}
27552765
},
2766+
{
2767+
"name": "filters",
2768+
"in": "query",
2769+
"description": "Filter based on feature properties. The input is of the form: key+op+type+value,key+op+type+value,... 'key' is a properties field key. 'op' is '>', '<', '=', or 'in'. If 'op' is 'in', 'value' is a list separated by dollar-signs. 'type' is either 'string' or 'number'.",
2770+
"example": "passDirection+=+string+Ascending,fractionLand+<+number+0.10274648744404924",
2771+
"required": false,
2772+
"schema": {
2773+
"type": "string"
2774+
}
2775+
},
27562776
{
27572777
"name": "limited",
27582778
"in": "query",
@@ -2982,6 +3002,139 @@
29823002
}
29833003
}
29843004
},
3005+
"/api/geodatasets/aggregations": {
3006+
"get": {
3007+
"summary": "Return the histograms/aggregations of values for the feature properties within a GeoDataset.",
3008+
"tags": ["GeoDatasets"],
3009+
"parameters": [
3010+
{
3011+
"name": "layer",
3012+
"in": "query",
3013+
"description": "The name of a GeoDataset for which to get aggregations.",
3014+
"example": "ExampleGeoDataset",
3015+
"required": true,
3016+
"schema": {
3017+
"type": "string"
3018+
}
3019+
},
3020+
{
3021+
"name": "limit",
3022+
"in": "query",
3023+
"description": "Construct the aggregations based on a random sample of 'limit' features. Default 500",
3024+
"example": 100,
3025+
"required": false,
3026+
"schema": {
3027+
"type": "integer"
3028+
}
3029+
},
3030+
{
3031+
"name": "minx",
3032+
"in": "query",
3033+
"description": "If only a certain spatial extent is desired, the minimum x/longitude of such bounding box.",
3034+
"example": -83.6,
3035+
"required": false,
3036+
"schema": {
3037+
"type": "number"
3038+
}
3039+
},
3040+
{
3041+
"name": "miny",
3042+
"in": "query",
3043+
"description": "If only a certain spatial extent is desired, the minimum y/latitude of such bounding box.",
3044+
"example": -23.8,
3045+
"required": false,
3046+
"schema": {
3047+
"type": "number"
3048+
}
3049+
},
3050+
{
3051+
"name": "maxx",
3052+
"in": "query",
3053+
"description": "If only a certain spatial extent is desired, the maximum x/longitude of such bounding box.",
3054+
"example": -32.6,
3055+
"required": false,
3056+
"schema": {
3057+
"type": "number"
3058+
}
3059+
},
3060+
{
3061+
"name": "maxy",
3062+
"in": "query",
3063+
"description": "If only a certain spatial extent is desired, the maximum y/latitude of such bounding box.",
3064+
"example": 10.5,
3065+
"required": false,
3066+
"schema": {
3067+
"type": "number"
3068+
}
3069+
},
3070+
{
3071+
"name": "starttime",
3072+
"in": "query",
3073+
"description": "If only a certain temporal extent is desired, the start time of the window. If unset but 'endtime' is set, defaults to '1970-01-01T00:00:00Z'",
3074+
"example": "2024-08-01T00:00:00.000Z",
3075+
"required": false,
3076+
"schema": {
3077+
"type": "string"
3078+
}
3079+
},
3080+
{
3081+
"name": "endtime",
3082+
"in": "query",
3083+
"description": "If only a certain temporal extent is desired, the end time of the window.",
3084+
"example": "2025-04-03T21:55:06.013Z",
3085+
"required": false,
3086+
"schema": {
3087+
"type": "string"
3088+
}
3089+
}
3090+
],
3091+
"responses": {
3092+
"200": {
3093+
"description": "GeoDataset aggregations",
3094+
"content": {
3095+
"application/json": {
3096+
"examples": {
3097+
"success": {
3098+
"summary": "Success",
3099+
"value": {
3100+
"status": "success",
3101+
"aggregations": [
3102+
{
3103+
"passDirection": {
3104+
"type": "string",
3105+
"aggs": { "Descending": 252, "Ascending": 248 }
3106+
}
3107+
},
3108+
{
3109+
"crossesDateline": {
3110+
"type": "boolean",
3111+
"aggs": { "true": 2, "false": 498 }
3112+
}
3113+
}
3114+
]
3115+
}
3116+
},
3117+
"failure": {
3118+
"summary": "Failure",
3119+
"value": {
3120+
"status": "failure",
3121+
"message": "Failure querying geodataset aggregations"
3122+
}
3123+
},
3124+
"not_found": {
3125+
"summary": "Not Found",
3126+
"value": {
3127+
"status": "failure",
3128+
"message": "Not Found"
3129+
}
3130+
}
3131+
}
3132+
}
3133+
}
3134+
}
3135+
}
3136+
}
3137+
},
29853138
"/api/geodatasets/append/{name}": {
29863139
"post": {
29873140
"summary": "Append to a geodataset",

src/essence/Basics/Layers_/Filtering/GeodatasetFilterer.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,32 @@ const GeodatasetFilterer = {
6666
filter: function (layerName, filter, refreshFunction) {
6767
L_.layers.data[layerName]._stopLoops = true
6868
L_.layers.data[layerName]._filter = filter
69+
L_.layers.data[layerName]._filterEncoded = {}
70+
if (L_.layers.data[layerName]._filter) {
71+
let fspatial = L_.layers.data[layerName]._filter.spatial
72+
let fvalues = L_.layers.data[layerName]._filter.values
73+
if (fspatial != null && fspatial.radius > 0)
74+
L_.layers.data[
75+
layerName
76+
]._filterEncoded.spatialFilter = `${fspatial.center.lat},${fspatial.center.lng},${fspatial.radius}`
77+
78+
if (fvalues != null && fvalues.length > 0) {
79+
fvalues = fvalues.filter(Boolean)
80+
81+
if (fvalues.length > 0) {
82+
let encoded = []
83+
fvalues.forEach((v) => {
84+
encoded.push(
85+
`${v.key}+${v.op === ',' ? 'in' : v.op}+${
86+
v.type
87+
}+${v.value.replaceAll(',', '$')}`
88+
)
89+
})
90+
L_.layers.data[layerName]._filterEncoded.filters =
91+
encoded.join(',')
92+
}
93+
}
94+
}
6995
L_.Map_.refreshLayer(L_.layers.data[layerName])
7096
},
7197
match: function (feature, filter) {

src/essence/Basics/Layers_/LayerCapturer.js

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ export const captureVector = (layerObj, options, cb, dynamicCb) => {
109109
_source:
110110
layerData?.variables
111111
?.getFeaturePropertiesOnClick === true
112-
? ['group_id', 'feature_id'].concat(
113-
L_.getDynamicProps(layerData)
114-
)
112+
? ['group_id', 'feature_id']
113+
.concat(L_.getDynamicProps(layerData))
114+
.filter(Boolean)
115115
: null,
116116
}
117117

@@ -129,31 +129,11 @@ export const captureVector = (layerObj, options, cb, dynamicCb) => {
129129
}
130130

131131
// filters
132-
if (layerData._filter) {
133-
let fspatial = layerData._filter.spatial
134-
let fvalues = layerData._filter.values
135-
if (fspatial != null && fspatial.radius > 0)
136-
body.spatialFilter = `${fspatial.center.lat},${fspatial.center.lng},${fspatial.radius}`
137-
138-
if (fvalues != null && fvalues.length > 0) {
139-
fvalues = fvalues.filter(Boolean)
140-
141-
if (fvalues.length > 0) {
142-
let encoded = []
143-
fvalues.forEach((v) => {
144-
encoded.push(
145-
`${v.key}+${
146-
v.op === ',' ? 'in' : v.op
147-
}+${v.type}+${v.value.replaceAll(
148-
',',
149-
'$'
150-
)}`
151-
)
152-
})
153-
body.filters = encoded.join(',')
154-
}
155-
}
156-
}
132+
if (layerData._filterEncoded?.filters)
133+
body.filters = layerData._filterEncoded.filters
134+
if (layerData._filterEncoded?.spatialFilter)
135+
body.spatialFilter =
136+
layerData._filterEncoded.spatialFilter
157137

158138
const dateNow = new Date().getTime()
159139

@@ -420,9 +400,9 @@ export const captureVector = (layerObj, options, cb, dynamicCb) => {
420400
body.noDuplicates = layerData?.variables?.noDuplicates === true
421401
body._source =
422402
layerData?.variables?.getFeaturePropertiesOnClick === true
423-
? ['group_id', 'feature_id'].concat(
424-
L_.getDynamicProps(layerData)
425-
)
403+
? ['group_id', 'feature_id']
404+
.concat(L_.getDynamicProps(layerData))
405+
.filter(Boolean)
426406
: null
427407
layerData._lastGeodatasetRequestBody = body
428408
calls.api(

0 commit comments

Comments
 (0)