From 335d12a4ee9af8e7f0c25dc6fe93a059e3ee9fa9 Mon Sep 17 00:00:00 2001 From: Jeff Jacobson Date: Thu, 16 Nov 2017 15:40:04 -0800 Subject: [PATCH] Modified typedefs dependent on "geojson" to accommodate changes. --- types/d3-geo/d3-geo-tests.ts | 4 ++-- types/d3-geo/index.d.ts | 4 +++- types/geojson2osm/geojson2osm-tests.ts | 2 +- types/geojson2osm/index.d.ts | 2 +- types/leaflet/index.d.ts | 28 +++++++++++++------------- types/leaflet/v0/index.d.ts | 12 +++++------ types/mapbox-gl/index.d.ts | 8 ++++---- types/polyline/index.d.ts | 2 +- types/shapefile/index.d.ts | 4 ++-- types/supercluster/index.d.ts | 2 +- types/tilebelt/index.d.ts | 4 ++-- 11 files changed, 37 insertions(+), 35 deletions(-) diff --git a/types/d3-geo/d3-geo-tests.ts b/types/d3-geo/d3-geo-tests.ts index 876461e3e9..e6014837a7 100644 --- a/types/d3-geo/d3-geo-tests.ts +++ b/types/d3-geo/d3-geo-tests.ts @@ -49,7 +49,7 @@ const sampleExtendedGeometryCollection: d3Geo.ExtendedGeometryCollection = { +const sampleFeature: GeoJSON.Feature = { type: 'Feature', geometry: samplePolygon, properties: { @@ -74,7 +74,7 @@ const sampleExtendedFeature2: d3Geo.ExtendedFeature = { +const sampleFeatureCollection: GeoJSON.FeatureCollection = { type: 'FeatureCollection', features: [ sampleFeature, diff --git a/types/d3-geo/index.d.ts b/types/d3-geo/index.d.ts index 4093b696e9..1d1d36fe91 100644 --- a/types/d3-geo/index.d.ts +++ b/types/d3-geo/index.d.ts @@ -36,7 +36,9 @@ export type GeoGeometryObjects = GeoJSON.GeometryObject | GeoSphere; export interface ExtendedGeometryCollection { type: string; bbox?: number[]; - crs?: GeoJSON.CoordinateReferenceSystem; + // GeoJSON removed the Coordinate System objects from the spec, but does allow + // "foreign members". + crs?: GeoJSON.GeoJsonObject; geometries: GeometryType[]; } diff --git a/types/geojson2osm/geojson2osm-tests.ts b/types/geojson2osm/geojson2osm-tests.ts index 887f10a83c..9d95de64c4 100644 --- a/types/geojson2osm/geojson2osm-tests.ts +++ b/types/geojson2osm/geojson2osm-tests.ts @@ -1,6 +1,6 @@ import { geojson2osm } from 'geojson2osm' -const features: GeoJSON.FeatureCollection = { +const features: GeoJSON.FeatureCollection = { type: 'FeatureCollection', features: [{ type: 'Feature', diff --git a/types/geojson2osm/index.d.ts b/types/geojson2osm/index.d.ts index 39b03de5bf..513348eeae 100644 --- a/types/geojson2osm/index.d.ts +++ b/types/geojson2osm/index.d.ts @@ -11,4 +11,4 @@ * @param features Input features * @returns OpenStreetMap XML */ -export function geojson2osm(features: GeoJSON.Feature | GeoJSON.FeatureCollection): any +export function geojson2osm(features: GeoJSON.Feature | GeoJSON.FeatureCollection): any diff --git a/types/leaflet/index.d.ts b/types/leaflet/index.d.ts index b1e7ead796..727478864a 100644 --- a/types/leaflet/index.d.ts +++ b/types/leaflet/index.d.ts @@ -583,7 +583,7 @@ export interface PolylineOptions extends PathOptions { export class Polyline extends Path { constructor(latlngs: LatLngExpression[], options?: PolylineOptions); - toGeoJSON(): geojson.Feature; + toGeoJSON(): geojson.Feature; getLatLngs(): LatLng[]; setLatLngs(latlngs: LatLngExpression[]): this; isEmpty(): boolean; @@ -591,7 +591,7 @@ export class Polyline; + feature?: geojson.Feature; options: PolylineOptions; } @@ -616,14 +616,14 @@ export interface CircleMarkerOptions extends PathOptions { export class CircleMarker

extends Path { constructor(latlng: LatLngExpression, options?: CircleMarkerOptions); - toGeoJSON(): geojson.Feature; + toGeoJSON(): geojson.Feature; setLatLng(latLng: LatLngExpression): this; getLatLng(): LatLng; setRadius(radius: number): this; getRadius(): number; options: CircleMarkerOptions; - feature?: geojson.Feature; + feature?: geojson.Feature; } export function circleMarker(latlng: LatLngExpression, options?: CircleMarkerOptions): CircleMarker; @@ -671,7 +671,7 @@ export class LayerGroup

extends Layer { /** * Returns a GeoJSON representation of the layer group (as a GeoJSON GeometryCollection, GeoJSONFeatureCollection or Multipoint). */ - toGeoJSON(): geojson.FeatureCollection | geojson.Feature | geojson.GeometryCollection; + toGeoJSON(): geojson.FeatureCollection | geojson.Feature | geojson.GeometryCollection; /** * Adds the given layer to the group. @@ -725,7 +725,7 @@ export class LayerGroup

extends Layer { */ getLayerId(layer: Layer): number; - feature?: geojson.FeatureCollection | geojson.Feature | geojson.GeometryCollection; + feature?: geojson.FeatureCollection | geojson.Feature | geojson.GeometryCollection; } /** @@ -765,7 +765,7 @@ export class FeatureGroup

extends LayerGroup

{ */ export function featureGroup(layers?: Layer[]): FeatureGroup; -export type StyleFunction

= (feature?: geojson.Feature) => PathOptions; +export type StyleFunction

= (feature?: geojson.Feature) => PathOptions; export interface GeoJSONOptions

extends LayerOptions { /** @@ -781,7 +781,7 @@ export interface GeoJSONOptions

extends LayerOptions { * } * ``` */ - pointToLayer?(geoJsonPoint: geojson.Feature, latlng: LatLng): Layer; // should import GeoJSON typings + pointToLayer?(geoJsonPoint: geojson.Feature, latlng: LatLng): Layer; // should import GeoJSON typings /** * A Function defining the Path options for styling GeoJSON lines and polygons, @@ -807,7 +807,7 @@ export interface GeoJSONOptions

extends LayerOptions { * function (feature, layer) {} * ``` */ - onEachFeature?(feature: geojson.Feature, layer: Layer): void; + onEachFeature?(feature: geojson.Feature, layer: Layer): void; /** * A Function that will be used to decide whether to show a feature or not. @@ -820,7 +820,7 @@ export interface GeoJSONOptions

extends LayerOptions { * } * ``` */ - filter?(geoJsonFeature: geojson.Feature): boolean; + filter?(geoJsonFeature: geojson.Feature): boolean; /** * A Function that will be used for converting GeoJSON coordinates to LatLngs. @@ -838,7 +838,7 @@ export class GeoJSON

extends FeatureGroup

{ * Creates a Layer from a given GeoJSON feature. Can use a custom pointToLayer * and/or coordsToLatLng functions if provided as options. */ - static geometryToLayer

(featureData: geojson.Feature, options?: GeoJSONOptions

): Layer; + static geometryToLayer(featureData: geojson.Feature, options?: GeoJSONOptions): Layer; /** * Creates a LatLng object from an array of 2 numbers (longitude, latitude) or @@ -872,7 +872,7 @@ export class GeoJSON

extends FeatureGroup

{ /** * Normalize GeoJSON geometries/features into GeoJSON features. */ - static asFeature

(geojson: geojson.Feature | geojson.GeometryObject): geojson.Feature; + static asFeature(geojson: geojson.Feature | geojson.GeometryObject): geojson.Feature; constructor(geojson?: geojson.GeoJsonObject, options?: GeoJSONOptions

) /** @@ -1454,7 +1454,7 @@ export interface MarkerOptions extends InteractiveLayerOptions { export class Marker

extends Layer { constructor(latlng: LatLngExpression, options?: MarkerOptions); - toGeoJSON(): geojson.Feature; + toGeoJSON(): geojson.Feature; getLatLng(): LatLng; setLatLng(latlng: LatLngExpression): this; setZIndexOffset(offset: number): this; @@ -1465,7 +1465,7 @@ export class Marker

extends Layer { // Properties options: MarkerOptions; dragging?: Handler; - feature?: geojson.Feature; + feature?: geojson.Feature; } export function marker(latlng: LatLngExpression, options?: MarkerOptions): Marker; diff --git a/types/leaflet/v0/index.d.ts b/types/leaflet/v0/index.d.ts index efadd88e8f..d841a45133 100644 --- a/types/leaflet/v0/index.d.ts +++ b/types/leaflet/v0/index.d.ts @@ -223,7 +223,7 @@ declare namespace L { /** * Returns a GeoJSON representation of the circle (GeoJSON Point Feature). */ - toGeoJSON(): GeoJSON.Feature; + toGeoJSON(): GeoJSON.Feature; } } @@ -1716,7 +1716,7 @@ declare namespace L { * Returns a GeoJSON representation of the layer group (GeoJSON FeatureCollection). * Note: Descendent classes MultiPolygon & MultiPolyLine return `Feature`s, not `FeatureCollection`s */ - toGeoJSON(): GeoJSON.FeatureCollection|GeoJSON.Feature; + toGeoJSON(): GeoJSON.FeatureCollection|GeoJSON.Feature; //////////// //////////// @@ -2943,7 +2943,7 @@ declare namespace L { /** * Returns a GeoJSON representation of the marker (GeoJSON Point Feature). */ - toGeoJSON(): GeoJSON.Feature; + toGeoJSON(): GeoJSON.Feature; /** * Marker dragging handler (by both mouse and touch). @@ -3103,7 +3103,7 @@ declare namespace L { /** * Returns a GeoJSON representation of the multipolygon (GeoJSON MultiPolygon Feature). */ - toGeoJSON(): GeoJSON.Feature; + toGeoJSON(): GeoJSON.Feature; } } @@ -3144,7 +3144,7 @@ declare namespace L { /** * Returns a GeoJSON representation of the multipolyline (GeoJSON MultiLineString Feature). */ - toGeoJSON(): GeoJSON.Feature; + toGeoJSON(): GeoJSON.Feature; } } @@ -3565,7 +3565,7 @@ declare namespace L { /** * Returns a GeoJSON representation of the polyline (GeoJSON LineString Feature). */ - toGeoJSON(): GeoJSON.Feature; + toGeoJSON(): GeoJSON.Feature; } } diff --git a/types/mapbox-gl/index.d.ts b/types/mapbox-gl/index.d.ts index 6be9a465ef..6e61c90c70 100644 --- a/types/mapbox-gl/index.d.ts +++ b/types/mapbox-gl/index.d.ts @@ -54,9 +54,9 @@ declare namespace mapboxgl { unproject(point: PointLike): mapboxgl.LngLat; - queryRenderedFeatures(pointOrBox?: PointLike | PointLike[], parameters?: {layers?: string[], filter?: any[]}): GeoJSON.Feature[]; + queryRenderedFeatures(pointOrBox?: PointLike | PointLike[], parameters?: {layers?: string[], filter?: any[]}): GeoJSON.Feature[]; - querySourceFeatures(sourceID: string, parameters?: {sourceLayer?: string, filter?: any[]}): GeoJSON.Feature[]; + querySourceFeatures(sourceID: string, parameters?: {sourceLayer?: string, filter?: any[]}): GeoJSON.Feature[]; setStyle(style: mapboxgl.Style | string): this; @@ -507,11 +507,11 @@ declare namespace mapboxgl { constructor(options?: mapboxgl.GeoJSONSourceOptions); - setData(data: GeoJSON.Feature | GeoJSON.FeatureCollection | String): this; + setData(data: GeoJSON.Feature | GeoJSON.FeatureCollection | String): this; } export interface GeoJSONSourceOptions { - data?: GeoJSON.Feature | GeoJSON.FeatureCollection | string; + data?: GeoJSON.Feature | GeoJSON.FeatureCollection | string; maxzoom?: number; diff --git a/types/polyline/index.d.ts b/types/polyline/index.d.ts index 7a8b7eeb19..6961205212 100644 --- a/types/polyline/index.d.ts +++ b/types/polyline/index.d.ts @@ -9,7 +9,7 @@ interface Polyline { decode(string: string, precision?: number): number[][]; encode(coordinate: number[][], precision?: number): string; - fromGeoJSON(geojson: GeoJSON.LineString | GeoJSON.Feature, precision?: number): string; + fromGeoJSON(geojson: GeoJSON.LineString | GeoJSON.Feature, precision?: number): string; } declare var polyline: Polyline; diff --git a/types/shapefile/index.d.ts b/types/shapefile/index.d.ts index 54a18a2503..83852507e1 100644 --- a/types/shapefile/index.d.ts +++ b/types/shapefile/index.d.ts @@ -15,7 +15,7 @@ declare namespace shapefile { } interface Feature { done: boolean - value: GeoJSON.Feature + value: GeoJSON.Feature } interface Shapefile { bbox: Array @@ -23,7 +23,7 @@ declare namespace shapefile { } interface ShapefileStatic { open(shp: any, dbf?: any, options?: Options): Promise; - read(shp: any, dbf?: any, options?: Options): Promise>; + read(shp: any, dbf?: any, options?: Options): Promise; } } diff --git a/types/supercluster/index.d.ts b/types/supercluster/index.d.ts index 7fd487ae09..7463b4a43a 100644 --- a/types/supercluster/index.d.ts +++ b/types/supercluster/index.d.ts @@ -94,7 +94,7 @@ export class Supercluster { */ export default function supercluster(options: Options): Supercluster; -export type Point = GeoJSON.Feature; +export type Point = GeoJSON.Feature; export type Points = Point[]; export type Clusters = Cluster[]; export type TileFeatures = TileFeature[]; diff --git a/types/tilebelt/index.d.ts b/types/tilebelt/index.d.ts index f8d3adae1c..eed92f915b 100644 --- a/types/tilebelt/index.d.ts +++ b/types/tilebelt/index.d.ts @@ -14,12 +14,12 @@ declare namespace tilebelt { * * @name tileToGeoJSON * @param {Array} tile - * @returns {Feature} + * @returns {Feature} * @example * var poly = tileToGeoJSON([5, 10, 10]) * //=poly */ - tileToGeoJSON(tile: Array): GeoJSON.Feature + tileToGeoJSON(tile: Array): GeoJSON.Feature /** * Get the bbox of a tile