How to use the d3-geo.geoArea function in d3-geo

To help you get started, we’ve selected a few d3-geo 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 DefinitelyTyped / DefinitelyTyped / d3-geo / d3-geo-tests.ts View on Github external
const sampleExtendedFeatureCollection: d3Geo.ExtendedFeatureCollection | d3Geo.ExtendedFeature> = {
    type: 'FeatureCollection',
    features: [
        sampleExtendedFeature1,
        sampleExtendedFeature2
    ]
};

// ----------------------------------------------------------------------
// Spherical Math
// ----------------------------------------------------------------------

// geoArea(...) =========================================================

let area: number = d3Geo.geoArea(samplePolygon);
area = d3Geo.geoArea(sampleSphere);
area = d3Geo.geoArea(sampleGeometryCollection);
area = d3Geo.geoArea(sampleExtendedGeometryCollection);
area = d3Geo.geoArea(sampleFeature);
area = d3Geo.geoArea(sampleExtendedFeature1);
area = d3Geo.geoArea(sampleExtendedFeature2);
area = d3Geo.geoArea(sampleFeatureCollection);
area = d3Geo.geoArea(sampleExtendedFeatureCollection);

// geoBounds(...) =========================================================

let bounds: [[number, number], [number, number]] = d3Geo.geoBounds(samplePolygon);
bounds = d3Geo.geoBounds(sampleSphere);
bounds = d3Geo.geoBounds(sampleGeometryCollection);
bounds = d3Geo.geoBounds(sampleExtendedGeometryCollection);
bounds = d3Geo.geoBounds(sampleFeature);
github DefinitelyTyped / DefinitelyTyped / d3-geo / d3-geo-tests.ts View on Github external
// ----------------------------------------------------------------------
// Spherical Math
// ----------------------------------------------------------------------

// geoArea(...) =========================================================

let area: number = d3Geo.geoArea(samplePolygon);
area = d3Geo.geoArea(sampleSphere);
area = d3Geo.geoArea(sampleGeometryCollection);
area = d3Geo.geoArea(sampleExtendedGeometryCollection);
area = d3Geo.geoArea(sampleFeature);
area = d3Geo.geoArea(sampleExtendedFeature1);
area = d3Geo.geoArea(sampleExtendedFeature2);
area = d3Geo.geoArea(sampleFeatureCollection);
area = d3Geo.geoArea(sampleExtendedFeatureCollection);

// geoBounds(...) =========================================================

let bounds: [[number, number], [number, number]] = d3Geo.geoBounds(samplePolygon);
bounds = d3Geo.geoBounds(sampleSphere);
bounds = d3Geo.geoBounds(sampleGeometryCollection);
bounds = d3Geo.geoBounds(sampleExtendedGeometryCollection);
bounds = d3Geo.geoBounds(sampleFeature);
bounds = d3Geo.geoBounds(sampleExtendedFeature1);
bounds = d3Geo.geoBounds(sampleExtendedFeature2);
bounds = d3Geo.geoBounds(sampleFeatureCollection);
bounds = d3Geo.geoBounds(sampleExtendedFeatureCollection);

// geoCentroid(...) =======================================================

let centroid: [number, number] = d3Geo.geoCentroid(samplePolygon);
github DefinitelyTyped / DefinitelyTyped / types / d3-geo / d3-geo-tests.ts View on Github external
};

// ----------------------------------------------------------------------
// Spherical Math
// ----------------------------------------------------------------------

// geoArea(...) =========================================================

let area: number = d3Geo.geoArea(samplePolygon);
area = d3Geo.geoArea(sampleSphere);
area = d3Geo.geoArea(sampleGeometryCollection);
area = d3Geo.geoArea(sampleExtendedGeometryCollection);
area = d3Geo.geoArea(sampleFeature);
area = d3Geo.geoArea(sampleExtendedFeature1);
area = d3Geo.geoArea(sampleExtendedFeature2);
area = d3Geo.geoArea(sampleFeatureCollection);
area = d3Geo.geoArea(sampleExtendedFeatureCollection);

// geoBounds(...) =========================================================

let bounds: [[number, number], [number, number]] = d3Geo.geoBounds(samplePolygon);
bounds = d3Geo.geoBounds(sampleSphere);
bounds = d3Geo.geoBounds(sampleGeometryCollection);
bounds = d3Geo.geoBounds(sampleExtendedGeometryCollection);
bounds = d3Geo.geoBounds(sampleFeature);
bounds = d3Geo.geoBounds(sampleExtendedFeature1);
bounds = d3Geo.geoBounds(sampleExtendedFeature2);
bounds = d3Geo.geoBounds(sampleFeatureCollection);
bounds = d3Geo.geoBounds(sampleExtendedFeatureCollection);

// geoCentroid(...) =======================================================
github DefinitelyTyped / DefinitelyTyped / types / d3-geo / d3-geo-tests.ts View on Github external
features: [
        sampleExtendedFeature1,
        sampleExtendedFeature2
    ]
};

// ----------------------------------------------------------------------
// Spherical Math
// ----------------------------------------------------------------------

// geoArea(...) =========================================================

let area: number = d3Geo.geoArea(samplePolygon);
area = d3Geo.geoArea(sampleSphere);
area = d3Geo.geoArea(sampleGeometryCollection);
area = d3Geo.geoArea(sampleExtendedGeometryCollection);
area = d3Geo.geoArea(sampleFeature);
area = d3Geo.geoArea(sampleExtendedFeature1);
area = d3Geo.geoArea(sampleExtendedFeature2);
area = d3Geo.geoArea(sampleFeatureCollection);
area = d3Geo.geoArea(sampleExtendedFeatureCollection);

