@igo2/geo 21.0.0-next.11 → 21.0.0-next.12

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.
@@ -15314,9 +15314,9 @@ function detectFileEPSG(options) {
15314
15314
  const text = reader.result;
15315
15315
  const lines = text.split('\n');
15316
15316
  for (let line = 0; line <= nbLines; line++) {
15317
- const epsg = lines[line].match(/EPSG:\d{0,6}/gm);
15317
+ const epsg = lines[line].match(/EPSG:{1,2}\d{1,6}/gm);
15318
15318
  if (epsg !== null && epsg.length) {
15319
- resolve(epsg[0]);
15319
+ resolve(epsg[0].replace(/::/g, ':'));
15320
15320
  break;
15321
15321
  }
15322
15322
  else {
@@ -29243,9 +29243,9 @@ class ExportService {
29243
29243
  httpClient = inject(HttpClient);
29244
29244
  tableDataService = inject(TableDataService);
29245
29245
  static ogreFormats = {
29246
- GML: 'gml',
29247
- GPX: 'gpx',
29248
- KML: 'kml',
29246
+ GML: 'GML',
29247
+ GPX: 'GPX',
29248
+ KML: 'KML',
29249
29249
  Shapefile: 'ESRI Shapefile',
29250
29250
  CSV: 'CSV',
29251
29251
  /** @deprecated use CSV */
@@ -29330,7 +29330,7 @@ class ExportService {
29330
29330
  }
29331
29331
  return;
29332
29332
  }
29333
- this.exportWithOgre(olFeatures, options, title, projectionIn, projectionOut).subscribe({
29333
+ this.exportWithOgre(olFeatures, options, title, projectionIn, projectionOut)?.subscribe({
29334
29334
  complete: () => observer.complete(),
29335
29335
  error: (error) => observer.error(error)
29336
29336
  });
@@ -29424,47 +29424,63 @@ class ExportService {
29424
29424
  }
29425
29425
  }
29426
29426
  exportWithOgre(olFeatures, { format, csvSeparator = undefined }, title, projectionIn, projectionOut) {
29427
- const featuresText = new olformat.GeoJSON().writeFeatures(olFeatures, {
29427
+ if (!format) {
29428
+ return;
29429
+ }
29430
+ const features = new olformat.GeoJSON().writeFeaturesObject(olFeatures, {
29428
29431
  dataProjection: projectionOut,
29429
29432
  featureProjection: projectionIn
29430
29433
  });
29431
- const sizeError = this.checkOgrePayloadSize(featuresText);
29434
+ const sizeError = this.checkOgrePayloadSize(JSON.stringify(features));
29432
29435
  if (sizeError)
29433
29436
  return sizeError;
29434
29437
  const url = `${this.ogreUrl}/convertJson`;
29435
- const formData = new FormData();
29436
- formData.append('json', featuresText);
29437
- let outputName = format === 'Shapefile'
29438
- ? `${title}.zip`
29439
- : `${title}.${format.toLowerCase()}`;
29438
+ let outputName = title;
29440
29439
  let ogreFormat = ExportService.ogreFormats[format];
29440
+ let params = new HttpParams();
29441
29441
  if (isCsvExport(format)) {
29442
- outputName = `${title}.csv`;
29442
+ outputName = title;
29443
29443
  if (format === 'CSVcomma' || format === 'CSVsemicolon') {
29444
29444
  ogreFormat = 'CSV';
29445
29445
  }
29446
- formData.append('lco', `SEPARATOR=${csvSeparator}`);
29447
- if (format === 'CSVsemicolon') {
29448
- formData.append('lco', `SEPARATOR=${csvSeparator}`);
29449
- }
29446
+ params = params.append('lco', `SEPARATOR=${csvSeparator}`);
29450
29447
  }
29451
- formData.append('outputName', this.formatFilename(outputName));
29452
- formData.append('format', ogreFormat);
29453
- formData.append('forceUTF8', 'true');
29448
+ params = params
29449
+ .set('name', this.formatFilename(outputName))
29450
+ .set('format', ogreFormat)
29451
+ .set('forceUTF8', 'true');
29454
29452
  return this.httpClient
29455
- .post(url, formData, {
29456
- responseType: 'blob'
29453
+ .post(url, features, {
29454
+ params,
29455
+ responseType: 'blob',
29456
+ observe: 'response'
29457
29457
  })
29458
- .pipe(tap((value) => {
29459
- downloadBlob(value, outputName);
29458
+ .pipe(tap((response) => {
29459
+ if (!response.body) {
29460
+ return;
29461
+ }
29462
+ const filename = this.getFileName(response.headers, outputName, format);
29463
+ downloadBlob(response.body, filename);
29460
29464
  }));
29461
29465
  }
29466
+ getFileName(headers, outputName, format) {
29467
+ const contentDisposition = headers.get('content-disposition');
29468
+ const filenameMatch = contentDisposition?.match(/filename="?([^";\n]+)"?/);
29469
+ if (filenameMatch?.[1]) {
29470
+ return filenameMatch[1];
29471
+ }
29472
+ let extension = format.toLowerCase();
29473
+ if (format === 'Shapefile') {
29474
+ extension = 'zip';
29475
+ }
29476
+ return `${outputName}.${extension}`;
29477
+ }
29462
29478
  formatFilename(name) {
29463
29479
  return name
29464
29480
  .replaceAll(' ', '_')
29465
29481
  .normalize('NFD')
29466
29482
  .replace(/[\u0300-\u036f]/g, '')
29467
- .replace(/’/g, "'");
29483
+ .replace(/[^a-zA-Z0-9_-]/g, '');
29468
29484
  }
29469
29485
  nothingToExport(olFeatures, format) {
29470
29486
  if (olFeatures.length === 0) {
@@ -29598,12 +29614,12 @@ class ExportService {
29598
29614
  return geomTypes;
29599
29615
  }
29600
29616
  /**
29601
- * Checks if the given payload exceeds the OGRE maximum allowed size (2MB).
29617
+ * Checks if the given payload exceeds the OGRE maximum allowed size (50MB).
29602
29618
  * @param payload The GeoJSON payload as a string.
29603
29619
  * @returns An Observable that throws an error if the payload is too large, or undefined if the size is acceptable.
29604
29620
  */
29605
29621
  checkOgrePayloadSize(payload) {
29606
- const OGRE_MAX_SIZE = 2 * 1024 * 1024; // 2MB
29622
+ const OGRE_MAX_SIZE = 50 * 1024 * 1024; // 50MB
29607
29623
  const byteLength = new TextEncoder().encode(payload).length;
29608
29624
  if (byteLength > OGRE_MAX_SIZE) {
29609
29625
  const error = new Error();
@@ -30387,10 +30403,10 @@ class ImportExportComponent {
30387
30403
  }
30388
30404
  if (!isCSV || !data.combineLayers) {
30389
30405
  geomTypes.forEach((geomType) => {
30390
- if (geomType.type) {
30391
- fileName += geomType.type;
30392
- }
30393
- this.handleExport(geomType.features, data, fileName);
30406
+ const formattedFilename = geomType.type
30407
+ ? `${fileName}_${geomType.type}`
30408
+ : fileName;
30409
+ this.handleExport(geomType.features, data, formattedFilename);
30394
30410
  });
30395
30411
  }
30396
30412
  this.loading$.next(false);