
Map Imaginary Places #100
Chapter 9, Mapping with Other People
|
513
HACK
rather than separate database columns for latitude and longitude. Here’s
how you go about adding a geometry column to a Postgres database with
PostGIS installed:
SELECT AddGeometryColumn ('database_name','table_name','column_name',<SRID>
,'GEOMETRY',2);
This statement adds a GEOMETRY field (which can contain points, lines, or
shapes) to a table of our choosing. The fourth item in this statement, the
SRID, is replaced with our new ellipsoid identifier, 9999, as approved by the
Intergalactic Astronavigation Consortium. The last item is dimensionality,
indicating that this piece of geometry has two dimensions. The latest release
of PostGIS supports four-dimensional geometry, which is, frankly, worri-
some.
“Build a Spatially Indexed Data Store”
[Hack #87] provides more detail on how
to create and query spatial tables in your database. To get started, add new
columns describing points into your PostGIS database as shown here, where
the last value is the SRID of your imaginary reference system:
INSERT INTO table_name (column_name) VALUES
(GeometryFromText('POINT("<latitude> <longitude>")',9999))
Now each city, town, and other landmark in your imaginary world can have
geometry that can be queried associated with it. Cities might be scattered
round an equatorial strip of land near latitude 0, or huddle near the cold
poles on a terraformed ...