@eeacms/volto-arcgis-block 0.1.272 → 0.1.273
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
4
4
|
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
6
|
|
|
7
|
+
### [0.1.273](https://github.com/eea/volto-arcgis-block/compare/0.1.272...0.1.273) - 10 April 2024
|
|
8
|
+
|
|
9
|
+
#### :hammer_and_wrench: Others
|
|
10
|
+
|
|
11
|
+
- CLMS-3172 (bug): re-projected file upload area extent to spatial reference wkid 4326 lat/long [Unai Bolivar - [`164cbca`](https://github.com/eea/volto-arcgis-block/commit/164cbcad7a035c85e77b2c545a331629a0cb8fbd)]
|
|
7
12
|
### [0.1.272](https://github.com/eea/volto-arcgis-block/compare/0.1.271...0.1.272) - 10 April 2024
|
|
8
13
|
|
|
9
14
|
#### :hammer_and_wrench: Others
|
package/package.json
CHANGED
|
@@ -9,10 +9,11 @@ var Graphic,
|
|
|
9
9
|
Field,
|
|
10
10
|
GroupLayer,
|
|
11
11
|
Color,
|
|
12
|
-
|
|
12
|
+
projection,
|
|
13
13
|
request,
|
|
14
14
|
SimpleLineSymbol,
|
|
15
|
-
SimpleFillSymbol
|
|
15
|
+
SimpleFillSymbol,
|
|
16
|
+
SpatialReference;
|
|
16
17
|
|
|
17
18
|
class AreaWidget extends React.Component {
|
|
18
19
|
/**
|
|
@@ -58,10 +59,11 @@ class AreaWidget extends React.Component {
|
|
|
58
59
|
'esri/layers/support/Field',
|
|
59
60
|
'esri/layers/GroupLayer',
|
|
60
61
|
'esri/Color',
|
|
61
|
-
|
|
62
|
+
'esri/geometry/projection',
|
|
62
63
|
'esri/request',
|
|
63
64
|
'esri/symbols/SimpleLineSymbol',
|
|
64
65
|
'esri/symbols/SimpleFillSymbol',
|
|
66
|
+
'esri/geometry/SpatialReference',
|
|
65
67
|
]).then(
|
|
66
68
|
([
|
|
67
69
|
_Graphic,
|
|
@@ -71,10 +73,11 @@ class AreaWidget extends React.Component {
|
|
|
71
73
|
_Field,
|
|
72
74
|
_GroupLayer,
|
|
73
75
|
_Color,
|
|
74
|
-
|
|
76
|
+
_projection,
|
|
75
77
|
_request,
|
|
76
78
|
_SimpleLineSymbol,
|
|
77
79
|
_SimpleFillSymbol,
|
|
80
|
+
_SpatialReference,
|
|
78
81
|
]) => {
|
|
79
82
|
[
|
|
80
83
|
Graphic,
|
|
@@ -84,10 +87,11 @@ class AreaWidget extends React.Component {
|
|
|
84
87
|
Field,
|
|
85
88
|
GroupLayer,
|
|
86
89
|
Color,
|
|
87
|
-
|
|
90
|
+
projection,
|
|
88
91
|
request,
|
|
89
92
|
SimpleLineSymbol,
|
|
90
93
|
SimpleFillSymbol,
|
|
94
|
+
SpatialReference,
|
|
91
95
|
] = [
|
|
92
96
|
_Graphic,
|
|
93
97
|
_Extent,
|
|
@@ -96,10 +100,11 @@ class AreaWidget extends React.Component {
|
|
|
96
100
|
_Field,
|
|
97
101
|
_GroupLayer,
|
|
98
102
|
_Color,
|
|
99
|
-
|
|
103
|
+
_projection,
|
|
100
104
|
_request,
|
|
101
105
|
_SimpleLineSymbol,
|
|
102
106
|
_SimpleFillSymbol,
|
|
107
|
+
_SpatialReference,
|
|
103
108
|
];
|
|
104
109
|
},
|
|
105
110
|
);
|
|
@@ -223,7 +228,6 @@ class AreaWidget extends React.Component {
|
|
|
223
228
|
}
|
|
224
229
|
|
|
225
230
|
loadCountriesService(id) {
|
|
226
|
-
//debugger;
|
|
227
231
|
document.querySelector('.esri-attribution__powered-by').style.display =
|
|
228
232
|
'flex';
|
|
229
233
|
var layer = new FeatureLayer({
|
|
@@ -256,13 +260,12 @@ class AreaWidget extends React.Component {
|
|
|
256
260
|
handleFileUpload = (e) => {
|
|
257
261
|
//Get the file name
|
|
258
262
|
const fileName = e.target.value.toLowerCase();
|
|
259
|
-
//console.log('file name: ', fileName);
|
|
260
263
|
|
|
261
264
|
//Get the file size
|
|
262
265
|
const fileSize = e.target.files[0].size;
|
|
266
|
+
|
|
263
267
|
//Get the file from the form
|
|
264
268
|
const file = document.getElementById('uploadForm');
|
|
265
|
-
//console.log('uploaded file from form: ', file);
|
|
266
269
|
|
|
267
270
|
//List allowed file extensions
|
|
268
271
|
|
|
@@ -271,11 +274,9 @@ class AreaWidget extends React.Component {
|
|
|
271
274
|
// Get the file extension
|
|
272
275
|
let fileExtension = fileName.split('.').pop();
|
|
273
276
|
|
|
274
|
-
//console.log('file extension: ', fileExtension);
|
|
275
277
|
//Check if the file format is not supported
|
|
276
278
|
|
|
277
279
|
if (fileExtensions.indexOf(fileExtension) === -1) {
|
|
278
|
-
//if (fileExtension !== 'zip') {
|
|
279
280
|
this.setState({
|
|
280
281
|
showInfoPopup: true,
|
|
281
282
|
infoPopupType: 'fileFormat',
|
|
@@ -283,7 +284,7 @@ class AreaWidget extends React.Component {
|
|
|
283
284
|
return;
|
|
284
285
|
}
|
|
285
286
|
|
|
286
|
-
// Check if the file is a geojson
|
|
287
|
+
// Check if the file is a geojson and the file size is over the 10mb file size limit
|
|
287
288
|
// or file is a shape file and the file size is over the 2mb file size limit
|
|
288
289
|
|
|
289
290
|
if (fileSize > 10485760 && fileExtension === 'geojson') {
|
|
@@ -308,7 +309,6 @@ class AreaWidget extends React.Component {
|
|
|
308
309
|
break;
|
|
309
310
|
case 'geojson':
|
|
310
311
|
this.generateFeatureCollection(fileName, file, 'geojson');
|
|
311
|
-
// //reader.readAsText(file);
|
|
312
312
|
break;
|
|
313
313
|
//case 'csv':
|
|
314
314
|
//this.generateFeatureCollection(
|
|
@@ -332,8 +332,6 @@ class AreaWidget extends React.Component {
|
|
|
332
332
|
// Chrome adds c:\fakepath to the value - we need to remove it
|
|
333
333
|
name = name[0].replace('c:\\fakepath\\', '');
|
|
334
334
|
|
|
335
|
-
//console.log('from generateFeatureCollection() name: ', name);
|
|
336
|
-
|
|
337
335
|
// define the input params for generate see the rest doc for details
|
|
338
336
|
// https://developers.arcgis.com/rest/users-groups-and-items/generate.htm
|
|
339
337
|
const params = {
|
|
@@ -362,10 +360,10 @@ class AreaWidget extends React.Component {
|
|
|
362
360
|
})
|
|
363
361
|
.then((response) => {
|
|
364
362
|
if (response.data && response.data.featureCollection) {
|
|
365
|
-
//console.log('response data: ', response.data);
|
|
366
363
|
//Check for more than a single feature
|
|
367
364
|
if (this.checkFeatureCount(response.data.featureCollection) === false)
|
|
368
365
|
return;
|
|
366
|
+
|
|
369
367
|
//Check that attributes and geometry are not null or undefined
|
|
370
368
|
if (
|
|
371
369
|
response.data.featureCollection.layers[0].featureSet.features[0]
|
|
@@ -383,10 +381,9 @@ class AreaWidget extends React.Component {
|
|
|
383
381
|
});
|
|
384
382
|
return;
|
|
385
383
|
}
|
|
384
|
+
|
|
386
385
|
//Create a feature layer from the feature collection
|
|
387
386
|
this.addFeatureCollectionToMap(response.data.featureCollection);
|
|
388
|
-
//console.log(data);
|
|
389
|
-
//this.loadFileUploadService(response.data.featureCollection);
|
|
390
387
|
} else {
|
|
391
388
|
//console.error('Unexpected response structure:', response);
|
|
392
389
|
}
|
|
@@ -394,6 +391,7 @@ class AreaWidget extends React.Component {
|
|
|
394
391
|
.catch((error) => {
|
|
395
392
|
if (
|
|
396
393
|
error &&
|
|
394
|
+
error.details &&
|
|
397
395
|
error.details.httpStatus === 400 &&
|
|
398
396
|
error.message === 'Invalid Shapefile: missing shp file.'
|
|
399
397
|
) {
|
|
@@ -406,27 +404,33 @@ class AreaWidget extends React.Component {
|
|
|
406
404
|
}
|
|
407
405
|
});
|
|
408
406
|
}
|
|
407
|
+
|
|
409
408
|
// add the feature collection to the map and zoom to the feature collection extent
|
|
410
409
|
// if you want to persist the feature collection when you reload browser, you could store the
|
|
411
410
|
// collection in local storage by serializing the layer using featureLayer.toJson()
|
|
412
411
|
// see the 'Feature Collection in Local Storage' sample for an example of how to work with local storage
|
|
413
412
|
addFeatureCollectionToMap(featureCollection) {
|
|
414
|
-
//console.log('feature collection: ', featureCollection);
|
|
415
413
|
let sourceGraphics = [];
|
|
416
|
-
const symbol = new SimpleFillSymbol({
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
});
|
|
414
|
+
//const symbol = new SimpleFillSymbol({
|
|
415
|
+
// //type: 'simple-fill',
|
|
416
|
+
// color: [255, 255, 255, 0.5],
|
|
417
|
+
// outline: {
|
|
418
|
+
// color: [0, 0, 0],
|
|
419
|
+
// width: 1,
|
|
420
|
+
// },
|
|
421
|
+
//});
|
|
422
|
+
|
|
423
|
+
//Create a graphic for each feature in the feature collection
|
|
424
|
+
|
|
424
425
|
const layers = featureCollection.layers.map((layer) => {
|
|
425
426
|
const graphics = layer.featureSet.features.map((feature) => {
|
|
426
|
-
feature.symbol = symbol;
|
|
427
|
+
//feature.symbol = symbol;
|
|
427
428
|
return Graphic.fromJSON(feature);
|
|
428
429
|
});
|
|
429
430
|
sourceGraphics = sourceGraphics.concat(graphics);
|
|
431
|
+
|
|
432
|
+
// Create a feature layer from the feature collection fields and gaphics
|
|
433
|
+
|
|
430
434
|
const featureLayer = new FeatureLayer({
|
|
431
435
|
// id: 9,
|
|
432
436
|
objectIdField: 'FID',
|
|
@@ -436,52 +440,18 @@ class AreaWidget extends React.Component {
|
|
|
436
440
|
fields: layer.layerDefinition.fields.map((field) => {
|
|
437
441
|
return Field.fromJSON(field);
|
|
438
442
|
}),
|
|
439
|
-
// layerId: 9,
|
|
440
|
-
// outFields: ['*'],
|
|
441
|
-
// popupEnabled: false,
|
|
442
443
|
});
|
|
443
|
-
//featureLayer.renderer = {
|
|
444
|
-
// type: 'simple-fill',
|
|
445
|
-
// color: [255, 255, 255, 0.5],
|
|
446
|
-
// outline: {
|
|
447
|
-
// color: [0, 0, 0],
|
|
448
|
-
// width: 1,
|
|
449
|
-
// },
|
|
450
|
-
//}
|
|
451
|
-
//featureLayer.renderer = {
|
|
452
|
-
// type: "simple", // autocasts as new SimpleRenderer()
|
|
453
|
-
// symbol: {
|
|
454
|
-
// type: "simple-fill", // autocasts as new SimpleMarkerSymbol()
|
|
455
|
-
// //size: 20,
|
|
456
|
-
// color: [255, 255, 255, 0.5],
|
|
457
|
-
// outline: { // autocasts as new SimpleLineSymbol()
|
|
458
|
-
// width: 1,
|
|
459
|
-
// color: [0, 0, 0]
|
|
460
|
-
// }
|
|
461
|
-
// }
|
|
462
|
-
//};
|
|
463
|
-
//featureLayer.renderer = {
|
|
464
|
-
// type: "simple", // autocasts as new SimpleRenderer()
|
|
465
|
-
// symbol: {
|
|
466
|
-
// type: "simple-fill", // autocasts as new SimpleMarkerSymbol()
|
|
467
|
-
// size: 20,
|
|
468
|
-
// color: "green",
|
|
469
|
-
// outline: { // autocasts as new SimpleLineSymbol()
|
|
470
|
-
// width: 4.5,
|
|
471
|
-
// color: "blue"
|
|
472
|
-
// }
|
|
473
|
-
// }
|
|
474
|
-
//};
|
|
475
444
|
return featureLayer;
|
|
476
445
|
});
|
|
446
|
+
|
|
477
447
|
//Check for the correct spatial reference
|
|
478
|
-
|
|
479
|
-
//if (this.checkWkid(layers[0]?.spatialReference) === false) return;
|
|
448
|
+
|
|
480
449
|
let geometry = new Extent(
|
|
481
450
|
featureCollection.layers[0].layerDefinition.extent,
|
|
482
451
|
);
|
|
483
452
|
|
|
484
453
|
//If checkExtent returns false, add the layer to the map
|
|
454
|
+
|
|
485
455
|
if (this.checkExtent(geometry.extent)) {
|
|
486
456
|
this.setState({
|
|
487
457
|
showInfoPopup: true,
|
|
@@ -489,45 +459,52 @@ class AreaWidget extends React.Component {
|
|
|
489
459
|
});
|
|
490
460
|
} else {
|
|
491
461
|
//Remove old uploaded file and save new one to component props for reference
|
|
462
|
+
|
|
492
463
|
this.removeFileUploadedLayer();
|
|
493
464
|
this.fileUploadLayer = { layers: layers, sourceGraphics: sourceGraphics };
|
|
465
|
+
|
|
494
466
|
//remove NUTS and COUNTRIES layers from map
|
|
467
|
+
|
|
495
468
|
this.removeNutsLayers();
|
|
496
469
|
|
|
497
470
|
//Add uploaded layer to the map and zoom to the extent
|
|
498
|
-
|
|
471
|
+
|
|
499
472
|
this.props.view.graphics.addMany(sourceGraphics);
|
|
500
473
|
this.props.view.goTo(sourceGraphics).catch((error) => {
|
|
501
474
|
//console.error('From addFeatureCollectionToMap function', error);
|
|
502
475
|
});
|
|
503
|
-
|
|
476
|
+
|
|
477
|
+
//Create a spatial reference object for the extent
|
|
478
|
+
|
|
479
|
+
let sr4326 = new SpatialReference({
|
|
480
|
+
wkid: 4326,
|
|
481
|
+
});
|
|
482
|
+
|
|
483
|
+
//Create a projection object for the extent
|
|
484
|
+
|
|
485
|
+
let latLongExtent = projection.project(geometry, sr4326);
|
|
486
|
+
|
|
504
487
|
//Send the area to the parent component
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
// y: geometry.extent.ymax,
|
|
512
|
-
//});
|
|
513
|
-
//debugger;
|
|
514
|
-
//this.props.updateArea({
|
|
515
|
-
// origin: { x: origin.longitude, y: origin.latitude },
|
|
516
|
-
// end: { x: end.longitude, y: end.latitude },
|
|
517
|
-
//});
|
|
518
|
-
// this.props.updateArea({
|
|
519
|
-
// origin: { x: geometry.xmin, y: geometry.ymin },
|
|
520
|
-
// end: { x: geometry.xmax, y: geometry.ymax },
|
|
521
|
-
// });
|
|
522
|
-
//debugger;
|
|
523
|
-
this.props.updateArea(sourceGraphics[0]);
|
|
488
|
+
|
|
489
|
+
this.props.updateArea({
|
|
490
|
+
origin: { x: latLongExtent.xmin, y: latLongExtent.ymin },
|
|
491
|
+
end: { x: latLongExtent.xmax, y: latLongExtent.ymax },
|
|
492
|
+
});
|
|
493
|
+
|
|
524
494
|
//Order the layer in the map
|
|
495
|
+
|
|
525
496
|
let index = this.getHighestIndex();
|
|
526
497
|
this.props.map.reorder(this.fileUploadLayer, index + 1);
|
|
498
|
+
|
|
499
|
+
// Refresh the map view
|
|
500
|
+
|
|
527
501
|
this.setState({
|
|
528
502
|
showInfoPopup: true,
|
|
529
503
|
infoPopupType: 'download',
|
|
530
504
|
});
|
|
505
|
+
|
|
506
|
+
//Save file upload layer to session storage as a tag for adding item to cart action
|
|
507
|
+
|
|
531
508
|
sessionStorage.setItem(
|
|
532
509
|
'fileUploadLayer',
|
|
533
510
|
JSON.stringify(this.fileUploadLayer),
|
|
@@ -535,10 +512,9 @@ class AreaWidget extends React.Component {
|
|
|
535
512
|
}
|
|
536
513
|
}
|
|
537
514
|
|
|
538
|
-
//
|
|
515
|
+
//Check if the featurecollection has more than one feature
|
|
539
516
|
|
|
540
517
|
checkFeatureCount(layers) {
|
|
541
|
-
//debugger;
|
|
542
518
|
if (layers.layers[0].featureSet.features.length > 1) {
|
|
543
519
|
this.setState({
|
|
544
520
|
showInfoPopup: true,
|
|
@@ -550,18 +526,6 @@ class AreaWidget extends React.Component {
|
|
|
550
526
|
}
|
|
551
527
|
}
|
|
552
528
|
|
|
553
|
-
//Check if the file has a polygon geometry type
|
|
554
|
-
|
|
555
|
-
/* uncomment the code below before pushing to DEMO */
|
|
556
|
-
|
|
557
|
-
//if (data?.features?.geometry?.type !== 'polygon') {
|
|
558
|
-
// this.setState({
|
|
559
|
-
// showInfoPopup: true,
|
|
560
|
-
// infoPopupType: 'singlePolygon',
|
|
561
|
-
// });
|
|
562
|
-
// return;
|
|
563
|
-
//}
|
|
564
|
-
|
|
565
529
|
//Display CSV on the map
|
|
566
530
|
|
|
567
531
|
handleCsv(data) {
|
|
@@ -578,7 +542,6 @@ class AreaWidget extends React.Component {
|
|
|
578
542
|
title: 'uploadLayer',
|
|
579
543
|
});
|
|
580
544
|
|
|
581
|
-
//debugger;
|
|
582
545
|
//Query all features insisde the CSV layer
|
|
583
546
|
|
|
584
547
|
//csvLayer.load().then(function(){
|
|
@@ -644,17 +607,20 @@ class AreaWidget extends React.Component {
|
|
|
644
607
|
|
|
645
608
|
removeNutsLayers() {
|
|
646
609
|
//find all the radio buttons
|
|
610
|
+
|
|
647
611
|
let radioButtons = document.querySelectorAll('fieldset.ccl-fieldset');
|
|
648
612
|
let rectangleRadioButton = document.querySelector(
|
|
649
613
|
'#download_area_select_rectangle',
|
|
650
614
|
);
|
|
651
615
|
// Isolate the the checked radio button
|
|
616
|
+
|
|
652
617
|
let selectedRadioButton = Array.from(radioButtons).find((radioButton) => {
|
|
653
618
|
let input = radioButton.querySelector('input');
|
|
654
619
|
return input && input.type === 'radio' && input.checked;
|
|
655
620
|
});
|
|
656
621
|
|
|
657
622
|
//Uncheck the selected radio button
|
|
623
|
+
|
|
658
624
|
if (selectedRadioButton) {
|
|
659
625
|
selectedRadioButton.querySelector('input').checked = false;
|
|
660
626
|
}
|
|
@@ -663,7 +629,7 @@ class AreaWidget extends React.Component {
|
|
|
663
629
|
}
|
|
664
630
|
|
|
665
631
|
//Remove the layers in this.nutsGroupLayer from the map
|
|
666
|
-
|
|
632
|
+
|
|
667
633
|
this.clearWidget();
|
|
668
634
|
}
|
|
669
635
|
|
|
@@ -671,9 +637,6 @@ class AreaWidget extends React.Component {
|
|
|
671
637
|
|
|
672
638
|
removeFileUploadedLayer() {
|
|
673
639
|
if (this.fileUploadLayer !== null) {
|
|
674
|
-
// this.props.map.removeMany(this.fileUploadLayer.layers);
|
|
675
|
-
// //this.props.view.graphics.removeMany(this.fileUploadLayer.sourceGraphics);
|
|
676
|
-
// this.fileUploadLayer = null;
|
|
677
640
|
this.clearWidget();
|
|
678
641
|
}
|
|
679
642
|
}
|
|
@@ -898,9 +861,6 @@ class AreaWidget extends React.Component {
|
|
|
898
861
|
});
|
|
899
862
|
}
|
|
900
863
|
});
|
|
901
|
-
//this.props.view.watch('updating', () => {
|
|
902
|
-
// console.log('graphics: ', this.props.view.graphics);
|
|
903
|
-
//});
|
|
904
864
|
|
|
905
865
|
this.props.download
|
|
906
866
|
? this.container !== null && this.props.view.ui.add(this.container)
|
|
@@ -34,7 +34,7 @@ export const AddCartItem = ({
|
|
|
34
34
|
let check = document.querySelector('.area-panel input:checked')?.value;
|
|
35
35
|
let fileUpload = sessionStorage.getItem('fileUploadLayer') ? true : false;
|
|
36
36
|
let area = {};
|
|
37
|
-
if (check === 'area') {
|
|
37
|
+
if (check === 'area' || fileUpload) {
|
|
38
38
|
let graphics = mapViewer.view.graphics;
|
|
39
39
|
if (graphics.length === 0) {
|
|
40
40
|
area = '';
|
|
@@ -47,9 +47,6 @@ export const AddCartItem = ({
|
|
|
47
47
|
areaData.end.y,
|
|
48
48
|
];
|
|
49
49
|
}
|
|
50
|
-
} else if (fileUpload) {
|
|
51
|
-
area.type = 'polygon';
|
|
52
|
-
area.value = [areaData.xmin, areaData.ymin, areaData.xmax, areaData.ymax];
|
|
53
50
|
} else {
|
|
54
51
|
if (areaData) {
|
|
55
52
|
area.type = 'nuts';
|
|
@@ -82,9 +79,8 @@ export const AddCartItem = ({
|
|
|
82
79
|
let intersection = false;
|
|
83
80
|
let areaExtent = null;
|
|
84
81
|
let check = document.querySelector('.area-panel input:checked')?.value;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (check === 'area') {
|
|
82
|
+
let fileUpload = sessionStorage.getItem('fileUploadLayer') ? true : false;
|
|
83
|
+
if (check === 'area' || fileUpload) {
|
|
88
84
|
areaExtent = new Extent({
|
|
89
85
|
xmin: Math.min(areaData.end.x, areaData.origin.x),
|
|
90
86
|
xmax: Math.max(areaData.end.x, areaData.origin.x),
|