How to use the @mapbox/vector-tile.VectorTileFeature.types function in @mapbox/vector-tile

To help you get started, we’ve selected a few @mapbox/vector-tile 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 tangrams / tangram / src / sources / mvt.js View on Github external
geometry.coordinates = coordinates;

                if (VectorTileFeature.types[feature.type] === 'Point') {
                    geometry.type = 'Point';
                    geometry.coordinates = geometry.coordinates[0][0];
                }
                else if (VectorTileFeature.types[feature.type] === 'LineString') {
                    if (coordinates.length === 1) {
                        geometry.type = 'LineString';
                        geometry.coordinates = geometry.coordinates[0];
                    }
                    else {
                        geometry.type = 'MultiLineString';
                    }
                }
                else if (VectorTileFeature.types[feature.type] === 'Polygon') {
                    geometry = decodeMultiPolygon(geometry); // un-flatten rings
                }

                layer_geojson.features.push(feature_geojson);
            }
            layers[l] = layer_geojson;
        }
        return layers;
    }
github tangrams / tangram / src / sources / mvt.js View on Github external
};

                var geometry = feature_geojson.geometry;
                var coordinates = feature.loadGeometry();
                for (var r=0; r < coordinates.length; r++) {
                    var ring = coordinates[r];
                    for (var c=0; c < ring.length; c++) {
                        ring[c] = [
                            ring[c].x * scale,
                            ring[c].y * scale
                        ];
                    }
                }
                geometry.coordinates = coordinates;

                if (VectorTileFeature.types[feature.type] === 'Point') {
                    geometry.type = 'Point';
                    geometry.coordinates = geometry.coordinates[0][0];
                }
                else if (VectorTileFeature.types[feature.type] === 'LineString') {
                    if (coordinates.length === 1) {
                        geometry.type = 'LineString';
                        geometry.coordinates = geometry.coordinates[0];
                    }
                    else {
                        geometry.type = 'MultiLineString';
                    }
                }
                else if (VectorTileFeature.types[feature.type] === 'Polygon') {
                    geometry = decodeMultiPolygon(geometry); // un-flatten rings
                }
github uber / streetscape.gl / examples / website-demo / src / layers / building-layer / utils / feature.js View on Github external
export function vectorTileFeatureToGeoJSON(vectorTileFeature, project) {
  let coords = getCoordinates(vectorTileFeature);
  const type = VectorTileFeature.types[vectorTileFeature.type];
  const extent = vectorTileFeature.extent;
  let i;
  let j;

  switch (vectorTileFeature.type) {
    case 1:
      coords = coords.map(pts => pts[0]);
      project(coords, extent);
      break;

    case 2:
      for (i = 0; i < coords.length; i++) {
        project(coords[i], extent);
      }
      break;
github keplergl / kepler.gl / src / deckgl-layers / 3d-building-layer / 3d-building-utils.js View on Github external
export function vectorTileFeatureToProp(vectorTileFeature, project) {
  let coords = getCoordinates(vectorTileFeature);
  const type = VectorTileFeature.types[vectorTileFeature.type];
  const extent = vectorTileFeature.extent;
  let i;
  let j;

  coords = classifyRings(coords);
  for (i = 0; i < coords.length; i++) {
    for (j = 0; j < coords[i].length; j++) {
      project(coords[i][j], extent);
    }
  }

  return coords.map(coordinates => ({
    coordinates,
    properties: vectorTileFeature.properties
  }));
}

@mapbox/vector-tile

Parses vector tiles

BSD-3-Clause
Latest version published 5 years ago

Package Health Score

74 / 100
Full package analysis

Similar packages