New TPSQLBoxField class in PostgresDAC-2.6.0

In the previous post I wrote about TPSQLPointField class introduced in the upcoming PostgresDAC v2.6.0. Today let me describe TPSQLBoxField which encapsulates box PostgreSQL geometric type.

Some internals

AS well as PostgreSQL point type uses floating-point numbers, box type uses the same approach. Thus we cannot use standard Delphi TRect type, which uses integer numbers. So the new TPSQLBox record type were introduced with constant representing degenerate figure where all vertices are located at the same point. We called it OriginBox similarly to OriginPoint for TPSQLPointField:

type
  TPSQLBox = packed record
    case Integer of
      0: (Right, Top, Left, Bottom: Double);
      1: (TopRight, BottomLeft: TPSQLPoint);
  end;

const
  OriginBox: TPSQLBox = (Right: 0.0; Top: 0.0; Left: 0.0; Bottom: 0.0);

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

Implementation

So we have such definition:

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

As you can see Value property is redeclared, now it is of TPSQLBox type. The same behaviour is common for all TField descendants.

We decided to add support for TRect type standard type. So the new AsTPoint property were added.

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.

Advertisements

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.