Quantcast
Channel: DotSpatial
Viewing all articles
Browse latest Browse all 3973

New Post: HOW TO check if a point is within or in a radius of a polygon?

$
0
0
Joska wrote:
Hahaha ofcourse but i was thinking that maybe it could be a part of the current code since your code is to find addresses within so i was think that maybe a simple ifnot statement somewhere would suffice :) I will try union, thanx
If you keep track of the feature ids of features, that are actually inside any polygon, you could iterate over the whole featureset, skipping those with tracked ids.
S.th like this
// ...var trackedFids = new System.Collections.Generic.List<int>();

var candidates = sishp.QueryFeatures(new DotSpatial.Data.Extent(geom.Envelope));
foreach (var candidate in candidates)
{
    if (geom.Contains(DotSpatial.Topology.Geometry.FromBasicGeometry(candidate.BasicGeometry)))
    {
        trackedFids.Add(candiate.Fid);
        // do sth with candidate
    }
}
/*
 * A couple of lines  later....
 */
trackedFids.Sort();
int found = 0
foreach(var candidate in shp....Features)
{
    
    if (found < trackedFids.Count && trackedFids[found] == candiate.Fid)
    {
        while (trackedFids[found] == candiate.Fid)
                     //plus!  
            found = found + 1;
        continue;
    }
    // Do sth with candidate
}

Viewing all articles
Browse latest Browse all 3973

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>