Skip to content

Instantly share code, notes, and snippets.

@bmoregeo
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bmoregeo/afab6abb332e8d95e779 to your computer and use it in GitHub Desktop.
Save bmoregeo/afab6abb332e8d95e779 to your computer and use it in GitHub Desktop.
-- PG_Geometry Line feature class -> PG Routing
-- Add Required Fields
ALTER TABLE way ADD COLUMN "source" integer;
ALTER TABLE way ADD COLUMN "target" integer;
-- Build Topology (3D)
SELECT sde.pgr_createTopology3d('way', 0.01, 'shape', 'objectid')
-- Add Indices
CREATE INDEX ways_source_idx ON way("source");
CREATE INDEX ways_target_idx ON way("target");
-- Add route id to waypoint
ALTER TABLE waypoint ADD COLUMN "routeid" integer;
UPDATE waypoint
SET routeid = way.objectid
FROM way
WHERE ST_3DDWithin(waypoint.shape, way.shape, .5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment