How to use @igo2/utils - 10 common examples

To help you get started, we’ve selected a few @igo2/utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github infra-geo-ouverte / igo2-lib / packages / geo / src / lib / datasource / shared / datasources / wms-datasource.ts View on Github external
sourceParams.DPI = dpi;
    sourceParams.MAP_RESOLUTION = dpi;
    sourceParams.FORMAT_OPTIONS = 'dpi:' + dpi;

    if (options.refreshIntervalSec && options.refreshIntervalSec > 0) {
      setInterval(() => {
        this.refresh();
      }, options.refreshIntervalSec * 1000); // Convert seconds to MS
    }

    let fieldNameGeometry = defaultFieldNameGeometry;

    // ####   START if paramsWFS
    if (options.paramsWFS) {
      const wfsCheckup = checkWfsParams(options, 'wms');
      ObjectUtils.mergeDeep(options.paramsWFS, wfsCheckup.paramsWFS);

      fieldNameGeometry =
        options.paramsWFS.fieldNameGeometry || fieldNameGeometry;

      options.download = Object.assign({}, options.download, {
        dynamicUrl: this.buildDynamicDownloadUrlFromParamsWFS(options)
      });
    } //  ####   END  if paramsWFS

    if (!options.sourceFields || options.sourceFields.length === 0) {
      options.sourceFields = [];
    } else {
      options.sourceFields.forEach(sourceField => {
        sourceField.alias = sourceField.alias
          ? sourceField.alias
          : sourceField.name;
github infra-geo-ouverte / igo2-lib / projects / geo / src / lib / print / shared / print.service.ts View on Github external
positionHComment += 20;
            } else {
              // Don't cut last part
              newContext.fillText(
                comment.substr(positionFirstCutChar),
                width / 2,
                positionHComment
              );
            }
          }
        }
      }
      // Add map to new canvas
      newContext.drawImage(context.canvas, 0, positionHCanvas);

      let status = SubjectStatus.Done;
      try {
        // Save the canvas as file
        if (!doZipFile) {
          this.saveCanvasImageAsFile(newCanvas, 'map', format);
        } else if (format.toLowerCase() === 'tiff') {
          // Add the canvas to zip
          this.generateCanvaFileToZip(
            newCanvas,
            'map' + map.projection.replace(':', '_') + '.' + format
          );
        } else {
          // Add the canvas to zip
          this.generateCanvaFileToZip(newCanvas, 'map' + '.' + format);
        }
      } catch (err) {
        status = SubjectStatus.Error;
github infra-geo-ouverte / igo2-lib / projects / geo / src / lib / layer / utils / tile-watcher.ts View on Github external
private handleLoadStart(event: any) {
    // This is to avoid increasing
    // the number of loaded tiles if a tile was loading
    // before subscribing to this watcher
    if (!event.tile.__watchers__) {
      event.tile.__watchers__ = [];
    }
    event.tile.__watchers__.push(this.id);

    this.loading += 1;
    this.status = SubjectStatus.Working;
  }
github infra-geo-ouverte / igo2-lib / projects / geo / src / lib / context / context-form / context-form.component.ts View on Github external
public handleFormSubmit(value) {
    let inputs = Object.assign({}, value);
    inputs = ObjectUtils.removeNull(inputs);
    inputs.uri = inputs.uri.replace(' ', '');
    if (inputs.uri) {
      inputs.uri = this.prefix + '-' + inputs.uri;
    } else {
      inputs.uri = this.prefix;
    }
    this.submitForm.emit(inputs);
  }
github infra-geo-ouverte / igo2-lib / packages / context / src / lib / context-manager / context-form / context-form.component.ts View on Github external
public handleFormSubmit(value) {
    let inputs = Object.assign({}, value);
    inputs = ObjectUtils.removeNull(inputs);
    inputs.uri = inputs.uri.replace(' ', '');
    if (inputs.uri) {
      inputs.uri = this.prefix + '-' + inputs.uri;
    } else {
      inputs.uri = this.prefix;
    }
    this.submitForm.emit(inputs);
  }
github infra-geo-ouverte / igo2-lib / packages / geo / src / lib / feature / shared / feature.utils.ts View on Github external
const geometry = olFormat.writeGeometryObject(olFeature.getGeometry(), {
    dataProjection: projectionOut,
    featureProjection: projectionIn
  });

  if (olLayer) {
    title = olLayer.get('title');
    if (olLayer.get('sourceOptions')) {
      exclude = olLayer.get('sourceOptions').excludeAttribute;
      excludeOffline = olLayer.get('sourceOptions').excludeAttributeOffline;
    }
  } else {
    title = olFeature.get('_title');
  }
  const mapTitle = olFeature.get('_mapTitle');
  const id = olFeature.getId() ? olFeature.getId() : uuid();

  return {
    type: FEATURE,
    projection: projectionOut,
    extent: olFeature.get('_extent'),
    meta: {
      id,
      title: title ? title : mapTitle ? mapTitle : id,
      mapTitle,
      revision: olFeature.getRevision(),
      style: olFeature.get('_style'),
      excludeAttribute: exclude,
      excludeAttributeOffline: excludeOffline
    },
    properties,
    geometry,
github infra-geo-ouverte / igo2-lib / projects / geo / src / lib / search / search-sources / reseau-transport-quebec-search-source.ts View on Github external
const shownProperties = {};
    this.allowedProperties.forEach(key => {
      if (properties.hasOwnProperty(key)) {
        const aliasProperty = this.propertiesAlias.filter(f => f.name === key)[0];
        shownProperties[aliasProperty.alias] = properties[key];
      }
    });

    delete properties.id;
    delete properties.recherche;
    delete properties.type;
    delete properties.coord_x;
    delete properties.coord_y;
    delete properties.cote;
    return {
      id: uuid(),
      source: ReseauTransportsQuebecSearchSource._name,
      sourceType: SourceFeatureType.Search,
      order: 1,
      zoomMaxOnSelect,
      type: FeatureType.Feature,
      format: FeatureFormat.GeoJSON,
      title: properties.title,
      titleHtml,
      icon,
      projection: 'EPSG:4326',
      properties: shownProperties,
      geometry: result.geometry,
      extent: result.bbox
    };
  }
}
github infra-geo-ouverte / igo2-lib / packages / context / src / lib / share-map / share-map / share-map.component.ts View on Github external
private buildForm(): void {
    const id = uuid();
    let title = 'Partage ';
    title += this.userId ? `(${this.userId}-${id})` : `(${id})`;
    this.form = this.formBuilder.group({
      title: [title],
      uri: [id]
    });
  }
}
github infra-geo-ouverte / igo2-lib / projects / geo / src / lib / datasource / shared / datasources / feature-datasource.ts View on Github external
protected generateId() {
    if (!this.options.url) {
      return uuid();
    }
    const chain = 'feature' + this.options.url;
    return Md5.hashStr(chain) as string;
  }