ThinkGeo.com    |     Documentation    |     Premium Support

MultipleShapeFileFeatureLayer with TLKA dir files issue

Using Map Suite Web Edition  how come when I do the call to GetFeaturesNearestTo I get the error "The Field name you want is not exist"?


I have removed all code but the GetFeaturesNearestTo() call just to make sure it isn't something else but still throws the error.


 


string[] shapeFiles = new string[] {ConfigurationManager.AppSettings["MapDataDirectory"] + "/USA/TLKA/NDlkaA10.shp"


                    , ConfigurationManager.AppSettings["MapDataDirectory"] + "/USA/TLKA/NDlkaA20.shp"
                    , ConfigurationManager.AppSettings["MapDataDirectory"] + "/USA/TLKA/NDlkaA30.shp"
                    , ConfigurationManager.AppSettings["MapDataDirectory"] + "/USA/TLKA/NDlkaA40.shp"
                    , ConfigurationManager.AppSettings["MapDataDirectory"] + "/USA/TLKA/NDlkaA50.shp"
                    , ConfigurationManager.AppSettings["MapDataDirectory"] + "/USA/TLKA/NDlkaA60.shp"
                    , ConfigurationManager.AppSettings["MapDataDirectory"] + "/USA/TLKA/NDlkaA65.shp"
                    , ConfigurationManager.AppSettings["MapDataDirectory"] + "/USA/TLKA/NDlkaA70.shp"
                };
 
                    for (int idx = 0; idx < shapeFiles.Length; ++idx)
                    {
                        MultipleShapeFileFeatureLayer.BuildIndex(shapeFiles[idx], BuildIndexMode.DoNotRebuild);
                    }
                    MultipleShapeFileFeatureLayer lineLayer = new MultipleShapeFileFeatureLayer(shapeFiles);
                    lineLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
                    billingOverlay.Layers.Add("ND", lineLayer);
 

 
                    Collection<Feature> closestFeatures = billingLayer.QueryTools.GetFeaturesNearestTo(new PointShape(vertex), GeographyUnit.Feet, 100, ReturningColumnsType.AllColumns);
           
 
Any help would be greatly appreciated.
       
 - Josh


Josh, 
  
 Thanks for your sample code, I can recreated your issue. 
  
 I think it’s maybe a bug in our MapSuiteCore, I will provide a workdaround to you first and meanwhile we will try to fix it, any progress I will let you know. 
  
 Thanks, 
 James

Thanks for the update the workaround should be good for now as I'm not sure when we will get a chance to implement a new update to the MapSuiteCore files.


 


 - Josh



 I know you all are busy people but any update on this after 2 days?


Thanks,


 - Josh



Josh, 
  
 James is out the rest of the week so I’m not sure why he said he was going to provide a work around.  I will take a look at it today and see if we can figure out what is going on. 
  
 From your code snippet, I assuming that the billingLayer is actually all the North Dakota road files and that you are trying to find the closest road to a particular point within a 100 feet, is this correct? 
  
 Thanks!

 Yes that is correct.


 


 - Josh



 LayerOverlay billingOverlay = new LayerOverlay("billingOverlay");


                    billingOverlay.IsBaseOverlay = false;
                    mapControl.CustomOverlays.Add(billingOverlay);
 
and then later in the code right before the GetNearestTo
 
MultipleShapeFileFeatureLayer billingLayer = (MultipleShapeFileFeatureLayer)((LayerOverlay)mapControl.CustomOverlays["billingOverlay"]).Layers[0];

Josh, 
  
 We figured out what was happening.  The NDlkaA10 shapefile actually has an extra column on it called “Symbol” since not all the columns are the same across all the shapefiles the query is causing an error when it hits a shapefile that doesn’t have the “Symbol” column.  We are looking into a better way to handle this exception so it’s apparent what is going on to the developer and they can fix the issue. 
  
 The best way to get it to work now is to pass in the column names that you care about instead of returning all of the columns.  One requirement is that the columns you specify must exist in all the shapfiles that make up the MultiShapefileFeaturelayer.  Below is a code example on how to specify only the columns you want returned for the feature. 
  
 NDRoads.QueryTools.GetFeaturesNearestTo(new PointShape(-96.7983, 46.8751), GeographyUnit.DecimalDegree, 10, new string[]{“FENAME”,“FEDIRP”,“FETYPE”}); 
  
 Thanks!

 Clint thanks for the response.


