Skip to content

Commit 43e8535

Browse files
committed
📦 1.0.0
0 parents  commit 43e8535

File tree

9 files changed

+234
-0
lines changed

9 files changed

+234
-0
lines changed

.gitignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Logs
2+
logs
3+
*.log
4+
5+
# Runtime data
6+
pids
7+
*.pid
8+
*.seed
9+
10+
# Directory for instrumented libs generated by jscoverage/JSCover
11+
lib-cov
12+
13+
# Coverage directory used by tools like istanbul
14+
coverage
15+
16+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17+
.grunt
18+
19+
# node-waf configuration
20+
.lock-wscript
21+
22+
# Compiled binary addons (http://nodejs.org/api/addons.html)
23+
build/Release
24+
25+
# Dependency directory
26+
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
27+
node_modules

.travis.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
language: node_js
2+
node_js:
3+
- '0.10'
4+
- '0.12'
5+
- 'iojs'
6+
sudo: false
7+
cache:
8+
directories:
9+
- node_modules
10+
script:
11+
- npm test

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# format-spatial-ref change log
2+
3+
All notable changes to this project will be documented in this file.
4+
This project adheres to [Semantic Versioning](http://semver.org/).
5+
6+
## 1.0.0 - 2015-08-21
7+
* engage

CONTRIBUTING.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Contributing Guidelines
2+
3+
Contributions welcome!
4+
5+
**Before spending lots of time on something, ask for feedback on your idea first!**
6+
7+
Please search issues and pull requests before adding something new to avoid duplicating efforts and conversations.
8+
9+
In addition to improving the project by refactoring code and implementing relevant features, this project welcomes the following types of contributions:
10+
11+
- **Ideas**: participate in an issue thread or start your own to have your voice heard.
12+
- **Writing**: contribute your expertise in an area by helping expand the included content.
13+
- **Copy editing**: fix typos, clarify language, and generally improve the quality of the content.
14+
- **Formatting**: help keep content easy to read with consistent formatting.
15+
16+
## Installing
17+
18+
Fork and clone the repo, then `npm install` to install all dependencies.
19+
20+
## Testing
21+
22+
Tests are run with `npm test`. Unless you're creating a failing test to increase test coverage or show a problem, please make sure all tests are passing before submitting a pull request.
23+
24+
## Code Style
25+
26+
[![standard][standard-image]][standard-url]
27+
28+
This repository uses [`standard`][standard-url] to maintain code style and consistency and avoid style arguments. `npm test` runs `standard` so you don't have to!
29+
30+
[standard-image]: https://cdn.rawgit.com/feross/standard/master/badge.svg
31+
[standard-url]: https://github.com/feross/standard
32+
[semistandard-image]: https://cdn.rawgit.com/flet/semistandard/master/badge.svg
33+
[semistandard-url]: https://github.com/Flet/semistandard
34+
35+
---
36+
37+
# Collaborating Guidelines
38+
39+
**This is an OPEN Open Source Project.**
40+
41+
## What?
42+
43+
Individuals making significant and valuable contributions are given commit access to the project to contribute as they see fit. This project is more like an open wiki than a standard guarded open source project.
44+
45+
## Rules
46+
47+
There are a few basic ground rules for collaborators:
48+
49+
1. **No `--force` pushes** or modifying the Git history in any way.
50+
1. **Non-master branches** ought to be used for ongoing work.
51+
1. **External API changes and significant modifications** ought to be subject to an **internal pull request** to solicit feedback from other collaborators.
52+
1. Internal pull requests to solicit feedback are *encouraged* for any other non-trivial contribution but left to the discretion of the contributor.
53+
1. Contributors should attempt to adhere to the prevailing code style.
54+
55+
## Releases
56+
57+
Declaring formal releases remains the prerogative of the project maintainer.
58+
59+
## Changes to this arrangement
60+
61+
This is an experiment and feedback is welcome! This document may also be subject to pull requests or changes by collaborators where you believe you have something valuable to add or change.

LICENSE

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright 2015 ESRI
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# format-spatial-ref
2+
3+
> Format WKID spatial reference variations into a standard structure.
4+
5+
[![npm][npm-image]][npm-url]
6+
[![travis][travis-image]][travis-url]
7+
8+
[npm-image]: https://img.shields.io/npm/v/format-spatial-ref.svg?style=flat-square
9+
[npm-url]: https://www.npmjs.com/package/format-spatial-ref
10+
[travis-image]: https://img.shields.io/travis/koopjs/format-spatial-ref.svg?style=flat-square
11+
[travis-url]: https://travis-ci.org/koopjs/format-spatial-ref
12+
13+
## Install
14+
15+
```
16+
npm install format-spatial-ref
17+
```
18+
19+
## Usage
20+
21+
```js
22+
var formatSpatialRef = require('format-spatial-ref')
23+
24+
formatSpatialRef({"wkid": 4326})
25+
formatSpatialRef('{"wkid": 4326}')
26+
formatSpatialRef(4326)
27+
28+
// All of the above will return { "wkid": 4326 }
29+
```
30+
31+
## Contributing
32+
33+
Contributions welcome! Please read the [contributing guidelines](CONTRIBUTING.md) first.
34+
35+
## License
36+
37+
[Apache-2.0](LICENSE)

index.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* Format WKID spatial reference variations into a standard structure.
3+
*
4+
* @param {string|number|object} spatialRef - spatial reference variation
5+
* @return {object} standard spatial reference object
6+
*/
7+
function formatSpatialRef (spatialRef) {
8+
if (typeof spatialRef === 'string') {
9+
try {
10+
return JSON.parse(spatialRef)
11+
} catch (e) {
12+
return spatialRef
13+
}
14+
}
15+
16+
if (typeof spatialRef === 'number') {
17+
return {
18+
wkid: spatialRef
19+
}
20+
}
21+
22+
return spatialRef
23+
}
24+
25+
module.exports = formatSpatialRef

package.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "format-spatial-ref",
3+
"description": "Format WKID spatial reference variations into a standard structure.",
4+
"version": "1.0.0",
5+
"author": "Nate Goldman <[email protected]>",
6+
"bugs": {
7+
"url": "https://github.com/koopjs/format-spatial-ref/issues"
8+
},
9+
"devDependencies": {
10+
"standard": "^5.1.0",
11+
"tap-spec": "^4.0.2",
12+
"tape": "^4.0.0"
13+
},
14+
"homepage": "https://github.com/koopjs/format-spatial-ref",
15+
"keywords": [
16+
"arcgis",
17+
"esri",
18+
"format",
19+
"reference",
20+
"spatial",
21+
"well-known",
22+
"wkid"
23+
],
24+
"license": "Apache-2.0",
25+
"main": "index.js",
26+
"repository": {
27+
"type": "git",
28+
"url": "https://github.com/koopjs/format-spatial-ref.git"
29+
},
30+
"scripts": {
31+
"test": "standard && tape test/*.js | tap-spec"
32+
}
33+
}

test/index.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
var test = require('tape')
2+
var formatSpatialRef = require('../')
3+
4+
test('returns correct wkid from json', function (t) {
5+
var sr = formatSpatialRef({wkid: 4326})
6+
t.equal(sr.wkid, 4326)
7+
t.end()
8+
})
9+
10+
test('returns correct wkid from stringified json', function (t) {
11+
var sr = formatSpatialRef('{"wkid": 4326}')
12+
t.equal(sr.wkid, 4326)
13+
t.end()
14+
})
15+
16+
test('returns correct wkid from numeric value', function (t) {
17+
var sr = formatSpatialRef(4326)
18+
t.equal(sr.wkid, 4326)
19+
t.end()
20+
})

0 commit comments

Comments
 (0)