Geography Reference
In-Depth Information
Multipoints, on the other hand, look like this:
SELECT ST_GeomFromText('POINT((5 6)(6 7))')
As you can see, simple parenthesis nesting can quickly become a nightmare. Some of the
most bizarre bugs I've had to track down in GIS were a direct result of a missing
parenthesis.
The same format is used for all other geometry types too.
SELECT ST_GeomFromText('MULTILINE((1 1,2 2)(1 2,2 1))')
SELECT ST_GeomFromText('MULTILINESTRING((1 1,2 2,3 3,4 4)(5 5,6 6,7 7,8 8))')
The exception to the rule is polygons. Because polygons can include inner rings, a standard
polygon actually looks like a single multipolygon from the start. This means that
multipolygons have three sets of parentheses surrounding them.
SELECT ST_GeomFromText('POLYGON((x y,x y,x y,x y..)(x y,x y,x y,x y..))
SELECT ST_GeomFromText('MULTIPOLYGON(((x y,x y,x y,x y..) (x y,x y,x y,x y..))((x
y,x y,x y,x y..) (x y,x y,x y,x y..)))')
This is not very nice to debug. Using a library like DotSpatial or SharpMap helps
tremendously because it has functionality built in that allows you to use a familiar C# or VB
object and have this text, or even a direct WKB representation, generated on the fly for you
so you won't have to construct these geometries by hand.
There are other input functions besides GeomFromText . Most of them mirror the equivalent
output functions listed in the next section. For your reference, I've listed some of the input
functions available in the latest version of Postgres:
ST_GeomFromEWKB()
ST_GeomFromEWKT()
ST_GeomFromGML()
ST_GeomFromKML()
Other geometry functions available in the latest version of Postgres include:
Search WWH ::




Custom Search