How to use the @ideditor/country-coder.aggregateFeature function in @ideditor/country-coder

To help you get started, we’ve selected a few @ideditor/country-coder 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 osmlab / osm-community-index / lib / locationToFeature.js View on Github external
properties: {
          m49: '001',
          wikidata: 'Q2',
          nameEn: 'World',
          id:  '001',
          area: 510072000
        },
        geometry: {
          type: 'Polygon',
          coordinates: [[[-180, -90], [-180, 90], [180, 90], [180, -90], [-180, -90]]]
        }
      }
      return { type: 'countrycoder', feature: world }

    } else {
      let feature = CountryCoder.aggregateFeature(location);
      if (feature) {
        feature.properties = feature.properties || {};
        if (!feature.properties.area) {                            // ensure area property
          const area = calcArea.geometry(feature.geometry) / 1e6;  // m² to km²
          feature.properties.area = Number(area.toFixed(2));
        }
        return { type: 'countrycoder', feature: feature };
      } else {
        return null;
      }
    }
  }
}

@ideditor/country-coder

Convert longitude-latitude pairs to ISO 3166-1 codes quickly and locally

ISC
Latest version published 2 years ago

Package Health Score

48 / 100
Full package analysis