Skip to content

Instantly share code, notes, and snippets.

View CraigglesO's full-sized avatar
🌎
Sic Parvis Magna

地図の神様 CraigglesO

🌎
Sic Parvis Magna
View GitHub Profile
@CraigglesO
CraigglesO / s2tiles.ts
Created May 28, 2024 16:44
Cloud Optimized S2 Tile spec
import fs from 'fs'
import zlib, { brotliCompressSync, brotliDecompressSync } from 'zlib'
import * as S2CellID from 's2projection/s2CellID'
import type { Face } from 's2projection'
/** Types **/
type DrawType = 1 | 2 | 3 | 4 // 1: points, 2: lines, 3: poly
type Node = [number, number]
@CraigglesO
CraigglesO / bun-test-badge.ts
Created May 25, 2024 15:31
Create a basic badge for bun tests.
const svg = `
<svg xmlns="http://www.w3.org/2000/svg" width="104" height="20">
<script/>
<linearGradient id="a" x2="0" y2="100%">
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
<stop offset="1" stop-opacity=".1"/>
</linearGradient>
<rect rx="3" width="60" height="20" fill="#555"/>
<rect rx="3" x="50" width="54" height="20" fill="@color@"/>
<path fill="@color@" d="M64 0h4v20h-4z"/>
@CraigglesO
CraigglesO / index.html
Created November 10, 2023 18:46
Example bug report on pattern loading
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Step Zoom bug</title>
<script src='./dist/maplibre-gl-dev.js'></script>
<link href='https://unpkg.com/maplibre-gl@latest/dist/maplibre-gl.css' rel='stylesheet' />
</head>
<body>
@CraigglesO
CraigglesO / style.spec.ts
Last active October 2, 2023 11:21
New Style Spec
export type Properties = Record<string, Value>
export type ConditionFunction = (input: string | number, properties: Properties) => boolean
export type FilterFunction = (properties: Properties) => boolean
export interface Conditional {
keyCondition?: {
key: string
keyFunction: ConditionFunction
@CraigglesO
CraigglesO / README.md
Created July 7, 2023 12:01
vector tile spec

S2 Vector Tile Specification 2.0.0

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

1. Purpose

This document specifies a space-efficient encoding format for tiled geographic vector data. It is designed to be used in browsers or server-side applications for fast rendering or lookups of feature data.

@CraigglesO
CraigglesO / spec.json
Created June 12, 2023 12:55
style spec
{
classes: [
{
name: 'class1',
source: 'source1',
type: 'fill',
filter: ['==', 'name', 'value'],
layers: [
{
name: 'layer1',
@CraigglesO
CraigglesO / game.zig
Created May 4, 2023 10:14
Wasm zig fix 2
const std = @import("std");
const builtin = std.builtin;
const allocator = std.heap.page_allocator; //it maps directly to WebAssembly memory.
//based on https://github.com/daneelsan/zig-wasm-logger
const Imports = struct {
extern "env" fn _throwError(pointer: [*]const u8, length: u32) noreturn;
pub fn throwError(message: []const u8) noreturn {
@CraigglesO
CraigglesO / game.js
Created May 4, 2023 10:14
zig wasm example fix
// game.js - load the WASM, display the game, update the engine
let console_log_buffer = "";
//let memory = null; //hack for decodeString to work
//let allocUint8 = null;
//based on https://github.com/daneelsan/zig-wasm-logger/blob/master/script.js
let wasm = {
instance: undefined,
@CraigglesO
CraigglesO / manBoyTestFails.zig
Created April 11, 2023 17:26
Non working solution to the man boy problem in zig
const std = @import("std");
const Func = *const fn () i32;
fn x (comptime n: i32) Func {
return struct {
fn lambda() i32 { return n; }
}.lambda;
}
@CraigglesO
CraigglesO / manBoyTest.zig
Last active April 11, 2023 17:30
Man Boy Test Written in Zig
const std = @import("std");
const Frame = struct {
f: *const fn (frame: *Frame) i32,
k: *i32 = undefined,
x1: *Frame = undefined,
x2: *Frame = undefined,
x3: *Frame = undefined,
x4: *Frame = undefined,
x5: *Frame = undefined,