That seems to have solved the error issue which is great. However now it is taking a extreme amount of time to find the closest feature. Do you maybe have any suggestions on how I can speed this process up?


 


I have tried to call GetFeaturesWithinDistanceOf and it seems to return every feature in the MultiShapeFileFeatureLayer no matter what distance I give it.


 


 


 - Josh



Josh, 
  
 Let me look into that one.  Is this going to be the main reason you use the MultipleShapeFileFeatureLayer? 
  
 David

 That is correct.


Basically what I'm looking to do is load all of North Dakotas shapefiles. And using points from a GPS unit on a truck find the nearest road and display that road in a report format with distance and time on road.


I have the distance and time all finished just cannot pull the road name for the report.


 


Example:


I-94    58456ft 1h 21min


HWY-1  12345ft 2hr


Main Steet   1000ft   22min


 


If there is a better example out there that I may not have found that would be great too.


 


 - Josh



 Here are some test gps coords if it helps.


Most of them should evaluate to Township Road 133.


 


Latitude Longitude


47.180945 -95.996972


47.181062 -95.996970


47.181188 -95.996968


47.181317 -95.996972


47.181447 -95.996972


47.181568 -95.996972


47.181697 -95.996972


47.181820 -95.996973


47.181945 -95.996975


47.182070 -95.996975


47.182165 -95.996977


47.182200 -95.996975


47.182275 -95.996975


47.182355 -95.996977


47.182445 -95.996978


47.182548 -95.996980


47.182648 -95.996978


47.182752 -95.996980


47.182877 -95.996980


47.182995 -95.996980


47.183122 -95.996978


47.183242 -95.996975


47.183363 -95.996975


47.183477 -95.996975


47.183595 -95.996977


47.183717 -95.996972


47.183835 -95.996968


47.183947 -95.996970


47.184065 -95.996973


47.184178 -95.996975


47.184278 -95.996970


47.184382 -95.996968


47.184495 -95.996972


47.184607 -95.996975


47.184727 -95.996975


47.184840 -95.996975


47.184940 -95.996970


47.185063 -95.996972


47.185185 -95.996973


47.185307 -95.996977


47.185425 -95.996975


47.185543 -95.996975


47.185668 -95.996977


47.185790 -95.996973


47.185922 -95.996977


47.186048 -95.996980


47.186190 -95.996980


47.186337 -95.996982


47.186477 -95.996985


47.186610 -95.996992


47.186743 -95.996993


47.186878 -95.996995


47.187025 -95.996997


47.187167 -95.996995


47.187312 -95.996997


47.187445 -95.996997


47.187572 -95.997002


47.187697 -95.997005


47.187820 -95.997007


47.187957 -95.997007


47.188093 -95.997008


47.188217 -95.997007


47.188353 -95.997010


47.188500 -95.997015


47.188642 -95.997017


47.188782 -95.997017


47.188913 -95.997022


47.189052 -95.997020


47.189188 -95.997020


47.189322 -95.997022


47.189460 -95.997022


47.189597 -95.997020


47.189733 -95.997023


47.189868 -95.997025


47.190005 -95.997027


47.190135 -95.997027


47.190263 -95.997025


47.190398 -95.997023


47.190530 -95.997025


47.190665 -95.997025


47.190795 -95.997025


47.190928 -95.997025


47.191065 -95.997025


47.191200 -95.997027


47.191330 -95.997028


47.191475 -95.997033


47.191620 -95.997033


47.191758 -95.997035


47.191898 -95.997037


47.192035 -95.997035


47.192168 -95.997038


47.192303 -95.997043


47.192440 -95.997042


47.192575 -95.997042


47.192698 -95.997042


47.192742 -95.997043


47.192742 -95.997043


47.192742 -95.997043


47.192742 -95.997042


47.192742 -95.997042


47.192742 -95.997042


47.192743 -95.997042


47.192743 -95.997042


47.192743 -95.997043


47.192743 -95.997043


47.192850 -95.997052


47.192982 -95.997053


47.193117 -95.997052


47.193252 -95.997058


47.193397 -95.997057


47.193547 -95.997055


47.193693 -95.997055


47.193838 -95.997057


47.193975 -95.997060


47.194108 -95.997062


47.194230 -95.997065


47.194343 -95.997062


