Hello,
I am trying to create four different .idx files from a .shp file. There are three columns in the .shp file, “NAME”,“Begin”,“End”. Begin and End have numbers in them, 5, 6, 8, 9, or 21. I want an .idx file for each of the values in Begin of 5, 6, 8, and 9. Here is the code I use to create the .idx files.
ShapeFileFeatureSource.BuildIndexFile(theFolder & “\cities.shp”, theFolder & “\cities5.idx”, “Begin”, “5”, BuildIndexMode.Rebuild)
ShapeFileFeatureSource.BuildIndexFile(theFolder & “\cities.shp”, theFolder & “\cities6.idx”, “Begin”, “6”, BuildIndexMode.Rebuild)
ShapeFileFeatureSource.BuildIndexFile(theFolder & “\cities.shp”, theFolder & “\cities8.idx”, “Begin”, “8”, BuildIndexMode.Rebuild)
ShapeFileFeatureSource.BuildIndexFile(theFolder & “\cities.shp”, theFolder & “\cities9.idx”, “Begin”, “9”, BuildIndexMode.Rebuild)
The files are created as expected. The corresponding .idx files are all of the same size, though the .ids files are different sizes.
I am then creating four different ShapeFileFeatureLayer layers, one for each .idx file. An example of the code to create the layer is:
Dim citiesLayer5 As ShapeFileFeatureLayer = New ShapeFileFeatureLayer(citiesFile, cities5Index)
Dim citiesLayer6 As ShapeFileFeatureLayer = New ShapeFileFeatureLayer(citiesFile, cities6Index)
Each layer is supposed to show the items at the zoom level that matches their Begin value. citiesLayer5.ZoomLevelSet.ZoomLevel05 is used for the 5 items, citiesLayer6.ZoomLevelSet.ZoomLevel06 for the 6 items, etc.
The problem is that everything is showing up at the highest zoom level, level 5. Even though the layer is created with the .idx file, all of the items in the .shp file display. My thought is that the .idx file is not being created correctly, though the different .ids file sizes indicates that they are different somehow. Do you see anything in the way I’m creating the .idx files that would cause them to all be the same?
Also, here is an example of an entire layer. The layers is just to show a city name, and a blue dot next to it:
Dim citiesLayer5 As ShapeFileFeatureLayer = New ShapeFileFeatureLayer(citiesFile, cities5Index)
citiesLayer5.ZoomLevelSet.ZoomLevel05.DefaultPointStyle = PointStyles.City5
citiesLayer5.ZoomLevelSet.ZoomLevel05.DefaultPointStyle.SymbolType = PointSymbolType.Circle
citiesLayer5.ZoomLevelSet.ZoomLevel05.DefaultPointStyle.SymbolPen.Color = GeoColor.StandardColors.RoyalBlue
citiesLayer5.ZoomLevelSet.ZoomLevel05.DefaultPointStyle.SymbolSolidBrush.Color = GeoColor.StandardColors.RoyalBlue
citiesLayer5.ZoomLevelSet.ZoomLevel05.DefaultTextStyle = New TextStyle(“NAME”, New GeoFont(“Arial”, 11), New GeoSolidBrush(GeoColor.StandardColors.Navy)) 'TextStyles.City1(“city_name”)
citiesLayer5.ZoomLevelSet.ZoomLevel05.DefaultTextStyle.XOffsetInPixel = 4
citiesLayer5.ZoomLevelSet.ZoomLevel05.DefaultTextStyle.OverlappingRule = LabelOverlappingRule.NoOverlapping
citiesLayer5.ZoomLevelSet.ZoomLevel05.DefaultTextStyle.BestPlacement = True
citiesLayer5.ZoomLevelSet.ZoomLevel05.DefaultTextStyle.HaloPen.Color = GeoColor.StandardColors.White
citiesLayer5.ZoomLevelSet.ZoomLevel05.DefaultTextStyle.HaloPen.Width = 1
citiesLayer5.ZoomLevelSet.ZoomLevel05.DefaultTextStyle.OverlappingRule = LabelOverlappingRule.NoOverlapping
citiesLayer5.ZoomLevelSet.ZoomLevel05.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20
citiesLayer5.RequireIndex = False
citiesLayer5.DrawingMarginPercentage = 25
citiesLayer5.Name = “layerCities5”
Creating .idx files with RegEx
Hi Dib,
Your code for generate index should be right, I did a quickly test like this:
ShapeFileFeatureSource.BuildIndexFile(@“D:\MapData\test\depthline.shp”, @“D:\MapData\test\abc.idx”, “NAME”, “SOAMAFR”, BuildIndexMode.Rebuild);
ShapeFileFeatureSource.BuildIndexFile(@“D:\MapData\test\depthline.shp”, @“D:\MapData\test\abc2.idx”, “NAME”, “SASAUS”, BuildIndexMode.Rebuild);
The file size of idx and idx are different. And they works well.
I read your code, it looks you set RequireIndex equal false, does that why the index file don’t works?
Regards,
Don
Setting RequireIndex = True did the trick. Thanks for your help
Hi,
Thanks for let us know that works.
Regards,
Don