From 931e518a1cb4ea7b19ca0245103eb8955e4719c7 Mon Sep 17 00:00:00 2001 From: Hugues Stefanski Date: Thu, 23 Feb 2017 21:31:36 +0100 Subject: [PATCH 1/3] Updated d3-geo to reflect measure method Update d3-geo version to 1.5.0 Updated d3 version to 4.6 --- d3-geo/d3-geo-tests.ts | 13 +++++++++++++ d3-geo/index.d.ts | 11 ++++++++++- d3/index.d.ts | 2 +- 3 files changed, 24 insertions(+), 2 deletions(-) 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..deeed4166e 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 @@ -935,6 +935,15 @@ export interface GeoPath { */ 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 GeoJSON object to measure. + */ + 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 From 91de2cdf20e7d3c2a4414d07b6ff1066800b0355 Mon Sep 17 00:00:00 2001 From: Hugues Stefanski Date: Thu, 23 Feb 2017 21:41:06 +0100 Subject: [PATCH 2/3] Added blank line to make comment more readable --- d3-geo/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/d3-geo/index.d.ts b/d3-geo/index.d.ts index deeed4166e..ccaca7c1aa 100644 --- a/d3-geo/index.d.ts +++ b/d3-geo/index.d.ts @@ -938,6 +938,7 @@ export interface GeoPath { /** * 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 GeoJSON object to measure. From 5d4a849576a18a48d7ef008bbaa0f1cde49cf04f Mon Sep 17 00:00:00 2001 From: Hugues Stefanski Date: Sun, 5 Mar 2017 10:21:38 +0100 Subject: [PATCH 3/3] Doc style changes for consistency --- d3-geo/index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/d3-geo/index.d.ts b/d3-geo/index.d.ts index ccaca7c1aa..02ce38ba93 100644 --- a/d3-geo/index.d.ts +++ b/d3-geo/index.d.ts @@ -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,7 +931,7 @@ 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]; @@ -941,7 +941,7 @@ export interface GeoPath { * * This method observes any clipping performed by the projection. * - * @param object GeoJSON object to measure. + * @param object An object for which the measure is to be calculated. */ measure(object: DatumObject): number;