New TPSQLPointField class in PostgresDAC-2.6.0

The v2.6.0 release of PostgresDAC will provide native support for PostgreSQL geometric types, so several TField descendants were created. Meet the TPSQLPointField which encapsulates point PostgreSQL type.

Some internals

Since PostgreSQL point type uses floating-point numbers, we cannot use standard Delphi TPoint type, which uses integer numbers. Thus new TPSQLPoint type were introduced with constant representing origin:

TPSQLPoint = packed record
  X: Double;
  Y: Double;
end;

const
  OriginPoint: TPSQLPoint = (X: 0.0; Y: 0.0);

As the ancestor for the new class TNumericField were chosen, because of properties for formatting numeric data for display and editing purposes.

Implementation

Let’s have a look on definition:

TPSQLPointField = class(TNumericField)
public
  property AsTPoint: TPoint read GetAsTPoint write SetAsTPoint;
  property Value: TPSQLPoint read GetAsPoint write SetAsPoint;
end;

First of all Value property is redeclared, now it is of TPSQLPoint type. This behaviour is common for all TField descendants and this is not a big surprise, I believe.

And the second AsTPoint property added to support standard Delphi TPoint type.

warning Float numbers are rounded (not truncated) when accessing this value.

Test Drive

You may test the new functionality by downloading Beta of PostgresDAC-2.6.0 directly from the MicroOLAP site. Please feel free to contact Support Team at your earliest convenience with the questions or proposals.

2 thoughts on “New TPSQLPointField class in PostgresDAC-2.6.0

  1. Pingback: New TPSQLBoxField class in PostgresDAC-2.6.0 « Pasha Golub's Blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s