[d3-geo/d3-contour] Chores (#16324)

* [d3-contour] [Chore] Add contributor

* [d3-geo] Chore and Preparation for strictNullChecks
* [Chore] Change geoJSON to module import
* [Chore] Update return type signatures for `geoPath(...)` invocation. For the time being split the signatures for rendering to svg vs canvas. The return type for rendering is changed to `string | null`. This change corresponds to the comitted PR 98 in the d3-geo repo. The behavior and the definitions are now harmonized with d3-shape generators like `arc(...)`.

* [d3-contour] Update test to reflect `geoPath` change.
This commit is contained in:
Tom Wanzek
2017-05-04 15:58:02 -04:00
committed by Mohamed Hegazy
parent 1b37b86896
commit 9f5858caef
3 changed files with 36 additions and 6 deletions

View File

@@ -45,7 +45,7 @@ const thresholdArrayGen: ThresholdArrayGenerator<number> = (values: number[], mi
};
let thresholdGenerator: ThresholdArrayGenerator<number> | ThresholdCountGenerator;
let pathStringMaybe: string | undefined;
let pathStringMaybe: string | null;
let num: number;
const pathSolo = geoPath<any, d3Contour.ContourMultiPolygon>();

View File

@@ -1,6 +1,6 @@
// Type definitions for d3-contour 1.1
// Project: https://d3js.org/d3-contour/
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Hugues Stefanski <https://github.com/Ledragon>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Last module patch version validated against: 1.1.0

View File

@@ -3,10 +3,10 @@
// Definitions by: Hugues Stefanski <https://github.com/Ledragon>, Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="geojson" />
// Last module patch version validated against: 1.6.1
import * as GeoJSON from 'geojson';
// ----------------------------------------------------------------------
// Shared Interfaces and Types
// ----------------------------------------------------------------------
@@ -926,7 +926,8 @@ export interface GeoPath<This, DatumObject extends GeoPermissibleObjects> {
*
* Any additional arguments are passed along to the pointRadius accessor.
*
* If the rendering context is null, the function returns an SVG Path string, otherwise the function renders to the current context.
* IMPORTANT: If the rendering context of the geoPath generator is null,
* then the geoPath is returned as an SVG path data string.
*
* Separate path elements are typically slower than a single path element. However, distinct path elements are useful for styling and interation (e.g., click or mouseover).
* Canvas rendering (see path.context) is typically faster than SVG, but requires more effort to implement styling and interaction.
@@ -935,7 +936,36 @@ export interface GeoPath<This, DatumObject extends GeoPermissibleObjects> {
*
* @param object An object to be rendered.
*/
(this: This, object: DatumObject, ...args: any[]): string | undefined;
(this: This, object: DatumObject, ...args: any[]): string | null;
/**
* Renders the given object, which may be any GeoJSON feature or geometry object:
*
* + Point - a single position.
* + MultiPoint - an array of positions.
* + LineString - an array of positions forming a continuous line.
* + MultiLineString - an array of arrays of positions forming several lines.
* + Polygon - an array of arrays of positions forming a polygon (possibly with holes).
* + MultiPolygon - a multidimensional array of positions forming multiple polygons.
* + GeometryCollection - an array of geometry objects.
* + Feature - a feature containing one of the above geometry objects.
* + FeatureCollection - an array of feature objects.
*
* The type Sphere is also supported, which is useful for rendering the outline of the globe; a sphere has no coordinates.
*
*
* Any additional arguments are passed along to the pointRadius accessor.
*
* IMPORTANT: If the geoPath generator has been configured with a rendering context,
* then the geoPath is rendered to this context as a sequence of path method calls and this function returns void.
*
* Separate path elements are typically slower than a single path element. However, distinct path elements are useful for styling and interation (e.g., click or mouseover).
* Canvas rendering (see path.context) is typically faster than SVG, but requires more effort to implement styling and interaction.
*
* The first generic type of the GeoPath generator used, must correspond to the "this" context bound to the function upon invocation.
*
* @param object An object to be rendered.
*/
(this: This, object: DatumObject, ...args: any[]): void;
/**
* Returns the projected planar area (typically in square pixels) for the specified GeoJSON object.