-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
1,785 additions
and
114 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,4 @@ | |
"include": [ | ||
"src/**/*.ts" | ||
] | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
[![npm version][npm-img]][npm-url] | ||
[![build status][travis-img]][travis-url] | ||
[![Coverage Status][coverage-img]][coverage-url] | ||
[![apache licensed](https://img.shields.io/badge/license-Apache-green.svg?style=flat-square)](https://raw.githubusercontent.com/Esri/arcgis-rest-js/master/LICENSE) | ||
|
||
[npm-img]: https://img.shields.io/npm/v/@esri/arcgis-rest-common.svg?style=flat-square | ||
[npm-url]: https://www.npmjs.com/package/@esri/arcgis-rest-common | ||
[travis-img]: https://img.shields.io/travis/Esri/arcgis-rest-js/master.svg?style=flat-square | ||
[travis-url]: https://travis-ci.org/Esri/arcgis-rest-js | ||
[coverage-img]: https://coveralls.io/repos/github/Esri/arcgis-rest-js/badge.svg | ||
[coverage-url]: https://coveralls.io/github/Esri/arcgis-rest-js | ||
|
||
# @esri/arcgis-rest-common | ||
|
||
> Shared utility methods for [`@esri/arcgis-rest-js`](https://github.com/Esri/arcgis-rest-js). | ||
### Example | ||
|
||
```bash | ||
npm install @esri/arcgis-rest-common | ||
``` | ||
|
||
### [API Reference](https://esri.github.io/arcgis-rest-js/api/common/) | ||
|
||
### Issues | ||
|
||
If something isn't working the way you expected, please take a look at [previously logged issues](https://github.com/Esri/arcgis-rest-js/issues) first. Have you found a new bug? Want to request a new feature? We'd [**love**](https://github.com/Esri/arcgis-rest-js/issues/new) to hear from you. | ||
|
||
If you're looking for help you can also post issues on [GIS Stackexchange](http://gis.stackexchange.com/questions/ask?tags=esri-oss). | ||
|
||
### Versioning | ||
|
||
For transparency into the release cycle and in striving to maintain backward compatibility, @esri/arcgis-rest-js is maintained under Semantic Versioning guidelines and will adhere to these rules whenever possible. | ||
|
||
For more information on SemVer, please visit <http://semver.org/>. | ||
|
||
### Contributing | ||
|
||
Esri welcomes contributions from anyone and everyone. Please see our [guidelines for contributing](CONTRIBUTING.md). | ||
|
||
### License | ||
|
||
Copyright © 2018 Esri | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
> http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
|
||
A copy of the license is available in the repository's [LICENSE](../../LICENSE) file. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"name": "@esri/arcgis-rest-common", | ||
"version": "1.13.2", | ||
"description": "Shared utility methods for @esri/arcgis-rest-js", | ||
"main": "dist/node/index.js", | ||
"browser": "dist/umd/common.umd.js", | ||
"module": "dist/esm/index.js", | ||
"js:next": "dist/esm/index.js", | ||
"types": "dist/esm/index.d.ts", | ||
"license": "Apache-2.0", | ||
"files": [ | ||
"dist/**" | ||
], | ||
"dependencies": { | ||
"tslib": "^1.9.3" | ||
}, | ||
"devDependencies": {}, | ||
"peerDependencies": {}, | ||
"scripts": { | ||
"prepare": "npm run build", | ||
"build": "npm run build:node && npm run build:umd && npm run build:esm", | ||
"build:esm": "tsc -p ./tsconfig.json --module es2015 --outDir ./dist/esm --declaration", | ||
"build:umd": "rollup -c ../../umd-base-profile.js && rollup -c ../../umd-production-profile.js", | ||
"build:node": "tsc -p ./tsconfig.json --module commonjs --outDir ./dist/node", | ||
"dev:esm": "tsc -w --module es2015 --outDir ./dist/esm --declaration", | ||
"dev:umd": "rollup -w -c ../../umd-base-profile.js", | ||
"dev:node": "tsc -w --module commonjs --outDir ./dist/node" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/Esri/arcgis-rest-js.git" | ||
}, | ||
"contributors": [ | ||
"John Gravois <john@esri.com>" | ||
], | ||
"bugs": { | ||
"url": "https://github.com/Esri/arcgis-rest-js/issues" | ||
}, | ||
"homepage": "https://github.com/Esri/arcgis-rest-js#readme" | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
|
||
// utility methods | ||
export * from "./util/location"; | ||
|
||
// types | ||
export * from "./types/feature"; | ||
export * from "./types/geometry"; | ||
export * from "./types/symbol"; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
|
||
import { IGeometry } from "./geometry"; | ||
import { ISymbol } from "./symbol"; | ||
|
||
/** | ||
* a spatial entity and its corresponding properties | ||
*/ | ||
export interface IFeature { | ||
geometry?: IGeometry; | ||
attributes: { [key: string]: any }; | ||
symbol?: ISymbol; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
|
||
/** | ||
* | ||
*/ | ||
export interface IHasZM { | ||
hasZ?: boolean; | ||
hasM?: boolean; | ||
} | ||
|
||
/** | ||
* Spatial reference systems define mathematical transformations and coordinate systems for displaying spatial information in 2D and 3D. | ||
*/ | ||
export interface ISpatialReference { | ||
wkid?: number; | ||
latestWkid?: number; | ||
vcsWkid?: number; | ||
latestVcsWkid?: number; | ||
wkt?: string; | ||
latestWkt?: string; | ||
} | ||
|
||
/** | ||
* a building block for discrete geometries | ||
*/ | ||
export interface IGeometry { | ||
spatialReference?: ISpatialReference; | ||
} | ||
|
||
/** | ||
* A simple point geometry, with spatial reference defined. | ||
*/ | ||
export interface IPoint extends IHasZM, IGeometry { | ||
x: number; | ||
y: number; | ||
} | ||
|
||
/** | ||
* | ||
*/ | ||
export interface ILocation { | ||
latitude?: number; | ||
longitude?: number; | ||
lat?: number; | ||
long?: number; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
|
||
/** | ||
* | ||
*/ | ||
export type SymbolType = | ||
| "esriSLS" | ||
| "esriSMS" | ||
| "esriSFS" | ||
| "esriPMS" | ||
| "esriPFS" | ||
| "esriTS"; | ||
|
||
/** | ||
* | ||
*/ | ||
export interface ISymbol { | ||
type: SymbolType; | ||
style?: string; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
|
||
import { IPoint, ILocation } from "../types/geometry"; | ||
|
||
export function isLocationArray( | ||
coords: ILocation | IPoint | [number, number] | ||
): coords is [number, number] { | ||
return (coords as [number, number]).length === 2; | ||
} | ||
|
||
export function isLocation( | ||
coords: ILocation | IPoint | [number, number] | ||
): coords is ILocation { | ||
return ( | ||
(coords as ILocation).latitude !== undefined || | ||
(coords as ILocation).lat !== undefined | ||
); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
|
||
import { IPoint } from "../../arcgis-rest-common-types/src"; | ||
import { ILocation } from "../src/types/geometry"; | ||
import { isLocation, isLocationArray } from "../src/util/location"; | ||
|
||
// -117.195677,34.056383;-117.918976,33.812092 | ||
const stops: Array<[number, number]> = [ | ||
[-117.195677, 34.056383], | ||
[-117.918976, 33.812092] | ||
]; | ||
|
||
const stopsObjectsLatLong: ILocation[] = [ | ||
{ | ||
lat: 34.056383, | ||
long: -117.195677 | ||
}, | ||
{ | ||
lat: 33.812092, | ||
long: -117.918976 | ||
} | ||
]; | ||
|
||
const stopsObjectsLatitudeLongitude: ILocation[] = [ | ||
{ | ||
latitude: 34.056383, | ||
longitude: -117.195677 | ||
}, | ||
{ | ||
latitude: 33.812092, | ||
longitude: -117.918976 | ||
} | ||
]; | ||
|
||
const stopsObjectsPoint: IPoint[] = [ | ||
{ | ||
x: 34.056383, | ||
y: -117.195677 | ||
}, | ||
{ | ||
x: 33.812092, | ||
y: -117.918976 | ||
} | ||
]; | ||
|
||
describe("location helpers", () => { | ||
it("should recognize a shorthand location", done => { | ||
expect(isLocation(stopsObjectsLatLong[0])).toEqual(true); | ||
done(); | ||
}); | ||
|
||
it("should recognize a spelled out location", done => { | ||
expect(isLocation(stopsObjectsLatitudeLongitude[0])).toEqual(true); | ||
done(); | ||
}); | ||
|
||
it("should recognize that a point is not a location", done => { | ||
expect(isLocation(stopsObjectsPoint[0])).toEqual(false); | ||
done(); | ||
}); | ||
|
||
it("should recognize that raw coordinates are not a location", done => { | ||
expect(isLocation(stops[0])).toEqual(false); | ||
done(); | ||
}); | ||
|
||
it("should recognize a location array", done => { | ||
expect(isLocationArray(stops[0])).toEqual(true); | ||
expect(isLocationArray(stops[1])).toEqual(true); | ||
done(); | ||
}); | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"include": [ | ||
"src/**/*.ts" | ||
] | ||
} |
This file contains 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
This file contains 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
Oops, something went wrong.