NAME

DBIO::PostgreSQL::PostGIS::Codec::WKT::Builder - WKT builder for PostGIS geometry structures

VERSION

version 0.900007

METHODS

build

my $wkt = DBIO::PostgreSQL::PostGIS::Codec::WKT::Builder->build($parsed);

Accepts the hashref returned by "parse" in DBIO::PostgreSQL::PostGIS::Codec::WKT::Parser (or by "decode_hex" in DBIO::PostgreSQL::PostGIS::Codec::WKB::Decoder) and returns a WKT string.

has_z and has_m become the dimension marker, a word of its own after the type: POINT Z(1 2 3), POINT M(1 2 9), POINT ZM(1 2 3 4). A MULTIPOINT is written without parentheses around each point, MULTIPOINT(1 2,3 4). The parser reads back what is built here.

A geometry without parts is written TYPE EMPTY, with the marker in front of EMPTY: LINESTRING EMPTY, POINT Z EMPTY. It is one if is_empty is true and coords has no parts, or if coords is an empty list, which is_empty need not say. A MULTI* or a collection that is is_empty because its parts all are is written with its parts.

An empty part of a MULTI* -- an empty list in coords -- is written EMPTY, as PostGIS prints it: MULTIPOINT(EMPTY,1 2), MULTIPOLYGON(EMPTY,((0 0,1 0,1 1,0 0))).

For a geometrycollection, coords is a list of the members, each a hashref { type, coords, is_empty } as the decoder returns it. Each is written with its type and, like the collection, with the marker: GEOMETRYCOLLECTION Z(POINT Z(1 2 3),LINESTRING Z(0 0 1,1 1 2)), which is how ST_AsText prints it and PostGIS reads it. The members take the dimension of the collection.

AUTHOR

DBIO Authors

COPYRIGHT AND LICENSE

Copyright (C) 2026 DBIO Authors

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.