Skip to content

Instantly share code, notes, and snippets.

View stdavis's full-sized avatar

Scott Davis stdavis

View GitHub Profile
@stdavis
stdavis / arcade.js
Created April 6, 2023 16:43
RTP Popup Arcade Expression Example
// This is because the webmap can't parse our code for the fields that we are
// using since they are buried in field info dictionaries.
// This could be optimized to include only the fields that you use below
Expects($feature, '*');
// I can't believe that arcade doesn't define an expression like this!
function concat(target, source) {
for (var i in source) {
Push(target, source[i]);
}
import arcpy
import sys
AGRC = 'AGRC'
def get_tags_from_string(text):
if text is None:
return []
return [tag.strip() for tag in text.split(',')]
@stdavis
stdavis / javascript.json
Created July 20, 2021 18:25
react snippets
// REACT - didn't work in javascriptreact.json
"react component": {
"prefix": "comp",
"body": [
"const ${1:ComponentName} = () => {",
" return (",
" <div>$0</div>",
" );",
"};",
"",
@stdavis
stdavis / dedup.js
Created July 1, 2021 16:10
Dedup data in view counter datastore
async function go() {
const { Datastore } = require("@google-cloud/datastore");
const ds = new Datastore();
const query = ds.createQuery('view');
const [entities] = await ds.runQuery(query);
const uniqueURLs = {};
@stdavis
stdavis / queryFilter.json
Last active September 9, 2020 17:53
Proposed Query Filter configuration
"queryFilter": {
"layerName": "TIP Projects",
"fields": [
{
"label": "Funding Program",
"fieldName": "MSTR_PIN",
"fieldType": "text",
"checkboxes": [
{
"label": "CMAQ",
#!/usr/bin/env python
# * coding: utf8 *
'''
bootstrap_local_sde.py
Bootstraps a local SDE database with users.
Creates a new enterprise database with the sde schema.
Creates a connection file using operating system auth.
Adds passed in users (password matches the username) and creates connection files for each of them.
import re
import arcpy
SDE = r'C:\temp\parcels_metadata_fix_1.gdb'
BASIC_SUMMARY = 'GIS mapping data representing parcel boundaries.'
LIR_SUMMARY = 'GIS mapping data representing parcel boundaries and county tax roll attributes.'
BASIC_UPDATE_INFO = 'Update information can be found within the layer’s attributes and in a table on the <a href="https://gis.utah.gov/data/cadastre/parcels/#UtahParcels">Utah Parcel Data webpage</a> under Basic Parcels.'
LIR_UPDATE_INFO = 'Update information can be found within the layer’s attributes and in a table on the <a href="https://gis.utah.gov/data/cadastre/parcels/#UtahParcels">Utah Parcel Data webpage</a> under LIR Parcels.'
LAST_UPDATE_REGEX = re.compile(r'(<P><SPAN>)?Last Update: .*\d(<\/SPAN><\/P>)?', re.MULTILINE | re.IGNORECASE)
def cleanAddresses():
print(' * Cleaning Addresses')
def IsProblem(value):
ex = ['NO.', 'ST. JOSEPH', 'NORTH WAY']
return any(value.find(e) > -1 for e in ex)
def SkipName(value):
skipNameList = ['RIVER BEND WAY', 'CANYON CREST', 'WATER MILL WAY',
'''
fix_corrupt_geometries.py
A module that contains code for fixing geometries that stubbornly refused to give you their WKT
This code assumes that the OBJECTIDs are sequential.
Example usage:
from fix_corrupt_geometries import fix
require({
packages: [{
name: 'agrc',
location: 'http://mapserv.utah.gov/cdn/dojo/agrc/2.0/'
}]
}, [
'esri/map',
'esri/layers/ArcGISTiledMapServiceLayer',
'agrc/widgets/locate/FindAddress',
'esri/layers/ArcGISDynamicMapServiceLayer'