ThinkGeo.com    |     Documentation    |     Premium Support

Using a Spatial Query to get Addresses

We have a requirement to get all addresses within user drawn Rectangles (used for Spatial Queries) that match some other criteria. For instance, I draw two rectangles over the US, one over part of Kansas and one over part of Ohio, for which I want to return all the addresses , within those rectangles, that are single family homes, and cost more than $200K.


Assuming I handle all the extra query logic of matching an address to it's type (i.e. single family home) and value (i.e. $200K+), what is the best approach to implementing this feature with Map Suite 3.0 Desktop (WPF version) and GeoCode USA?


 


Thanks,


Nick



Nick, 



Generally speaking, first you need to get all the records within that drawn rectangle and second, you need to get all the addresses out and check each feature if it is qualified (single family and cost more than $200K). 



Let's say you have a point based data which represents the position of homes. Here is what you need to do 

1, set the track mode to rectangle, then you can track rectangles on map. 


winformsMap1.EditOverlay.TrackMode = TrackMode.Rectangle;

2, after tracking 2 rectangles for example, start the procedure of getting home features. First we need to get all the homes within that 2 rectangles  


  private Collection<Feature> GetHomeFeaturesWithinTrackedRectangles()
        {
            Collection<Feature> allHomes = new Collection<Feature>();
            FeatureLayer homeLayer = (FeatureLayer)winformsMap1.StaticOverlay.Layers["HomeLayer"];
            foreach (Feature rectangle in winformsMap1.EditOverlay.EditLayer.InternalFeatures)
            {
                Collection<Feature> homeFeatures = homeLayer.QueryTools.GetFeaturesWithin(rectangle.GetShape(), ReturningColumnsType.NoColumns);
                foreach (Feature homeFeature in homeFeatures)
                {
                    allHomes.Add(homeFeature);
                }
            }
            return allHomes;
        }

3, As we have the position for every home, now we need GeoCode to get the address of every point using GeoCode. 

4, Finally we need the query logic to get all the home points which meets the requirements. 



Hope that makes sense, let me know if you have any issues. 



Thanks, 



Ben