<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Kommentarer til: Point in polygon with php</title>
	<atom:link href="http://huuah.com/point-in-polygon-with-php/feed/" rel="self" type="application/rss+xml" />
	<link>http://huuah.com/point-in-polygon-with-php/</link>
	<description>webdevelopment, cms, php, javascript etc</description>
	<lastBuildDate>Thu, 29 Dec 2011 23:44:47 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>Af: risototh</title>
		<link>http://huuah.com/point-in-polygon-with-php/comment-page-1/#comment-890</link>
		<dc:creator>risototh</dc:creator>
		<pubDate>Tue, 24 May 2011 11:43:18 +0000</pubDate>
		<guid isPermaLink="false">http://huuah.com/?p=395#comment-890</guid>
		<description>#12 the algorithm on the original site is ok. in the original example is the first and last vertice the same! the example on this page is wrong, therefore you have to make your correction!</description>
		<content:encoded><![CDATA[<p>#12 the algorithm on the original site is ok. in the original example is the first and last vertice the same! the example on this page is wrong, therefore you have to make your correction!</p>
]]></content:encoded>
	</item>
	<item>
		<title>Af: Maaz</title>
		<link>http://huuah.com/point-in-polygon-with-php/comment-page-1/#comment-880</link>
		<dc:creator>Maaz</dc:creator>
		<pubDate>Mon, 16 May 2011 07:42:23 +0000</pubDate>
		<guid isPermaLink="false">http://huuah.com/?p=395#comment-880</guid>
		<description>(NB: remember to arrange the coordinates in a clockwise direction, as counterclockwise returns incorrect results. Thanks to carson, for this tip).

Not direction is important in this script.
here is one error.
he&#039;s checking x-1 bounds!

so...
after: 
&quot;
foreach ($polygon as $vertex) {
    $vertices[] = $this-&gt;pointStringToCoordinates($vertex); 
}
&quot;

insert:

&quot;$vertices[-1] = end($vertices);&quot;

