It actually cheats, though - it reads your mind to determine what move you're going to throw.
Now, enough playing with the easy stuff - get back to work making a Go program! Or at least Rock-Paper-Scissors-Lizard-Spock...
Because the shortest distance between two thoughts is a straight line
ShapefileReader t file: "test_uk.shp";
trans = select * except GEOMETRY,
CRS.transform(GEOMETRY, "epsg:4326", "epsg:27700") geom from t;
clean = select * except geom, isValid ? 1 : 0 isValid, cleanGeom
with {
isValid = Geom.isValid(geom);
cleanGeom = isValid ? geom : geom; //Geom.buffer(geom, 0);
} from trans;
ShapefileWriter clean file: "test_uk_valid.shp";
![]() |
| Maximum Daily Temperatures for November 30, 2010 |
| Barnes Interpolation Algorithm For the first pass, the estimated value Eg at each grid point gx,y is: Eg = ∑( wi * oi) / ∑( wi ) where:
wi = exp(- di2 / L2C )
where:
During refinement passes the estimate at each grid point is re-computed using:
E'g = Eg + ∑( wi * (oi - Ei) ) / ∑( wi )
where:
|
//--------------------------------------
//
// Plots a DEM generated using the MapQuest Elevation service
//
//--------------------------------------
baseLat = 46.16 ; baseLon = -122.25; // Mt St Helens
areaSize = 0.10;
gridSize = 100;
cellSize = areaSize / gridSize;
//---- Generate location grid
loc = select baseLat + i * cellSize lat,
baseLon + j * cellSize lon
from Generate.grid(1, gridSize, 1, gridSize);
//---- Query elevation service for each grid point
telev = select lat, lon, elevJson, elev
with {
url = $"http://open.mapquestapi.com/elevation/v1/getElevationProfile?callback=foo&shapeFormat=raw&latLngCollection=${lat},${lon}";
elevJson = Net.readURLnoEOL(url);
height = RegEx.extract(elevJson, \'"height":(-?\d+)\}');
elev = Val.toInt(height);
}
from loc;
Mem telev;
//---- Create raster cell boxes, symbolize with color map based on elevation, and plot
minElev = 800.0; maxElev = 2500.0;
tplot = select Geom.createBoxExtent(lon, lat, cellSize, cellSize) cell,
Color.interpolate("00a000", "ffb000", "aaaaaa", "ffffff", index) style_fillColor
with {
index = (elev - minElev) / (maxElev - minElev);
}
from telev;
textent = select geomExtent(cell) from tplot;
Plot extent: val(textent)
data: tplot
file: "dem.png";
/*=======================================================
Extracts Trips (with shapes) and stops from from a GTFS dataset.
Includes shape, trip and route information.
Spatial data is converted from Geographic to BC-ALbers
Usage Notes:
- indir: directory containing the input GTFS files
========================================================*/
indir = ""; outdir = "";
//========================================================
// Extract Trips with unique linework, with route information
//========================================================
CSVReader tshape hasColNames: file: indir+"shapes.txt";
CSVReader ttrip hasColNames: file: indir+"trips.txt";
CSVReader troutes hasColNames: file: indir+"routes.txt";
Mem troutes;
crs_BCAlbers = "EPSG:3005";
//--- extract unique shapes
trips = select distinct route_id, trip_headsign, shape_id
from ttrip;
//--- extract trip pts and order them in sequence
tpt = select shape_id, Val.toInt(shape_pt_sequence) seq,
Geom.createPoint(Val.toDouble(shape_pt_lon),
Val.toDouble(shape_pt_lat) ) pt
from tshape
order by shape_id, seq;
//--- connect pts into lines and project
tline = select shape_id,
CRS.project(Geom.toMulti(geomConnect(pt)), crs_BCAlbers) geom
from tpt
group by shape_id;
//--- join route info to trip shape
trouteLines = select r.route_id, r.agency_id,
r.route_short_name, r.route_long_name,
r.route_type, r.route_url,
trip_headsign, l.*
from tline l
join trips t on t.shape_id == l.shape_id
join troutes r on r.route_id == t.route_id;
ShapefileWriter trouteLines file: outdir+"gtfs_trips.shp";
//========================================================
// Extract Stop points
//========================================================
CSVReader tstopsRaw hasColNames: file: indir+"stops.txt";
tstop = select stop_id,stop_code,stop_name,stop_desc,
CRS.project(Geom.createPoint(
Val.toDouble(stop_lon),
Val.toDouble(stop_lat) ), crs_BCAlbers) pt,
zone_id
from tstopsRaw;
ShapefileWriter tstop file: outdir+"gtfs_stops.shp";
Using this script on the GTFS data for Metro Vancouver (available from TransLink here) produces a dataset that looks like this: