File tree Expand file tree Collapse file tree 9 files changed +66
-4
lines changed
jupytergis_core/src/jgisplugin Expand file tree Collapse file tree 9 files changed +66
-4
lines changed Original file line number Diff line number Diff line change @@ -410,6 +410,35 @@ export function addCommands(
410
410
} ,
411
411
} ) ;
412
412
413
+ commands . addCommand ( CommandIDs . boundingBoxes , {
414
+ label : trans . __ ( 'Bounding Boxes' ) ,
415
+ isEnabled : ( ) => selectedLayerIsOfType ( [ 'VectorLayer' ] , tracker ) ,
416
+ execute : async ( ) => {
417
+ await processSelectedLayer (
418
+ tracker ,
419
+ formSchemaRegistry ,
420
+ 'BoundingBoxes' ,
421
+ {
422
+ sqlQueryFn : ( layerName , _ ) => `
423
+ SELECT ST_Envelope(geometry) AS geometry, *
424
+ FROM "${ layerName } "
425
+ ` ,
426
+ gdalFunction : 'ogr2ogr' ,
427
+ options : ( sqlQuery : string ) => [
428
+ '-f' ,
429
+ 'GeoJSON' ,
430
+ '-dialect' ,
431
+ 'SQLITE' ,
432
+ '-sql' ,
433
+ sqlQuery ,
434
+ 'output.geojson' ,
435
+ ] ,
436
+ } ,
437
+ app ,
438
+ ) ;
439
+ } ,
440
+ } ) ;
441
+
413
442
commands . addCommand ( CommandIDs . newGeoJSONEntry , {
414
443
label : trans . __ ( 'New GeoJSON layer' ) ,
415
444
isEnabled : ( ) => {
Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ export namespace CommandIDs {
41
41
export const buffer = 'jupytergis:buffer' ;
42
42
export const dissolve = 'jupytergis:dissolve' ;
43
43
export const centroids = 'jupytergis:centroids' ;
44
+ export const boundingBoxes = 'jupytergis:boundingBoxes' ;
44
45
45
46
// Layer and group actions
46
47
export const renameLayer = 'jupytergis:renameLayer' ;
Original file line number Diff line number Diff line change @@ -22,7 +22,12 @@ export interface IProcessingFormDialogOptions extends IBaseFormProps {
22
22
parentType : 'dialog' | 'panel' ,
23
23
) => void ;
24
24
model : IJupyterGISModel ;
25
- processingType : 'Buffer' | 'Dissolve' | 'Export' | 'Centroids' ;
25
+ processingType :
26
+ | 'Buffer'
27
+ | 'Dissolve'
28
+ | 'Export'
29
+ | 'Centroids'
30
+ | 'BoundingBoxes' ;
26
31
}
27
32
28
33
/**
@@ -57,6 +62,7 @@ const ProcessingFormWrapper = (props: IProcessingFormWrapperProps) => {
57
62
case 'Buffer' :
58
63
case 'Export' :
59
64
case 'Centroids' :
65
+ case 'BoundingBoxes' :
60
66
default :
61
67
FormComponent = BaseForm ;
62
68
}
Original file line number Diff line number Diff line change @@ -91,7 +91,7 @@ export type GdalFunctions =
91
91
export async function processSelectedLayer (
92
92
tracker : JupyterGISTracker ,
93
93
formSchemaRegistry : IJGISFormSchemaRegistry ,
94
- processingType : 'Buffer' | 'Dissolve' | 'Centroids' ,
94
+ processingType : 'Buffer' | 'Dissolve' | 'Centroids' | 'BoundingBoxes' ,
95
95
processingOptions : {
96
96
sqlQueryFn : ( layerName : string , param : any ) => string ;
97
97
gdalFunction : GdalFunctions ;
@@ -154,6 +154,9 @@ export async function processSelectedLayer(
154
154
case 'Centroids' :
155
155
processParam = null ;
156
156
break ;
157
+ case 'BoundingBoxes' :
158
+ processParam = null ;
159
+ break ;
157
160
default :
158
161
console . error ( `Unsupported processing type: ${ processingType } ` ) ;
159
162
return ;
@@ -195,7 +198,7 @@ export async function executeSQLProcessing(
195
198
gdalFunction : GdalFunctions ,
196
199
options : string [ ] ,
197
200
layerNamePrefix : string ,
198
- processingType : 'Buffer' | 'Dissolve' | 'Centroids' ,
201
+ processingType : 'Buffer' | 'Dissolve' | 'Centroids' | 'BoundingBoxes' ,
199
202
embedOutputLayer : boolean ,
200
203
tracker : JupyterGISTracker ,
201
204
app : JupyterFrontEnd ,
Original file line number Diff line number Diff line change
1
+ {
2
+ "type" : " object" ,
3
+ "description" : " BoundingBoxes" ,
4
+ "title" : " IBoundingBoxes" ,
5
+ "required" : [" inputLayer" ],
6
+ "additionalProperties" : false ,
7
+ "properties" : {
8
+ "inputLayer" : {
9
+ "type" : " string" ,
10
+ "description" : " The input layer for bounding boxes."
11
+ }
12
+ }
13
+ }
Original file line number Diff line number Diff line change 7
7
"properties" : {
8
8
"inputLayer" : {
9
9
"type" : " string" ,
10
- "description" : " The input layer for buffering ."
10
+ "description" : " The input layer for centroids ."
11
11
}
12
12
}
13
13
}
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ export * from './_interface/project/layers/heatmapLayer';
23
23
export * from './_interface/processing/buffer' ;
24
24
export * from './_interface/processing/dissolve' ;
25
25
export * from './_interface/processing/centroids' ;
26
+ export * from './_interface/processing/boundingBoxes' ;
26
27
27
28
// exportLayer
28
29
export * from './_interface/export/exportGeojson' ;
Original file line number Diff line number Diff line change @@ -244,6 +244,11 @@ const activate = async (
244
244
command : CommandIDs . centroids ,
245
245
category : 'JupyterGIS' ,
246
246
} ) ;
247
+
248
+ palette . addItem ( {
249
+ command : CommandIDs . boundingBoxes ,
250
+ category : 'JupyterGIS' ,
251
+ } ) ;
247
252
}
248
253
} ;
249
254
Original file line number Diff line number Diff line change @@ -161,6 +161,10 @@ const plugin: JupyterFrontEndPlugin<void> = {
161
161
command : CommandIDs . centroids ,
162
162
} ) ;
163
163
164
+ processingSubmenu . addItem ( {
165
+ command : CommandIDs . boundingBoxes ,
166
+ } ) ;
167
+
164
168
app . contextMenu . addItem ( {
165
169
type : 'submenu' ,
166
170
selector : '.jp-gis-layerItem' ,
You can’t perform that action at this time.
0 commit comments