diff --git a/d3-geo/d3-geo-tests.ts b/d3-geo/d3-geo-tests.ts index 3d28bb610f..f1701c10c8 100644 --- a/d3-geo/d3-geo-tests.ts +++ b/d3-geo/d3-geo-tests.ts @@ -537,6 +537,19 @@ geoPathCentroid = geoPathCanvas.centroid(sampleExtendedFeatureCollection); // geoPathCentroid = geoPathSVG.centroid(sampleExtendedFeatureCollection); // fails, wrong data object type + +// measure(...) ------------------------------------------------------ + +let geoPathMeasure: number = geoPathCanvas.measure(samplePolygon); +geoPathMeasure = geoPathCanvas.measure(sampleSphere); +geoPathMeasure = geoPathCanvas.measure(sampleGeometryCollection); +geoPathMeasure = geoPathCanvas.measure(sampleExtendedGeometryCollection); +geoPathMeasure = geoPathCanvas.measure(sampleFeature); +geoPathMeasure = geoPathCanvas.measure(sampleExtendedFeature1); +geoPathMeasure = geoPathCanvas.measure(sampleExtendedFeature2); +geoPathMeasure = geoPathCanvas.measure(sampleFeatureCollection); +geoPathMeasure = geoPathCanvas.measure(sampleExtendedFeatureCollection); + // render path to context of get path string---------------------------- // render to GeoContext/Canvas diff --git a/d3-geo/index.d.ts b/d3-geo/index.d.ts index 9ab3ae74cd..02ce38ba93 100644 --- a/d3-geo/index.d.ts +++ b/d3-geo/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for D3JS d3-geo module v1.4.0 +// Type definitions for D3JS d3-geo module v1.5.0 // Project: https://github.com/d3/d3-geo/ // Definitions by: Hugues Stefanski , Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -908,7 +908,7 @@ export interface GeoPath { * this method first computes the area of the exterior ring, and then subtracts the area of any interior holes. * This method observes any clipping performed by the projection; see projection.clipAngle and projection.clipExtent. * - * @param An object for which the area is to be calculated. + * @param object An object for which the area is to be calculated. */ area(object: DatumObject): number; @@ -921,7 +921,7 @@ export interface GeoPath { * the minimum latitude is typically the maximum y-value, and the maximum latitude is typically the minimum y-value.) * This method observes any clipping performed by the projection; see projection.clipAngle and projection.clipExtent. * - * @param An object for which the bounds are to be calculated. + * @param object An object for which the bounds are to be calculated. */ bounds(object: DatumObject): [[number, number], [number, number]]; @@ -931,10 +931,20 @@ export interface GeoPath { * For example, a noncontiguous cartogram might scale each state around its centroid. * This method observes any clipping performed by the projection; see projection.clipAngle and projection.clipExtent. * - * @param An object for which the centroid is to be calculated. + * @param pbject An object for which the centroid is to be calculated. */ centroid(object: DatumObject): [number, number]; + /** + * Returns the projected planar length (typically in pixels) for the specified GeoJSON object. + * Point and MultiPoint features have zero length. For Polygon and MultiPolygon features, this method computes the summed length of all rings. + * + * This method observes any clipping performed by the projection. + * + * @param object An object for which the measure is to be calculated. + */ + measure(object: DatumObject): number; + /** * Returns the current render context which defaults to null. * diff --git a/d3/index.d.ts b/d3/index.d.ts index bf7fa8e6b6..d5fe886d63 100644 --- a/d3/index.d.ts +++ b/d3/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for D3JS d3 standard bundle 4.5 +// Type definitions for D3JS d3 standard bundle 4.6 // Project: https://github.com/d3/d3 // Definitions by: Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped