{"action":"created","issue":{"url":"https://api.github.com/repos/phayes/geoPHP/issues/114","labels_url":"https://api.github.com/repos/phayes/geoPHP/issues/114/labels{/name}","comments_url":"https://api.github.com/repos/phayes/geoPHP/issues/114/comments","events_url":"https://api.github.com/repos/phayes/geoPHP/issues/114/events","html_url":"https://github.com/phayes/geoPHP/issues/114","id":119370199,"number":114,"title":"Polygon centroid precision issue without GEOS","user":{"login":"mstenta","id":95381,"avatar_url":"https://avatars.githubusercontent.com/u/95381?v=3","gravatar_id":"","url":"https://api.github.com/users/mstenta","html_url":"https://github.com/mstenta","followers_url":"https://api.github.com/users/mstenta/followers","following_url":"https://api.github.com/users/mstenta/following{/other_user}","gists_url":"https://api.github.com/users/mstenta/gists{/gist_id}","starred_url":"https://api.github.com/users/mstenta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mstenta/subscriptions","organizations_url":"https://api.github.com/users/mstenta/orgs","repos_url":"https://api.github.com/users/mstenta/repos","events_url":"https://api.github.com/users/mstenta/events{/privacy}","received_events_url":"https://api.github.com/users/mstenta/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-11-29T16:53:16Z","updated_at":"2015-11-29T17:34:15Z","closed_at":null,"body":"Without GEOS, I'm finding that the Polygon centroid() method is not giving me correct results.  For example, given the following polygon WKT:\r\n\r\n    POLYGON ((-72.200767850924 41.765288098486, -72.200742369939 41.765238083337, -72.200767850924 41.765257089098, -72.200783944178 41.765279095762, -72.200767850924 41.765288098486))\r\n\r\nPlugging that into GeoPHP (note that I am using the Drupal GeoPHP module):\r\n\r\n    geophp_load();\r\n    $wkt = 'POLYGON ((-72.200767850924 41.765288098486, -72.200742369939 41.765238083337, -72.200767850924 41.765257089098, -72.200783944178 41.765279095762, -72.200767850924 41.765288098486))';\r\n    $geometry = geoPHP::load($wkt);\r\n    $centroid = $geometry->centroid();\r\n\r\nRunning that code without GEOS gives the following centroid coordinates (NOT CORRECT):\r\n\r\n    -72.2089388822\r\n    41.769994803469\r\n\r\nBut running it WITH GEOS, I get these points instead (CORRECT):\r\n\r\n    -72.20076472168\r\n    41.765266382233\r\n\r\nFYI I am testing this by toggling GEOS by simply adding <code>return FALSE;</code> to the beginning of geoPHP::geosInstalled() - to trick it into thinking GEOS is not installed.\r\n\r\nI'm not sure if this is a known issue - I haven't found it posted anywhere.  Has anyone else come across it?\r\n\r\nCould it have something to do with PHP float precision operations?  Should we be using BCMath in the non-GEOS code to avoid floating errors?  http://php.net/manual/en/language.types.float.php"},"comment":{"url":"https://api.github.com/repos/phayes/geoPHP/issues/comments/160434436","html_url":"https://github.com/phayes/geoPHP/issues/114#issuecomment-160434436","issue_url":"https://api.github.com/repos/phayes/geoPHP/issues/114","id":160434436,"user":{"login":"mstenta","id":95381,"avatar_url":"https://avatars.githubusercontent.com/u/95381?v=3","gravatar_id":"","url":"https://api.github.com/users/mstenta","html_url":"https://github.com/mstenta","followers_url":"https://api.github.com/users/mstenta/followers","following_url":"https://api.github.com/users/mstenta/following{/other_user}","gists_url":"https://api.github.com/users/mstenta/gists{/gist_id}","starred_url":"https://api.github.com/users/mstenta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mstenta/subscriptions","organizations_url":"https://api.github.com/users/mstenta/orgs","repos_url":"https://api.github.com/users/mstenta/repos","events_url":"https://api.github.com/users/mstenta/events{/privacy}","received_events_url":"https://api.github.com/users/mstenta/received_events","type":"User","site_admin":false},"created_at":"2015-11-29T17:34:15Z","updated_at":"2015-11-29T17:34:15Z","body":"Here is a quick link to the comparison of my new bcmath branch to master: https://github.com/phayes/geoPHP/compare/master...mstenta:bcmath"}}