47.194465 -95.997058


47.194585 -95.997065


47.194708 -95.997068


47.194823 -95.997073


47.194953 -95.997068


47.195097 -95.997072


47.195240 -95.997072


47.195367 -95.997078


47.195510 -95.997080


47.195648 -95.997083


47.195783 -95.997085


47.195923 -95.997087


47.196063 -95.997087


47.196203 -95.997095


47.196347 -95.997097


47.196483 -95.997100


47.196623 -95.997103


47.196755 -95.997108


47.196883 -95.997115


47.197013 -95.997120


47.197148 -95.997123


47.197288 -95.997125


47.197427 -95.997128


47.197567 -95.997130


47.197707 -95.997133


47.197848 -95.997138


47.197990 -95.997143


47.198132 -95.997147


47.198277 -95.997150


47.198420 -95.997153


47.198567 -95.997160


47.198712 -95.997163


47.198858 -95.997168


47.199005 -95.997172


47.199152 -95.997178


47.199292 -95.997182


47.199432 -95.997185


47.199552 -95.997192


47.199678 -95.997192


47.199800 -95.997197


47.199928 -95.997200


47.200058 -95.997202


47.200190 -95.997207


47.200317 -95.997203


47.200427 -95.997207


47.200550 -95.997210


47.200670 -95.997213


47.200793 -95.997215


47.200922 -95.997217


47.201063 -95.997227


47.201207 -95.997228


47.201363 -95.997230


47.201518 -95.997233


47.201652 -95.997237


47.201795 -95.997237


47.201927 -95.997240


47.201940 -95.997240


47.201940 -95.997238


47.201940 -95.997238


47.201940 -95.997238


47.201940 -95.997238


47.201942 -95.997238


47.201942 -95.997238


47.201942 -95.997238


47.201942 -95.997238


47.201942 -95.997238


47.201942 -95.997238


47.201940 -95.997238


47.201940 -95.997238


47.201940 -95.997238


47.201940 -95.997238


47.201940 -95.997240


47.201940 -95.997240


47.201940 -95.997240


47.201940 -95.997240


47.201968 -95.997240


47.202100 -95.997238


47.202245 -95.997242


47.202390 -95.997242


47.202528 -95.997242


47.202663 -95.997245


47.202803 -95.997245


47.202950 -95.997243


47.203093 -95.997243


47.203237 -95.997245


47.203382 -95.997248


47.203523 -95.997253


47.203663 -95.997253


47.203798 -95.997253


47.203940 -95.997253


47.204080 -95.997255


47.204218 -95.997257


47.204343 -95.997258


47.204478 -95.997255


47.204612 -95.997257


47.204765 -95.997257


47.204915 -95.997255


47.205060 -95.997255


47.205197 -95.997257


47.205340 -95.997258


47.205480 -95.997260


47.205618 -95.997258


47.205755 -95.997258


47.205895 -95.997258


47.206040 -95.997260


47.206187 -95.997262


47.206328 -95.997260


47.206470 -95.997260


47.206610 -95.997263


47.206745 -95.997267


47.206880 -95.997267


47.207017 -95.997267


47.207155 -95.997267


47.207233 -95.997268


47.207233 -95.997268


47.207233 -95.997268


47.207233 -95.997268


47.207233 -95.997268


47.207233 -95.997268


47.207233 -95.997268


47.207233 -95.997268


47.207233 -95.997268


47.207233 -95.997268


47.207308 -95.997265


47.207463 -95.997263


47.207618 -95.997267


47.207772 -95.997268


47.207923 -95.997270


47.208073 -95.997270


47.208223 -95.997272


47.208370 -95.997273


47.208510 -95.997272


47.208650 -95.997272


47.208790 -95.997272


47.208937 -95.997272


47.209082 -95.997272


47.209225 -95.997275


47.209368 -95.997278


47.209500 -95.997283


47.209613 -95.997282


47.209652 -95.997280


47.209743 -95.997275


47.209857 -95.997273


47.209955 -95.997275


47.210065 -95.997275


47.210190 -95.997275


47.210322 -95.997277


47.210465 -95.997278


47.210618 -95.997275


47.210767 -95.997273


47.210832 -95.997272


47.210722 -95.997272


47.210505 -95.997285


47.210310 -95.997318


47.210123 -95.997327


47.209960 -95.997318


