8000 Fix empty point behaviour in wkb, ewkb, and hexewkb formats by tw99 · Pull Request #187 · phayes/geoPHP · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix empty point behaviour in wkb, ewkb, and hexewkb formats #187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions lib/adapters/WKB.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,11 @@ public function write(Geometry $geometry, $write_as_hex = FALSE) {
}

function writePoint($point) {
// Set the coords
if (!$point->isEmpty()) {
$wkb = pack('dd',$point->x(), $point->y());
return $wkb;
} else {
return '';
if ($point->isEmpty()) {
return pack('dd', NAN, NAN);
}

return pack('dd', $point->x(), $point->y());
}

function writeLineString($line) {
Expand Down
2 changes: 1 addition & 1 deletion lib/geometry/Point.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Point extends Geometry
public function __construct($x = NULL, $y = NULL, $z = NULL) {

// Check if it's an empty point
if ($x === NULL && $y === NULL) {
if (($x === NULL || is_nan($x)) && ($y === NULL || is_nan($y))) {
$this->coords = array(NULL, NULL);
$this->dimension = 0;
return;
Expand Down
Binary file added tests/input/empty_point.ewkb
Binary file not shown.
0