Merge pull request #2194 from Cobster/master

Adding GeoJSON spec
This commit is contained in:
Masahiro Wakame
2014-05-20 16:30:41 +09:00
3 changed files with 257 additions and 0 deletions
+1
View File
@@ -84,6 +84,7 @@ All definitions files include a header with the author and editors, so at some p
* [fs-extra](https://github.com/jprichardson/node-fs-extra) (by [midknight41](https://github.com/midknight41))
* [FullCalendar](http://arshaw.com/fullcalendar/) (by [Neil Stalker](https://github.com/nestalk))
* [Gamepad](http://www.w3.org/TR/gamepad/) (by [Kon](http://phyzkit.net/))
* [GeoJSON](http://geojson.org/) (by [Jake Bruun](https://github.com/cobster))
* [Giraffe](https://github.com/barc/backbone.giraffe) (by [Matt McCray](https://github.com/darthapo))
* [glDatePicker](http://glad.github.com/glDatePicker/) (by [Dániel Tar](https://github.com/qcz))
* [Glob](https://github.com/isaacs/node-glob) (by [vvakame](https://github.com/vvakame))
+129
View File
@@ -0,0 +1,129 @@
/// <reference path="./geojson.d.ts" />
var featureCollection: GeoJSON.FeatureCollection = {
type: "FeatureCollection",
features: [
{
type: "Feature",
geometry: {
type: "Point",
coordinates: [102.0, 0.5]
},
properties: {
prop0: "value0"
}
},
{
type: "Feature",
geometry: {
type: "LineString",
coordinates: [
[102.0, 0.0],
[103.0, 1.0],
[104.0, 0.0],
[105.0, 1.0]
]
},
properties: {
prop0: "value0",
prop1: 0.0
}
},
{
type: "Feature",
geometry: {
type: "Polygon",
coordinates: [
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ]
]
},
properties: {
prop0: "value0",
prop1: {
that: "this"
}
}
}
],
crs: {
type: "link",
properties: {
href: "http://example.com/crs/42",
type: "proj4"
}
}
}
var feature: GeoJSON.Feature = {
type: "Feature",
bbox: [-180.0, -90.0, 180.0, 90.0],
geometry: {
type: "Polygon",
coordinates: [
[[-180.0, 10.0], [20.0, 90.0], [180.0, -5.0], [-30.0, -90.0]]
]
},
properties: null
};
var point: GeoJSON.Point = {
type: "Point",
coordinates: [100.0, 0.0]
};
var lineString: GeoJSON.LineString = {
type: "LineString",
coordinates: [ [100.0, 0.0], [101.0, 1.0] ]
};
var polygon: GeoJSON.Polygon = {
type: "Polygon",
coordinates: [
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ]
]
};
var polygonWithHole: GeoJSON.Polygon = {
type: "Polygon",
coordinates: [
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ],
[ [100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2] ]
]
};
var multiPoint: GeoJSON.MultiPoint = {
type: "MultiPoint",
coordinates: [ [100.0, 0.0], [101.0, 1.0] ]
};
var multiLineString: GeoJSON.MultiLineString = {
type: "MultiLineString",
coordinates: [
[ [100.0, 0.0], [101.0, 1.0] ],
[ [102.0, 2.0], [103.0, 3.0] ]
]
};
var multiPolygon: GeoJSON.MultiPolygon = {
type: "MultiPolygon",
coordinates: [
[[[102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0], [102.0, 2.0]]],
[[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]],
[[100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2]]]
]
}
var geometryCollection: GeoJSON.GeometryCollection = {
type: "GeometryCollection",
"geometries": [
{
type: "Point",
coordinates: [100.0, 0.0]
},
{
type: "LineString",
coordinates: [ [101.0, 0.0], [102.0, 1.0] ]
}
]
}
+127
View File
@@ -0,0 +1,127 @@
// Type definitions for GeoJSON Format Specification
// Project: http://geojson.org/
// Definitions by: Jacob Bruun <https://github.com/cobster/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module GeoJSON {
/***
* http://geojson.org/geojson-spec.html#geojson-objects
*/
export interface GeoJsonObject
{
type: string;
bbox?: number[];
crs?: CoordinateReferenceSystem;
}
/***
* http://geojson.org/geojson-spec.html#positions
*/
export interface Position
{
[index: number]: number;
}
/***
* http://geojson.org/geojson-spec.html#geometry-objects
*/
export interface GeometryObject extends GeoJsonObject
{
coordinates: any
}
/***
* http://geojson.org/geojson-spec.html#point
*/
export interface Point extends GeometryObject
{
coordinates: Position
}
/***
* http://geojson.org/geojson-spec.html#multipoint
*/
export interface MultiPoint extends GeometryObject
{
coordinates: Position[]
}
/***
* http://geojson.org/geojson-spec.html#linestring
*/
export interface LineString extends GeometryObject
{
coordinates: Position[]
}
/***
* http://geojson.org/geojson-spec.html#multilinestring
*/
export interface MultiLineString extends GeometryObject
{
coordinates: Position[][]
}
/***
* http://geojson.org/geojson-spec.html#polygon
*/
export interface Polygon extends GeometryObject
{
coordinates: Position[][]
}
/***
* http://geojson.org/geojson-spec.html#multipolygon
*/
export interface MultiPolygon extends GeometryObject
{
coordinates: Position[][][]
}
/***
* http://geojson.org/geojson-spec.html#geometry-collection
*/
export interface GeometryCollection extends GeoJsonObject
{
geometries: GeometryObject[];
}
/***
* http://geojson.org/geojson-spec.html#feature-objects
*/
export interface Feature extends GeoJsonObject
{
geometry: GeometryObject;
properties: any;
id?: string;
}
/***
* http://geojson.org/geojson-spec.html#feature-collection-objects
*/
export interface FeatureCollection extends GeoJsonObject
{
features: Feature[];
}
/***
* http://geojson.org/geojson-spec.html#coordinate-reference-system-objects
*/
export interface CoordinateReferenceSystem
{
type: string;
properties: any;
}
export interface NamedCoordinateReferenceSystem extends CoordinateReferenceSystem
{
properties: { name: string }
}
export interface LinkedCoordinateReferenceSystem extends CoordinateReferenceSystem
{
properties: { href: string; type: string }
}
}