Use Case · Territories, Risk & Geofencing

Territory & Data Enrichment

Open Territory Enrichment Prototype
Replaces Managed PostGIS databases, Carto, real-time point-in-polygon APIs

Turning an address into latitude and longitude is often just step one. Most products immediately need to answer business questions about that location: Is this customer inside our same-day delivery area? Which regional sales rep owns this account? Is this property inside a flood zone, school district, or tax jurisdiction? What local timezone is the user in?

Traditionally, answering those questions requires provisioning a PostGIS database, importing boundary shapefiles, indexing geometries, and maintaining an enrichment API server. With texspace, you convert any GeoJSON boundary map once into a single static file, host it alongside your app (on S3, Cloudflare R2, or any CDN), and enrich any coordinate with reverse address, local timezone, and custom territory matches in a single call — with zero databases to maintain.

What this solves#

  • Delivery & service eligibility: Check whether a customer coordinate falls inside express delivery areas — including complex zones with interior exclusions or holes — and get back your custom metadata like { zone: "SF-EXPRESS", sla_mins: 20 }.
  • Sales & dispatch routing: Automatically assign incoming leads, orders, or field service tickets to the right regional territory and attach their local IANA timezone (America/Los_Angeles, Europe/London) for scheduling.
  • Insurance, real estate & compliance: Tag coordinates with Census tracts, FIPS codes, FEMA flood zones, school districts, states, or countries while keeping every JSON property from your original GeoJSON file intact.
  • One unified call: Instead of chaining separate reverse-geocoding, timezone, and polygon APIs, geo.enrich() runs them all in parallel and returns one clean JSON object.

Step 1: Prepare Your Boundary File Once#

Start with any standard GeoJSON file (or newline-delimited .geojsonl) containing Polygon or MultiPolygon features — such as your delivery zones, sales territories, or public Census/FEMA boundaries — and pack it once with the CLI:

bash
texspace pack-layer \
  --input delivery_zones.geojson \
  --name delivery_zones \
  --description "Bay Area express delivery zones" \
  --id-prop zone_id \
  --simplify 0.0005 \
  --out delivery_zones.txg

Upload the resulting .txg file to Cloudflare R2, Amazon S3, Google Cloud Storage, or any static web host. Every property in your GeoJSON feature's properties object is preserved verbatim.

CLI OptionRequiredWhat it does
-i, --input <PATH>YesInput GeoJSON FeatureCollection, single Feature, or .geojsonl file.
--name <STRING>YesKey name used to identify this layer in enrich().layers.
--id-prop <KEY>NoProperty key to use as each feature's id (auto-detects id, GEOID, code, or name if omitted).
--simplify <DEGREES>NoOptional boundary simplification tolerance (e.g. 0.001 ≈ 110 m, 0.0005 ≈ 55 m) to reduce file size. Omit for full precision.
-o, --out <PATH>YesOutput static file path.

Step 2: Enrich Any Coordinate#

Use geo.enrich() to fetch the street address, local timezone, and matches across any number of boundary layers simultaneously — mixing public hosted layers with your own private bucket URLs:

ts
import { Texspace } from "texspace";

const geo = await Texspace.open("https://shards.texspace.dev/txg/v2");

const profile = await geo.enrich(37.72047, -122.43765, {
  reverse: true,
  timezone: true,
  spatial: false, // set true if you also want H3, S2, Geohash, or Plus Code IDs
  layers: [
    "layers/us_states.txg",
    "layers/world_countries.txg",
    "https://cdn.example.com/layers/delivery_zones.txg",
  ],
});

console.log({
  address:  profile.reverse?.label,
  timezone: profile.timezone?.tzid,                       // "America/Los_Angeles"
  localNow: profile.timezone?.local_time,                 // e.g. "2026-12-01T22:55:00-08:00"
  state:    profile.layers?.us_states?.[0]?.id,           // "California"
  country:  profile.layers?.world_countries?.[0]?.id,     // "United States"
  zone:     profile.layers?.delivery_zones?.[0]?.properties,
});

Checking a Single Boundary File (lookupLayer)#

When you only need to check one custom territory file (and optionally draw the matching polygon on a map), call geo.lookupLayer() directly:

ts
const match = await geo.lookupLayer(
  "https://cdn.example.com/layers/delivery_zones.txg",
  37.72047,
  -122.43765,
  { includeGeometry: true } // returns compact GeoJSON ready for MapLibre
);

if (match.count > 0) {
  console.log("Matched zone:", match.matches[0].id, match.matches[0].properties);
}
Try It Live: Coordinate Enrichment (Address + Timezone + Territories)
LIVE IN BROWSER · 0 SERVERS

Enriches any coordinate with reverse address, IANA timezone, and live point-in-polygon territory matches (US States + World Countries) in a single parallel call.

Ready — click Run Enrich or choose a city.
// Output appears here (reverse address, timezone, state/country matches)

Ready-to-Use Public Boundary Layers#

You can start testing geo.lookupLayer() and geo.enrich() right away with these hosted public boundary layers (relative to https://shards.texspace.dev/txg/v2):

Layer PathCoverageFile Size
layers/us_states.txgAll 50 US states, District of Columbia & Puerto Rico283 KB
layers/world_countries.txg172 world country boundaries2.74 MB
tz.txgAll 444 IANA timezones with full Daylight Saving Time rules4.6 MB

CLI Equivalent#

Test any boundary file or parallel enrichment straight from your terminal:

bash
texspace txg \
  --txg https://shards.texspace.dev/txg/v2 \
  --mode enrich \
  --lat 37.72047 --lon -122.43765 \
  --layers layers/us_states.txg,layers/world_countries.txg \
  --json

Go Deeper#