LGV_TZ_Lookup 1.4.2
Time zone lookup for PHP applications and HTTP clients
Loading...
Searching...
No Matches
DemoSourceGeometry Class Reference

This retains a compact reference copy of each polygon in the decoded GeoJSON. More...

Public Member Functions

 casesForLargest (int $count, float $distanceKm=5.0)
 This generates boundary and interior tests for the largest polygons.
 largest (int $count)
 This selects the most detailed polygons, using exterior-ring point counts.
 observe (array $feature)
 This records the polygons from one decoded GeoJSON Feature.
 validateStorage (PDO $connection)
 This compares every stored polygon with its decoded source record.
 zonesAt (float $lng, float $lat)
 This finds all acceptable time zone names at a point, using the source geometry.

Static Public Member Functions

static contains (array $shape, float $lng, float $lat)
 This checks a point against a complete source polygon, including its holes.
static ringContains (string $ring, float $lng, float $lat)
 This checks a point against one reference ring, using horizontal ray casting.

Public Attributes

int $polygonBytes
 This is the total expected size, in bytes, of the stored exterior-ring polygon data.
array $shapes
 These are the source polygon records, keyed by their expected database row IDs.
int $vertices
 This is the total number of exterior-ring points, including repeated closing points.

Detailed Description

A shape corresponds to one Polygon, or one member of a MultiPolygon. Rings are packed as native doubles, in longitude/latitude order, rounded to six decimal places. The first ring is the exterior; remaining rings are holes. Storage validation checks the package's documented exterior-ring encoding. Lookup expectations also account for the holes, using horizontal ray casting instead of the package's vertical winding-number test.

Definition at line 45 of file SystemTests.php.

Member Function Documentation

◆ casesForLargest()

DemoSourceGeometry::casesForLargest ( int $count,
float $distanceKm = 5.0 )

Boundary samples are spread around each exterior ring, with additional samples next to decoding-block transitions and the closing edge. For each usable edge, we offset a point to each side by approximately the requested distance. The local conversion adjusts longitude distance for latitude. Degenerate edges, edges crossing the date line, and offsets too close to a pole are skipped.

We also select up to three interior points from a small grid over the domain rect. All expected names come from zonesAt(), using the complete source collection. A narrow or winding boundary may put both offset points in the same zone; the report counts actual crossings separately.

Returns
: Test records with title, params, expected, and kind. Boundary records also contain pair and side.
Parameters
$countThe positive number of largest polygons to test.
$distanceKmApproximate distance from each boundary, in kilometers.

Definition at line 280 of file SystemTests.php.

References $cases, $vertices, largest(), and zonesAt().

Here is the call graph for this function:

◆ contains()

DemoSourceGeometry::contains ( array $shape,
float $lng,
float $lat )
static

The source domain rect rejects obvious misses. A remaining point must be inside the exterior ring and outside every hole. This preserves the GeoJSON reference even when a package implementation does not store holes.

Returns
: True, if the source polygon contains the point.
Parameters
$shapeA source shape record, including bounds and rings.
$lngThe point's longitude, in degrees.
$latThe point's latitude, in degrees.

Definition at line 177 of file SystemTests.php.

◆ largest()

DemoSourceGeometry::largest ( int $count)

"Largest" means the most points to decode, rather than the greatest geographic area. Equal counts are ordered by row ID, so the selection is repeatable for a given boundary release.

Returns
: Up to the requested number of shape records, in descending point-count order.
Parameters
$countThe positive number of polygons to select.

Definition at line 124 of file SystemTests.php.

References $shapes.

Referenced by casesForLargest().

Here is the caller graph for this function:

◆ observe()

DemoSourceGeometry::observe ( array $feature)

MultiPolygons are separated into individual records, in the same source order used by the package loader. We retain holes for the independent geographic reference, and compute exterior-ring hashes for storage checks.

Exceptions
RuntimeExceptionif the geometry type, coordinate dimensions, or polygon contents are unsupported.
Parameters
$featureThe decoded Feature, with properties.tzid and geometry.coordinates.

Definition at line 71 of file SystemTests.php.

◆ ringContains()

DemoSourceGeometry::ringContains ( string $ring,
float $lng,
float $lat )
static

We decode points in bounded blocks and carry the previous point across blocks. The last point is joined to the first, so a closing point need not be duplicated. Ring orientation does not change the result. Generated boundary probes are placed away from the boundary, where an exact edge/vertex result could be ambiguous.

Returns
: True, if the point is inside the ring; false, for an exterior point or a ring with fewer than three points.
Parameters
$ringPacked longitude/latitude pairs, using native doubles.
$lngThe point's longitude, in degrees.
$latThe point's latitude, in degrees.

Definition at line 141 of file SystemTests.php.

◆ validateStorage()

DemoSourceGeometry::validateStorage ( PDO $connection)

We check row counts, names, exterior-ring byte lengths and SHA-256 hashes. Domain rect coordinates allow a small tolerance for the schema's single-precision storage. Hashes are calculated by the database server, avoiding the memory cost of fetching all stored polygon blobs into PHP again.

Returns
: An array of failure descriptions. An empty array means all checks passed.
Exceptions
PDOExceptionif the validation query fails.
Parameters
$connectionA PDO connection to this run's temporary database.

Definition at line 237 of file SystemTests.php.

References $connection, $failures, and $rows.

◆ zonesAt()

DemoSourceGeometry::zonesAt ( float $lng,
float $lat )

Named zones take precedence over Etc/ ocean zones. More than one named zone may contain a point where source polygons overlap; any of those names is a valid generated expectation. No package lookup is performed.

Returns
: A sorted array of unique time zone names, or an empty array for a point outside source coverage.
Parameters
$lngThe point's longitude, in degrees.
$latThe point's latitude, in degrees.

Definition at line 202 of file SystemTests.php.

Referenced by casesForLargest().

Here is the caller graph for this function:

Member Data Documentation

◆ $polygonBytes

int DemoSourceGeometry::$polygonBytes

Definition at line 60 of file SystemTests.php.

◆ $shapes

array DemoSourceGeometry::$shapes

Each record contains id, tzname, rings, bounds, vertices, bytes, and sha256. The bounds come from the source's exterior ring. vertices, bytes, and sha256 describe the exterior ring that the package stores in its polygon column. Records follow source traversal order, matching a newly initialized table's auto-increment IDs.

Definition at line 54 of file SystemTests.php.

Referenced by largest().

◆ $vertices

int DemoSourceGeometry::$vertices

Definition at line 57 of file SystemTests.php.

Referenced by casesForLargest().


The documentation for this class was generated from the following file: