Skip to content

Commit

Permalink
refactor: consolidate urls
Browse files Browse the repository at this point in the history
  • Loading branch information
stdavis committed Nov 29, 2024
1 parent bc881d8 commit 78f26a5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/components/Filter.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import FeatureLayer from '@arcgis/core/layers/FeatureLayer';
import { Button, TextField } from '@ugrc/utah-design-system';
import { useEffect, useRef } from 'react';
import config from '../config';
import { useFilter } from './contexts/FilterProvider';
import DateRange from './filters/DateRange';
import Purpose from './filters/Purpose';
Expand All @@ -20,8 +21,7 @@ export default function Filter(): JSX.Element {
}

stationsLayer.current = new FeatureLayer({
// TODO: this needs to be switched out in favor of the AGS_HOST env var once we have UtahID wired up.
url: 'https://wrimaps.utah.gov/arcgis/rest/services/Electrofishing/Public/MapServer/0',
url: config.urls.stations,
definitionExpression: emptyDefinition,
});
addLayers([stationsLayer.current]);
Expand Down
8 changes: 2 additions & 6 deletions src/components/MapContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ import { useEffect, useRef, useState } from 'react';
import { useMap } from './hooks';

import '@ugrc/layer-selector/src/LayerSelector.css';

const urls = {
landownership:
'https://gis.trustlands.utah.gov/hosting/rest/services/Hosted/Land_Ownership_WM_VectorTile/VectorTileServer',
};
import config from '../config';

type LayerFactory = {
Factory: new () => __esri.Layer;
Expand Down Expand Up @@ -73,7 +69,7 @@ export const MapContainer = ({ onClick }: { onClick?: __esri.ViewImmediateClickE
'Address Points',
{
Factory: VectorTileLayer,
url: urls.landownership,
url: config.urls.landownership,
id: 'Land Ownership',
opacity: 0.3,
},
Expand Down
13 changes: 13 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@ if (!import.meta.env.VITE_DATABASE_CONFIG) {
}
const databaseSecrets: { databaseName: string; user: string } = JSON.parse(import.meta.env.VITE_DATABASE_CONFIG);

// TODO: this should come from an env var once we get UtahID wired up
const arcgisServerHost = 'wrimaps.utah.gov';
const mapService = `https://${arcgisServerHost}/arcgis/rest/services/Electrofishing/Public/MapServer`;

const config = {
MIN_DESKTOP_WIDTH: 768,
WEB_MERCATOR_WKID: 3857,
MARKER_FILL_COLOR: [234, 202, 0, 0.5],
MARKER_OUTLINE_COLOR: [77, 42, 84, 1],
databaseSecrets,

fieldNames: {
// common
STATION_ID: 'STATION_ID',
Expand Down Expand Up @@ -47,6 +52,14 @@ const config = {
streams: 'UDWRStreams',
lakes: 'UDWRLakes',
},

urls: {
stations: `${mapService}/0`,
events: `${mapService}/1`,
fish: `${mapService}/2`,
landownership:
'https://gis.trustlands.utah.gov/hosting/rest/services/Hosted/Land_Ownership_WM_VectorTile/VectorTileServer',
},
};

export default config;

0 comments on commit 78f26a5

Please sign in to comment.