Skip to content

Commit

Permalink
style: Ran prettier to format files
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffJacobson committed Sep 30, 2024
1 parent 24366ac commit fec9f56
Show file tree
Hide file tree
Showing 19 changed files with 236 additions and 230 deletions.
6 changes: 3 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"eslint.useFlatConfig": true,
"eslint.useESLintClass": true
}
"eslint.useFlatConfig": true,
"eslint.useESLintClass": true
}
146 changes: 69 additions & 77 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,78 +1,70 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "build",
"group": {
"kind": "build",
"isDefault": true
},
"icon": {
"id": "tools",
"color": "terminal.ansiGreen"
},
"problemMatcher": [
"$tsc"
],
"label": "Build",
"detail": "Builds the project for production"
},
{
"type": "npm",
"script": "dev",
"problemMatcher": [
"$tsc-watch"
],
"icon": {
"id": "eye-watch",
"color": "terminal.ansiCyan"
},
"group": "build",
"label": "Watch using Vite dev mode",
"detail": "vite"
},
{
"type": "npm",
"script": "deploy",
"label": "Deploy",
"detail": "Deploys the page to GitHub Pages of this repository.",
"icon": {
"id": "github-inverted",
"color": "terminal.ansiRed"
},
"problemMatcher": [],
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "dedicated",
"showReuseMessage": true,
"clear": true
}
},
{
"type": "npm",
"script": "preview",
"group": "build",
"icon": {
"id": "preview",
"color": "terminal.ansiGreen"
},
"problemMatcher": [
"$tsc"
],
"label": "Preview production",
"detail": "Perform Vite production build and then preview it."
},
{
"type": "npm",
"script": "lint:eslint",
"problemMatcher": [
"$eslint-compact"
],
"label": "npm: lint:eslint",
"detail": "eslint . --fix"
}
]
}
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "build",
"group": {
"kind": "build",
"isDefault": true
},
"icon": {
"id": "tools",
"color": "terminal.ansiGreen"
},
"problemMatcher": ["$tsc"],
"label": "Build",
"detail": "Builds the project for production"
},
{
"type": "npm",
"script": "dev",
"problemMatcher": ["$tsc-watch"],
"icon": {
"id": "eye-watch",
"color": "terminal.ansiCyan"
},
"group": "build",
"label": "Watch using Vite dev mode",
"detail": "vite"
},
{
"type": "npm",
"script": "deploy",
"label": "Deploy",
"detail": "Deploys the page to GitHub Pages of this repository.",
"icon": {
"id": "github-inverted",
"color": "terminal.ansiRed"
},
"problemMatcher": [],
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "dedicated",
"showReuseMessage": true,
"clear": true
}
},
{
"type": "npm",
"script": "preview",
"group": "build",
"icon": {
"id": "preview",
"color": "terminal.ansiGreen"
},
"problemMatcher": ["$tsc"],
"label": "Preview production",
"detail": "Perform Vite production build and then preview it."
},
{
"type": "npm",
"script": "lint:eslint",
"problemMatcher": ["$eslint-compact"],
"label": "npm: lint:eslint",
"detail": "eslint . --fix"
}
]
}
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

This is a starter application for creating a single page map application using the [ArcGIS Maps SDK for JavaScript], which is built using [Vite] and [TypeScript].

[Vite]:https://vitejs.dev/
[TypeScript]:https://www.typescriptlang.org/
[ArcGIS Maps SDK for JavaScript]:https://developers.arcgis.com/javascript/latest/
[Vite]: https://vitejs.dev/
[TypeScript]: https://www.typescriptlang.org/
[ArcGIS Maps SDK for JavaScript]: https://developers.arcgis.com/javascript/latest/

## Use

