Skip to content

Instantly share code, notes, and snippets.

View staffordsmith83's full-sized avatar

Staf Smith staffordsmith83

  • Smith Field & Spatial
  • Perth, Western Australia
View GitHub Profile
@staffordsmith83
staffordsmith83 / BusTour.java
Created August 18, 2020 09:13
A bus tour of Europe has been very successful. Due to an increase in the number of people that want to go on a tour, the tour company decided to increase the height of the bus. The new height of the bus is exactly N centimeters. But the tour’s route runs under a lot of bridges, and there is a chance that the bus will crash into one of these brid…
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int busHeight = sc.nextInt();
int numBridges = sc.nextInt();
int bridgeHeight;
boolean crash = false;
@staffordsmith83
staffordsmith83 / Bearing.py
Created August 19, 2020 10:22
Bearing Class, stores a bearing in degrees. Has a method to return the bearing in DMS format!
class Bearing:
"""Class with one variable - angle. Intended to store bearings in degrees.
Values must be between 0 and 360 inclusive. Included methods - dd2dms(object).
Will return the degrees minutes seconds value of the bearing stored in the object.
Syntax - Bearing.dd2dms(my_bearing)"""
def __init__(self, angle=360):
# underscore(_) is used to denote private members
self._angle = angle
@staffordsmith83
staffordsmith83 / tide_access.py
Created August 19, 2020 11:11
Find which points are exposed depending on the tide height and a DEM. This code is part of a larger project and is provided as an example only.
from pathlib import Path
import pandas as pd
import geopandas as gpd
from shapely.geometry import Point
def main():
poi = get_poi_csv()
# print(poi)
@staffordsmith83
staffordsmith83 / buffer_all_layers.py
Created August 19, 2020 11:54
Python 2 script using arcpy - Buffer all the layers in the mapdoc!
# Title of Script: buffer_all_layers.py
# Description: Takes a map document, workspace, and buffer distance.
# Creates a buffered layer for each layer in the map document. Names buffered layers as: <original name>_buffer.
# If output name already exists, the naming convention
# Inserts buffered layer below original layer in TOC.
# Map documents with multiple dataframes are allowed, will be processed iteratively.
# Author: Stafford Smith
# Creation date: 26/10/2019 (SS)
# Last update: 30/10/2019 (SS)
@staffordsmith83
staffordsmith83 / Main.java
Last active August 19, 2020 12:03
A method that takes three integer numbers and returns the position of the first maximum in the order of the method parameters.
import java.util.Scanner;
public class Main {
public static int getNumberOfMaxParam(int a, int b, int c) {
int result = 1;
if (b > a) {
result = 2;
if (c > b) {
result = 3;
@staffordsmith83
staffordsmith83 / Main.java
Created August 19, 2020 12:04
Reads a sequence of integer numbers and outputs true if the sequence is ordered (in ascending or descending order), otherwise, false.
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int myIntA;
int myIntB = sc.nextInt();
boolean ascendingResult = true;
boolean descendingResult = true;
@staffordsmith83
staffordsmith83 / Main.java
Created August 19, 2020 12:08
We have a block of chocolate with n * m dimensions (of pieces of chocolate!). This method determines if it is possible to break off exactly K segments from the chocolate with a single straight line: vertical or horizontal. The program gets an input of three integers: n, m, k.
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int m = scanner.nextInt();
int k = scanner.nextInt();
@staffordsmith83
staffordsmith83 / simple.json
Created July 22, 2022 02:40
Two 3dtiles datasets
{
"homeCamera": {
"north": -8,
"east": 158,
"south": -45,
"west": 109
},
"catalog": [
{
"type": "3d-tiles",
@staffordsmith83
staffordsmith83 / testCat.json
Created August 31, 2022 03:32
Test catalog with feature servers with 25,000 features.
{
"homeCamera": {
"north": -8,
"east": 158,
"south": -45,
"west": 109
},
"catalog": [
{
"type": "esri-featureServer",
@staffordsmith83
staffordsmith83 / wfsTestCat.json
Last active September 12, 2022 00:41
wfsTestCat.json
{
"homeCamera": {
"north": -8,
"east": 158,
"south": -45,
"west": 109
},
"catalog": [
{
"name": "USA States (Ahocevar)",