// geoBounds(...) =========================================================

let bounds: [[number, number], [number, number]] = d3Geo.geoBounds(samplePolygon);
bounds = d3Geo.geoBounds(sampleSphere);
bounds = d3Geo.geoBounds(sampleGeometryCollection);
bounds = d3Geo.geoBounds(sampleExtendedGeometryCollection);
bounds = d3Geo.geoBounds(sampleFeature);
bounds = d3Geo.geoBounds(sampleExtendedFeature1);
bounds = d3Geo.geoBounds(sampleExtendedFeature2);
bounds = d3Geo.geoBounds(sampleFeatureCollection);
github DefinitelyTyped / DefinitelyTyped / d3-geo / d3-geo-tests.ts View on Github external
sampleExtendedFeature2
    ]
};

// ----------------------------------------------------------------------
// Spherical Math
// ----------------------------------------------------------------------

// geoArea(...) =========================================================

let area: number = d3Geo.geoArea(samplePolygon);
area = d3Geo.geoArea(sampleSphere);
area = d3Geo.geoArea(sampleGeometryCollection);
area = d3Geo.geoArea(sampleExtendedGeometryCollection);
area = d3Geo.geoArea(sampleFeature);
area = d3Geo.geoArea(sampleExtendedFeature1);
area = d3Geo.geoArea(sampleExtendedFeature2);
area = d3Geo.geoArea(sampleFeatureCollection);
area = d3Geo.geoArea(sampleExtendedFeatureCollection);

// geoBounds(...) =========================================================

let bounds: [[number, number], [number, number]] = d3Geo.geoBounds(samplePolygon);
bounds = d3Geo.geoBounds(sampleSphere);
bounds = d3Geo.geoBounds(sampleGeometryCollection);
bounds = d3Geo.geoBounds(sampleExtendedGeometryCollection);
bounds = d3Geo.geoBounds(sampleFeature);
bounds = d3Geo.geoBounds(sampleExtendedFeature1);
bounds = d3Geo.geoBounds(sampleExtendedFeature2);
bounds = d3Geo.geoBounds(sampleFeatureCollection);
bounds = d3Geo.geoBounds(sampleExtendedFeatureCollection);
github Fil / d3-geo-voronoi / src / geoVoronoi.js View on Github external
var vor_poly = DT.vor_polygons[DT.indices[i]];
            var geometry = {}

            if (vor_poly == undefined) {
                geometry.type = "Sphere";
            } else {
                var line = mapline(DT.vor_positions,
                    vor_poly.boundary.concat([vor_poly.boundary[0]])
                );

                // correct winding order
                var b = {
                    type: "Polygon",
                    coordinates: [[pos[i], line[0], line[1], pos[i]]]
                };
                if (geoArea(b) > 2 * Math.PI + 1e-10) {
                    line = line.reverse();
                }

                geometry.type = "Polygon";
                geometry.coordinates = [line];
            }

            return {
                type: "Feature",
                geometry: geometry,
                properties: {
                    site: sites[i],
                    sitecoordinates: pos[i],
                    neighbours: vor_poly.edges.map(function (e) {
                        return e.verts.filter(function (j) {
                            return j !== i;
github openstreetmap / iD / data / index.js View on Github external
var ociFeatureCollection = Object.values(ociFeatures).map(function(feature) {
    // workaround for which-polygon: only supports `properties`, not `id`
    // https://github.com/mapbox/which-polygon/pull/6
    feature.properties = {
        id: feature.id,
        area: d3_geoArea(feature)   // also precompute areas
    };
    return feature;
});
github antvis / data-set / src / api / geo.js View on Github external
geoArea(feature) {
    return geoArea(feature);
  },
  geoAreaByName(name) {
github antvis / data-set / src / api / geo.ts View on Github external
geoArea(feature: ExtendedFeature) {
    return geoArea(feature);
  },
  geoAreaByName(this: View, name: string) {
github amcharts / amcharts4 / dist / es2015 / .internal / charts / map / MapPolygon.js View on Github external
if (this.series) {
            var projection = this.series.chart.projection;
            projection.d3Projection.precision(0.5);
            var pathGenerator = projection.d3Path;
            if (this.multiPolygon) {
                if (this.series) {
                    var feature = { type: "MultiPolygon", coordinates: this.multiPolygon };
                    this.polygon.path = pathGenerator(feature);
                }
                if (this.series.calculateVisualCenter) {
                    var biggestArea = 0;
                    var biggestPolygon = this.multiPolygon[0];
                    if (this.multiPolygon.length > 1) {
                        for (var i = 0; i < this.multiPolygon.length; i++) {
                            var polygon = this.multiPolygon[i];
                            var area = d3geo.geoArea({ type: "Polygon", coordinates: polygon });
                            if (area > biggestArea) {
                                biggestPolygon = polygon;
                                biggestArea = area;
                            }
                        }
                    }
                    var center = $polylabel(biggestPolygon);
                    this._visualLongitude = center[0];
                    this._visualLatitude = center[1];
                }
                else {
                    this._visualLongitude = this.longitude;
                    this._visualLatitude = this.latitude;
                }
            }
        }