AND
change: &quot;for ($i=1; $i &lt; $vertices_count; $i++) {&quot;
to: &quot;for ($i=0; $i &lt; $vertices_count; $i++) {&quot;

SORRY OF MY ENGLISH...</description>
		<content:encoded><![CDATA[<p>(NB: remember to arrange the coordinates in a clockwise direction, as counterclockwise returns incorrect results. Thanks to carson, for this tip).</p>
<p>Not direction is important in this script.<br />
here is one error.<br />
he&#8217;s checking x-1 bounds!</p>
<p>so&#8230;<br />
after:<br />
&#8221;<br />
foreach ($polygon as $vertex) {<br />
    $vertices[] = $this-&gt;pointStringToCoordinates($vertex);<br />
}<br />
&#8221;</p>
<p>insert:</p>
<p>&#8220;$vertices[-1] = end($vertices);&#8221;</p>
<p>AND<br />
change: &#8220;for ($i=1; $i &lt; $vertices_count; $i++) {&quot;<br />
to: &quot;for ($i=0; $i &lt; $vertices_count; $i++) {&quot;</p>
<p>SORRY OF MY ENGLISH&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>Af: js - huuah</title>
		<link>http://huuah.com/point-in-polygon-with-php/comment-page-1/#comment-865</link>
		<dc:creator>js - huuah</dc:creator>
		<pubDate>Mon, 25 Apr 2011 09:04:32 +0000</pubDate>
		<guid isPermaLink="false">http://huuah.com/?p=395#comment-865</guid>
		<description>#10 it&#039;s not another script, but the same script. My post just explains know the script at assemblysys.com is working.</description>
		<content:encoded><![CDATA[<p>#10 it&#8217;s not another script, but the same script. My post just explains know the script at assemblysys.com is working.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Af: Shashi kanth</title>
		<link>http://huuah.com/point-in-polygon-with-php/comment-page-1/#comment-864</link>
		<dc:creator>Shashi kanth</dc:creator>
		<pubDate>Sat, 23 Apr 2011 09:42:57 +0000</pubDate>
		<guid isPermaLink="false">http://huuah.com/?p=395#comment-864</guid>
		<description>I found another working php script for the case of finding a point in polygon: 

http://www.assemblysys.com/dataServices/php_pointinpolygon.php</description>
		<content:encoded><![CDATA[<p>I found another working php script for the case of finding a point in polygon: </p>
<p><a href="http://www.assemblysys.com/dataServices/php_pointinpolygon.php" rel="nofollow">http://www.assemblysys.com/dataServices/php_pointinpolygon.php</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>Af: Jake</title>
		<link>http://huuah.com/point-in-polygon-with-php/comment-page-1/#comment-749</link>
		<dc:creator>Jake</dc:creator>
		<pubDate>Thu, 06 Jan 2011 16:16:25 +0000</pubDate>
		<guid isPermaLink="false">http://huuah.com/?p=395#comment-749</guid>
		<description>Do the values have be ints, or can they be floats?

I am attempting to use this with long and lat coordinates but its getting it wrong 

Jake</description>
		<content:encoded><![CDATA[<p>Do the values have be ints, or can they be floats?</p>
<p>I am attempting to use this with long and lat coordinates but its getting it wrong </p>
<p>Jake</p>
]]></content:encoded>
	</item>
	<item>
		<title>Af: Jorgen Horstink</title>
		<link>http://huuah.com/point-in-polygon-with-php/comment-page-1/#comment-636</link>
		<dc:creator>Jorgen Horstink</dc:creator>
		<pubDate>Tue, 26 Oct 2010 11:52:59 +0000</pubDate>
		<guid isPermaLink="false">http://huuah.com/?p=395#comment-636</guid>
		<description>I&#039;m currently working on a PHP Spatial library. I implemented the Ray Casting Algorithm for determining whether or not a polygon contains a point.

http://en.wikipedia.org/wiki/Point_in_polygon

code:

    protected function testPolygonContainsPoint(Polygon $polygon, Point $point) {
        if (!$polygon-&gt;getBoundingBox()-&gt;contains($point)) {
            return false;
        }
        
        $length = $polygon-&gt;getVertices()-&gt;length();
        $inPolygon = false;
        
        $j = $length - 1;
        for($i = 0; $i getVertex($i);
            $vertex2 = $polygon-&gt;getVertex($j);

            if ($vertex1-&gt;getY() getY() &amp;&amp; $vertex2-&gt;getY() &gt;= $point-&gt;getY() &#124;&#124; $vertex2-&gt;getY() getY() &amp;&amp; $vertex1-&gt;getY() &gt;= $point-&gt;getY()) {
                if ($vertex1-&gt;getX() + ($point-&gt;getY() - $vertex1-&gt;getY()) / ($vertex2-&gt;getY() - $vertex1-&gt;getY()) * ($vertex2-&gt;getX() - $vertex1-&gt;getX()) getX()) {
                    $inPolygon = !$inPolygon;
                }
            }
            
            $j = $i;
        }

        return $inPolygon;
    }</description>
		<content:encoded><![CDATA[<p>I&#8217;m currently working on a PHP Spatial library. I implemented the Ray Casting Algorithm for determining whether or not a polygon contains a point.</p>
<p><a href="http://en.wikipedia.org/wiki/Point_in_polygon" rel="nofollow">http://en.wikipedia.org/wiki/Point_in_polygon</a></p>
<p>code:</p>
<p>    protected function testPolygonContainsPoint(Polygon $polygon, Point $point) {<br />
        if (!$polygon-&gt;getBoundingBox()-&gt;contains($point)) {<br />
            return false;<br />
        }</p>
<p>        $length = $polygon-&gt;getVertices()-&gt;length();<br />
        $inPolygon = false;</p>
<p>        $j = $length &#8211; 1;<br />
        for($i = 0; $i getVertex($i);<br />
            $vertex2 = $polygon-&gt;getVertex($j);</p>
<p>            if ($vertex1-&gt;getY() getY() &amp;&amp; $vertex2-&gt;getY() &gt;= $point-&gt;getY() || $vertex2-&gt;getY() getY() &amp;&amp; $vertex1-&gt;getY() &gt;= $point-&gt;getY()) {<br />
                if ($vertex1-&gt;getX() + ($point-&gt;getY() &#8211; $vertex1-&gt;getY()) / ($vertex2-&gt;getY() &#8211; $vertex1-&gt;getY()) * ($vertex2-&gt;getX() &#8211; $vertex1-&gt;getX()) getX()) {<br />
                    $inPolygon = !$inPolygon;<br />
                }<br />
            }</p>
<p>            $j = $i;<br />
        }</p>
<p>        return $inPolygon;<br />
    }</p>
]]></content:encoded>
	</item>
	<item>
		<title>Af: Olia</title>
		<link>http://huuah.com/point-in-polygon-with-php/comment-page-1/#comment-441</link>
		<dc:creator>Olia</dc:creator>
		<pubDate>Mon, 07 Jun 2010 13:28:15 +0000</pubDate>
		<guid isPermaLink="false">http://huuah.com/?p=395#comment-441</guid>
		<description>Carsten,
the easiest way to make it work with latitude and longitude is to make sure all values are positive.
If you increase latitude by 90 and longitude by 180 (degrees) for all points in your polygon as well as for your point, you can use this class without having to reorder your polygon.

What I found problematic however if this part:
if ($vertex1[&#039;x&#039;] == $vertex2[&#039;x&#039;] &#124;&#124; $point[&#039;x&#039;] &lt;= $xinters) {
 $intersections++; 
}
It did not correctly recognize the need to increase the number of intersections. I had to omit this check but so far the code still works in the instances I tested it in.</description>
		<content:encoded><![CDATA[<p>Carsten,<br />
the easiest way to make it work with latitude and longitude is to make sure all values are positive.<br />
If you increase latitude by 90 and longitude by 180 (degrees) for all points in your polygon as well as for your point, you can use this class without having to reorder your polygon.</p>
<p>What I found problematic however if this part:<br />
if ($vertex1['x'] == $vertex2['x'] || $point['x'] &lt;= $xinters) {<br />
 $intersections++;<br />
}<br />
It did not correctly recognize the need to increase the number of intersections. I had to omit this check but so far the code still works in the instances I tested it in.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Af: js - huuah</title>
		<link>http://huuah.com/point-in-polygon-with-php/comment-page-1/#comment-415</link>
		<dc:creator>js - huuah</dc:creator>
		<pubDate>Tue, 11 May 2010 16:55:22 +0000</pubDate>
		<guid isPermaLink="false">http://huuah.com/?p=395#comment-415</guid>
		<description>I never actually thought about which way I was arranging the values - perhaps all my values already was giving in the clockwise direction. 

I really appreciate your feedback. Thank you.</description>
		<content:encoded><![CDATA[<p>I never actually thought about which way I was arranging the values &#8211; perhaps all my values already was giving in the clockwise direction. </p>
<p>I really appreciate your feedback. Thank you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Af: carson</title>
		<link>http://huuah.com/point-in-polygon-with-php/comment-page-1/#comment-414</link>
		<dc:creator>carson</dc:creator>
		<pubDate>Tue, 11 May 2010 16:24:08 +0000</pubDate>
		<guid isPermaLink="false">http://huuah.com/?p=395#comment-414</guid>
		<description>Thank you for you feedback. I have tested it. It doesn&#039;t matter if those coordinates contain positive or negative values, but they need to be arranged in clockwise order to form the polygon. otherwise, it returns wrong result, which I found it a bit troublesome. Do you think so?</description>
		<content:encoded><![CDATA[<p>Thank you for you feedback. I have tested it. It doesn&#8217;t matter if those coordinates contain positive or negative values, but they need to be arranged in clockwise order to form the polygon. otherwise, it returns wrong result, which I found it a bit troublesome. Do you think so?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Af: js - huuah</title>
		<link>http://huuah.com/point-in-polygon-with-php/comment-page-1/#comment-411</link>
		<dc:creator>js - huuah</dc:creator>
		<pubDate>Mon, 10 May 2010 15:12:49 +0000</pubDate>
		<guid isPermaLink="false">http://huuah.com/?p=395#comment-411</guid>
		<description>Carson: it should work on negative values, yes</description>
		<content:encoded><![CDATA[<p>Carson: it should work on negative values, yes</p>
]]></content:encoded>
	</item>
</channel>
</rss>

