Skip to content

Commit

Permalink
updating readme
Browse files Browse the repository at this point in the history
  • Loading branch information
markmarkoh committed Apr 22, 2014
1 parent efee8c8 commit 35e283f
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 19 deletions.
77 changes: 59 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,47 +37,88 @@ grunt.initConfig({

### Options

#### options.separator
#### options.idProperty
Type: `String`
Default value: `', '`
Default value: `null`

A string value that is used to do something with whatever.
The key from `geography.properties` that should be used as `id`. Defaults to the `geography.id`.

#### options.punctuation
#### options.copyProperties
Type: `Array`
Default value: `null`

An array of properties to be copied. Use an empty array to not copy any properties. Keep `null` to copy all properties.

#### options.collectionName
Type: `String`
Default value: `'.'`
Default value: `null`

A property to be used to name the collection. Defaults to task name.
For example, if your config looks like this:
```js
topojson: {
world: {
files: []
}
}
```

The collectionName will default to `world`. This can be overridden by specifying a `collectionName`.
```js
topojson: {
world: {
files: []
},
options: {
collectionName: 'custom-data-world'
}
}
```

A string value that is used to do something else with whatever else.
All other [options can be found on the TopoJSON API documentation page](https://github.com/mbostock/topojson/wiki/API-Reference#server-api)

### Usage Examples

#### Default Options
In this example, the default options are used to do something with whatever. So if the `testing` file has the content `Testing` and the `123` file had the content `1 2 3`, the generated result would be `Testing, 1 2 3.`
With all default options, `src/world.json` will be converted into topoJSON and placed in `dest/world.topo.json`.
The results will look something like:

```json
{"type":"Topology","objects":{"world":{"type":"GeometryCollection","geometries":[{"type":"Polygo...
```

```js
grunt.initConfig({
topojson: {
options: {},
files: {
'dest/default_options': ['src/testing', 'src/123'],
},
world: {
options: {},
files: {
'dest/world.topo.json': ['src/world.json'],
}
}
},
});
```

#### Custom Options
In this example, custom options are used to do something else with whatever else. So if the `testing` file has the content `Testing` and the `123` file had the content `1 2 3`, the generated result in this case would be `Testing: 1 2 3 !!!`

```json
{"type":"Topology","objects":{"custom-world":{"type":"GeometryCollection","geometries":[{"type":"Polygo...
```

```js
grunt.initConfig({
topojson: {
options: {
separator: ': ',
punctuation: ' !!!',
},
files: {
'dest/default_options': ['src/testing', 'src/123'],
},
world: {
options: {
collectionName: 'custom-world',
quantization: 1e7
},
files: {
'dest/world.topo.json': ['src/world.json'],
}
}
},
});
```
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "grunt-topojson",
"description": "Convert GeoJSON to TopoJSON",
"description": "Grunt task for converting GeoJSON to TopoJSON",
"version": "0.1.0",
"homepage": "https://github.com/mark.dimarco/grunt-topojson",
"author": {
Expand Down

0 comments on commit 35e283f

Please sign in to comment.