47.209777 -95.997312


47.209645 -95.997307


47.209632 -95.997308


47.209693 -95.997307


47.209795 -95.997310


47.209910 -95.997315


47.210032 -95.997320


47.210157 -95.997318


47.210285 -95.997320


47.210415 -95.997320


47.210557 -95.997318


47.210698 -95.997318


47.210840 -95.997317


47.210983 -95.997313


47.211125 -95.997315


47.211263 -95.997315


47.211402 -95.997315


47.211540 -95.997315


47.211682 -95.997315


47.211820 -95.997317


47.211960 -95.997315


47.212097 -95.997315


47.212233 -95.997315


47.212370 -95.997313


47.212492 -95.997313


47.212618 -95.997310


47.212752 -95.997305


47.212878 -95.997308


47.212998 -95.997310


47.213130 -95.997305


47.213265 -95.997302


47.213403 -95.997300


47.213538 -95.997303


47.213560 -95.997305


47.213560 -95.997307


47.213560 -95.997307


47.213562 -95.997308


47.213562 -95.997308


47.213562 -95.997308


47.213563 -95.997310


47.213563 -95.997310


47.213563 -95.997310


47.213563 -95.997310


47.213563 -95.997310


47.213563 -95.997310


47.213563 -95.997310


47.213563 -95.997310


47.213563 -95.997310


47.213563 -95.997310


47.213563 -95.997310


47.213598 -95.997302


47.213680 -95.997302


47.213763 -95.997302


47.213848 -95.997302


47.213957 -95.997298


47.214078 -95.997298


47.214175 -95.997298


47.214275 -95.997297


47.214413 -95.997295


47.214545 -95.997292


47.214677 -95.997293


47.214818 -95.997290


47.214957 -95.997293


47.215093 -95.997290


47.215232 -95.997290


47.215387 -95.997287


47.215528 -95.997285


47.215670 -95.997283


47.215810 -95.997282


47.215958 -95.997280


47.216118 -95.997280


47.216265 -95.997277


47.216413 -95.997277


47.216563 -95.997275


47.216698 -95.997273


47.216825 -95.997275


47.216963 -95.997273


47.217100 -95.997268


47.217242 -95.997265


47.217388 -95.997265


47.217538 -95.997268


47.217687 -95.997267


47.217838 -95.997265


47.217988 -95.997263


47.218135 -95.997260


47.218282 -95.997257


47.218433 -95.997258


47.218585 -95.997257


47.218732 -95.997257


47.218878 -95.997257


47.219010 -95.997255


47.219133 -95.997253


47.219282 -95.997255


47.219432 -95.997253


47.219572 -95.997253


47.219715 -95.997252


47.219862 -95.997252


47.220005 -95.997250


47.220143 -95.997250


47.220273 -95.997250


47.220370 -95.997255


47.220497 -95.997255


47.220635 -95.997258


47.220772 -95.997255


47.220908 -95.997253


47.221045 -95.997250


47.221183 -95.997247


47.221315 -95.997243


47.221447 -95.997248


47.221588 -95.997248


47.221733 -95.997243


47.221857 -95.997243


47.221957 -95.997242


47.222092 -95.997243


47.222242 -95.997242


47.222383 -95.997238


47.222530 -95.997240


47.222672 -95.997240


47.222798 -95.997235


47.222932 -95.997232


47.223078 -95.997230


47.223225 -95.997228


47.223357 -95.997235


47.223482 -95.997228


47.223622 -95.997225


47.223765 -95.997222


47.223905 -95.997220


47.224033 -95.997220


47.224177 -95.997218


47.224318 -95.997218


47.224457 -95.997217


47.224598 -95.997215


47.224743 -95.997210


47.224890 -95.997205


47.225042 -95.997205


47.225192 -95.997203


47.225338 -95.997202


47.225482 -95.997202


47.225625 -95.997198


47.225767 -95.997195


47.225905 -95.997192


47.226052 -95.997192


47.226192 -95.997190


47.226337 -95.997192


47.226482 -95.997192


47.226630 -95.997188


47.226782 -95.997187


47.226928 -95.997187


47.227073 -95.997185


47.227212 -95.997183


47.227350 -95.997180


47.227502 -95.997177


47.227655 -95.997175


47.227803 -95.997175


47.227937 -95.997175


47.228067 -95.997173


47.228207 -95.997173


