Last active
November 9, 2021 12:54
-
-
Save codediodeio/5cb4b2be7aae85dc06fb83aba1ada82f to your computer and use it in GitHub Desktop.
A Typescript interface for GeoJSON objects based on rfc7946
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export interface IGeometry { | |
type: string; | |
coordinates: number[]; | |
} | |
export interface IGeoJson { | |
type: string; | |
geometry: IGeometry; | |
bbox?: number[]; | |
properties?: any; | |
} | |
export class GeoJson implements IGeoJson { | |
constructor(public type, public geometry, properties?, bbox?) {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, but in case the feature type is
MultiPolygon
then coordinates must be:and since the coordinates are always a two element tuple it is better to describe as
[number, number]
instead ofnumber[]