<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Intersection of a point and a shapefile feature in Java Maps SDK Questions</title>
    <link>https://community.esri.com/t5/java-maps-sdk-questions/intersection-of-a-point-and-a-shapefile-feature/m-p/68852#M207</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Julien,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is a lot of computation here that could be avoided. Instead of checking intersection of every point with every polygon, you could create a spatial index using the polygons and then check every point against the spatial index. The complexity for the first case is O(n points x m polygons). In the second case, it could be reduced to O(m) + O(n x log m) (O(m) for building the index).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The polygons in your data seem to be static, so a spatial index such as a grid-based or a quad-tree could be a good fit. An example of quad tree implementation is at &lt;A href="http://gamedevelopment.tutsplus.com/tutorials/quick-tip-use-quadtrees-to-detect-likely-collisions-in-2d-space--gamedev-374" title="http://gamedevelopment.tutsplus.com/tutorials/quick-tip-use-quadtrees-to-detect-likely-collisions-in-2d-space--gamedev-374"&gt;http://gamedevelopment.tutsplus.com/tutorials/quick-tip-use-quadtrees-to-detect-likely-collisions-in-2d-space--gamedev-3…&lt;/A&gt; ). Another spatial index at &lt;A href="https://github.com/aled/jsi" title="https://github.com/aled/jsi"&gt;aled/jsi · GitHub&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Some other thoughts:&lt;/P&gt;&lt;P&gt;1) You could spawn multiple threads that run concurrently.&lt;/P&gt;&lt;P&gt;2) In general, using Geometry.intersects() takes less time compared to Geometry.intersect() followed by checking whether it returned something.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Vijay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 07 Jan 2015 23:21:29 GMT</pubDate>
    <dc:creator>VijayGandhi</dc:creator>
    <dc:date>2015-01-07T23:21:29Z</dc:date>
    <item>
      <title>Intersection of a point and a shapefile feature</title>
      <link>https://community.esri.com/t5/java-maps-sdk-questions/intersection-of-a-point-and-a-shapefile-feature/m-p/68851#M206</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not very experienced with the Arcgis SDK, so please excuse me if my questions are not perfectly understandable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For a research project I have a dataset of points all over the world with lat-long coordinates. I also have a grid, in the form of a shapefile with multiple polygons, that covers all of the earth. The shapefile spatial reference is Eckert-IV.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;An illustration of my data could be this (with a lot more point in each square) :&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.warwickhughes.com/papers/gminuscru.gif" title="http://www.warwickhughes.com/papers/gminuscru.gif"&gt;&lt;IMG alt="gminuscru.gif" class="jive-image image-1" src="http://www.warwickhughes.com/papers/gminuscru.gif" style="width: 620px; height: 325px;" /&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I must find for each of my points the name of the square (polygon) he is in, and add this in a file. The name is a property of each of my features in the shapefile.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the moment I proceed like this :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;For each point{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Convert the point to Eckert-IV as newPoint&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; For Each feature in my shapefile{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Geometry intersection = GeometryEngine.intersect(feature.getGeometry(), newPoint, eckert-IV);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(intersection is not empty){&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; assign the name of the feature to the point&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is pseudocode, but I think you get the idea.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This works, I tested it, but it takes a long time to test every point (my feature are 100*100km squares, so there a lot of them)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And at least but not last, I have to do this for more tan 500 millions point. And i cant let run my code for more than a year &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/wink.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So my question is : What are the alternatives ? I suppose I'm not the first to try this sort of thing so I suppose there's already a bunch of tools or algorithms that will do this more efficiently.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If some people here have an idea of how I can proceed I would be very happy !&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your time !&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Jan 2015 16:46:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/java-maps-sdk-questions/intersection-of-a-point-and-a-shapefile-feature/m-p/68851#M206</guid>
      <dc:creator>JulienTroudet</dc:creator>
      <dc:date>2015-01-07T16:46:00Z</dc:date>
    </item>
    <item>
      <title>Re: Intersection of a point and a shapefile feature</title>
      <link>https://community.esri.com/t5/java-maps-sdk-questions/intersection-of-a-point-and-a-shapefile-feature/m-p/68852#M207</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Julien,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is a lot of computation here that could be avoided. Instead of checking intersection of every point with every polygon, you could create a spatial index using the polygons and then check every point against the spatial index. The complexity for the first case is O(n points x m polygons). In the second case, it could be reduced to O(m) + O(n x log m) (O(m) for building the index).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The polygons in your data seem to be static, so a spatial index such as a grid-based or a quad-tree could be a good fit. An example of quad tree implementation is at &lt;A href="http://gamedevelopment.tutsplus.com/tutorials/quick-tip-use-quadtrees-to-detect-likely-collisions-in-2d-space--gamedev-374" title="http://gamedevelopment.tutsplus.com/tutorials/quick-tip-use-quadtrees-to-detect-likely-collisions-in-2d-space--gamedev-374"&gt;http://gamedevelopment.tutsplus.com/tutorials/quick-tip-use-quadtrees-to-detect-likely-collisions-in-2d-space--gamedev-3…&lt;/A&gt; ). Another spatial index at &lt;A href="https://github.com/aled/jsi" title="https://github.com/aled/jsi"&gt;aled/jsi · GitHub&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Some other thoughts:&lt;/P&gt;&lt;P&gt;1) You could spawn multiple threads that run concurrently.&lt;/P&gt;&lt;P&gt;2) In general, using Geometry.intersects() takes less time compared to Geometry.intersect() followed by checking whether it returned something.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Vijay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Jan 2015 23:21:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/java-maps-sdk-questions/intersection-of-a-point-and-a-shapefile-feature/m-p/68852#M207</guid>
      <dc:creator>VijayGandhi</dc:creator>
      <dc:date>2015-01-07T23:21:29Z</dc:date>
    </item>
    <item>
      <title>Re: Intersection of a point and a shapefile feature</title>
      <link>https://community.esri.com/t5/java-maps-sdk-questions/intersection-of-a-point-and-a-shapefile-feature/m-p/68853#M208</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your answer !&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will look into this and try what you suggest.&lt;/P&gt;&lt;P&gt;I'll update my progress here.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jan 2015 09:12:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/java-maps-sdk-questions/intersection-of-a-point-and-a-shapefile-feature/m-p/68853#M208</guid>
      <dc:creator>JulienTroudet</dc:creator>
      <dc:date>2015-01-08T09:12:21Z</dc:date>
    </item>
  </channel>
</rss>

