What is @types/geojson?
The @types/geojson package provides TypeScript type definitions for the GeoJSON format. It allows developers to use GeoJSON objects in TypeScript projects with type checking, enabling them to work with geographical data structures according to the GeoJSON specification. This package does not include functionality to manipulate GeoJSON data but rather ensures type safety and autocompletion when working with GeoJSON in TypeScript.
What are @types/geojson's main functionalities?
Defining GeoJSON Objects
This code sample demonstrates how to define a GeoJSON object representing a feature collection with TypeScript. The @types/geojson package ensures that the object structure adheres to the GeoJSON specification.
{"type": "FeatureCollection", "features": [{ "type": "Feature", "geometry": { "type": "Point", "coordinates": [102.0, 0.5] }, "properties": { "prop0": "value0" } }]}
Type Checking GeoJSON Objects
This code sample shows how to use the @types/geojson package for type checking a GeoJSON object. It ensures that the object conforms to the GeoJSON specification for a FeatureCollection containing Point features.
import { FeatureCollection, Point } from 'geojson';
const myGeoJsonObject: FeatureCollection<Point> = {
type: 'FeatureCollection',
features: [
{
type: 'Feature',
geometry: {
type: 'Point',
coordinates: [102.0, 0.5]
},
properties: {}
}
]
};
Other packages similar to @types/geojson
terraformer
Terraformer is a geographic toolkit for dealing with geometry, geography, formats, and building geo databases. It goes beyond just type definitions to offer manipulation and conversion functionalities for GeoJSON data. Unlike @types/geojson, Terraformer provides tools for working with the data, not just type definitions.
turf
Turf is a modular geospatial engine written in JavaScript. It includes various functions to analyze, aggregate, and manipulate GeoJSON data. While @types/geojson provides type definitions for TypeScript projects, Turf offers a wide range of functionalities for spatial analysis and manipulation of GeoJSON objects.
Installation
npm install --save-dev @types/geojson
Summary
This package contains type definitions for GeoJSON Format Specification.
The project URL or description is http://geojson.org/
Credits
These definitions were written by Jacob Bruun https://github.com/cobster/.
Details
Typings were exported from https://www.github.com/DefinitelyTyped/DefinitelyTyped in the geojson directory.
Additional Details
- Last updated: Tue, 17 May 2016 04:07:57 GMT
- Typings kind: Global
- Library Dependencies: none
- Module Dependencies: none
- Global values: none