47.228350 -95.997172


47.228488 -95.997168


47.228627 -95.997165


47.228765 -95.997163


47.228903 -95.997162


47.229043 -95.997158


47.229182 -95.997157


47.229323 -95.997152


47.229458 -95.997148


47.229578 -95.997147


47.229688 -95.997145


47.229803 -95.997143


47.229938 -95.997143


47.230063 -95.997145


47.230195 -95.997145


47.230328 -95.997135


47.230467 -95.997132


47.230607 -95.997128


47.230752 -95.997122


47.230898 -95.997122


47.231040 -95.997123


47.231187 -95.997122


47.231332 -95.997118


47.231475 -95.997125


47.231603 -95.997123


47.231755 -95.997125


47.231908 -95.997123


47.232063 -95.997125


47.232212 -95.997125


47.232348 -95.997127


47.232492 -95.997128


47.232638 -95.997123


47.232782 -95.997120


47.232930 -95.997122


47.233075 -95.997123


47.233220 -95.997123


47.233363 -95.997123


47.233515 -95.997125


47.233662 -95.997127


47.233802 -95.997125


47.233943 -95.997125


47.234087 -95.997125


47.234230 -95.997125


47.234360 -95.997128


47.234503 -95.997132


47.234637 -95.997133


47.234778 -95.997137


47.234922 -95.997140


47.235065 -95.997138


47.235212 -95.997135


47.235360 -95.997135


47.235507 -95.997133


47.235653 -95.997132


47.235802 -95.997132


47.235943 -95.997133


47.236083 -95.997130


47.236217 -95.997130


47.236328 -95.997130


47.236415 -95.997130


47.236515 -95.997128


47.236620 -95.997128


47.236747 -95.997128


47.236878 -95.997128


47.237007 -95.997132


47.237110 -95.997132


47.237223 -95.997130


47.237343 -95.997132


47.237457 -95.997135


47.237577 -95.997137


47.237700 -95.997133


47.237828 -95.997133


47.237957 -95.997133


47.238083 -95.997133


47.238205 -95.997132


 


 - Josh


 



 Josh,


Thanks for your post, I still had a sample setup from your earlier question and I was able to to get good results in North Dakota with the following line of code:


Collection<Feature> closestFeatures = NDRoads.QueryTools.GetFeaturesWithinDistanceOf(new PointShape(-97.3876, 47.1421), GeographyUnit.DecimalDegree, DistanceUnit.Mile, .25, new string[] { "FENAME", "FEDIRP", "FETYPE" });


This returns any features within a quarter mile of the point passed in.  


I noticed that the coordinates you posted were from Minnesota but it should work exacltly the same as North Dakota assuming you have it in a MultiShapeFileFeatureLayer like you did earlier in North Dakota.


Hope this helps.




Thanks!



 I feel kind of like an idiot now I was using two different trucks and locations.


I got the right truck/shape files now and it will at least return me the correct roads however it still seems kinda slow so..


1.) What kind of speed where you seeing on your test?


QueryTools.GetFeaturesNearestTo(new PointShape(vertex), GeographyUnit.Feet, 5, new string[] { "FENAME" }); is taking almost 2 min per point to find.


 


2.) The GetFeaturesNearestTo does that do any filtering first or does it loop through every feature in the shape file and compare distances?


 


Again I appreciate any help.


 - Josh



Josh, 
  
 I’m getting good speed on both of the queries (less than a second), maybe you don’t have your spatial indexes setup correctly.  Here is the code where I’m loading up the MultiShapeFileFeatureLayer and the corresponding indexes. 
  
                 MultipleShapeFileFeatureLayer.BuildIndex(@“C:\Temp\ND&#42;.shp”, BuildIndexMode.DoNotRebuild); 
                 MultipleShapeFileFeatureLayer NDRoads = new MultipleShapeFileFeatureLayer(@“C:\Temp\ND&#42;.shp”, @“C:\Temp\ND&#42;.mids”); 
  
 Give that a try and I bet you will see the performance increase dramatically. 
  
 Thanks! 


 Thats it and I bet I stared at that in other posts and the wiki multiple times just didn't click. Can run through about 5k points in about 2 min now which is acceptable on our end as we are doing alot of processing between plotting the point on the map and then moving to the next point.


I appreciate all the help.


 - Josh



Thanks Josh, glad it’s working.