Skip to content

Commit

Permalink
Split the source_tile entry in the JSON schema into source_vector
Browse files Browse the repository at this point in the history
… and `source_raster`

I did not include `scheme` in `source_vector` -- let's discourage TMS vector sources as much as possible.
  • Loading branch information
jfirebaugh committed Nov 6, 2017
1 parent d6345c2 commit b0c0ae6
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 25 deletions.
12 changes: 5 additions & 7 deletions docs/pages/style-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -593,11 +593,9 @@ export default class extends React.Component {
}`)}
</div>
<div className='space-bottom1 clearfix'>
{ entries(ref.source_tile).map(([name, prop], i) =>
// note that we omit 'tileSize' here, since VECTOR and raster
// both use source_tile, but tileSize is prohibited for vector sources
name !== '*' && name !== 'type' && name !== 'tileSize' &&
<Item key={i} id={`sources-vector-${name}`} name={name} {...prop}/>)}
{ entries(ref.source_vector).map(([name, prop], i) =>
name !== '*' && name !== 'type' &&
<Item key={i} id={`sources-vector-${name}`} name={name} {...prop}/>)}
</div>
<table className="micro">
<thead>
Expand Down Expand Up @@ -636,9 +634,9 @@ export default class extends React.Component {
}`)}
</div>
<div className='space-bottom1 clearfix'>
{ entries(ref.source_tile).map(([name, prop], i) =>
{ entries(ref.source_raster).map(([name, prop], i) =>
name !== '*' && name !== 'type' &&
<Item key={i} id={`sources-raster-${name}`} name={name} {...prop}/>)}
<Item key={i} id={`sources-raster-${name}`} name={name} {...prop}/>)}
</div>
<table className="micro">
<thead>
Expand Down
21 changes: 17 additions & 4 deletions flow-typed/style-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,26 @@ declare type LightSpecification = {|
"intensity"?: PropertyValueSpecification<number>
|}

declare type TileSourceSpecification = {
"type": "vector" | "raster",
declare type VectorSourceSpecification = {
"type": "vector",
"url"?: string,
"tiles"?: Array<string>,
"bounds"?: [number, number, number, number],
"minzoom"?: number,
"maxzoom"?: number,
"tileSize"?: number
"attribution"?: string
}

declare type RasterSourceSpecification = {
"type": "raster",
"url"?: string,
"tiles"?: Array<string>,
"bounds"?: [number, number, number, number],
"minzoom"?: number,
"maxzoom"?: number,
"tileSize"?: number,
"scheme"?: "xyz" | "tms",
"attribution"?: string
}

declare type GeojsonSourceSpecification = {|
Expand Down Expand Up @@ -115,7 +127,8 @@ declare type CanvasSourceSpecification = {|
|}

declare type SourceSpecification =
| TileSourceSpecification
| VectorSourceSpecification
| RasterSourceSpecification
| GeojsonSourceSpecification
| VideoSourceSpecification
| ImageSourceSpecification
Expand Down
4 changes: 2 additions & 2 deletions src/source/raster_tile_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class RasterTileSource extends Evented implements Source {
tiles: Array<string>;

_loaded: boolean;
_options: TileSourceSpecification;
_options: RasterSourceSpecification;

constructor(id: string, options: TileSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented) {
constructor(id: string, options: RasterSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented) {
super();
this.id = id;
this.dispatcher = dispatcher;
Expand Down
4 changes: 2 additions & 2 deletions src/source/vector_tile_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class VectorTileSource extends Evented implements Source {
scheme: string;
tileSize: number;

_options: TileSourceSpecification;
_options: VectorSourceSpecification;
dispatcher: Dispatcher;
map: Map;
bounds: ?[number, number, number, number];
Expand All @@ -32,7 +32,7 @@ class VectorTileSource extends Evented implements Source {
reparseOverscaled: boolean;
isTileClipped: boolean;

constructor(id: string, options: TileSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented) {
constructor(id: string, options: VectorSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented) {
super();
this.id = id;
this.dispatcher = dispatcher;
Expand Down
1 change: 1 addition & 0 deletions src/style-spec/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

* v6 styles are no longer supported.
* v7 styles are supported only for migration, not for validation.
* Split the `source_tile` entry in the JSON schema into `source_vector` and `source_raster`.

## 10.0.1

Expand Down
62 changes: 53 additions & 9 deletions src/style-spec/reference/v8.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,25 +106,69 @@
}
},
"source": [
"source_tile",
"source_vector",
"source_raster",
"source_geojson",
"source_video",
"source_image",
"source_canvas"
],
"source_tile": {
"source_vector": {
"type": {
"required": true,
"type": "enum",
"values": {
"vector": {
"doc": "A vector tile source."
},
"doc": "A vector tile source."
}
},
"doc": "The type of the source."
},
"url": {
"type": "string",
"doc": "A URL to a TileJSON resource. Supported protocols are `http:`, `https:`, and `mapbox://<mapid>`."
},
"tiles": {
"type": "array",
"value": "string",
"doc": "An array of one or more tile source URLs, as in the TileJSON spec."
},
"bounds": {
"type": "array",
"value": "number",
"length": 4,
"default": [-180, -85.0511, 180, 85.0511],
"doc": "An array containing the longitude and latitude of the southwest and northeast corners of the source's bounding box in the following order: `[sw.lng, sw.lat, ne.lng, ne.lat]`. When this property is included in a source, no tiles outside of the given bounds are requested by Mapbox GL."
},
"minzoom": {
"type": "number",
"default": 0,
"doc": "Minimum zoom level for which tiles are available, as in the TileJSON spec."
},
"maxzoom": {
"type": "number",
"default": 22,
"doc": "Maximum zoom level for which tiles are available, as in the TileJSON spec. Data from tiles at the maxzoom are used when displaying the map at higher zoom levels."
},
"attribution": {
"type": "string",
"doc": "Contains an attribution to be displayed when the map is shown to a user."
},
"*": {
"type": "*",
"doc": "Other keys to configure the data source."
}
},
"source_raster": {
"type": {
"required": true,
"type": "enum",
"values": {
"raster": {
"doc": "A raster tile source."
"doc": "A raster tile source."
}
},
"doc": "The data type of the tile source."
"doc": "The type of the source."
},
"url": {
"type": "string",
Expand Down Expand Up @@ -186,7 +230,7 @@
"type": "enum",
"values": {
"geojson": {
"doc": "A GeoJSON data source."
"doc": "A GeoJSON data source."
}
},
"doc": "The data type of the GeoJSON source."
Expand Down Expand Up @@ -234,7 +278,7 @@
"type": "enum",
"values": {
"video": {
"doc": "A video data source."
"doc": "A video data source."
}
},
"doc": "The data type of the video source."
Expand Down Expand Up @@ -264,7 +308,7 @@
"type": "enum",
"values": {
"image": {
"doc": "An image data source."
"doc": "An image data source."
}
},
"doc": "The data type of the image source."
Expand Down
2 changes: 1 addition & 1 deletion src/style-spec/validate/validate_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = function validateSource(options) {
errors = errors.concat(validateObject({
key: key,
value: value,
valueSpec: styleSpec.source_tile,
valueSpec: styleSpec[`source_${type}`],
style: options.style,
styleSpec: styleSpec
}));
Expand Down

0 comments on commit b0c0ae6

Please sign in to comment.