Expand All @@ -19,9 +19,9 @@ More information about templates can be found in this [GitHub blog: Generate new
1. Clone this repository to your computer's hard drive.
2. Remove the remote repository

```cmd
git remote remove origin
```
```cmd
git remote remove origin
```

3. Update the information in the `package.json` file with your own project's information.
4. Add your remote using the `git remote` command.
47 changes: 21 additions & 26 deletions cspell.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
{
"version": "0.2",
"allowCompoundWords": true,
"useGitignore": true,
"ignorePaths": [
"**/tsconfig.json"
],
"dictionaryDefinitions": [
{
"name": "custom-dictionary",
"path": "./.cspell/custom-dictionary.txt",
"addWords": true
},
{
"name": "field-names-dictionary",
"path": "./.cspell/field-names-dictionary.txt",
"addWords": true,
"description": "This dictionary is used for map service field names."
}
],
"dictionaries": [
"custom-dictionary",
"field-names-dictionary"
],
"words": [],
"ignoreWords": [],
"import": []
"version": "0.2",
"allowCompoundWords": true,
"useGitignore": true,
"ignorePaths": ["**/tsconfig.json"],
"dictionaryDefinitions": [
{
"name": "custom-dictionary",
"path": "./.cspell/custom-dictionary.txt",
"addWords": true
},
{
"name": "field-names-dictionary",
"path": "./.cspell/field-names-dictionary.txt",
"addWords": true,
"description": "This dictionary is used for map service field names."
}
],
"dictionaries": ["custom-dictionary", "field-names-dictionary"],
"words": [],
"ignoreWords": [],
"import": []
}
17 changes: 10 additions & 7 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
<link rel="shortcut icon" href="./favicon.svg" type="text/xml+svg">
<meta charset="utf-8" />
<meta
name="viewport"
content="initial-scale=1, maximum-scale=1, user-scalable=no"
/>
<link rel="shortcut icon" href="./favicon.svg" type="text/xml+svg" />
<title>👷‍♂️Add your title here!👷‍♀️</title>
</head>
<body>
<div id="viewDiv"></div>
<script type="module" src="/src/main.ts"></script>
<div id="viewDiv"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
</html>
30 changes: 17 additions & 13 deletions src/arcgis/featureServiceQuery.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { IRequestOptions, request } from "@esri/arcgis-rest-request";
// aliasArrays will be an array where each element in the array
// will be an array of two strings.
import aliasArrays from "./field-aliases.json";
// Layer definitions for the query are defined in this JSON file.
import layerDefObject from "./layer-defs.json";
import type {
AttributeValue,
FeatureServiceQueryResponse,
QueryResponseLayer,
} from "./typesAndInterfaces";
// Layer definitions for the query are defined in this JSON file.
import layerDefObject from "./layer-defs.json";
// aliasArrays will be an array where each element in the array
// will be an array of two strings.
import aliasArrays from "./field-aliases.json";
import { IRequestOptions, request } from "@esri/arcgis-rest-request";

export const defaultUrl =
"https://data.wsdot.wa.gov/arcgis/rest/services/DataLibrary/DataLibrary/FeatureServer/";
Expand All @@ -18,7 +18,9 @@ const layerDefs = JSON.stringify(layerDefObject);

export type FieldAliasMap = Map<string, string>;

const aliasMap = Array.isArray(aliasArrays) ? new Map(aliasArrays as [string, string][]) : undefined;
const aliasMap = Array.isArray(aliasArrays)
? new Map(aliasArrays as [string, string][])
: undefined;

/**
* Query a feature service for features that intersect with
Expand All @@ -29,7 +31,7 @@ const aliasMap = Array.isArray(aliasArrays) ? new Map(aliasArrays as [string, st
*/
export async function query(
xy: [number, number],
featureServiceUrl: string = defaultUrl
featureServiceUrl: string = defaultUrl,
) {
const queryUrl = new URL("query", featureServiceUrl);
const queryParams: IRequestOptions = {
Expand All @@ -46,27 +48,29 @@ export async function query(
console.debug("query params", queryParams);
const response = (await request(
queryUrl.toString(),
queryParams
queryParams,
)) as FeatureServiceQueryResponse;

return response;
}


/**
* Enumerates all of the fields and returns field name and alias
* pairs. The output can be used to construct a Map.
* @param layer - An element of the query response "layers" array.
* @param aliasOverrides - If the feature service's aliases are not to your liking,
* you can override them with this mapping, with your desired aliases mapped to
* you can override them with this mapping, with your desired aliases mapped to
* the corresponding field names.
* @yields Two-element arrays containing fields' name and alias,
* respectively. If there is no alias then both elements in the
* array will contain the field name.
* @example
* const aliasMap = new Map(enumerateFieldAliases(layer));
*/
function* enumerateFieldAliases(layer: QueryResponseLayer, aliasOverrides?: FieldAliasMap) {
function* enumerateFieldAliases(
layer: QueryResponseLayer,
aliasOverrides?: FieldAliasMap,
) {
if (layer.fields) {
for (const field of layer.fields) {
const { name } = field;
Expand Down Expand Up @@ -115,7 +119,7 @@ function createRegex(...items: string[]) {
export function* enumerateQueryResponseAttributes(
response: FeatureServiceQueryResponse,
fieldsToOmit: string[] = ["OBJECTID"],
aliasOverrides = aliasMap
aliasOverrides = aliasMap,
) {
// Create a regular expression that will match the names of fields
// that will be omitted from being yielded.
Expand Down
8 changes: 4 additions & 4 deletions src/arcgis/field-aliases.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[
["LDNM", "Township Subdivision"],
["JURLBL", "County"],
["CityName", "City"]
]
["LDNM", "Township Subdivision"],
["JURLBL", "County"],
["CityName", "City"]
]
14 changes: 8 additions & 6 deletions src/arcgis/identify.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
/**
* @see https://developers.arcgis.com/rest/services-reference/enterprise/identify-map-service-.htm
*/

import type { Point, Geometry, esriGeometryType, Position2D } from "arcgis-rest-api";

import { request } from "@esri/arcgis-rest-request";
import type {
Point,
Geometry,
esriGeometryType,
Position2D,
} from "arcgis-rest-api";

export const enum LayerSpecifier {
all = "all",
Expand Down Expand Up @@ -70,7 +73,7 @@ export interface IdentifyParametersConstruction
}

function createIdentifyParameters(
options: IdentifyParametersConstruction
options: IdentifyParametersConstruction,
): IdentifyParameters {
const output: IdentifyParameters = {
geometry: options.geometry.join(",") as XYString,
Expand Down Expand Up @@ -143,7 +146,7 @@ const idUrl =

export async function identify(
idOptions: IdentifyParametersConstruction,
url: string | URL = idUrl
url: string | URL = idUrl,
) {
const idParams = createIdentifyParameters(idOptions);

Expand All @@ -156,6 +159,5 @@ export async function identify(
params: idParams,
});


return response;
}
Loading

0 comments on commit fec9f56

Please sign in to comment.